## `intlib::byparts` -- performs integration by parts

#### Introduction

`intlib::byparts``(integral, du)` performs on `integral` the integration by parts, where `du` is the part to be integrated.

#### Call(s)

`intlib::byparts(integral, du)`

#### Parameters

`integral` | - | integral: an expression of type `"int"` of the form `int(du*v, x)`
`du` | - | the part to be integrated: an arithmetical expression

#### Returns

an arithmetical expression containing the type `"int"` or the unevaluated function call.

#### Related Functions

`subs`, `intlib::changevar`

#### Details

- Mathematically, the rule of integration by parts is formally defined for indefinite integrals as

       int(u'(x)*v(x), x) = u(x)*v(x) - int(u(x)*v'(x), x)

  and for definite integrals as

       int(u'(x)*v(x), x = a..b) = u(b)*v(b) - u(a)*v(a) -
                                                  int(u(x)*v'(x), x = a..b)

- `intlib::byparts``(integral, du)` performs in `integral` the integration by parts where `du` is the part to be integrated and returns an expression containing the unevaluated partial integral.
- `intlib::byparts` works for indefinite as well as for definite integrals.
- If MuPAD cannot solve the integral for `du` in case of definite integration, the function call is returned unevaluated.
- The first argument must be an expression of type `"int"`. This can be obtained with `hold` or `freeze` (cf. example 1).
- The second argument `du` should typically be a partial expression of the integrand in `integral`.

#### Example 1

As a first example we apply the rule of integration by parts to the integral int(x*exp(x), x=a..b). By using the `hold` function we secure that the first argument is of type `"int"`:

    >> intlib::byparts(hold(int)(x*exp(x), x = a..b), exp(x))

                    b exp(b) - a exp(a) - int(exp(x), x = a..b)

In this case the ansatz is choosen as u'(x)=exp(x) and thus v(x)=x.

#### Example 2

In the following we give a more advanced example using the method of integration by parts for solving the integral int(exp(a*x)*sin(b*x), x). For this we have to prevent that the integrator already evaluates the integrals. Thus we first inactivate the requested integral with the function `freeze`

    >> F := freeze(int)(exp(a*x)*sin(b*x), x)

                             int(sin(b x) exp(a x), x)

and apply afterwards partial integration with u'(x)=exp(ax):

    >> F1 := intlib::byparts(F, exp(a*x))

                 sin(b x) exp(a x)      / b cos(b x) exp(a x)    \
                 ----------------- - int| -------------------, x |
                         a              \          a             /

To this result again we can apply integration by parts. But to avoid evaluating that integral we have to be very carefully. In order to get it we must use the function `level`:

    >> F2 := -op(level(F1, 1), 2)

                              / b cos(b x) exp(a x)    \
                           int| -------------------, x |
                              \          a             /

With that we can now calculate the requested integral:

    >> F3 := expand(simplify(op(F1, 1) -
                    intlib::byparts(level(F2, 1), exp(a*x))))

          sin(b x) exp(a x)   b cos(b x) exp(a x)
          ----------------- - ------------------- -
                  a                    2
                                      a

              2
             b  int(sin(b x) exp(a x), x)
             ----------------------------
                           2
                          a

As we can see the both integration by parts steps lead to same integral but with a different factor. Therefore we can solve it for the requested integral and we finally get:

    >> F = normal(1/(1 + b^2/a^2)*
                  _plus(op(level(F3, 1), [1..2])))

          int(sin(b x) exp(a x), x) =

             a sin(b x) exp(a x) - b cos(b x) exp(a x)
             -----------------------------------------
                               2    2
                              a  + b

#### Example 3

Here we demonstrate the difference between indefinite and definite integration by parts. If in the indefinite case the partial part cannot be solved, simply the unevaluated integral is plugged into the integration rule:

    >> intlib::byparts(hold(int)(x*f(x), x),f(x))

                       x int(f(x), x) - int(int(f(x), x), x)

This is no longer true for the definite case:

    >> intlib::byparts(hold(int)(x*f(x), x=a..b),f(x))

          Warning: found no closed form for int(f(x), x) [intlib::bypart\
          s]

                   intlib::byparts(int(x f(x), x = a..b), f(x))

#### Changes

- new function

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