In the interest of doing something other than yelling at clouds, it occurred to me that rather than just sniping at other people’s Perl, I might step up and demonstrate an alternate path. So, here goes; reference code is at my convenience fork of Math::Derivative. The original: 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; } My substitute: …