int
-- definite and indefinite
integrationint
(f, x)
computes the indefinite (formal)
integral int(f,x).
int
(f, x = a..b)
computes the definite
integral int(f,x=a..b).
int(f, x)
int(f, x = a..b <, Continuous>)
int(f, x = a..b <, PrincipalValue>)
f |
- | the integrand: an arithmetical
expression representing a function in x |
x |
- | the integration variable: an identifier |
a, b |
- | the boundaries: arithmetical expressions |
Continuous |
- | do not look for discontinuities. |
PrincipalValue |
- | compute the Cauchy principal value of the integral. |
f
int
is sensitive to properties of identifiers set by assume
; see example 4.
Section 7.2 of the MuPAD Tutorial.
D
, diff
, intlib
, limit
, numeric::int
, sum
int(
f, x)
computes the antiderivative
g=int(f,x), i.e., it determines formally a function
g with diff(g,x)=f. Note:
x
is implicitly assumed to be real. For definite
integration the integration variable x
is further
implicitly assumed to be restricted to the given real range of
integration. See ``background'' section for more details.
This means that in general, the result of int
need not
be valid for non-real values of x
, e.g., the identity
ln(exp(x)) = x is only valid for real values of x
and thus the same is true for int(ln(exp(x)), x) =
x^2/2.
int
call. In this
case, you can use numerical integration (cf. example 2) or try to compute a series expansion of the integral
(cf. example 3).int
may not be able to find a
closed form due to singularities in the interval of integration. If the
system can assert that the integral does not exist mathematically, then
it returns undefined
. In some cases, it may
still be possible to obtain a result in closed form by using
assumptions or one of the options Continuous or
PrincipalValue (cf. example 4).numeric::int
or
float
. Numerical
integration is only possible if the boundaries a
and
b
can be converted into floating
point numbers via float
. See example 2.g
of f
with respect to
x
, such that diff(g,x)=f. If g
is
continuous on the interval [a,b], then the fundamental
theorem of calculus int(f,x=a..b)=g(a)-g(b) is used to
obtain the definite integral. Normally, it is tested if g
is continuous. In case of doubt a symbolic int
call is
returned. See ``background'' section for more details.
The option Continuous is a technical
option to tell the system that it may assume that g
is
continuous. With the option Continuous,
int
suppresses the search for discontinuities of
g
in the interval of integration and uses the fundamental
theorem of calculus without checking whether it applies mathematically.
See example 4.
int
computes this Cauchy
principal value. If the usual definite integral exists, then it agrees
with the Cauchy principal value. See example 4.We compute the two indefinite integrals int(1/x/ln(x), x) and int(1/(x^2-8), x):
>> int(1/x/ln(x), x)
ln(ln(x))
>> int(1/(x^2 - 8), x)
1/2 1/2 1/2 1/2 2 ln(x - 2 2 ) 2 ln(x + 2 2 ) ------------------- - ------------------- 8 8
We compute the definite integral of (x*ln(x))^(-1) over the interval [e, e^2]:
>> int(1/x/ln(x), x = E..E^2)
ln(2)
The boundaries of definite integrals may be +-infinity as well:
>> int(exp(-x^2), x = 0..infinity)
1/2 PI ----- 2
One can also determine multiple integrals such as, e.g., the definite multiple integral int(int(int(1, z=0..c*(1-x/a-y/b)), y=0..b*(1-x/a)), x=0..a):
>> int(int(int(1, z = 0..c*(1 - x/a - y/b)), y = 0..b*(1 - x/a)), x = 0..a)
a b c ----- 6
The system cannot find a closed form for the following
definite integral and returns a symbolic int
call. You can
obtain a floating point approximation by applying float
to the result:
>> int(sin(cos(x)), x = 0..1)
int(sin(cos(x)), x = 0..1)
>> float(%)
0.738642998
Alternatively, you can use the function numeric::int
. This is recommended if
you are interested only in a numerical approximation, since it does not
involve any symbolic preprocessing and is therefore usually much faster
than applying float
to a
symbolic int
call.
>> numeric::int(sin(cos(x)), x = 0..1)
0.738642998
int
cannot find a closed form for the
following indefinite integral and returns a symbolic int
call:
>> int((x^2 + 1)/sqrt(x^3 + 1), x)
/ 2 \ | x + 1 | int| -----------, x | | 3 1/2 | \ (x + 1) /
You can use series
to obtain a series expansion
of the integral:
>> series(%, x = 0)
3 4 6 x x x 7 x + -- - -- - -- + O(x ) 3 8 12
Alternatively, you can compute a series expansion of the integrand and integrate it afterwards. This is recommended if you are not interested in a closed form of the integral, but only in a series expansion, since it is usually much faster than the other way round:
>> int(series((x^2 + 1)/sqrt(x^3 + 1), x = 0), x)
3 4 6 x x x 7 x + -- - -- - -- + O(x ) 3 8 12
int
correctly asserts that the following
definite integral, where the integrand has a pole in the interior of
the interval of integration, is not defined:
>> int(1/(x - 1), x = 0..2)
undefined
However, the Cauchy principle value of the integral exists:
>> int(1/(x - 1), x = 0..2, PrincipalValue)
0
If, however, the integrand contains a parameter, then
int
may not be able to decide whether the integrand has
poles in the interval of integration. In such a case, a warning is
issued and a symbolic int
call is returned:
>> int(1/(x - a), x = 0..2)
Warning: Found potential discontinuities of the antiderivative\ . Try option 'Continuous' or use properties (?assume). [intlib::\ antiderivative] / 1 \ int| -----, x = 0..2 | \ x - a /
We follow the suggestion given by the text of the
warning and make an assumption on the parameter a
implying
that the integrand has no poles in the interval of integration. In this
example, int
is able to find a closed form of the
integral:
>> assume(a > 2): int(1/(x - a), x = 0..2)
ln(2 - a) - ln(-a)
Alternatively, we can use the option Continuous to tell int
that it may assume
that the integrand is continuous in the range of integration:
>> unassume(a): int(1/(x - a), x = 0..2, Continuous)
ln(2 - a) - ln(-a)
Mathematically, the result with option Continuous may be incorrect for some values of the occurring parameters. In the example above, the result is incorrect for 0 < a < 2. We therefore recommend to use this option only as a last resort.
In this example we will stress the effects of assumptions on the integration variable. See ``background'' section for more details.
The integration variable is implicitly assumed to be real, or even for a given (real) interval of integration restricted to that interval. Among other things this assumption has an impact on the simplification of results.
For example, to compute the following integral internally the so-called Risch algorithm is used and only because of that implicit assumption the result is simplified into a real representation.
>> int(1/cos(x)^2, x)
2 sin(2 x) -------------- 2 cos(2 x) + 2
In order to see what will happen without this implicit assumption one can explicitly define the integration variable to be complex:
>> assume(x, Type::Complex): int(1/cos(x)^2, x)
2 I - ------------------------- cos(2 x) - I sin(2 x) + 1
User-defined assumptions which are inconsistent with the assumptions made internally in the integration do not lead to an integration error as they should. However, the user must become aware of the inconsistency.
>> assume(x, Type::Imaginary): int(1/cos(x)^2, x)
Warning: Cannot integrate when x has property Type::Imaginary. While integrating, we will assume x has property Type::Complex\ . [intlib::int] 2 I - ------------------------- cos(2 x) - I sin(2 x) + 1
>> assume(x, Type::Integer): int(1/cos(x)^2, x)
Warning: Cannot integrate when x has property Type::Integer. While integrating, we will assume x has property Type::Real. [\ intlib::int] 2 sin(2 x) -------------- 2 cos(2 x) + 2
The same holds for definite integration.
>> assume(x, Type::Interval(-5, -2)): int(x, x = 0..1)
Warning: While integrating, we will assume x has property [0, \ 1] of Type::Real instead of given property ]-5, -2[ of Type::R\ eal. [intlib::defInt] 1/2
sqrt(-1)*diff(ln((u + sqrt(-1))/(u - sqrt(-1))), x) = 2*diff(arctan(x), x)where u is an element of K(x) such that u^2 <> -1 and K is a subfield of the reals, it does not eliminate the problem. However, it may be used in some integration tables.
Thus, if such results are used for definite integration, it is necessary to investigate the search for discontinuities of the antiderivatives in the interval of integration.
Type::Real
). Moreover, for definite
integration, the range of validity is restricted to the interval of
integration (Type::Interval
[a, b]
).
If conflicts occur with user-defined properties by assume
of identifiers, an appropriate
warning is given. The warnings may be toggled on and off with
intlib::printWarnings(TRUE)
and
intlib::printWarnings(FALSE)
.
In the case of indefinite integration the user-defined properties are used if the conflict can be resolved. If not, but the given properties describe a subset of the real numbers, the real assumption is used. Otherwise, while integrating, the integration variable is assumed to be complex.
If, in the case of definite integration, the user-defined properties contains the given integration interval, these properties are used. Otherwise, the previously given assumption are set locally.
Cf. example 5.
Continuous
was added.