The Volume of a 4-Dimensional Sphere
and Other Multiple Integrals
Using Maple and the vec_calc Package
In this worksheet we will see how to compute multiple integrals using Maple and the vec_calc package. The student package has the commands Doubleint and Tripleint for computing double and triple integrals. The vec_calc package has the command Multipleint which can compute multiple integrals of any dimension. In addition the multipleint command can display all the intermediate steps. As examples, we will consider problems which
* Compute a 5-Dimensional Integral and Display the Steps
* Interchange the Order of Integration
* Compute an Integral in Curvilinear Coordinates
* Compute the Volume of a 4-Dimensional Sphere
We start by initializing the vec_calc package:
> restart;
> libname:="C:/mylib/vec_calc7", libname:
> with(vec_calc): vc_aliases:
> with(linalg):with(student):with(plots):
Warning, the protected names norm and trace have been redefined and unprotected
Warning, the name changecoords has been redefined
Compute a 5-Dimensional Integral and Display the Steps
To compute the integral enter the integral using
> Muint(x^2*y^3*z*cos(theta)*sin(phi), x=2..4, y=-1..2, z=1..4, theta=0..Pi/2, phi=0..Pi/4);
and compute it using
> value(%);
Note: It is usually best to put the Muint and value commands on the same line. Then if you change the integral, the value automatically updates. This will be done throughout the rest of this worksheet.
You can also compute the answer directly using muint instead of Muint:
> muint(x^2*y^3*z*cos(theta)*sin(phi), x=2..4, y=-1..2, z=1..4, theta=0..Pi/2, phi=0..Pi/4);
However, this should only be done in the middle of a program where there is no human to look at the output. In normal interactive use, you should use Muint, look at the result to be sure you typed it correctly, and only then use value to compute it.
The muint command can also be used to show all the intermediate steps of the computation:
> simplify(muint(x^2*y^3*z*cos(theta)*sin(phi), x=2..4, y=-1..2, z=1..4, theta=0..Pi/2, phi=0..Pi/4, step));
>
Interchange the Order of Integration
A typical problem in multivariable calculus is to compute the integral . To do this by hand, we need to reverse the order of integration. So we first plot the region. From the limits we have and . So the region is
> with(plottools):
Warning, the name arrow has been redefined
> display(polygon([[0,0], [sqrt(Pi),0], [sqrt(Pi),sqrt(Pi)]]), color=red, scaling=constrained);
So the limits can also be taken as and . In this order the integral is which can easily be computed:
> simplify(muint(sin(x^2), y=0..x, x=0..sqrt(Pi), step));
With Maple, it may not be necessary to interchange the order. We can also compute the integral in the original order:
> Muint(sin(x^2), x=y..sqrt(Pi), y=0..sqrt(Pi)); value(%);
Unfortunately, Maple is unable to simplify this to 1:
> simplify(%);
However, it can get a decimal value which is almost correct:
> evalf(%);
On the other hand, the muint command with the step parameter can do even better:
> muint(sin(x^2), x=y..sqrt(Pi), y=0..sqrt(Pi), step): simplify(%);
I don't know why the value command gives the answer in a different form.
Compute an Integral in Curvilinear Coordinates
We want to compute the integral over the regoin bounded by the curves , , and .
We first plot the region:
> plot([1/x, 4/x, x, 9*x], x=0..3, y=0..7, color=[red, blue, green, maroon]);
From the form of the boundary curves, we take the curvilinear coordinates as
> eqsuv:={u=x*y, v=y/x};
so that the limits are , , and . To convert the integral, we need to find the Jacobian and re-express the integrand in terms of and . To do this, we first express and in terms of and .
> solve(eqsuv,{x,y}); allvalues(%); eqsxy:=%[1];
We use these equations to define a curvilinear coordinate system as a pair of functions:
> UV:=MF([u,v], subs(eqsxy,[x,y]));
From this we can find the Jacobian determinant:
> J:=JAC_DET(UV);
The integrand is
> integ:=exp(x*y);
which becomes
> integ:=subs(eqsxy,integ);
So the integral becomes
> Muint(integ*J(u,v), u=1..4, v=1..9); value(%);
Compute the Volume of a 4-Dimensional Sphere
We will compute the 4-dimensional volume of a 4-dimensional sphere of radius .
Spherical coordinates in 4-dimension are given by
> x0:=rho*sin(chi)*sin(phi)*cos(theta); y0:=rho*sin(chi)*sin(phi)*sin(theta); z0:=rho*sin(chi)*cos(phi); w0:=rho*cos(chi);
Here is defined on , while and are defined on .
To find the Jacobian, we first define the coordinate system as a function
> T:=MF([rho,chi,phi,theta],[x0,y0,z0,w0]);
So the Jacobian is
> J:=JAC_DET(T);
Notice that this is negative. So we need to take the absolute value.
The volume is the 4-dimensional integral of the Jacobian:
> Muint(abs(J(rho,chi,phi,theta)), rho=0..R, chi=0..Pi, phi=0..Pi, theta=0..2*Pi); value(%);