| Symbolic Math Toolbox | ![]() |
Integration
If f is a symbolic expression, then
attempts to find another symbolic expression, F, so that diff(F) = f. That is, int(f) returns the indefinite integral or antiderivative of f (provided one exists in closed form). Similar to differentiation,
uses the symbolic object v as the variable of integration, rather than the variable determined by findsym. See how int works by looking at this table.
| Mathematical Operation |
MATLAB Command |
![]() |
int(x^n) orint(x^n,x) |
![]() |
int(sin(2*x),0,pi/2) or int(sin(2*x),x,0,pi/2) |
![]() ![]() |
g = cos(a*t + b) orint(g,t) |
![]() |
int(besselj(1,z)) orint(besselj(1,z),z) |
In contrast to differentiation, symbolic integration is a more complicated task. A number of difficulties can arise in computing the integral:
F, may not exist in closed form.
Nevertheless, in many cases, MATLAB can perform symbolic integration successfully. For example, create the symbolic variables
The following table illustrates integration of expressions containing those variables.
| f |
int(f) |
x^n |
x^(n+1)/(n+1) |
y^(-1) |
log(y) |
n^x |
1/log(n)*n^x |
sin(a*theta+b) |
-1/a*cos(a*theta+b) |
1/(1+u^2) |
atan(u) |
exp(-x^2) |
1/2*pi^(1/2)*erf(x) |
In the last example, exp(-x^2), there is no formula for the integral involving standard calculus expressions, such as trigonometric and exponential functions. In this case, MATLAB returns an answer in terms of the error function erf.
If MATLAB is unable to find an answer to the integral of a function f, it just returns int(f).
Definite integration is also possible. The commands
are used to find a symbolic expression for
Here are some additional examples.
| f |
a, b |
int(f,a,b) |
x^7 |
0, 1 |
1/8 |
1/x |
1, 2 |
log(2) |
log(x)*sqrt(x) |
0, 1 |
-4/9 |
exp(-x^2) |
0, inf |
1/2*pi^(1/2) |
besselj(1,z)^2 |
0, 1 |
1/12*hypergeom([3/2, 3/2], |
For the Bessel function (besselj) example, it is possible to compute a numerical approximation to the value of the integral, using the double function. The commands
Integration with Real Parameters
One of the subtleties involved in symbolic integration is the "value" of various parameters. For example, if a is any positive real number, the expression
is the positive, bell shaped curve that tends to 0 as x tends to
. You can create an example of this curve, for
, using the following commands:
However, if you try to calculate the integral
without assigning a value to a, MATLAB assumes that a represents a complex number, and therefore returns a complex answer. If you are only interested in the case when a is a positive real number, you can calculate the integral as follows:
The argument positive in the syms command restricts a to have positive values. Now you can calculate the preceding integral using the commands
If you want to calculate the integral
for any real number a, not necessarily positive, you can declare a to be real with the following commands:
You can put this in a more readable form by entering
The ~ after a is simply a reminder that a is real, and signum(a~) is the sign of a. So the integral is
when a is positive, just as in the preceding example, and
when a is negative.
You can also declare a sequence of symbolic variables w, y, x, z to be real by entering
Integration with Complex Parameters
for complex values of a, enter
Note that syms is used with the unreal option to clear the real property that was assigned to a in the preceding example -- see Clearing Variables in the Maple Workspace.
The preceding commands produce is the complex output
You can make this output more readable by entering
The expression csgn(a) (complex sign of a) is defined by
The condition csgn(a) = 1 corresponds to the shaded region of the complex plane shown in the following figure.
The square root of a in the answer is the unique square root lying in the shaded region.
| Limits | Symbolic Summation | ![]() |
Learn more about the latest releases of MathWorks products: |
| © 1994-2009 The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |