next up previous contents
Next: Numerical Integration Up: Calculus Previous: Taylorpolynomial

Indefinite Integral

integrate(function, x) integrates expression function with respect to the symbolic variable x. Jasymca uses the following strategy:
  1. Integrals of builtin-functions and all polynomials are provided:
    >> syms x
    >> integrate(x^2+x-3,x)
    ans = 0.33333*x^3+0.5*x^2-3*x
    >> integrate(sin(x),x)
    ans = -cos(x)
  2. If function is rational (i.e. quotient of two polynomials, whose coefficients do not depend on x)) we use the standard approach: Separate a polynomial part, then separate a square free part using Horowitz' [11] method, and finally integrate the rest using partial fractions. The final terms are collected to avoid complex expressions.
    >> syms x
    >> y=(x^3+2*x^2-x+1)/((x+i)*(x-i)*(x+3))       
    y = (x^3+2*x^2-x+1)/(x^3+3*x^2+x+3)
    >> integrate(y,x)
    ans = -1/4*log(x^2+1)+(-1/2*log(x+3)+(-1/2*atan(x)+x))
    >> diff(ans,x)           % control
    ans = (x^3+2*x^2-x+1)/(x^3+3*x^2+x+3)
  3. Expressions of type $g(f(x))\cdot f'(x)$ and $\frac{f'(x)}{f(x)}$ are detected:
    >> syms x
    >> integrate(x*exp(-2*x^2),x)                  
    ans = -0.25*exp(-2*x^2)
    >> integrate(exp(x)/(3+exp(x)),x)               
    ans = log(exp(x)+3)
  4. Substitutions of type $(a\cdot x+b)$ are applied:
    >> syms x
    >> integrate(3*sin(2*x-4),x)                    
    ans = -1.5*cos(2*x-4)
  5. Products $polynomial(x)\cdot f(x)$ are fed through partial integration. This solves all cases where $f$ is one of exp, sin , cos , log , atan.
    >> syms x
    >> integrate(x^3*exp(-2*x),x)                  
    ans = (-0.5*x^3-0.75*x^2-0.75*x-0.375)*exp(-2*x)
    >> integrate(x^2*log(x),x)                    
    ans = 0.33333*x^3*log(x)-0.11111*x^3
  6. All trig and exp-functions are normalized. This solves any expression, which is the product of any number and any type of exponentials and trigonometric functions, and some cases of rational expressions of trig- and exp-functions
    >> syms x
    >> integrate(sin(x)*cos(3*x)^2,x)         
    ans = -3.5714E-2*cos(7*x)+(5.0E-2*cos(5*x)-0.5*cos(x))
    >> integrate(1/(sin(3*x)+1),x)             
    ans = -2/3*cos(3/2*x)/(sin(3/2*x)+cos(3/2*x))
  7. The special case $\sqrt{ax^2+bx+c}$ is implemented:
    >> syms x
    >> integrate(sqrt(x^2-1),x)                     
    ans = 0.5*x*sqrt(x^2-1)-0.5*log(2*sqrt(x^2-1)+2*x)
  8. Clever substitutions may be supplied manually through subst(). If all fails, integrate numerically using quad or romberg.
The symbolic variable may be omitted if it is the main variable of expression. Integrations can be quickly verified using diff() on the result.

next up previous contents
Next: Numerical Integration Up: Calculus Previous: Taylorpolynomial
Helmut Dersch