int (and Int)

The
int command is used to compute both definite and indefinite integrals of Maple expressions. The syntax of int is Maple's usual

int(what, how );

syntax. "What" in this case refers to "take the integral of what?", and "how" to "with respect to what variable?" (and also "over what interval?" if the integral is a definite one).  For example, to compute

int((3*x-6)/(x^2-4),x)

 we would enter:

>   restart:

>   int((3*x-6)/(x^2-4),x);

3*ln(x+2)

Notice, the first argument of int is the expression whose integral is being taken, and the second tells with respect to what variable the integral is being done.  In this example of an indefinite integral, notice that Maple does not  provide a constant of integration. You will occasionally have to take this into account and provide your own constant.

The second "how" argument of
int becomes crucial in expressions such as:

>   int(exp(a*x),x);

1/a*exp(a*x)

where there are constants, parameters or other variables around. Maple assumes that you mean to take the integral as the variable you specify changes, and that all other letters in the expression represent constants.

To compute a definite integral, you provide a "range" for the variable, just as in plot statements. For example, to compute:

Int(x^2*exp(x),x = 0 .. 2)

we enter

>   int(x^2*exp(x),x=0..2);

2*exp(2)-2

There are a few things that can go "wrong" when you use a computer algebra package to calculate integrals:

(1) The integral might be impossible to evaluate in closed form. When Maple encounters such an integral (or one it can't do for some other reason) it simply returns the "unevaluated" integral. For example:

>   int(ln(sin(sqrt(x^12-5*x^7+50*x+2))),x);

int(ln(sin((x^12-5*x^7+50*x+2)^(1/2))),x)

This indicates that Maple has "given up" on the integral (see the section below on numerical evaluation of integrals).

(2) The integral cannot be evaluated in closed form in terms of "elementary" functions (trig, exponential, powers, roots, logs), but mathematicians have assigned a special name to it (or a closely related integral) because it comes up a lot in applications. For example:

>   int(sin(2*x)/x,x);

Si(2*x)

Here "Si" is the name of one of these "special functions of mathematical physics". To learn about such a function, if it comes up, use Maple's help facility. Typing

>   ?Si


will bring up a window with somewhat helpful information about the "Si" function (at least its definition). You can be fairly (but not completely) certain that if Maple produces an answer in terms of one of these exotic functions then there is not an answer in terms of elementary functions.


(3) Doing the integral involves some hypotheses on the variables involved (ranges not specified for indefinite integrals), or there are complex (as in complex numbers) versions of the answers that may seem unfamiliar -- the telltale sign of this is an answer involving capital "I" (which Maple uses for the complex number
sqrt(-1)).
An example:

>   int(x^2*sqrt(1-sin(x)^2),x);

-1/2*I*(2+2*I*x-x^2-2*exp(2*I*x)+2*I*exp(2*I*x)*x+x^2*exp(2*I*x))/exp(2*I*x)^(1/2)

Of course, this example is somewhat contrived, since if we used the obvious trig identity first, then Maple would have no problem:

>   int(x^2*cos(x),x);

x^2*sin(x)-2*sin(x)+2*x*cos(x)

But this shows that it is sometimes wise to think a little before you press "enter".

Numerical integration:  You can force Maple to apply a numerical approximation technique for definite integration (Maple uses techniques that are related to but more sophisticated than Simpson's rule and the trapezoidal rule) as follows:

>   evalf(Int(sqrt(1+x^10),x=0..1));

1.040899075

Notice that the Int command is capitalized in this statement -- this is to prevent Maple from attempting to evaluate the integral symbolically and then just "evalf"-ing the answer (see below for other uses of capitalized Int).


Multiple integrals  (for Calculus II and beyond): Maple can do "iterated" integrals once you have set them up. For example, to perform the double integration:

Int(Int(x^2*y^3,x = 0 .. y),y = 2 .. 3)

you use the statement:

>   int(int(x^2*y^3,x=0..y),y=2..3);

2059/21


Note that this is literally an iterated integral -- one
int expression is nested inside another.

Remarks:  Occasionally, to make your worksheets easier to read, you may wish to have Maple display an integral in standard mathematical notation without evaluating it. For this there is a capitalized, "inert" form of the int command:

>   Int(exp(x)/(1-x),x);

Int(exp(x)/(1-x),x)

or, for a definite integral:

>   Int(ln(1+3*x),x=1..4);

Int(ln(1+3*x),x = 1 .. 4)


Sometimes, you can use the two forms together to produce meaningful sentences:

>   Int(ln(1+3*x),x=1..4)=int(ln(1+3*x),x=1..4);

Int(ln(1+3*x),x = 1 .. 4) = 13/3*ln(13)-3-8/3*ln(2)


A few other things can go wrong using the int command, other than syntax errors -- for example, the variable in the command (the x above) has already been given a value that you forgot about:

>   x:=3;

x := 3

>   int(x^2/sin(2*x^2),x);

Error, (in int) wrong number (or type) of arguments


or

>   int(x^2/sin(2*x^2),x=0..3);

Error, (in int) wrong number (or type) of arguments

The other common mistake (especially with indefinite integrals) is to forget the "how" part (which is required):

>   int(y^2);

Error, (in int) wrong number (or type) of arguments

You must type:

>   int(y^2,y);

1/3*y^3