Learn R Programming

polynomial (version 0.1.0)

CommonPolynomials: Common Polynomials

Description

Determines the polynomial coefficients of some common n-th order polynomials.

Usage

Abel(n, a = 1)

Bessel(n) rBessel(n)

Chebyshev1(n) Chebyshev2(n) ChebyshevT(n) ChebyshevU(n)

Cyclotomic(n)

Hermite(n)

Arguments

n

a non-negative integer; the order of the polynomial. For Cyclotomic, n must be positive.

a

a real or complex number; most commonly a positive integer.

Value

For Cyclotomic, a numeric vector of length sum(coprime(1:n, n)) + 1; the coefficients of the n-th order Cyclotomic polynomial.

For all others, a numeric vector of length n + 1; the coefficients of the n-th order polynomial.

Details

The n-th order Abel polynomial is defined as

$$p_n(x) = x (x - a n)^{n - 1}$$

The n-th order Bessel polynomial (\(y_n\)) and reverse Bessel polynomial (\(\theta_n\)) are defined as

$$y_n(x) = \sum_{k=0}^n\frac{(n + k)!}{(n - k)!\,k!} (\frac{x}{2})^k$$

$$\theta_n(x) = x^n y_n(1/x) = \sum_{k=0}^n\frac{(n + k)!}{(n - k)!\,k!} \frac{x^{n - k}}{2^k}$$

The n-th order Chebyshev polynomials of the first kind (\(T_n\)) and the second kind (\(U_n\)) are defined as

$$T_n(cos(\theta)) = cos(n \theta)$$

$$U_n(cos(\theta)) sin(\theta) = sin((n + 1) \theta)$$

where upon defining \(x = cos(\theta)\) and using trig identities to replace \(cos(n \theta)\) and \(sin((n + 1) \theta)\), we find two polynomials in terms of x.

The n-th order Cyclotomic polynomial is defined as

$$\Phi_n(x) = \prod_{\stackrel{1 \le k \le n}{\gcd(k, n) = 1}} \left(x - e^{2 i \pi \frac{k}{n}}\right)$$

The n-th order Hermite polynomial is defined as

