Physics 350:
Computational Methods
for the Physical Sciences

Spring Semester 2009

Solutions for Physics 350 Lab 1: Maple Basics 

It's always a good idea to first restart your Maple spreadsheet. 

> restart;

The first question you are asked is for the indefinite integral of x^5*exp(-7x), so we can try: 

> s := int(x^5*exp(-7*x),x);
 
`+`(`-`(`*`(`/`(1, 117649), `*`(`+`(120, `*`(840, `*`(x)), `*`(2940, `*`(`^`(x, 2))), `*`(6860, `*`(`^`(x, 3))), `*`(12005, `*`(`^`(x, 4))), `*`(16807, `*`(`^`(x, 5)))), `*`(exp(`+`(`-`(`*`(7, `*`(x))... (1.1)

Next we are asked for the definite integral of exp(-q*x) from 0 to infinity.  You are told this only converges for q>0, therefore I use: 

> assume(q>0);
> int(exp(-q*x),x=0..infinity);
`/`(1, `*`(q)) (2.1)
 
We are also asked to evaluate the definite integral of ([sin(x)]^2)/(x^2+a^2) from -infinity to infinity, assuming a>0, which is just: 

> assume(a>0);
> f := (sin(x)^2)/(x^2+a^2);
`/`(`*`(`^`(sin(x), 2)), `*`(`+`(`*`(`^`(x, 2)), `*`(`^`(a, 2))))) (3.1)
 
> g := int(f,x=-infinity..infinity);
`+`(`/`(`*`(`/`(1, 2), `*`(Pi, `*`(`+`(1, sinh(`+`(`*`(2, `*`(a)))), `-`(cosh(`+`(`*`(2, `*`(a))))))))), `*`(a))) (3.2)
 

Then we are asked to plot the integral from a=0 to infinity and to determine the limit as a --> 0, I do that next: 

> plot(g,a=0..10);
 
Plot_2d
> limit(g,a=0);
Pi (3.3)
 
Finally, I am asked to compute the value of molecular velocity which maximizes the distribution of molecular speeds of a gas, so I solve for when the first derivative is zero (either a minima or maxima), then plot up the function to see which it is: 
> f := N*(v^2)*exp((-m*v^2)/(2*k*T));
`*`(N, `*`(`^`(v, 2), `*`(exp(`+`(`-`(`/`(`*`(`/`(1, 2), `*`(m, `*`(`^`(v, 2)))), `*`(k, `*`(T))))))))) (4.1)
> g := diff(f,v);
`+`(`*`(2, `*`(N, `*`(v, `*`(exp(`+`(`-`(`/`(`*`(`/`(1, 2), `*`(m, `*`(`^`(v, 2)))), `*`(k, `*`(T)))))))))), `-`(`/`(`*`(N, `*`(`^`(v, 3), `*`(m, `*`(exp(`+`(`-`(`/`(`*`(`/`(1, 2), `*`(m, `*`(`^`(v, 2... (4.2)
> solve(g = 0, v);
0, `/`(`*`(`^`(2, `/`(1, 2)), `*`(`^`(`*`(m, `*`(k, `*`(T))), `/`(1, 2)))), `*`(m)), `+`(`-`(`/`(`*`(`^`(2, `/`(1, 2)), `*`(`^`(`*`(m, `*`(k, `*`(T))), `/`(1, 2)))), `*`(m)))) (4.3)
> subs(v=0,f);subs(v=(2^(1/2)*(m*k*T)^(1/2)/m),f);subs(v=-(2^(1/2)*(m*k*T)^(1/2)/m),f);
0 (4.4)
`+`(`/`(`*`(2, `*`(N, `*`(k, `*`(T, `*`(exp(-1)))))), `*`(m))) (4.4)
`+`(`/`(`*`(2, `*`(N, `*`(k, `*`(T, `*`(exp(-1)))))), `*`(m))) (4.4)
>