MAKE A MEME View Large Image Arnold tongues.png ru Языки А нольда 2012-08-26 own Ilya Voyager Other fields SVG Created with Asymptote n fl CPP //tongues C include <iostream> include <fstream> include <stdio h> include <assert h> include <math h> double f ...
View Original:Arnold tongues.png (1500x378)
Download: Original    Medium    Small Thumb
Courtesy of:commons.wikimedia.org More Like This
Keywords: Arnold tongues.png ru Языки А нольда 2012-08-26 own Ilya Voyager Other fields SVG Created with Asymptote n fl CPP //tongues C include <iostream> include <fstream> include <stdio h> include <assert h> include <math h> double f double x double alpha double eps return x+alpha+eps sin x ; double rotation_number double alpha double eps int iterations int i; double x 0; for i 0;i<iterations;i++ x f x alpha eps ; return x/iterations; class RNParam_eps public double eps; int iterations; ; double rotation_number_of_alpha double alpha void param RNParam_eps p RNParam_eps param ; return rotation_number alpha p->eps p->iterations ; double bisect double func double void void p double x0 double level double precision int emergency_stop 1000 double step precision; double left x0; double right x0; double x x0; int i 0; double f fl fr; do left- step; right+ step; step 2; i++; assert i<emergency_stop ; fl func left p ; fr func right p ; while fl-level fr-level >0 ; while right-left>precision x left+right /2; f func x p ; if fl-level f-level >0 fl f; left x; else fr f; right x; return left+right /2; //this function is copypasted from Rossetta Code //http //rosettacode org/wiki/Greatest_common_divisor Iterative_Euclid_algorithm //I believe it's PD-trivial int gcd_iter int u int v int t; while v t u; u v; v t v; return u < 0 -u u; / abs u / ////////////////////////////////////// using namespace std; main double epsmax 0 99;//maximal value of epsilon double epsdelta 1E-3; double rhomax 1 1 2 M_PI; //maximal value of rotation number for tongues to draw double threshold 1E-4; int iterations 1E5;//rotation number iterations double bisection_precision threshold/10; int qmin 4; int qmax 6; int p q; double rho left right; double subleft subright; double eps; int i n; char filename256; ofstream leftborder rightborder; RNParam_eps param; param iterations iterations; for q qmin;q<qmax;q++ for p 0; rho 2 M_PI double p /q <rhomax;p++ //hehe if gcd_iter p q 1 continue; sprintf filename leftborder- i- i data q p ; //it's more natural way to enumerate rationals in this form the denominator is more important for the analysys leftborder open filename ; sprintf filename rightborder- i- i data q p ; rightborder open filename ; leftborder precision 16 ; rightborder precision 16 ; left rho; right rho; for eps 0;eps<epsmax;eps+ epsdelta param eps eps; leftborder << eps << << left << endl; rightborder << eps << << right << endl; left bisect rotation_number_of_alpha param left rho-threshold bisection_precision ; right bisect rotation_number_of_alpha param right rho+threshold bisection_precision ; leftborder close ; rightborder close ; asymptote //tongues asy import graph; size 400 100 IgnoreAspect ; string ids 1-0 1-1 2-1 3-1 3-2 4-1 4-3 5-1 5-2 5-3 5-4 ; file leftborder; file rightborder; pair leftcoords; pair rightcoords; guide left right tongue; pair transpose pair T pair ret ; for pair t T ret push t y t x ; return ret; for string id ids leftborder input leftborder- +id+ data csv ; rightborder input rightborder- +id+ data csv ; leftcoords leftborder; rightcoords rightborder; write leftcoords ; left graph transpose leftcoords ; right graph transpose rightcoords ; //draw left ; //draw right ; tongue reverse left --right--cycle; filldraw tongue yellow 0 7+cyan 0 3+magenta 0 3 black ; xaxis \alpha xmin -1 xmax 7 5 ; xtick L 0 0 dir N ; xtick L \frac 1 2 pi dir N ; xtick L 1 2 pi dir N ; xtick L \frac 1 3 2 pi/3 dir N ; xtick L \frac 2 3 4 pi/3 dir N ; ytick L 0 0 ; yaxis \varepsilon LeftRight ymin 0 ymax 1 ; bash /bin/bash makepng sh g++ tongue C -o tongue /tongue asy tongue convert -density 269 4 tongue eps tongue png Uploaded with UploadWizard Dynamical systems Images with C++ source code Images with Asymptote source code Images with BASH source code cc-zero
Terms of Use   Search of the Day