> restart;
>
Integration by Substitution and by Parts
Maple knows all the basic techniques of integration that we are supposed to learn, including substitution, integration by parts, and integration by partial fraction decomposition. Maple applies these techniques without telling us about it and comes up with a final answer. For example,
> Int(x^2*exp(2*x),x); value(%);
> Int(x^2/(x^3+2),x);value(%);
>
Note that Maple does not add an arbitrary constant C when evaluating indefinite integrals. It does the hard part of the job: provides an antiderivative. It is up to us to remember that an indefinite integral contains an arbitrary constant, as well. We are guessing that Maple found the first integral by integration by parts, the second by substitution. Maple didn't bother to tell us about it, and normally we wouldn't care to know. However, in this worksheet, since we are supposed to learn the basic methods of integration, we shall use Maple to illustrate substitution and integration by parts, and help us understand them. Commands that allow us to do this are contained in the " student " package. We load the package.
> with(student);
>
Integration by Substitution
In this worksheet we are going to consider a lot of integrals and further process outputs of many commands. Hence, in order to avoid retyping, we shall be giving names to most of integrals Q1, Q2,.. .etc, and names to most of outputs expr1, expr2,... etc.
The command that allows us to see the results of substitution in a given integral is "
changevar
". It works as follows. Suppose we want to perform the substitution
in the integral
and see what the integral becomes. We type
> changevar(u=x^3+2,Int(x^2/(x^3+2),x),u);
>
Observe that first we enter the desired substitution, then the integral, using not " int " but the inert version " Int " of the integration command, and lastly the name of the new variable of integration. We used the inert version " Int " of the integration command, which does not evaluate the integral, because we want to perfom substitution in the original integral and not in its value. As in the rest of the worksheet, we shall give names to the integral and the subsequent outputs.
> Q1:=Int(x^2/(x^3+2),x);
> expr1:=changevar(u=x^3+2,Q1,u);
Although the integral is easy to do by hand, we can ask Maple to evaluate it anyway.
> expr2:=value(expr1);
We obtained the integral in terms of u. To have it in terms of x we have to substitute back the formula for u.
> subs(u=x^3+2,expr2);
>
Observe that Maple returns ln(u), rather than ln|u|, as an antiderivative of
. This limits the antiderivative to the domain u > 0. It is one of a few little imperfections of Maple.
The command " changevar " handles subsitution for definite integrals as well. For example,
> Q2:=Int(cos(x)*exp(sin(x)),x=0..Pi/2);
> expr3:=changevar(u=sin(x),Q2,u);
>
As we see, Maple properly adjusted the limits of integration. Hence, the value of the latter integral is equal to the value of the original integral Q2. Indeed
> value(Q2); value(expr3);
>
Example 1. Consider the integral
Find a substitution u = u(x) that changes the integral into an integral of a polynomial in terms of u.
Denote
> Q3:=Int(x^3*sqrt(4-x^2),x);
The rest is pretty much trial and errror. We shall try a few substitutions and see if we can generate an integral of a desired form. The first substitution that comes to mind is
> changevar(u=4-x^2,Q3,u);
We obtained an integral that, after multiplication, consists of powers of u. Hence, it can be done by hand. Still, the integrand is not a polynomial in u. Let's try something else
> changevar(u=sqrt(4-x^2),Q3,u);
Done! The integrand is a polynomial in u.
>
Example 2. Consider the integrals
.
Find a substitution for each of them, so that both integrals are reduced to the same simple and familiar integral in terms of u.
>
Let's start with the first integral a nd try to find a substitution that reduces it to something simple.
> Q4:=Int(exp(x)/(1+exp(2*x)),x);
> changevar(u=1+exp(2*x),Q4,u);
> changevar(u=exp(2*x),Q4,u);
None of the two substitutions led us to a simple integral. Let's try
> changevar(u=exp(x),Q4,u);
That's it! The latter integral is simply arctan(u) as you remember from last semester. Let's see if we can find a substitution which reduces the second integral to the same simple integral in u.
> Q5:=Int(cos(x)/(1+(sin(x))^2),x);
A natural thing to try is to mimic what we did above, that is
> changevar(u=cos(x),Q5,u);
It didn't work. Let's try
> changevar(u=sin(x),Q5,u);
>
Success! We reduced the integral to the same integral in terms of u, which is arctan(u). You shouldn't think, of course, that the integrals Q4 and Q5 are equal. To obtain their values in terms of x we have to substitute into arctan(u) the corresponding u(x) for each of the integrals. Q4 and Q5 are equal respectively:
> subs(u=exp(x),arctan(u));
> subs(u=sin(x),arctan(u));
Recall that you can always check if your answers are correct by differentiating.
> diff(arctan(exp(x)),x); diff(arctan(sin(x)),x);
Everything checks out.
>
Example 3. Consider the integral
.
Find the integral by
(a) Completing the square in the denominator.
(b) Using a subsitution to reduce the integral to something simple.
Do you remember how to complete the square? If not, don't despair. Among the commands in the " student " package we see "completesquare ". It is easy to guess how it works. We have to type in a polynomial and tell Maple with respect to which variable we want it to complete the square.
> completesquare(x^2+x+5/4,x);
Our integral becomes
> Q6:=Int(5/((x+(1/2))^2+1),x);
We use the obvious substitution
> changevar(u=x+1/2,Q6,u);
Hence, Q6=5arctan(u)+C=5arctan(x+1/2)+C.
>
Integration by Parts
As you know integration by parts is nothing else but an integral version of the product rule. The formula for integration by parts is
,
where D denotes the derivative. If we want to find the integral
and the integral
is simpler, integration by parts helps. Consider a typical example.
> Q7:=Int(x*exp(2*x),x);
>
Observe that, as above, we are using the inert version of the integral command, as we are going to work with the integral and not its value. Which term do you choose as u and which term do you consider as the derivative of something D(v)? Usually, you have many possible choices. Maple can show you how each of the choices works with the command "
intparts
" in the "
student
" package. Under the command "
intparts
" you have to tell Maple what is your integral, and what term you are choosing as u, that is, the term which during integration by parts will get differentiated. For example, in the latter integral choose
as u and consider the term x as the derivative D(v) of some v. Let's see what the formula for integration by parts gives us.
> intparts(Q7,exp(2*x));
According to the formula for integration by parts,
is differentiated and x replaced by its antiderivative
. The new integral to be found,
, is not any easier than the integral that we started from. Let's try a different choice of u.
> expr4:=intparts(Q7,x);
This, of course, worked as the latter integral involving a single exponential is very easy to find by hand. We can ask Maple to do it, too
> value(expr4);
>
Example 4. Show by integration by parts that for any positive integer n
.
This is a so called reduction formula. It shows that any integral of the form
can be found after integrating by parts n times. To show that the formula is true define
> Q7:=Int(x^n*exp(x),x);
Now we integrate by parts
> expr5:=intparts(Q7,x^n);
>
This isn't exactly the form we want. Let's try the simplify command
> simplify(expr5);
We have shown that Q7 reduces to the above formula after integration by parts.
>
The next example is a little excercise in processing algebraically expressions in Maple. It also introduces you to an important technique called the method of undetermined coefficients.
Example 5. Find the integral
without performing any integration.
Observe that the above reduction formula tells us that the integral, which can be obtained by integrating by parts three times, will eventually be of the form
.
for some constants a,b,c. All we have to do is find the right constants a,b,c. Solving problems by guessing a form of the solution and then working backwards to find the right constants is called the method of undetermined coeficients . Let's define an appropriate expression
> expr6:=x^3*exp(x)+a*x^2*exp(x)+b*x*exp(x)+c*exp(x);
Since expr6 is an anitiderivative of
its derivative
> expr7:=diff(expr6,x);
has to be equal to
. We have to find constants a,b,c such that expr7=
. Let's process expr7 a little. There are many commands in Maple which allow you to process algebraic expressions, among others "
simplify
", "
factor
", "
expand
", "
collect
", "
combine
" etc. We shall slowly learn by examples how to use them. Let's try
> expr8:=factor(expr7);
Since expr7 is supposed to be equal to
, the polynomial in parentheses has to be equal to
. Let's get rid of the exponential first
> expr9:=expr8/exp(x);
Now we want to group together terms according to powers of x. This is accomplished by the command "collect"
> expr10:=collect(expr9,x);
Since the latter polynomial has to be equal to
, the corresponding coefficients must be equal. We solve the system of the following equations for a,b,c
> solve({a+3=0,b+2*a=0,b+c=0},{a,b,c});
We have found our constants a,b,c. We substitute them back into expr6 and obtain our answer
> an:=subs(a=-3,b=6,c=-6,expr6);
To check our answer we can simply differentiate it
> diff(an,x);
We could also ask Maple to find the integral to begin with
> Int(x^3*exp(x),x); value(%);
but that would be cheating!
>
Homework Problems
Problem 1. Find a substitution u=u(x) that reduces the integral
to an integral of a polynomial in terms of u.
Problem 2. Find a substitution for each of the following two integrals which reduces them to the same easy integral in terms of u
.
Problem 3. Let n be a positive integer, a a nonzero constant. Show that the following reduction formula holds
.
Problem 4. Using the reduction formula
,
guess the form of the integral
.
Then find the integral using the method of undetermined coefficients as in Example 5.
Problem 5.
Have Maple find
for several values of
, say,
...12. Note that for some values of
Maple gives an answer entirely in terms of familiar functions, but for other values of
the answer involves some
mysterious function called erf.
(a) Which values of n result in only familiar functions? Make a conjecture (a guess) about the general situation, not just the values of n you actually checked.
(b) Explain why your answer to part (a) is reasonable, in terms of what you know about substitution and
integration by parts.
>
Note. If you use the restart command in your homework worksheet, do not forget to reload the package with(student) .
MTH 142 Maple Worksheets written by B. Kaskosz and L. Pakula, Copyright 1999.
Last modified August 1999.
>