A MAPLE tutorial.
Functions that I have used in this course.
diff(func(x),x); to take the derivative of func(x).
int(func(x),x); to obtain the integral of func(x).
with(plots): plot(func(x),x=lower..upper); plots func(x) from the given lower bound to the upper bound.
evalf(func); returns a numerical evaluation (like a calculator)
Integration and Differentiation
For example, in problem 4 of homework #5.
To take the derivative of I0(a) with respect to a.
At the MAPLE prompt type:
>diff(sqrt(Pi/a),a);

Note that MAPLE did not simplify this and I had to simplify it myself.
To take the second derivative of I0(a) with respect to a you must plug the answer from part one (i.e. the right hand side of the answer given above).
>diff((-1)^2*(1/2)*sqrt(Pi/a^3),a);

To do the integral you need to recognize that the Gaussian integral can be written in the form.

Transform to spherical polar coordinates recognizing that
x = r sin
q and y = r cosq.
To evaluate this we use the substitution u = r2 again so that du = 2rdr. The radial part is trivial using the formula
.
However, the trig part is a little difficult. So use the int() command. First let’s use the indefinite integral.
At the MAPLE prompt type
>int(cos(t)^2*sin(t)^2,t);
-1/4*sin(t)*cos(t)^3+1/8*cos(t)*sin(t)+1/8*t
Or we can get a numerical result if we like using the command
>int(cos(t)^2*sin(t)^2,t=0..Pi/2);
1/16*Pi
Notice that the limits are entered as x=lower..upper with two dots inbetween the lower and upper limit.
This leads to the following answer.
To obtain the result for v = 2 by integration

Using the same protocol as above for I0(a) we obtain the square in two dimensions
Making the same substitution of variable for polar coordinates
And the radial part can be solved analytically and easily by techniques you are now familiar with.
Now, for the angular terms in the I2(a) integral, the indefinite integral is:
>int(cos(t)^4*sin(t)^4,t);
-1/8*sin(t)^3*cos(t)^5 - 1/16*sin(t)*cos(t)^5 + 1/64* sin(t)*cos(t)^3 + 3/128*cos(t)*sin(t) + 3/128*t
and the definite integral is:
>int(cos(t)^4*sin(t)^4,t=0..Pi/2);
3/256*Pi
Plotting functions
Example. Plotting the particle in a box wave functions.
You must always type:
>with(plots):
in the MAPLE session in order to use the plot command.
For a box of length 1 the energy levels are n2h2/8m. If we plot in units of m = 1 and h = 1, then energy levels are 1/8 for n=2, 4/8 (i.e. ½) for n=2, 9/8 for n=3 etc.
The wavefunction is: ![]()
To plot just the first wave function from 0 to 1
>plot(1/8+0.4*sin(3.1416*x)^2,x=0..1);
To include an x-axis label use the following syntax.
>plot(1/8+0.4*sin(3.1416*x)^2,x=0..1,labels=[length,E],labelfont=[TIMES,ROMAN,16]);
To plot several solutions on the same plot use the syntax below. The functions are in {} and separated by commas. Notice that I scaled the normalization prefactors to get these to look good on the plot.
>plot({1/8+0.4*sin(3.1416*x)^2,4/8+0.5*sin(2*3.1416*x)^2,9/8+0.5*sin(3*3.1416*x)^2,16/8+0.5*sin(5*3.1416*x)^2,25/8+0.5*sin(5*3.1416*x)^2},x=0..1,labels=[length,E],labelfont=[TIMES,ROMAN,16]);
It will look like this.
