/* Bifurcation Map Generator Generates Bifurcation Map of x = rx(1 - x) Right-click the underlined blue "exe" file links below to save a PC executable version of the relevant program to your local disk. Note: to scale the display for "r" to run between 0 and 1, the formula x = 4rx(1 - x) is used in the program. bifmap1.c Compiles to bifmap1.exe */ #include #include #include #define XBIAS 120 #define YBIAS 440 int e = 0; void scan(float L1, float L2, int L3) { int i; float l, x; for(l = L1; l < L2 && e == 0; l += .001) { _settextposition(29, 45); printf("%f",l); for(x = .4, i = 0; i < 50; i++) { if( kbhit()) {e = 1; break;} x = 4 * l * x * (1 - x); } _settextposition(15, 7); printf("%f",x); for(i = 0; i < L3; i++) { if( kbhit() ) {e = 1; break;} x = 4 * l * x * (1 - x); _setpixel(XBIAS + (int)(l * 400), YBIAS - (int)(x * 400)); } } } main() { int c; _setvideomode(_VRES16COLOR); _settextposition(1, 26); printf("THE BIFURCATION MAP"); _settextposition(15, 3); printf("X = "); _setcolor(7); _moveto(XBIAS, YBIAS - 400); _lineto(XBIAS, YBIAS); _lineto(XBIAS + 400, YBIAS); _settextposition(29, 36); printf("LAMBDA = "); _setcolor(15); scan(0.001, 0.75, 20); scan(0.751, 0.85, 600); scan(0.851, 1.00, 3000); if(e == 0) {_settextposition(29, 36); printf("Finished\07");} c = getchar(); _setvideomode(_DEFAULTMODE); } /* Generates Bifurcation Map of x = x2 + c bifmap2.c compiles to "bifmap2.exe". */ #include #include #include #define XBIAS 370 #define YBIAS 240 int e = 0; float x, y, cx, cy; int ComplexIterate() { x = x * x + cx; if (x > 15 || x < -25) return(1); return(0); } void scan(void) { int i, I = 100; for (cx = 1.5, cy = 0; cx > -2.5 && e == 0; cx -= .01) { _settextposition(21, 54); printf("%f",cx); for (x = 0, y = 0, i = 0; i < 50; i++) { if(kbhit()) {e = 1; break;} if(ComplexIterate()) break; } if(cx < -1.25) I = 1000; for(i = 0; i < I; i++) { if(kbhit()) {e = 1; break;} if(ComplexIterate()) break; _setpixel( XBIAS + (int)(cx * 100), YBIAS - (int)(x * 100) ); } } } yscale(int a) { //a = -260 or +160 int y; _moveto (XBIAS + a, YBIAS - 200); _lineto (XBIAS + a, YBIAS + 200); for(y = -200; y < 201; y += 50) { _moveto (XBIAS + a - 5, YBIAS + y); _lineto (XBIAS + a + 5, YBIAS + y); } } xscale(int b) { //b = -210 or +210 int x; _moveto (XBIAS - 250, YBIAS + b); _lineto (XBIAS + 150, YBIAS + b); for(x = -250; x < 151; x += 50) { _moveto (XBIAS + x, YBIAS + b - 5); _lineto (XBIAS + x, YBIAS + b + 5); } } main() { int c; _setvideomode(_VRES16COLOR); //640 by 480 16-colour _setcolor(7); _settextposition(1, 16); printf("THE BIFURCATION MAP FOR X = X * X + C."); _moveto(XBIAS, YBIAS - 200); _lineto(XBIAS, YBIAS + 200); _moveto(XBIAS + 150, YBIAS); _lineto(XBIAS - 250, YBIAS); yscale( -260 ); yscale( 160 ); xscale( -210 ); xscale( 210 ); _settextposition(21, 50); printf("C = "); _setcolor(15); scan(); if(e == 0) {_settextposition(23, 50); printf("Finished\07");} c = getchar(); _setvideomode(_DEFAULTMODE); } /* Author: 1997 Robert John Morton */