As a followup (of sorts) to my last post, I give you the following: sub Derivative1 { my ($x,$y)=@_; my @y2; my $n=$#{$x}; $y2[0]=($y->[1]-$y->[0])/($x->[1]-$x->[0]); $y2[$n]=($y->[$n]-$y->[$n-1])/($x->[$n]-$x->[$n-1]); my $i; for($i=1; $i<$n; $i++) { $y2[$i]=($y->[$i+1]-$y->[$i-1])/($x->[$i+1]-$x->[$i-1]); } return @y2; } That code is correct, right? I sure hope so, because man do I not want to grovel over that and figure out what the hell it is doing. This glorious manifestation of the human intellect comes from Math::Derivative, a Perl module which, well, does what it says on the tin: it provides functions that compute first and second derivatives of matrices of points. …