Compute 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.

To integrate a mathematical expression f means to find an expression F such that the first derivative of F is f. The expression F is an antiderivative of f. Integration is a more complicated task than differentiation. In contrast to differentiation, there is no general algorithm for computing integrals of an arbitrary expression. When you differentiate an expression, the result is often represented in terms of the same or less complicated functions. When you integrate an expression, the result often involves much more complicated functions than those you use in the original expression. For example, if the original expression consists of elementary functions, you can get the result in terms of elementary functions:

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

The following integrand also consists of standard trigonometric functions, but here the integrator cannot return the result in terms of elementary functions. The antiderivative involves a special function:

int(sin(x)/x, x)

When you compute an indefinite integral, MuPAD® implicitly assumes that the integration variable is real. The result of integration is valid for all real numbers, but can be invalid for complex numbers. You also can define properties of the integration variables by using the assume function. The properties you specify can interfere with the assumption that the integration variable is real. If MuPAD cannot integrate an expression using your assumption, the int function issues a warning. Use the intlib::printWarnings function to switch the warnings on and off. For example, switch on the warnings:

intlib::printWarnings(TRUE):

Suppose you want to integrate the following expression under the assumption that the integration variable is positive. This assumption does not conflict with the assumption that the variable is real. The int command uses your assumption:

f := abs(x):
int(f, x) assuming x > 0

Integrate this expression under the assumption that x is an integer. MuPAD cannot integrate the expression over a discrete subset of the real numbers. The int command issues a warning, and then integrates over the field of real numbers:

int(f, x) assuming x in Z_
Warning: Unable to integrate when 'x' has property 'Z_'. Using assumption 'x' has property 'R_' for integration. [intlib::int]

For a discrete set of values of the integration variable, compute a sum instead of computing an integral. See Summation for details.

Now integrate under the assumption that x is imaginary. The int command cannot compute the integral of the expression over imaginary numbers. It issues a warning and integrates the expression over the domain of complex numbers:

assume(x, Type::Imaginary);
int(f, x)
Warning: Unable to integrate when 'x' has property 'Dom::ImageSet(x*I, x, R_)'. Using assumption 'x' has property 'C_' for integration. [intlib::int]

For more information about the assumptions, see Properties and Assumptions. Before you proceed with other computations, clear the assumption on the variable x:

unassume(x):

Also, disable the warnings:

intlib::printWarnings(FALSE):