Integrals
==========
.. module:: sympy.integrals
The *integrals* module in SymPy implements methdos calculating definite un undefinite integrals of expressions.
Principal method in this module is integrate()
- integrate(f, x) returns the indefinite integral :math:`\int f\,dx`
- integrate(f, (x, a, b)) returns the definite integral :math:`\int_{a}^{b} f\,dx`
Examples
--------
SymPy can integrate a vast array of functions. It can integrate polynomial functions::
>>> from sympy import *
>>> import sys
>>> sys.displayhook = pprint
>>> x = Symbol('x')
>>> integrate(x**2 + x + 1, x)
3 2
x x
-- + -- + x
3 2
Rational functions::
>>> integrate(x/(x**2+2*x+1), x)
1
log(x + 1) + -----
x + 1
Exponential-polynomial functions. Multiplicative combinations of polynomials and the functions exp, cos and sin can be integrated by hand using repeated integration by parts, which is an extremely tedious process. Happily, SymPy will deal with these integrals.
::
>>> integrate(x**2 * exp(x) * cos(x), x)
2 x 2 x x x
x *e *sin(x) x *e *cos(x) x e *sin(x) e *cos(x)
------------ + ------------ - x*e *sin(x) + --------- - ---------
2 2 2 2
even a few nonelementary integrals (in particular, some integrals involving the error function) can be evaluated::
>>> integrate(exp(-x**2)*erf(x), x)
____ 2
\/ pi *erf (x)
--------------
4
Internals
---------
There is a general method for calculating antiderivatives of elementary functions, called the Risch algorithm. The Risch algorithm is a decision procedure that can determine whether an elementary solution exists, and in that case calculate it. It can be extended to handle many nonelementary functions in addition to the elementary ones.
SymPy currently uses a simplified version of the Risch algorithm, called the Risch-Norman algorithm. This algorithm is much faster, but may fail to find an antiderivative, although it is still very powerful. SymPy also uses pattern matching and heuristics to speed up evaluation of some types of integrals, e.g. polynomials.
API reference
-------------
.. automethod:: sympy.integrals.integrate
Class Integral represents an unevaluated integral and has some methods that help in the integration of an expression.
.. autoclass:: sympy.integrals.Integral
:members:
TODO and Bugs
-------------
There are still lots of functions that sympy does not know how to integrate. For bugs related to this module, see http://code.google.com/p/sympy/issues/list?q=label:Integration