Horner

From WeBWorK_wiki
Jump to navigation Jump to search

horner

Description

Defines a polynomial passing through specified points (a Newton polynomial) and returns an efficient subroutine for evaluating that polynomial (using Horner's method).

Syntax

$fn = horner([$x0,$x1,$x2...],[$q0,$q1,$q2...]);

Params

A pair of references to arrays representing the x values and y values respectively of the interpolated points. The x values must be strictly increasing.

Returns

A non-parametric function subroutine representing the newton polynomial
&$fn($x) = $q0 + $q1*($x-$x0) +q2*($x-$x1)*($x-$x0);

Notes

This macro is defined in [PGnumericalmacros.pl].