Physics 350:
Computational Methods
for the Physical Sciences

Spring Semester 2009

Lab 3: Spherical Coordinates Solutions Example 

As per usual, we will start by clearing Maple's memory: 

> restart; 

In this week's lab we are going to be making spherical plots, so I am going to load the "plots" package Maple uses for some high end plotting with the command: 

> with(plots): 

Problem 1) I am asked to use a specified probability distribution for an orbital of the hydrogen atom defined as: 

> p := (1/(39366*Pi))*r^4*exp(-2*r/3)*(3*cos(theta)^2-1)^2; 

`+`(`/`(`*`(`/`(1, 39366), `*`(`^`(r, 4), `*`(exp(`+`(`-`(`*`(`/`(2, 3), `*`(r))))), `*`(`^`(`+`(`*`(3, `*`(`^`(cos(theta), 2))), `-`(1)), 2))))), `*`(Pi)))  (1.1)

a. I am asked to convert this probability density from spherical coordinates to Cartesian coordinates and make a contour plot of a slice through this function in the xz plane.   

Remember you can convert this expression to Cartesian (xyz) coordinates using the conversions: 

r = sqrt(`+`(`*`(`^`(x, 2)), `*`(`^`(y, 2)), `*`(`^`(z, 2)))) 

and 

cos(theta) = `/`(`*`(z), `*`(sqrt(`+`(`*`(`^`(x, 2)), `*`(`^`(y, 2)), `*`(`^`(z, 2)))))) 

> pxyz:= eval(p,{r=sqrt(x^2+y^2+z^2),theta=arccos(z/sqrt(x^2+y^2+z^2))}); 

