Learn R Programming

pracma (version 1.2.5)

pade: Pade Approximation

Description

A Pade approximation is a rational function (of a specified order) whose power series expansion agrees with a given function and its derivatives to the highest possible order.

Usage

pade(p1, p2 = c(1), d1 = 5, d2 = 5)

Arguments

p1
polynomial representing or approximating the function, preferably the Taylor series of the function around some point.
p2
if present, the function is given as p1/p2.
d1
the degree of the numerator of the rational function.
d2
the degree of the denominator of the rational function.

Value

  • List with components r1 and r2 for the numerator and denominator polynomials, i.e. r1/r2 is the rational approximation sought.

Details

The relationship between the coefficients of p1 (and p2) and r1 and r2 is determined by a system of linear equations. The system is then solved by applying the pseudo-inverse pinv for for the left-hand matrix.

References

Press, W. H., S. A. Teukolsky, W. T Vetterling, and B. P. Flannery (2007). Numerical Recipes: The Art of Numerical Computing. Third Edition, Cambridge University Press, New York.

See Also

taylor, ratInterp

Examples

Run this code
##  Exponential function
p1 <- c(1/24, 1/6, 1/2, 1.0, 1.0)  # Taylor series of exp(x) at x=0
R  <- pade(p1); r1 <- R$r1; r2 <- R$r2
f1 <- function(x) polyval(r1, x) / polyval(r2, x)
xs <- seq(-1, 1, length.out=51); ys1 <- exp(xs); ys2 <- f1(xs)
plot(xs, ys1, type = "l", col="blue")
lines(xs, ys2, col = "red")
grid()

Run the code above in your browser using DataLab