plpoly

calculate and plot a polynomial through a set of points

parametertypeunitsdescription
x,yfloat*uudatapoints
nint--number of datapoints
kint--degree of the polynomial
xmin,xmaxfloatuuplotrange
linetypeint--format of the line drawn
returns:void

Description

plpoly fits a polynomial of degree k through n points stored in the arrays x and y, and then plots it between xmin and xmax. If the NULL pointer is given instead of x or y, the values 0..n-1 are used instead. After executing it, the function plpolv may be used to get the value of the polynomial in any x-position, or the function plpolc may be used to find the coefficients.

See also

plpolf, plpolc, plpolv

G.E.Forsythe, "Generation and use of orthogonal polynomials for data-fitting with a digital computer" SIAM Journal on Numerical Analysis vol 5, page 74

Examples

n=4 xmin=1991 xmax=1992.1 ymin=0 ymax=2500
plinit PS plpoly A4 50 50 "" ""
plrdx n 1991 1991.5 1992 1992.1
plrdy n 800 700 1600 2200
plaxes xmin ymin xmax ymax 100 70 "" "" ""
plpline n X DOWN
plframe 5 3
plclip xmin ymin xmax ymax
plpoly n 2 xmin xmax DOWN
plpolc

plpoly

Because of the plpolc statement this program prints:
expcoeff
09801916765.45
1-9844674.11426
22471.90463773
which tells that the equation of the polynomial is:

y = 9801916765.45 - 9844674.11426 x + 2471.90463773 x2

Examples

See also

plpolv