$$He(x) = (-1)^n exp(\frac{x^2}{2}) \frac{d^n}{dx^n} exp(-\frac{x^2}{2}$$

Examples

Run this code
# NOT RUN {
colours <- grDevices::palette.colors()[c("vermillion", "bluishgreen",
    "blue", "skyblue", "reddishpurple", "orange")]


## Abel polynomials
n <- 0:4
plot(
    xlim = c(-3, 6), ylim = c(-20, 30),
    panel.first = graphics::grid(col = "gray69"),
    x = NA_real_, y = NA_real_,
    xlab = "x", ylab = as.call(list(call("[", as.symbol("p"),
        as.symbol("n")), as.symbol("x"))),
    main = "Abel Polynomials"
)
for (i in seq_along(n)) {
    graphics::lines(as.polynomial(Abel(n[[i]])),
        col = colours[[i]], n = 1001, lwd = 2,
        xlim = graphics::par("usr")[1:2])
}
graphics::box()
graphics::legend(
    x        = "bottomright",
    legend   = as.expression(lapply(X = n, FUN = function(n1) {
        call("==", as.symbol("n"), n1)
    })),
    col      = colours[seq_along(n)],
    lwd      = 2,
    bty      = "n"
)
graphics::title(sub = ~"All with" ~ list(a == 1), adj = 1)


## Bessel polynomials
n <- 0:5
plot(
    xlim = c(-3, 6), ylim = c(-10, 20),
    panel.first = graphics::grid(col = "gray69"),
    x = NA_real_, y = NA_real_,
    xlab = "x", ylab = as.call(list(call("[", as.symbol("y"),
        as.symbol("n")), as.symbol("x"))),
    main = "Bessel Polynomials"
)
for (i in seq_along(n)) {
    graphics::lines(as.polynomial(Bessel(n[[i]])),
        col = colours[[i]], n = 1001, lwd = 2,
        xlim = graphics::par("usr")[1:2])
}
graphics::box()
graphics::legend(
    x        = "bottomright",
    legend   = as.expression(lapply(X = n, FUN = function(n1) {
        call("==", as.symbol("n"), n1)
    })),
    col      = colours[seq_along(n)],
    lwd      = 2,
    bty      = "n"
)


## Reverse Bessel polynomials
n <- 0:5
plot(
    xlim = c(-10, 10), ylim = c(-10, 20),
    panel.first = graphics::grid(col = "gray69"),
    x = NA_real_, y = NA_real_,
    xlab = "x", ylab = as.call(list(call("[", as.symbol("theta"),
        as.symbol("n")), as.symbol("x"))),
    main = "Reverse Bessel Polynomials"
)
for (i in seq_along(n)) {
    graphics::lines(as.polynomial(rBessel(n[[i]])),
        col = colours[[i]], n = 1001, lwd = 2,
        xlim = graphics::par("usr")[1:2])
}
graphics::box()
graphics::legend(
    x        = "bottomright",
    legend   = as.expression(lapply(X = n, FUN = function(n1) {
        call("==", as.symbol("n"), n1)
    })),
    col      = colours[seq_along(n)],
    lwd      = 2,
    bty      = "n"
)


## Chebyshev polynomials of the first kind
n <- 0:4
plot(
    xlim = c(-1, 1), ylim = c(-1, 1),
    panel.first = graphics::grid(col = "gray69"),
    x = NA_real_, y = NA_real_,
    xlab = "x", ylab = as.call(list(call("[", as.symbol("T"),
        as.symbol("n")), as.symbol("x"))),
    main = "Chebyshev polynomials of the first kind"
)
for (i in seq_along(n)) {
    graphics::lines(as.polynomial(Chebyshev1(n[[i]])),
        col = colours[[i]], n = 1001, lwd = 2,
        xlim = graphics::par("usr")[1:2]
    )
}
graphics::box()
graphics::legend(
    x        = "bottomright",
    legend   = as.expression(lapply(X = n, FUN = function(n1) {
        call("==", as.symbol("n"), n1)
    })),
    col      = colours[seq_along(n)],
    lwd      = 2,
    bty      = "n"
)


## Chebyshev polynomials of the second kind
n <- 0:4
plot(
    xlim = c(-1, 1), ylim = c(-4, 5),
    panel.first = graphics::grid(col = "gray69"),
    x = NA_real_, y = NA_real_,
    xlab = "x", ylab = as.call(list(call("[", as.symbol("U"),
        as.symbol("n")), as.symbol("x"))),
    main = "Chebyshev polynomials of the second kind"
)
for (i in seq_along(n)) {
    graphics::lines(as.polynomial(Chebyshev2(n[[i]])),
        col = colours[[i]], n = 1001, lwd = 2,
        xlim = graphics::par("usr")[1:2]
    )
}
graphics::box()
graphics::legend(
    x        = "bottomright",
    legend   = as.expression(lapply(X = n, FUN = function(n1) {
        call("==", as.symbol("n"), n1)
    })),
    col      = colours[seq_along(n)],
    lwd      = 2,
    bty      = "n"
)


## Cyclotomic polynomials
n <- 1:5
plot(
    xlim = c(-3, 3), ylim = c(-10, 10),
    panel.first = graphics::grid(col = "gray69"),
    x = NA_real_, y = NA_real_,
    xlab = "x", ylab = as.call(list(call("[", as.symbol("Phi"),
        as.symbol("n")), as.symbol("x"))),
    main = "Cyclotomic Polynomials"
)
for (i in seq_along(n)) {
    graphics::lines(as.polynomial(Cyclotomic(n[[i]])),
        col = colours[[i]], n = 1001, lwd = 2,
        xlim = graphics::par("usr")[1:2]
    )
}
graphics::box()
graphics::legend(
    x        = "bottomright",
    legend   = as.expression(lapply(X = n, FUN = function(n1) {
        call("==", as.symbol("n"), n1)
    })),
    col      = colours[seq_along(n)],
    lwd      = 2,
    bty      = "n"
)


## Hermite polynomials
n <- 0:5
plot(
    xlim = c(-3, 6), ylim = c(-10, 20),
    panel.first = graphics::grid(col = "gray69"),
    x = NA_real_, y = NA_real_,
    xlab = "x", ylab = as.call(list(call("[", as.symbol("H"),
        as.symbol("n")), as.symbol("x"))),
    main = "Hermite Polynomials"
)
for (i in seq_along(n)) {
    graphics::lines(as.polynomial(Hermite(n[[i]])),
        col = colours[[i]], n = 1001, lwd = 2,
        xlim = graphics::par("usr")[1:2]
    )
}
graphics::box()
graphics::legend(
    x        = "bottomright",
    legend   = as.expression(lapply(X = n, FUN = function(n1) {
        call("==", as.symbol("n"), n1)
    })),
    col      = colours[seq_along(n)],
    lwd      = 2,
    bty      = "n"
)
# }

Run the code above in your browser using DataLab