I see two problems, and I have a feeling there are others.
1. You're calling P_j with an argument of 4.
This number is used as an index into @pair_points,
which might not have any data at that index. With your
sample data, for example, it doesn't.
2. In the for loop, you give $generic_pol a value
only conditionally (i.e. when $k != $j) but you
always multiply $pol by it, regardless.
Perhaps the for loop should be something like this:
for( my $k = 0 ; $k < $n ; $k++ ) {
next if $k == $j;
my $generic_pol = Math::Polynomial->new( 1, -$pair_points[$k]-
+>[0] )
/ ( $pair_points[$j]->[0] - $pair_points[$k]->
+[0]);
$pol *= $generic_pol;
}
A word spoken in Mind will reach its own level, in the objective world, by its own weight
|