Feigenbaum constant calculation: Difference between revisions
Content added Content deleted
m (Updated description and link for Fōrmulæ solution) |
No edit summary |
||
Line 1,768: | Line 1,768: | ||
12 4.66920098 |
12 4.66920098 |
||
13 4.66920537</pre> |
13 4.66920537</pre> |
||
=={{header|Vlang}}== |
|||
{{trans|Go}} |
|||
<lang vlang>fn feigenbaum() { |
|||
max_it, max_itj := 13, 10 |
|||
mut a1, mut a2, mut d1 := 1.0, 0.0, 3.2 |
|||
println(" i d") |
|||
for i := 2; i <= max_it; i++ { |
|||
mut a := a1 + (a1-a2)/d1 |
|||
for j := 1; j <= max_itj; j++ { |
|||
mut x, mut y := 0.0, 0.0 |
|||
for k := 1; k <= 1<<u32(i); k++ { |
|||
y = 1.0 - 2.0*y*x |
|||
x = a - x*x |
|||
} |
|||
a -= x / y |
|||
} |
|||
d := (a1 - a2) / (a - a1) |
|||
println("${i:2} ${d:.8f}") |
|||
d1, a2, a1 = d, a1, a |
|||
} |
|||
} |
|||
fn main() { |
|||
feigenbaum() |
|||
}</lang> |
|||
{{out}} |
|||
<pre> |
|||
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|Wren}}== |
=={{header|Wren}}== |