int
Definite and indefinite integrals
Description
computes the integral of the symbolic expression F = int(expr)expr.
Because you do not specify bounds for the integral, this syntax computes the
indefinite integral. int uses the default integration
variable determined by symvar(expr,1). If expr is a
constant, then the default integration variable is x.
specifies additional options using one or more F = int(___,Name=Value)Name=Value
arguments. For example, IgnoreAnalyticConstraints=true
specifies that int applies additional simplifications to the integrand.
Note
The int function computes integral symbolically,
and it is not related to integer data types in MATLAB®. For more information about integers, see Integers.
Examples
Input Arguments
Name-Value Arguments
Tips
In contrast to differentiation, symbolic integration is a more complicated task. If
intcannot compute an integral of an expression, check for these reasons:The antiderivative does not exist in a closed form.
The antiderivative exists, but
intcannot find it.
If
intcannot compute a closed form of an integral, it returns an unresolved integral.For some integrals that have closed form solutions, where these solutions are complicated and
intreturns unresolved integrals, you can usesimplifyto obtain the closed form solutions. For example, the following code finds the closed form solution of the integral off(x):syms x f(x) = x*log(x/2+sqrt(x^2+1)); F = int(f,x) simplify(F,Steps=10)Otherwise, you can try approximating unresolved integrals by using one of these methods:
For indefinite integrals, use series expansions. Use this method to approximate an integral around a particular value of the variable.
For definite integrals, use numeric approximations.
For indefinite integrals,
intdoes not return a constant of integration in the result. The results of integrating mathematically equivalent expressions may be different. For example,syms x; int((x+1)^2)returns(x+1)^3/3, whilesyms x; int(x^2+2*x+1)returns(x*(x^2+3*x+3))/3, which differs from the first result by1/3.For indefinite integrals,
intimplicitly assumes that the integration variablevaris real. For definite integrals,intrestricts the integration variablevarto the specified integration interval, unless the interval is incompatible with an existing assumption. If one or both integration boundsaandbare not numeric,intassumes thata <= bunless you explicitly specify otherwise.For example, using the default assumption
a <= b, this code returns 0 as the result of evaluating the definite integral at(a,b)=(3,2).syms x a b F(a,b) = int(heaviside(x-1)*heaviside(4-x),a,b); F(3,2)
If you explicitly specify the assumptionans = 0
a > b, then this code returns –1 as the integral result.assume(a > b) F(a,b) = int(heaviside(x-1)*heaviside(4-x),a,b); F(3,2)
ans = -1
Algorithms
When you use IgnoreAnalyticConstraints, int
applies some of 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
Wk(x·ex) = x for all branch indices k of the Lambert W function.
Version History
Introduced before R2006aSee Also
diff | dsolve | functionalDerivative | symvar | vpaintegral | integrateByParts | changeIntegrationVariable | release | rewrite