Feigenbaum constant calculation: Difference between revisions
Content added Content deleted
(Added XPL0 example.) |
(add RPL) |
||
Line 1,685: | Line 1,685: | ||
12 4.66920098 |
12 4.66920098 |
||
13 4.66920537</pre> |
13 4.66920537</pre> |
||
=={{header|RPL}}== |
|||
{{trans|Python}} |
|||
{{works with|Halcyon Calc|4.2.7}} |
|||
{| class="wikitable" |
|||
! RPL code |
|||
! Python code |
|||
|- |
|||
| |
|||
≪ { } |
|||
13 10 → maxit maxitj |
|||
≪ 3.2 1 0 |
|||
2 maxit 1 + '''FOR''' ii |
|||
DUP2 - 4 PICK / 3 PICK + |
|||
1 maxitj 1 + '''START''' |
|||
0 0 |
|||
1 2 ii ^ '''START''' |
|||
OVER * 2 * 1 SWAP - |
|||
3 PICK ROT SQ - SWAP '''NEXT''' |
|||
/ - '''NEXT''' |
|||
3 PICK ROT - OVER 4 PICK - / |
|||
5 ROLL OVER + 5 ROLLD |
|||
4 ROLL DROP SWAP ROT '''NEXT''' |
|||
3 DROPN |
|||
≫ ≫ |
|||
´'''FBAUM'''’ STO |
|||
| |
|||
'''FBAUM''' ''( -- { δ1..δ13 } )'' |
|||
max_it, max_it_j = 13, 10 |
|||
d1, a1, a2 = 3.2, 1, 0 |
|||
for i in range(2, max_it + 1): |
|||
a = a1 + (a1 - a2) / d1 |
|||
for j in range(1, max_it_j + 1): |
|||
x = y = 0 |
|||
for k in range(1, (1 << i) + 1): |
|||
y = 1.0 - 2.0 * y * x |
|||
x = a - x * x |
|||
a = a - x / y |
|||
d = (a1 - a2) / (a - a1) |
|||
print(d) |
|||
d1, a2, a1 = d, a1, a |
|||
clean stack |
|||
. |
|||
. |
|||
|} |
|||
{{out}} |
|||
<pre> |
|||
1: { 3.21851142204 4.38567759857 4.60094927654 4.65513049539 4.66611194782 4.66854858152 4.66906066029 4.66917155686 4.6691951528 4.66920033694 4.66920090912 4.66920429563 4.66917851362 } |
|||
</pre> |
|||
The above program (limited at 10 iterations) takes 33 minutes and 50 seconds to be executed on a HP-28S. |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |