Task

Calculate the Feigenbaum constant.



See

   Details in the Wikipedia article:   Feigenbaum constant.


 
window 1, @"Feignenbaum Constant", ( 0, 0, 200, 300 )
 
_maxIt  = 13
_maxItJ = 10
 
void local fn Feignenbaum
NSUInteger i, j, k
double     a1 = 1.0, a2 = 0.0, d1 = 3.2
 
print "Feignenbaum Constant"
print " i       d"
 
for i = 2 to _maxIt
double a = a1 + ( a1 - a2 ) / d1
for j = 1 to _maxItJ
double x = 0, y = 0
for k = 1 to fn pow( 2, i )
y = 1 - 2 * y * x
x = a - x * x
next
a = a - x / y
next
double d = ( a1 - a2 ) / ( a - a1 )
printf @"%2d.   %.8f", i, d
d1 = d
a2 = a1
a1 = a
next
end fn
 
fn Feignenbaum
 
HandleEvents
 