#!/usr/bin/perl -Wall # ================================================================ # John Kerl # kerl at math dot arizona dot edu # 2006-10-11 # ================================================================ # ---------------------------------------------------------------- # Simulation parameters $tmax = 10.0; $h = 0.002; $N = int($tmax/$h); # $h = 0.002; # $N = 5000; # $tmax = $h * $N; # ---------------------------------------------------------------- # Initial conditions $x0 = 10.0; $y0 = 0.0; $z0 = 10.0; # ---------------------------------------------------------------- # Functional parameters $s = 10.0; $r = 28.0; $b = 2.666667; # ---------------------------------------------------------------- # Output parameters if (@ARGV >= 2) { $h = $ARGV[1]; $N = int($tmax/$h); } # ---------------------------------------------------------------- # Integration $x = $x0; $y = $y0; $z = $z0; for ($t = 0; $t < $tmax; $t += $h) { printf "%11.8f\t%11.8f\t%11.8f\n", $x, $y, $z; # Cheesy Euler integrator. $xp = $s * ($y - $x); $yp = $r * $x - $y - $x * $z; $zp = $x * $y - $b * $z; $x += $h * $xp; $y += $h * $yp; $z += $h * $zp; }