Professional Documents
Culture Documents
Syntax
int(expr,var)
int(expr,var,a,b)
int( ___ ,Name,Value)
Description
int(expr,var) computes the indefinite integral of expr with respect to the symbolic scalar example
variable var. Specifying the variable var is optional. If you do not specify it, int uses the
default variable determined by symvar. If expr is a constant, then the default variable is x.
example
int(expr,var,a,b) computes the definite integral of expr with respect to var from a to b.
If you do not specify it, int uses the default variable determined by symvar. If expr is a
constant, then the default variable is x.
int(expr,var,[a b]) is equivalent to int(expr,var,a,b).
example
int( ___ ,Name,Value) specifies additional using one or more Name,Value pair arguments.
For example, 'IgnoreAnalyticConstraints',true specifies that int applies additional
simplifications to the integrand.
syms x
f = -2*x/(1+x^2)^2;
int(f)
ans =
1/(x^2 + 1)
Find indefinite integrals of this multivariate expression with respect to the variables x and z.
syms x z
f = x/(1+z^2);
int(f,x)
int(f,z)
ans =
x^2/(2*(z^2 + 1))
ans =
x*atan(z)
If you do not specify the integration variable, int uses the variable returned by symvar. For this
expression, symvar returns x.
symvar(f, 1)
ans =
x
syms x
f = x*log(1+x);
int(f,[0 1])
ans =
1/4
Integrate an expression from sin(t) to 1.
syms t
int(2*x, [sin(t) 1])
ans =
cos(t)^2
When int cannot compute a definite integral, numerically approximate the integral by using vpa.
syms x
f = cos(x)/sqrt(1 + x^2);
fInt = int(f,x,[0 10]);
fVpa = vpa(fInt)
fVpa =
0.37570628299079723478493405557162
To approximate integrals directly, use vpaintegral instead of vpa. The vpaintegral function is
faster and provides control over integration tolerances.
fVpa =
0.375706
Find indefinite integrals for the expressions listed as the elements of a matrix.
ans =
[ exp(t), exp(a*t)/a]
[ -cos(t), sin(t)]
Apply IgnoreAnalyticConstraints
Compute this indefinite integral. By default, int uses strict mathematical rules. These rules do not let
int rewrite asin(sin(x)) and acos(cos(x)) as x.
syms x
f = acos(sin(x));
int(f,x)
ans =
x*acos(sin(x)) + x^2/(2*sign(cos(x)))
If you want a simple practical solution, try IgnoreAnalyticConstraints.
ans =
-(x*(x - pi))/2
Compute this integral with respect to the variable x. By default, int returns the integral as a piecewise
object where every branch corresponds to a particular value (or a range of values) of the symbolic
parameter t.
syms x t
int(x^t, x)
ans =
piecewise(t == -1, log(x), t ~= -1, x^(t + 1)/(t + 1))
To ignore special cases of parameter values, use IgnoreSpecialCases. With this option, int
ignores the special case t=-1 and returns only the branch where t<>–1.
ans =
x^(t + 1)/(t + 1)
Compute this definite integral, where the integrand has a pole in the interior of the interval of
integration. Mathematically, this integral is not defined.
syms x
f = 1/(x-1);
int(f,x,0,2)
ans =
NaN
However, the Cauchy principal value of the integral exists. Use PrincipalValue to compute the
Cauchy principal value of the integral.
int(f,x,0,2,'PrincipalValue',true)
ans =
0
syms x
f = sin(sinh(x));
int(f,x)
ans =
int(sin(sinh(x)), x)
If int cannot compute a closed form of an indefinite integral, try to approximate the expression around
some point using taylor, and then compute the integral. For example, approximate the expression
around x = 0.
ans =
x^10/56700 - x^8/720 - x^6/90 + x^2/2
expr — Integrand
symbolic expression | symbolic function | symbolic vector | symbolic matrix | symbolic number
Integration variable, specified as a symbolic variable. If you do not specify this variable, int uses the
default variable determined by symvar(expr,1). If expr is a constant, then the default variable is x.
a — Lower bound
number | symbolic number | symbolic variable | symbolic expression | symbolic function
Lower bound, specified as a number, symbolic number, variable, expression, or function (including
expressions and functions with infinities).
b — Upper bound
number | symbolic number | symbolic variable | symbolic expression | symbolic function
Upper bound, specified as a number, symbolic number, variable, expression, or function (including
expressions and functions with infinities).
Indicator for applying purely algebraic simplifications to integrand, specified as true or false. If the
value is true, apply purely algebraic simplifications to the integrand. This option can provide simpler
results for expressions, for which the direct use of the integrator returns complicated results.
Sometimes, it also enables int to compute integrals that cannot be computed otherwise.
Indicator for ignoring special cases, specified as true or false. This ignores cases that require one or
more parameters to be elements of a comparatively small set, such as a fixed finite set or a set of
integers.
Indicator for returning principal value, specified as true or false. If the value is true, compute the
Cauchy principal value of the integral.
Tips
• In contrast to differentiation, symbolic integration is a more complicated task. If int cannot compute an
integral of an expression, check for these reasons:
˗ The antiderivative does not exist in a closed form.
˗ The antiderivative exists, but int cannot find it.
Algorithms
When you use IgnoreAnalyticConstraints, int applies these rules:
• log(a) + log(b) = log(a·b) for all values of a and b. In particular, the following equality is valid for all values of
a, b, and c:
(a·b)c = ac·bc.
• log(ab) = b·log(a) for all values of a and b. In particular, the following equality is valid for all values of a, b,
and c:
(ab)c = ab·c.
• If f and g are standard mathematical functions and f(g(x)) = x for all small positive numbers, then f(g(x)) = x
is assumed to be valid for all complex values x. In particular:
˗ log(ex) = x
˗ asin(sin(x)) = x, acos(cos(x)) = x, atan(tan(x)) = x
˗ asinh(sinh(x)) = x, acosh(cosh(x)) = x, atanh(tanh(x)) = x
˗ lambertWk(x·ex) = x for all values of k
See Also
diff | functionalDerivative | symprod | symsum | symvar | vpaintegral
Topics
Integration