Feigenbaum constant calculation: Difference between revisions

Content added Content deleted
(→‎{{header|Perl 6}}: Add a Perl6 example)
(Added Sidef)
Line 239: Line 239:
12 4.66920098
12 4.66920098
13 4.66920537
13 4.66920537
</pre>

=={{header|Sidef}}==
{{trans|Perl 6}}
<lang ruby>var a1 = 1
var a2 = 0
var δ = 3.2.float

say " i\tδ"

for i in (2..15) {
var a0 = ((a1 - a2)/δ + a1)
10.times {
var (x, y) = (0, 0)
2**i -> times {
y = (1 - 2*x*y)
x = (a0 - x²)
}
a0 -= x/y
}
δ = ((a1 - a2) / (a0 - a1))
(a2, a1) = (a1, a0)
printf("%2d %.8f\n", i, δ)
}</lang>
{{out}}
<pre>
i δ
2 3.21851142
3 4.38567760
4 4.60094928
5 4.65513050
6 4.66611195
7 4.66854858
8 4.66906066
9 4.66917156
10 4.66919516
11 4.66920023
12 4.66920131
13 4.66920155
14 4.66920160
15 4.66920161
</pre>
</pre>