Feigenbaum constant calculation: Difference between revisions

Content deleted Content added
SqrtNegInf (talk | contribs)
m →‎{{header|Perl}}: oops, add 'my' for 'strict' compliance
Added Algol 68
Line 9:
:*   Details in the Wikipedia article:   [https://en.wikipedia.org/wiki/Feigenbaum_constants Feigenbaum constant].
<br><br>
 
=={{header|ALGOL 68}}==
{{works with|ALGOL 68G|Any - tested with release 2.8.3.win32}}
{{Trans|Ring}}
<lang algol68># Calculate the Feigenbaum constant #
print( ( "Feigenbaum constant calculation:", newline ) );
INT max it = 13;
INT max it j = 10;
REAL a1 := 1.0;
REAL a2 := 0.0;
REAL d1 := 3.2;
print( ( "i ", "d", newline ) );
FOR i FROM 2 TO max it DO
REAL a := a1 + (a1 - a2) / d1;
FOR j TO max it j DO
REAL x := 0;
REAL y := 0;
FOR k TO 2 ^ i DO
y := 1 - 2 * y * x;
x := a - x * x
OD;
a := a - x / y
OD;
REAL d = (a1 - a2) / (a - a1);
IF i < 10 THEN
print( ( whole( i, 0 ), " ", fixed( d, -10, 8 ), newline ) )
ELSE
print( ( whole( i, 0 ), " ", fixed( d, -10, 8 ), newline ) )
FI;
d1 := d;
a2 := a1;
a1 := a
OD</lang>
{{out}}
<pre>
Feigenbaum constant calculation:
i d
2 3.21851142
3 4.38567760
4 4.60094928
5 4.65513050
6 4.66611195
7 4.66854858
8 4.66906066
9 4.66917155
10 4.66919515
11 4.66920026
12 4.66920098
13 4.66920537
</pre>
 
=={{header|AWK}}==
Line 55 ⟶ 106:
13 4.66920537
</pre>
 
=={{header|C}}==
{{trans|Ring}}