integral.rationalfun {rationalfun} | R Documentation |
Calculate the integral of a rational function. See "Details".
## S3 method for class 'rationalfun'
integral(expr, ...)
expr |
an object of class "rationalfun" |
... |
not used in this function |
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.
A function call representing the explicit form of the integral.
T. N. Subramaniam, and Donald E. G. Malm, How to Integrate Rational Functions, The American Mathematical Monthly, Vol. 99, No.8 (1992), 762-772.
# (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)