Previous: Curve Fitting Details, Up: Curve Fitting [Contents][Index]

The `a p` (`calc-poly-interp`

) [`polint`

] command does
a polynomial interpolation at a particular ‘`x`’ value. It takes
two arguments from the stack: A data matrix of the sort used by
`a F`, and a single number which represents the desired ‘`x`’
value. Calc effectively does an exact polynomial fit as if by `a F i`,
then substitutes the ‘`x`’ value into the result in order to get an
approximate ‘`y`’ value based on the fit. (Calc does not actually
use `a F i`, however; it uses a direct method which is both more
efficient and more numerically stable.)

The result of `a p` is actually a vector of two values: The ‘`y`’
value approximation, and an error measure ‘`dy`’ that reflects Calc’s
estimation of the probable error of the approximation at that value of
‘`x`’. If the input ‘`x`’ is equal to any of the ‘`x`’ values
in the data matrix, the output ‘`y`’ will be the corresponding ‘`y`’
value from the matrix, and the output ‘`dy`’ will be exactly zero.

A prefix argument of 2 causes `a p` to take separate x- and
y-vectors from the stack instead of one data matrix.

If ‘`x`’ is a vector of numbers, `a p` will return a matrix of
interpolated results for each of those ‘`x`’ values. (The matrix will
have two columns, the ‘`y`’ values and the ‘`dy`’ values.)
If ‘`x`’ is a formula instead of a number, the `polint`

function
remains in symbolic form; use the `a "` command to expand it out to
a formula that describes the fit in symbolic terms.

In all cases, the `a p` command leaves the data vectors or matrix
on the stack. Only the ‘`x`’ value is replaced by the result.

The `H a p` [`ratint`

] command does a rational function
interpolation. It is used exactly like `a p`, except that it
uses as its model the quotient of two polynomials. If there are
‘`N`’ data points, the numerator and denominator polynomials will
each have degree ‘`N/2`’ (if ‘`N`’ is odd, the denominator will
have degree one higher than the numerator).

Rational approximations have the advantage that they can accurately
describe functions that have poles (points at which the function’s value
goes to infinity, so that the denominator polynomial of the approximation
goes to zero). If ‘`x`’ corresponds to a pole of the fitted rational
function, then the result will be a division by zero. If Infinite mode
is enabled, the result will be ‘`[uinf, uinf]`’.

There is no way to get the actual coefficients of the rational function
used by `H a p`. (The algorithm never generates these coefficients
explicitly, and quotients of polynomials are beyond `a F`’s
capabilities to fit.)

Previous: Curve Fitting Details, Up: Curve Fitting [Contents][Index]