Learn R Programming

pracma (version 1.8.8)

chebPoly: 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.

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.

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.

References

Carothers, N. L. (1998). A Short Course on Approximation Theory. Bowling Green State University, URL: http://personal.bgsu.edu/~carother/Approx.html.

See Also

chebCoeff, chebApprox

Examples

Run this code
chebPoly(6)

##  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)

Run the code above in your browser using DataLab