
Symbolic calculus: limits, symbolic matrices, first-order ODEs and the rational Risch algorithm
Source:R/SymbolicCalculus.R
RischIntegration.RdSymbolicLimit: the limit of an elementary expression, by
substitution when the expression is continuous at the point, by the
leading Taylor coefficients of numerator and denominator, by L'Hopital's
rule for the indeterminate forms zero over zero and infinity over
infinity (at most twelve differentiations), and at an infinite limit point
by the exact degree comparison of a rational function, by the dominant
monomial of an exp-log expression written as a sum of terms
c exp(P(x)) x^a (log x)^b (Gruntz's most-rapidly-varying comparison
restricted to that class), or by the squeeze theorem for a bounded
numerator over an unbounded denominator. Anything else raises an error
rather than returning a guess.
Usage
RischIntegration(expr, x = "x")
SymbolicLimit(expr, x = "x", x0 = 0, side = "both")
MatrixSymbolic(M, eigen_var = "t")
OdeSymbolic(ode = NULL, x = "x", y = "y", M = NULL, N = NULL)Arguments
- expr
Expression string.
- x
Variable name (the integration or limit variable).
- x0
Limit point;
"inf","-inf"and numbers are accepted.- side
"both","+"or"-".- M
Square matrix of numbers or expression strings, or the
Mcoefficient of a differential form inOdeSymbolic.- eigen_var
Name of the characteristic-polynomial variable.
- ode
Right-hand side
f(x, y), or"y' = f(x, y)".- y
Name of the dependent variable.
- N
The
Ncoefficient of a differential form.
Value
SymbolicLimit: list with limit, method, lhopital_steps and
expression. MatrixSymbolic: list with determinant, inverse,
char_poly, char_coeffs, eigenvalues, eigenvalues_numeric, trace and n.
OdeSymbolic: list with classes, solution, form, coefficients,
exponent and rhs. RischIntegration: list with integral,
polynomial_part, rational_part, log_part, rational, out_of_scope,
generators, verified and max_rel_error.
Details
MatrixSymbolic: determinant by Laplace cofactor expansion, inverse
as the adjugate over the determinant, characteristic polynomial
det(A - t I) expanded in eigen_var, and eigenvalues in
closed form when that polynomial is linear or quadratic, numerically from
the Durand-Kerner roots when all its coefficients are numbers, and not at
all for a higher degree with symbolic entries (Abel-Ruffini).
OdeSymbolic: classification and closed-form solution of
dy/dx = f(x, y) (or of a differential form M dx + N dy = 0):
linear by the integrating factor exp(-int p dx), Bernoulli through
v = y^(1-n), separable as the implicit int dy/h = int g dx +
C, exact through the potential int M dx + int (N - d/dy int M dx)
dy, and homogeneous reported with the substitution v = y/x. Each
criterion is checked at five sample points.
RischIntegration: the rational case of the Risch-Bronstein
algorithm: Euclidean division for the polynomial part, Hermite reduction
(Yun squarefree decomposition and Bezout identities) for the rational
part, and the Rothstein-Trager residues at the roots of the squarefree
denominator for the logarithmic part, with conjugate pairs combined into
real logarithms and arctangents. The transcendental tower and algebraic
extensions are reported as out of scope rather than guessed.
The expression core, the shunting-yard parser and the integrator are
copied from ExactAlgebra.R and SymbolicIntegration.R.
Identical to the Python arm morie.fn.symcalc.
References
Risch, R. H. (1969). The problem of integration in finite terms. Transactions of the American Mathematical Society 139, 167-189.
Bronstein, M. (1997). Symbolic Integration I: Transcendental Functions. Springer, sections 2.2 and 2.4.
Yun, D. Y. Y. (1976). On square-free decomposition algorithms. Proceedings of SYMSAC 76, 26-35.
Gruntz, D. (1996). On Computing Limits in a Symbolic Manipulation System. PhD thesis, ETH Zurich.
Horn, R. A. and Johnson, C. R. (2013). Matrix Analysis, 2nd edn, sections 0.3 and 1.2. Cambridge University Press.
Boyce, W. E. and DiPrima, R. C. (2012). Elementary Differential Equations, 10th edn, sections 2.1, 2.2, 2.4 and 2.6. Wiley.
Examples
SymbolicLimit("sin(x)/x", "x", 0)$limit
#> [1] 1
SymbolicLimit("x*exp(-x)", "x", "inf")$limit
#> [1] 0
MatrixSymbolic(list(c("a", "b"), c("c", "d")))$determinant
#> [1] "a*d - b*c"
OdeSymbolic("dy/dx = 2*x*y")$solution
#> [1] "C*exp(x^2)"
RischIntegration("(x^2 + 1)/(x^3 - x)")$integral
#> [1] "log(x + 1) + log(x - 1) - log(x)"