`+`(`/`(`*`(`/`(1, 39366), `*`(`^`(`+`(`*`(`^`(x, 2)), `*`(`^`(y, 2)), `*`(`^`(z, 2))), 2), `*`(exp(`+`(`-`(`*`(`/`(2, 3), `*`(`^`(`+`(`*`(`^`(x, 2)), `*`(`^`(y, 2)), `*`(`^`(z, 2))), `/`(1, 2))))))),... (1.2) 

 

> pxyz:=simplify(pxyz); 

`+`(`/`(`*`(`/`(1, 39366), `*`(exp(`+`(`-`(`*`(`/`(2, 3), `*`(`^`(`+`(`*`(`^`(x, 2)), `*`(`^`(y, 2)), `*`(`^`(z, 2))), `/`(1, 2))))))), `*`(`^`(`+`(`-`(`*`(2, `*`(`^`(z, 2)))), `*`(`^`(x, 2)), `*`(`^`... (1.3) 

For the following contourplot command, I used a 100x100 grid to make it look better, this is not necessary.. 

> contourplot(eval(pxyz,y=0),x=-15..15,z=-15..15,grid=[100,100]);  

Plot_2d  

b. I am also asked to do two 3-D plots of the probability at two different probability levels, so for example I can do: 

> implicitplot3d(p=0.0002,r=0..20,phi=0..2*Pi,theta=0..Pi,coords=spherical,axes=box,view=[-20..20,-20..20,-20..20],grid=[25,25,25],orientation=[30,65]); 

Plot  
> implicitplot3d(p=0.00005,r=0..20,phi=0..2*Pi,theta=0..Pi,coords=spherical,axes=box,view=[-20..20,-20..20,-20..20],grid=[25,25,25],orientation=[30,65]); 

Plot  

c. Next I am asked to find the probability of finding an electron in a sphere of radius R and then asked to plot this probability as a function of R. 

> prob := int(int(int(p*r^2*sin(theta),theta=0..Pi),phi=0..2*Pi),r=0..R); 

`+`(1, `-`(exp(`+`(`-`(`*`(`/`(2, 3), `*`(R)))))), `-`(`*`(`/`(2, 3), `*`(exp(`+`(`-`(`*`(`/`(2, 3), `*`(R))))), `*`(R)))), `-`(`*`(`/`(2, 9), `*`(exp(`+`(`-`(`*`(`/`(2, 3), `*`(R))))), `*`(`^`(R, 2))...
`+`(1, `-`(exp(`+`(`-`(`*`(`/`(2, 3), `*`(R)))))), `-`(`*`(`/`(2, 3), `*`(exp(`+`(`-`(`*`(`/`(2, 3), `*`(R))))), `*`(R)))), `-`(`*`(`/`(2, 9), `*`(exp(`+`(`-`(`*`(`/`(2, 3), `*`(R))))), `*`(`^`(R, 2))...
(1.4) 
> limit(prob,R=infinity); 

1  (1.5)
> plot(prob,R=0..20); 

Plot_2d

d. We are also asked to compute the probability for finding an electron in the top half (theta<Pi/2), top third (theta < Pi/3), and top quarter (theta < Pi/4) of the volume. 

> prob_half := int(int(int(p*r^2*sin(theta),theta=0..Pi/2),phi=0..2*Pi),r=0..infinity); 

`/`(1, 2)  (1.6)
> evalf(prob_half); 

.5000000000  (1.7)
> prob_third := int(int(int(p*r^2*sin(theta),theta=0..Pi/3),phi=0..2*Pi),r=0..infinity); 

`/`(79, 256) (1.8)
> evalf(prob_third); 

.3085937500 (1.9) 
> prob_quarter := int(int(int(p*r^2*sin(theta),theta=0..Pi/4),phi=0..2*Pi),r=0..infinity); 

`+`(`/`(1, 2), `-`(`*`(`/`(9, 64), `*`(`^`(2, `/`(1, 2)))))) (1.10) 
> evalf(prob_quarter); 

.3011262178 (1.11) 

And just for humor's sake (not needed for credit), I decided to plot the probabilty of finding an electron (at any distance) versus theta. 

> prob_theta := int(int(int(p*r^2*sin(theta),theta=0..THETA),phi=0..2*Pi),r=0..infinity); 

`+`(`/`(1, 2), `-`(`*`(`/`(5, 8), `*`(cos(THETA)))), `-`(`*`(`/`(9, 8), `*`(`^`(cos(THETA), 5)))), `*`(`/`(5, 4), `*`(`^`(cos(THETA), 3)))) (1.12) 
> plot(prob_theta,THETA=0..Pi); 

Plot_2d  

 

Problem 2) And now we need to consider a different hydrogen atom orbital with the following probability distribution. 

> p2 := (5/(2048*Pi))*(1 - (r/4) + (r^2/80))^2 * r^2 * exp(-r/2)*(sin(theta))^2; 

`+`(`/`(`*`(`/`(5, 2048), `*`(`^`(`+`(1, `-`(`*`(`/`(1, 4), `*`(r))), `*`(`/`(1, 80), `*`(`^`(r, 2)))), 2), `*`(`^`(r, 2), `*`(exp(`+`(`-`(`*`(`/`(1, 2), `*`(r))))), `*`(`^`(sin(theta), 2)))))), `*`(P... (2.1) 

a. I am asked to compute the probability that the electron will be found within one bohr radius (r<1) 

> prob2 := int(int(int(p2*r^2*sin(theta),theta=0..Pi),phi=0..2*Pi),r=0..1); 

`+`(1, `-`(`*`(`/`(809929, 491520), `*`(exp(-`/`(1, 2)))))) (2.2) 
> evalf(prob2); 

0.5558864e-3 (2.3) 

b. And between 1 and 2 bohr radii (1 < r < 2): 

> prob2_2 := int(int(int(p2*r^2*sin(theta),theta=0..Pi),phi=0..2*Pi),r=1..2); 

`+`(`*`(`/`(809929, 491520), `*`(exp(-`/`(1, 2)))), `-`(`*`(`/`(1727, 640), `*`(exp(-1))))) (2.4) 
> evalf(prob2_2); 

0.67444340e-2 (2.5) 

c. And finally within 10 bohr radii (r>10): 

> prob2_10 := int(int(int(p2*r^2*sin(theta),theta=0..Pi),phi=0..2*Pi),r=10..infinity); 

`+`(`*`(`/`(50729, 384), `*`(exp(-5)))) (2.6) 
> evalf(prob2_10); 

.8901284199 (2.7) 

d. Finally, for my own sanity (not required for credit), I am going to check the limits of this probabilty versus radius and do some plots: 

> implicitplot3d(p2=0.000015,r=0..20,phi=0..2*Pi,theta=0..Pi,coords=spherical,axes=box,view=[-20..20,-20..20,-20..20],grid=[25,25,25],orientation=[30,65]); 

Plot  
> prob2_RAD := int(int(int(p2*r^2*sin(theta),theta=0..Pi),phi=0..2*Pi),r=0..R); 

`+`(1, `-`(exp(`+`(`-`(`*`(`/`(1, 2), `*`(R)))))), `-`(`*`(`/`(1, 2), `*`(exp(`+`(`-`(`*`(`/`(1, 2), `*`(R))))), `*`(R)))), `-`(`*`(`/`(1, 8), `*`(exp(`+`(`-`(`*`(`/`(1, 2), `*`(R))))), `*`(`^`(R, 2))...
`+`(1, `-`(exp(`+`(`-`(`*`(`/`(1, 2), `*`(R)))))), `-`(`*`(`/`(1, 2), `*`(exp(`+`(`-`(`*`(`/`(1, 2), `*`(R))))), `*`(R)))), `-`(`*`(`/`(1, 8), `*`(exp(`+`(`-`(`*`(`/`(1, 2), `*`(R))))), `*`(`^`(R, 2))...
(2.8) 
> limit(prob2_RAD,R=infinity); 

1 (2.9) 
> plot(prob2_RAD,R=0..50); 

Plot_2d