#!/usr/bin/perl -w
#iterate some, well, iteration formula to produce data points for plotting (or whatever)
#by Thomas Orgis <thomas@orgis.org>, licensed under the Artistic License

use lib $ENV{HOME}.'/lib/perl';
use Param;

my $param = Param::Parse
(
	{'info','I will iterate a given formula given times with given start value. You give me parameters (some iteration formula would be good), I spit data points out to STDOUT that you may plot with Gnuplot or whatever sane program is out there for that stuff.'},
	[
		'begin',0,'b','start value',
		'nit',10,'n','number of iterations',
		'formula','2.8*$x*(1-$x)','f','the formula in PERL syntax with $x being the last x value'
	]
);



my $x = $param->{begin};
print "0\t$x\n";
for(my $i = 1; $i <= $param->{nit}; ++$i)
{
	$x = eval($param->{formula});
	print "$i\t$x\n";
}
