Page 82 - A Guide to MATLAB for Beginners and Experienced Users
P. 82
Doing Calculus with MATLAB 63
You have another option. If you type double(int( )), then Maple’s
numerical integration routine will evaluate the integral — even over an
infinite range.
MATLAB can also do multiple integrals. The following command computes
the double integral
π sin x
2
2
(x + y ) dy dx :
0 0
>> syms x y; int(int(xˆ2 + yˆ1, y, 0, sin(x)), 0, pi)
ans =
pi^2-32/9
Note that MATLAB presumes that the variable of integration in int is x
unless you prescribe otherwise. Note also that the order of integration is as in
calculus, from the “inside out”. Finally, we observe that there is a numerical
double integral command dblquad, whose properties and use we will allow
you to discover from the online help.
Limits
You can use limit to compute right- and left-handed limits and limits at
infinity. For example, here is lim sin(x)/x:
x→0
>> syms x; limit(sin(x)/x, x, 0)
ans =
1
To compute one-sided limits, use the ’right’ and ’left’ options. For exam-
ple,
>> limit(abs(x)/x, x, 0, ’left’)
ans =
-1
Limits at infinity can be computed using the symbol Inf:
>> limit((xˆ4 + xˆ2 - 3)/(3*xˆ4 - log(x)), x, Inf)
ans =
1/3