poly1d
Syntax
poly1d(z,x)
Arguments
z is a numeric vector indicating the polynomial coefficients in ascending powers. It must not contain NULL values.
x is a numeric scalar or vector indicating the independent variable. It must not contain NULL values.
Details
Calculate the value of the dependent variable for a one-dimensional polynomial based on the given coefficients and independent variable.
Return value: A numeric vector of the same length as x.
Examples
For a third-degree polynomial 2x^3+3x^2+4x+5
with coefficients
[5,4,3,2] in ascending powers, the value of the dependent variable can be
calculated:
z = [5,4,3,2]
x = [2.0,5.0,3.0,3.0,4.0,5.0]
y = poly1d(z,x)
y
// output
[41,350,98,98,197,350]
With the x and y in the above example, the coefficients can be calculated with
polyFit
:
polyFit(x,y,3)
// output
[5,4,3,2]
Related function: polyFit