## `int` -- definite and indefinite integration

#### Introduction

`int``(f, x)` computes the indefinite (formal) integral int(f,x).

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

#### Call(s)

`int(f, x)`
`int(f, x = a..b <, Continuous>)`
`int(f, x = a..b <, PrincipalValue>)`

#### Parameters

`f` | - | the integrand: an arithmetical expression representing a function in `x`
`x` | - | the integration variable: an identifier
`a, b` | - | the boundaries: arithmetical expressions

#### Options

`Continuous` | - | do not look for discontinuities.
`PrincipalValue` | - | compute the Cauchy principal value of the integral.

#### Returns

an arithmetical expression.

### Overloadable:

`f`

#### Side Effects

`int` is sensitive to properties of identifiers set by `assume`; see example 4.

#### Further Documentation

Section 7.2 of the MuPAD Tutorial.

#### Related Functions

`D`, `diff`, `intlib`, `limit`, `numeric::int`, `sum`

#### Details

- `int(`f, x`)` computes the antiderivative g=int(f,x), i.e., it determines formally a function g with diff(g,x)=f. Note:
  - No constant of integration appears in the result.
  - The result is not necessarily continuous, even if the integrand is continuous. See ``background'' section for more details.
  - In general, the derivative of the result coincides with f only on some open interval of the real domain.
  It is not always possible to decide algorithmically whether diff(g,x) and f are equivalent. This is due to the so-called zero equivalence problem, which in general is undecidable.
- For the case of indefinite integration, the integration variable `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.

- If MuPAD cannot find a closed form solution for the integral, then it returns a symbolic `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).
- For definite integrals, `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).
- Numerical approximations to a definite integral can be obtained with `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.

#### Option: Continuous

- For definite integration, the system may first compute an antiderivative `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.

#### Option: PrincipalValue

- If the interior of the interval of integration contains poles of the integrand or the boundaries are a=-infinity and b=infinity, then the definite integral may not exist in a strict mathematical sense. However, if the integrand changes sign at all poles in the interval of integration, then a weaker form of definite integral, the Cauchy principal value, which allows ``infinite parts'' of the integral to the left and to the right of a pole to cancel each other, may still exist. With the option PrincipalValue, `int` computes this Cauchy principal value. If the usual definite integral exists, then it agrees with the Cauchy principal value. See example 4.

#### Example 1

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

#### Example 2

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

#### Example 3

`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

#### Example 4

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

#### Example 5

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

#### Background

- With the integration techniques used in computer algebra like table lookup or Risch integration for an indefinite integral, in addition to the possible discontinuities of the initial integrand, some more discontinuities may occur during the integration process. This is due to the fact that algebraic numbers can be complex. It may cause branch problems in numerical computation, since, e.g., the arguments to the logarithms may have complex zeros while the initial integrand has no pole in the path of integration. If the classical algorithm is used for rewriting complex logarithms as real-valued arcus-tangents,

      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.

- The integration variable is implicitly assumed to be real (`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.

- For details of the algorithms and simplification strategies see:
  - M. Bronstein. A Unification of Liouvillian Extension. AAECC Applicable Algebra in Engineering, Communication and Computing. 1: 5-24, 1990.
  - M. Bronstein. The Transcendental Risch Differential Equation. Journal of Symbolic Computation. 9: 49-60, 1990.
  - M. Bronstein. Symbolic Integration I: Transcendental Functions. Springer. 1997.
  - H. I. Epstein 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.
  - W. Fakler. Vereinfachen von komplexen Integralen reeller Funktionen. mathPAD 9 No. 1: 5-9, 1999.
  - K. O. Geddes, S. R. Czapor and G. Labahn. Algorithms for Computer Algebra. 1992.

#### Changes

- More classes of functions can now be handled.
- The option `Continuous` was added.

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000