Math-Calculus-TaylorSeries
view release on metacpan or search on metacpan
TaylorSeries.pm view on Meta::CPAN
{
$self->{'error'} = 'Attempt to evaluate Taylor series about an invalid value.';
return undef;
}
# Create a clone of the expression object that we'll differentiate and prepare to find co-efficients.
my $diffExp = $self->clone;
my @coeffs = ();
my $coeffsFound = 0;
# Loop until we've found enough terms or we hit our maximum number of iterations.
my $numIters = 0;
while ($coeffsFound < $terms) {
# Evaluate.
my $coeff = $diffExp->evaluate($variable => $about);
return undef unless defined($coeff);
# Put in co-effs list, and if it's non-zero then state we've found a term.
push @coeffs, $coeff;
$coeffsFound++ if $coeff != 0;
( run in 0.837 second using v1.01-cache-2.11-cpan-71847e10f99 )