polnm: Defines a univariate polynomial with coefficients set by the...

View source: R/polnm.R

polnmR Documentation

Defines a univariate polynomial with coefficients set by the user

Description

Returns a 2 column dataframe.
First column containts the independent variable.
Second column contains the dependent variable (polynomial outputs against the independent variable).

Usage

polnm(X, v)

Arguments

X

The independent variable against which the polynomial needs to be defined.
Has to be numeric.

v

The vector comprising of the sequence of coefficients of the polynomials.
Has to be numeric.

Details

Suppose that a polynomial is defined as y = ao + a1*x + a2*x^2 + a3*x^3 + ...
Then for the vector v, v[1] = a0 v[2] = a1 v[3] = a2 v[4] = a3 . . . so on and so forth

Value

The returned value is always a dataframe with column names 'X' and 'Y'

Author(s)

Chitran Ghosal

Examples

S <- seq(-2, 2, by = 0.001) #define the independent variable
coeff <- c(0, 1, 1) #define the coefficient vector ( a0 = 0, a1 = 1, a2 = 1)
df <- polnm(X = S, v = coeff) #call the polnm function
plot(df$X, df$Y) #plot the output
##check the roots
abline(h = 0)
abline(v = c(-1, 0))

Chitran1987/StatsChitran documentation built on Feb. 23, 2025, 8:30 p.m.