Definite and indefinite integrals

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

For indefinite integration in MATLAB®, see the Symbolic Math Toolbox™ int function. For numerical integration, see the integral function.


int(f, x)
int(f, x = a .. b, options)


int(f, x) computes the indefinite integral .

int(f, x = a..b) computes the definite integral .

int(f, x) determines a function F such that . The function F(x) is called the antiderivative of f(x). Results returned by int do not include integration constants.

For indefinite integrals, int implicitly assumes that the integration variable x is real. For definite integrals, int restricts the integration variable x to the specified integration interval [a, b] of the type Type::Interval. If one or both integration bounds a and b are not numeric, int assumes that a <= b unless you explicitly specify otherwise. By default, int does not issue warnings about these assumptions. To display the warnings about using implicit assumptions, set the value of intlib::printWarnings to TRUE.

In general, the result of int is not required to be valid for all complex values of x. For example, the identity is only valid for real values of x. Therefore, is also valid only for real values of x.

You can specify your own assumptions of the integration variable. If these assumptions do not conflict with the default assumption that the variable is real or with the integration interval, then MuPAD® uses your assumptions. Otherwise, the int function issues a warning and changes the assumptions. Use intlib::printWarnings to enable or disable the warnings.

If you compute an indefinite integral and specify properties of the integration variable that describe a subset of the real numbers, MuPAD assumes that the variable is real. Otherwise, the system uses temporary assumption that the integration variable is complex. This assumption holds only during this particular integration.

If you compute a definite integral and specify properties that conflict with the integration interval, int uses the integration interval.

int can return results with discontinuities even if the integrand is continuous.

Integration techniques, such as table lookup or Risch integration for an indefinite integral, can add new discontinuities during the integration process. These new discontinuities appear because the antiderivatives can require the introduction of complex logarithms. Complex logarithms have a jump discontinuity when the argument crosses the negative real axis, and the integration algorithms sometimes cannot find a representation where these jumps cancel.

If you compute a definite integral by first computing an indefinite integral and then substituting the integration boundaries into the result, remember that indefinite integration can produce discontinuities. If it does, you must investigate the discontinuities in the integration interval.

If MuPAD cannot find a closed-form solution for the integral and cannot prove that such form does not exist, it returns an unresolved integral. In this case, you can approximate the integral numerically or try computing a series expansion of the integral. See Example 2 and Example 3.

You can approximate a definite integral numerically using numeric::int or float. Numeric approximation of a definite integral only works when the float function can convert the boundaries a and b of the integration interval to floating-point numbers. See Example 2.

int might not find a closed form of a definite integral because of singularities of the integrand in the interval of integration. If the integral does not exist in a strict mathematical sense, int returns the value undefined. In this case, try using assumptions. Alternatively, use the PrincipalValue option to compute a weaker form of a definite integral called the Cauchy principal value. This form of an integral can exist even though the standard integral value is undefined. See Example 6.

In general, the derivative of the result coincides with f on a dense subset of the real numbers (or, if you use assumptions on the integration variable, the subset of real numbers specified by these assumptions).

It is not always possible to decide algorithmically if and f are equivalent. The reason is the so-called zero equivalence problem, which in general is undecidable.

Environment Interactions

int is sensitive to properties of identifiers set by assume. See Example 6.


Example 1

Compute the indefinite integrals and :

int(1/x/ln(x), x)

int(1/(x^2 - 8), x)

Compute the definite integral over the interval [e, e2]:

int(1/x/ln(x), x = exp(1)..exp(2))

When computing definite integrals, you can use infinities as the boundaries of the integration interval:

int(exp(-x^2), x = 0..infinity)

You can compute multiple integrals. For example, compute the following definite multiple integral:

int(int(int(1, z = 0..c*(1 - x/a - y/b)),
        y = 0..b*(1 - x/a)), x = 0..a)

Example 2

Use int to compute this definite integral. Since int cannot find a closed form of this integral, it returns an unresolved integral:

S := int(sin(cos(x)), x = 0..1)

Use the float function to approximate the integral numerically:


Alternatively, use the numeric::int function, which is faster because it does not involve any symbolic preprocessing:

numeric::int(sin(cos(x)), x = 0..1)

Example 3

Use int to compute this indefinite integral. Since int cannot find a closed form of this integral, it returns an unresolved integral:

int((x^2 + 1)/sqrt(sqrt(x + 1) + 1), x)

Use the series function to compute a series expansion of the integral:

series(%, x = 0)

Alternatively, compute a series expansion of the integrand, and then integrate the result. This approach is faster because it does not try to integrate the original expression. It integrates an approximation (the series expansion) of the original expression:

int(series((x^2 + 1)/sqrt(sqrt(x + 1) + 1), x = 0), x)

Example 4

