Skip to content

Instantly share code, notes, and snippets.

@hacktor
Last active July 25, 2021 06:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hacktor/7612e64562a44325e9209bf3f25e3165 to your computer and use it in GitHub Desktop.
Save hacktor/7612e64562a44325e9209bf3f25e3165 to your computer and use it in GitHub Desktop.
# 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