Last active
July 25, 2021 06:54
-
-
Save hacktor/7612e64562a44325e9209bf3f25e3165 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The Feigenbaum constant delta is a universal constant for functions approaching chaos via period doubling. | |
use strict; | |
use warnings; | |
use Math::AnyNum 'sqr'; | |
my $a1 = 1.0; | |
my $a2 = 0.0; | |
my $d1 = 3.2; | |
print " i δ\n"; | |
for my $i (2..13) { | |
my $a = $a1 + ($a1 - $a2)/$d1; | |
for (1..10) { | |
my $x = 0; | |
my $y = 0; | |
for (1 .. 2**$i) { | |
$y = 1 - 2 * $y * $x; | |
$x = $a - sqr($x); | |
} | |
$a -= $x/$y; | |
} | |
$d1 = ($a1 - $a2) / ($a - $a1); | |
($a2, $a1) = ($a1, $a); | |
printf "%2d %17.14f\n", $i, $d1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment