Learn R Programming

rationalfun (version 0.1-1)

integral.rationalfun: Integrate a rational function

Description

Calculate the integral of a rational function. See "Details".

Usage

# S3 method for rationalfun
integral(expr, ...)

Arguments

expr

an object of class "rationalfun"

not used in this function

Value

A function call representing the explicit form of the integral.

Details

The returned value is a function call with argument named "x". That is, the integral is an expression in R with an explicit form, which could be evaluated directly by calling eval(), or indirectly using the int2fun() function.

The algorithm is based on the Hermite-Ostrogradski formula which is discussed in the reference. See the article for more details.

References

T. N. Subramaniam, and Donald E. G. Malm, How to Integrate Rational Functions, The American Mathematical Monthly, Vol. 99, No.8 (1992), 762-772.

See Also

integral.polynomial

Examples

Run this code
# NOT RUN {
# (x + 1) / (x^2 + x + 1)
r <- rationalfun(c(1, 1), c(1, 1, 1))
expr <- integral(r)
# Evaluate the call directly
eval(expr, list(x = 2))
# Use int2fun()
f <- int2fun(expr)
f(2)
# }

Run the code above in your browser using DataLab