You are a guest. Restricted access. Read more

# Indefinite Integral

integrate(function, x) integrates a function with respect to the symbolic variable x. The program recognizes all built-in functions and polynomials:

syms x
a=integrate(x^2+x-3,x)
printf('%f',a)

Let us consider an example which shows the original function and its integral in a single 2D plot:

syms x
w1=x^2+x
w2=integrate(w1,x)
plot2d()
draw2d(w1,'name=x^{2}+x')
draw2d(w2,'name=integral;linestyle=2;color=blue;')

All trigonometric functions are also supported. Run this script to see the answer.

syms x
y=integrate(cos(x)*sin(x),x)
printf('%f',y)

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))
printf('%f',y)

syms x
y = (x^3+2*x^2-x+1)/(x^3+3*x^2+x+3)
a=integrate(y,x)
printf('%f',a)
b=diff(a,x)           % control
printf('%f',b)

Expressions of type $g(f(x))\cdot f'(x)$ and $\frac{f'(x)}{f(x)}$ are detected:

syms x
y=integrate(x*exp(-2*x^2),x)
printf('%f',y)

syms x
y=integrate(exp(x)/(3+exp(x)),x)
printf('%f',y)

Substitutions of type $(a\cdot x+b)$ are applied:

syms x
y=integrate(3*sin(2*x-4),x)
printf('%f',y)

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
y=integrate(x^3*exp(-2*x),x)
printf('%f',y)

syms x
y=integrate(x^2*log(x),x)
printf('%f',y)

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
y=integrate(sin(x)*cos(3*x)^2,x)
printf('%f',y)

syms x
y=integrate(1/(sin(3*x)+1),x)
printf('%f',y)

The special case $\sqrt{ax^2+bx+c}$ is implemented:

syms x
y=integrate(sqrt(x^2-1),x)
printf('%f',y)

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. Integration can be quickly verified using diff() on the result.