The `a i` (`calc-integral`

) [`integ`

] command computes the
indefinite integral of the expression on the top of the stack with
respect to a variable. The integrator is not guaranteed to work for
all integrable functions, but it is able to integrate several large
classes of formulas. In particular, any polynomial or rational function
(a polynomial divided by a polynomial) is acceptable. (Rational functions
don't have to be in explicit quotient form, however; @c{$x/(1+x^{-2})$}
x/(1+x^-2)
is not strictly a quotient of polynomials, but it is equivalent to
x^3/(x^2+1), which is.) Also, square roots of terms involving
x and x^2 may appear in rational functions being
integrated. Finally, rational functions involving trigonometric or
hyperbolic functions can be integrated.

Please note that the current implementation of Calc's integrator sometimes
produces results that are significantly more complex than they need to
be. For example, the integral Calc finds for @c{$1/(x+\sqrt{x^2+1})$}
1/(x+sqrt(x^2+1))
is several times more complicated than the answer Mathematica
returns for the same input, although the two forms are numerically
equivalent. Also, any indefinite integral should be considered to have
an arbitrary constant of integration added to it, although Calc does not
write an explicit constant of integration in its result. For example,
Calc's solution for @c{$1/(1+\tan x)$}
1/(1+tan(x)) differs from the solution given
in the *CRC Math Tables* by a constant factor of @c{$\pi i / 2$}
pi i / 2,
due to a different choice of constant of integration.

The Calculator remembers all the integrals it has done. If conditions
change in a way that would invalidate the old integrals, say, a switch
from degrees to radians mode, then they will be thrown out. If you
suspect this is not happening when it should, use the
`calc-flush-caches`

command; see section Caches.

Calc normally will pursue integration by substitution or integration by
parts up to 3 nested times before abandoning an approach as fruitless.
If the integrator is taking too long, you can lower this limit by storing
a number (like 2) in the variable `IntegLimit`

. (The `s I`
command is a convenient way to edit `IntegLimit`

.) If this variable
has no stored value or does not contain a nonnegative integer, a limit
of 3 is used. The lower this limit is, the greater the chance that Calc
will be unable to integrate a function it could otherwise handle. Raising
this limit allows the Calculator to solve more integrals, though the time
it takes may grow exponentially. You can monitor the integrator's actions
by creating an Emacs buffer called `*Trace*`

. If such a buffer
exists, the `a i` command will write a log of its actions there.

If you want to manipulate integrals in a purely symbolic way, you can set the integration nesting limit to 0 to prevent all but fast table-lookup solutions of integrals. You might then wish to define rewrite rules for integration by parts, various kinds of substitutions, and so on. See section Rewrite Rules.

Go to the first, previous, next, last section, table of contents.