Next: Customizing the Integrator, Previous: Differentiation, Up: Calculus [Contents][Index]

#### 10.5.2 Integration

The `a i` (`calc-integral`) [`integ`] command computes the indefinite integral of the expression on the top of the stack with respect to a prompted-for 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; ‘`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.

With an argument (`C-u a i`), this command will compute the definite integral of the expression on top of the stack. In this case, the command will again prompt for an integration variable, then prompt for a lower limit and an upper limit.

If you use the `integ` function directly in an algebraic formula, you can also write ‘`integ(f,x,v)`’ which expresses the resulting indefinite integral in terms of variable `v` instead of `x`. With four arguments, ‘`integ(f(x),x,a,b)`’ represents a definite integral from `a` to `b`.

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 ‘`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 ‘`1/(1+tan(x))`’ differs from the solution given in the CRC Math Tables by a constant factor of ‘`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 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 Rewrite Rules.

Next: Customizing the Integrator, Previous: Differentiation, Up: Calculus [Contents][Index]