## `intlib::changevar` -- change of variable

#### Introduction

`intlib::changevar``(integral, eq, ..)` performs a change of variable for indefinite and definite integrals.

#### Call(s)

`intlib::changevar(integral, eq <, var>)`

#### Parameters

`integral` | - | integral: an expression of type `"int"`
`eq` | - | equation defining the new integration variable in terms of the old one: an equation
`var` | - | new integration variable: an identifier

#### Returns

an expression of type `"int"`.

#### Related Functions

`subs`, `intlib::byparts`

#### Details

- Mathematically, the substitution rule is formally defined for indefinite integrals as

       int(f(g(x))*g'(x), x) = int(f(t), t), [t=g(x)]

  and for definite integrals as

       int(f(g(x))*g'(x), x=a..b) = int(f(t), t=g(a)..g(b)),[t=g(x)]

- `intlib::changevar``(integral, eq <, var>)` performs in `integral` the change of variable defined by `eq` and returns the unevaluated new integral.
- `intlib::changevar` works for indefinite as well as for definite integrals.
- The first argument must be an expression of type `"int"`. This can be obtained with `hold` or `freeze` (cf. example 1).
- If more than two variables occur in `eq`, the new variable must be given as third argument.
- If MuPAD cannot solve the given equation `eq` an error will occur.

#### Example 1

As a first example we perform a change of variable for the integral int(f(x+c), x=a..b). By using the `hold` function we secure that the first argument is of type `"int"`:

    >> intlib::changevar(hold(int)(f(x + c), x = a..b),
                         t = x + c, t)

                            int(f(t), t = a + c..b + c)

Note, that in this case the substitution equation has among x two further variables. Thus it is necessary to specify the new integration variable as third argument.

#### Example 2

In the following we give a more advanced example using the change of variable method for solving the integral int(sqrt(tan(x)), x). First we perform the transformation t = tan(x):

    >> f1:=intlib::changevar(hold(int)(sqrt(tan(x)), x),
                             t = tan(x), t)

                                    /   1/2     \
                                    |  t        |
                                 int| ------, t |
                                    |  2        |
                                    \ t  + 1    /

We apply the further substitution t = u2 to that result. In order to keep this transformation invertible we have to restrict the domain of u:

    >> assume(u > 0): f2:=intlib::changevar(f1, t = u^2, u)

                                    /     2     \
                                    |  2 u      |
                                 int| ------, u |
                                    |  4        |
                                    \ u  + 1    /

The result of the last transformation is a rational function integral which we can now solve with MuPAD's integrator. Finally we only have to perform the two back substitutions to get the requested integral.

    >> F:=simplify(subs(subs(eval(f2), u = sqrt(t)),
                        t = tan(x)))

                 / /              1/2 \2       \
           1/2   | |       1/2   2    |        |
          2    ln| | tan(x)    - ---- |  + 1/2 |
                 \ \              2   /        /
          -------------------------------------- -
                            4

                    / /              1/2 \2       \
              1/2   | |       1/2   2    |        |
             2    ln| | tan(x)    + ---- |  + 1/2 |
                    \ \              2   /        /
             -------------------------------------- +
                               4

                        /      /              1/2 \ \
              1/2       |  1/2 |       1/2   2    | |
             2    arctan| 2    | tan(x)    - ---- | |
                        \      \              2   / /
             ---------------------------------------- +
                                2

                        /      /              1/2 \ \
              1/2       |  1/2 |       1/2   2    | |
             2    arctan| 2    | tan(x)    + ---- | |
                        \      \              2   / /
             ----------------------------------------
                                2

Verifying solutions of integrals is almost always a hard task. In this case we may do it with the following function sequence:

    >> factor(normal(expand(diff(F, x))))

                                   / sin(x) \1/2
                                   | ------ |
                                   \ cos(x) /

#### Changes

- used to be called `changevar`

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