<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Some of you have told me that you are struggling with my problem
on HW4. Here is some python code that does 3 point
Gauss-Laguerre integration for that problem. Pay attention to how
I scaled things in the problem...<br>
</p>
<p><font face="monospace">import math<br>
def fofx(x):<br>
r = x*0.529e-10<br>
Z = 1.0<br>
a0 = 0.529e-10<br>
a = 1.0 / (4.0 *
math.sqrt(2.0*math.pi))*math.pow(Z/a0,3.0/2.0)<br>
b = 2.0 - Z/a0*r<br>
c = math.exp(-(Z/a0*r)/2.0)<br>
psi = a*b*c<br>
return psi*psi*math.pow(r,3)<br>
<br>
<br>
X = [4.15774556783479E-01,<br>
2.29428036027904E+00,<br>
6.28994508293748E+00]<br>
W = [7.11093009929173E-01,<br>
2.78517733569241E-01,<br>
1.03892565015861E-02]<br>
<br>
<br>
sum = 0.0;<br>
for i in range(0,3):<br>
sum += W[i] * fofx(X[i]) * math.exp(X[i])<br>
<br>
print "Value of integral is " + str(sum)<br>
<br>
print "Value of expectation value is " + str( sum * 4 * math.pi)<br>
</font><br>
</p>
<div class="moz-signature">-- <br>
<b><i>Andrew J. Pounds, Ph.D.</i></b> <a
href="mailto:pounds_aj@mercer.edu">(pounds_aj@mercer.edu)</a><br>
<i>Professor of Chemistry and Computer Science</i><br>
<i>Director of the Computational Science Program</i><br>
<i>Mercer University, Macon, GA 31207</i><br>
</div>
</body>
</html>