The IgnoreAnalyticConstraints option applies a set of purely algebraic simplifications including the equality of sum of logarithms and a logarithm of a product. Using this option, you get a simpler result, but one that might be incorrect for some of the values of the variables:

int(ln(x) + ln(y) - ln(x*y), x, IgnoreAnalyticConstraints)

Without using this option, you get the following result, which is valid for all values of the parameters:

int(ln(x) + ln(y) - ln(x*y), x)

The results obtained with IgnoreAnalyticConstraints might be not generally valid:

f := int(ln(x) + ln(y) - ln(x*y), x):
g := int(ln(x) + ln(y) - ln(x*y), x, IgnoreAnalyticConstraints):
simplify([f, g]) assuming x = -1 and y = -1

Example 5

By default, int returns this integral as a piecewise object where every branch corresponds to a particular value (or a range of values) of the symbolic parameter t:

int(x^t, x)

To ignore special cases of parameter values, use IgnoreSpecialCases:

int(x^t, x, IgnoreSpecialCases)

Example 6

Compute this definite integral, where the integrand has a pole in the interior of the interval of integration. Mathematically, this integral is not defined:

int(1/(x - 1), x = 0..2)

However, the Cauchy principal value of the integral exists. Use the PrincipalValue option to compute the Cauchy principal value of the integral:

hold(int)(1/(x - 1), x = 0..2, PrincipalValue) =
     int( 1/(x - 1), x = 0..2, PrincipalValue)

For integrands with parameters, int might be unable to decide if the integrand has poles in the interval of integration. In this case, int returns a piecewise-defined function or an unresolved integral:

int(1/(x - a), x = 0..2)

int does not call simplification functions for its results. To simplify results returned by int, use eval, simplify, or Simplify:


The resulting piecewise expression has only one branch. If the parameter a does not satisfy this condition, the integral is undefined.



The integrand: an arithmetical expression representing a function in x


The integration variable: an identifier

a, b

The boundaries: arithmetical expressions



When you use this option, int applies these simplifications rules to the integrand:

  • ln(a) + ln(b) = ln(ab) for all values of a and b. In particular:

    for all values of a, b, and c

  • ln(ab) = bln(a) for all values of a and b. In particular:

    for all values of a, b, and c

  • If f and g are standard mathematical functions and f(g(x)) = x for all small positive numbers, f(g(x)) = x is assumed to be valid for all complex x. In particular:

    • arcsin(sin(x)) = x, arccos(cos(x)) = x, arctan(tan(x)) = x

    • arcsinh(sinh(x)) = x, arccosh(cosh(x)) = x, arctanh(tanh(x)) = x

    • for all values of k

Using this option, you can get simpler solutions for some integrals for which the direct call of the integrator returns complicated results. With this option the integrator does not verify the correctness and completeness of the result. See Example 4.


If integration requires case analysis, ignore 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.

With this option, int tries to reduce the number of branches in piecewise objects. MuPAD finds equations and memberships in comparatively small sets. First, MuPAD tries to prove such equations and memberships by using the property mechanism. If the property mechanism proves an equation or a membership is true, MuPAD keeps that statement. Otherwise, MuPAD can replace that statement with the value FALSE.

For example, if the property mechanism cannot prove that a denominator is equal to zero, MuPAD regards this denominator as nonzero. This option can significantly reduce the number of piecewise objects in the result.

See Example 5.


Compute the Cauchy principal value of the integral.

If the interior of the integration interval contains poles of the integrand or the boundaries are a = - ∞ and b = ∞, then the definite integral might not exist in a strict mathematical sense. However, if the integrand changes sign at all poles in the integration interval, you can compute a weaker form of a definite integral called the Cauchy principal value. In this form, the so-called infinite parts of the integral to the left and to the right of a pole cancel each other. When you use the PrincipalValue option, int computes the Cauchy principal value. If the definite integral exists in a strict mathematical sense, it coincides with the Cauchy principal value. See Example 6.

Overloaded By



[1] Bronstein, M. “A Unification of Liouvillian Extension.” AAECC Applicable Algebra in Engineering, Communication and Computing. 1: 5–24, 1990.

[2] Bronstein, M. “The Transcendental Risch Differential Equation.” Journal of Symbolic Computation. 9: 49–60, 1990.

[3] Bronstein, M. “Symbolic Integration I: Transcendental Functions.” Springer. 1997.

[4] Epstein, H. I. and B. F. Caviness. “A Structure Theorem for the Elementary Functions and its Application to the Identity Problem.” International Journal of Computer and Information Science. 8: 9–37, 1979.

[5] Fakler, W. “Vereinfachen von komplexen Integralen reeller Funktionen.” mathPAD 9 No. 1: 5-9, 1999.

[6] Geddes, K. O., S. R. Czapor and G. Labahn. “Algorithms for Computer Algebra.” 1992.