chebPoly: Chebyshev Polynomials

View source: R/chebyshev.R

chebPolyR Documentation

Chebyshev Polynomials

Description

Chebyshev polynomials and their values.

Usage

chebPoly(n, x = NULL)

Arguments

n

an integer >= 0.

x

a numeric vector, possibly empty; default NULL.

Details

Determines an (n+1)-ny-(n+1)-Matrix of Chebyshev polynomials up to degree n.

The coefficients of the first n Chebyshev polynomials are computed using the recursion formula. For computing any values at points the well known Horner schema is applied.

Value

If x is NULL, returns an (n+1)-by-(n+1) matrix with the coefficients of the first Chebyshev polynomials from 0 to n, one polynomial per row with coefficients from highest to lowest order.

If x is a numeric vector, returns the values of the n-th Chebyshev polynomial at the points of x.

Note

See the “Chebfun Project” <https://www.chebfun.org/> by Nick Trefethen.

References

Carothers, N. L. (1998). A Short Course on Approximation Theory. Bowling Green State University.

See Also

chebCoeff, chebApprox

Examples

chebPoly(6)

## Not run: 
##  Plot 6 Chebyshev Polynomials
plot(0, 0, type="n", xlim=c(-1, 1), ylim=c(-1.2, 1.2),
    main="Chebyshev Polynomials for n=1..6", xlab="x", ylab="y")
grid()
x <- seq(-1, 1, length.out = 101)
for (i in 1:6) {
    y <- chebPoly(i, x)
    lines(x, y, col=i)
}
legend(x = 0.55, y = 1.2, c("n=1", "n=2", "n=3", "n=4", "n=5", "n=6"),
    col = 1:6, lty = 1, bg="whitesmoke", cex = 0.75)

## End(Not run)

pracma documentation built on March 19, 2024, 3:05 a.m.