Tuesday, November 29, 2022

Computer AssistedTesting/Learning using php

The following php programs are presented to aid educators in developing interactive modules for their students on the world wide web. Where teachers have access solely to the public_html directory, and no access to the cgi-bin directory, php is a method of writing interactive material without using Perl. The following code, 2 programs, one a question (test.php), and one a grading module called "process.php", are presented. I am no expert in php, and cobbled this together just to show the reader that it can be done.

test.php

<?php
// Start the session
session_start();
?>
<!DOCTYPE html>
<html>
<body>
   <title>Prototype php Computer Assisted Learning/Testing</title>
 </head>
<?php
//global $root2;
$true = "true";
$false = "false";
$debug = $false;
function sigFig($value, $digits)
{
    if ($value == 0) {
        $decimalPlaces = $digits - 1;
    } elseif ($value < 0) {
        $decimalPlaces = $digits - floor(log10($value * -1)) - 1;
    } else {
        $decimalPlaces = $digits - floor(log10($value)) - 1;
    }

    $answer = round($value, $decimalPlaces);
    return $answer;
}


function randomFloat($min = 0, $max = 1) {
    return $min + mt_rand() / mt_getrandmax() * ($max - $min);
}
$r_no_a = randomFloat(1,2);
$r_no_a = sigFig($r_no_a,3);
$r_no_c = sigFig(randomFloat(1,2),3);
$r_no_b = sigFig(randomFloat(4*$r_no_a*$r_no_c, 4.3*$r_no_a*$r_no_c),3);
$root1 = (-$r_no_b +sqrt( pow($r_no_b,2)-4*$r_no_a*$r_no_c))/(2*$r_no_a);
$root1 =  sigFig($root1,3);
$text = "
<h2>A php protypical computer assisted learning/testing module</h2>
<br> For the equaton <br>
<center>
<h2>
 $r_no_a  x<sup>2</sup> +   $r_no_b x +   $r_no_c  = 0 
</h2>
</center>
one root is $root1. What is the second root?";
$root2 = (-$r_no_b - sqrt( pow($r_no_b,2)-4*$r_no_a*$r_no_c))/(2*$r_no_a);
$root2 =sigFig($root2,3);
echo $text;
if ($debug == $true){
echo "<br> debug::: root2 = $root2<br>";
echo sigFig($root1,3);}
?>
<body>
  <form action="process.php" method="post">
   <fieldset>
     <table>
      <tr>
       <td>First Name: </td>
       <td><input type="text" name="fname" value="John"></td>
      </tr>
      <tr>
       <td>Last Name: </td>
       <td><input type="text" name="lname" value="Smith"></td>
      </tr>
      <tr>
       <td>e-mail address: </td>
       <td><input type="text" name="email address" value="john.smith@university.edu"></td>
      </tr>
     </table>
   </fieldset>
   <fieldset>
<input type="hidden" name="root2" value="<?php echo $root2;?>" />
<input type="hidden" name="a" value="<?php echo $r_no_a;?>" />
<input type="hidden" name="b" value="<?php echo $r_no_b;?>" />
<input type="hidden" name="c" value="<?php echo $r_no_c;?>" />
<input type="hidden" name="text" value="
<?php echo $text;?>"/>
<font size="+3">
<select name="firstSign">
  <option value="+">+</option>
  <option value="-"> -</option>
</select>
<select name="firstDigit">
  <option value="1">1</option>
  <option value="2"> 2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
  <option value="6">6</option>
  <option value="7">7</option>
  <option value="8">8</option>
  <option value="9">9</option>
</select>
.
<select name="secondDigit">
  <option value="0">0</option>
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
  <option value="6">6</option>
  <option value="7">7</option>
  <option value="8">8</option>
  <option value="9">9</option>
</select>
<select name="thirdDigit">
  <option value="0">0</option>
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
  <option value="6">6</option>
  <option value="7">7</option>
  <option value="8">8</option>
  <option value="9">9</option>
</select>
x 10
</font>
<sup>
<select name="firstExpSign">
  <option value="+">+</option>
  <option value="-">-</option>
</select>
<select name="firstExpDigit">
  <option value="0">0</option>
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
  <option value="6">6</option>
  <option value="7">7</option>
  <option value="8">8</option>
  <option value="9">9</option>
</select>
<select name="secondExpDigit">
  <option value="0">0</option>
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
  <option value="6">6</option>
  <option value="7">7</option>
  <option value="8">8</option>
  <option value="9">9</option>
</select>
<input type="hidden" name="correctAnswer" value='<?php "$root2";?>' />
       <input type="submit"  name="submit" value="Submit Your  Answer">
   </fieldset>
   </sup>
  </form>
 </body>
 </html>
process.php
The process module starts here:
<?php
$true = "true";
$false = "false";
$debug = $false;
   if (isset($_POST['submit']))
   {
     echo "<big/><big/>";
     echo "Your First Name is: " . $_POST["fname"] . "<br>";
     echo "Your Last Name is: " . $_POST["lname"] . "<br>";
/*     echo "Your e-mail address is: " . $_POST["email address"] . "<br>";
/*     echo "Your State is: " . $_POST["state"] . "<br>";*/
     echo "<br>";
     $correctAnswer = $_POST["correctAnswer"];
/*var_dump($_POST["correctAnswer"]);*/
     $text = $_POST["text"];
/*var_dump($_POST["text"]);*/
     $root2 = $_POST["root2"];
/*var_dump($_POST["correctAnswer"]);*/
     $firstDigit = $_POST["firstDigit"];
     $secondDigit = $_POST["secondDigit"];
     $thirdDigit = $_POST["thirdDigit"];
    $firstExpSign = $_POST['firstExpSign'];
    $firstExpDigit = $_POST['firstExpDigit'];
    $secondExpDigit = $_POST['secondExpDigit'];
    $power = $firstExpDigit*10+$secondExpDigit;
    if ($firstExpSign == "-"){$power=-$power;}
    $studentAnswer = $firstDigit+$secondDigit/10+$thirdDigit/100;
    if ($firstSign == "-"){-$studentAnswer = -$studentAnswer;}
    $studentAnswer = $studentAnswer*pow(10,$power);
    echo $text;
    echo "<br> Your answer was = ".$studentAnswer;
    if($studentAnswer == $root2){
       echo "Right! <img src=./icons/check.gif> ";
    }else{
    echo "<br>
    Wrong! <img src=./icons/checkno.gif><br>";}
    echo "<h2>Use back arrow to return to question</h2>";
   }
?>
The above text can be executed at my physical chemistry site

Friday, July 22, 2022

Revisiting educational value of educational journal articles

Revisiting educational value of educational articles

There is a powerful belief amongst us that teaching and learning are coupled in some magical way.


Recently, while searching for an article I'd written and had accepted, I came across a letter to the editor referring to earlier work of mine. How wonderful; an indication that someone had actually read something I'd written.


But, in thinking about it, I was apalled that the editor had not told me about this letter. I refer to J. Chem. Ed. 61,268(1984), by F. O. Ellison. Ellison objected to my using Cartesian coördinates to show that an LCAO-MO for the hydrogen molecule cation was not an eigenfunction of the appropriate Hamilonian. Instead, Ellison showed symbolically that this was the case. Of course, we were both "correct", but the question in my mind then, and now, is- what pedagogically works for students of physical chemistry.

 Three coördinate systems, cartesian, spherical polar and elliptical, are shown

In teaching valence bond or molecular orbital theory, one needs to deal explicitly with coördinate systems, so that one can locate the nuclei. The figure shows three coördinate systems applicable to the problem at hand. Which should one use? How should it be used? What does using it do for the student?


The typical chemistry student has ended his/her mathematical formal instruction with differential equations. Thus partial differential equations in two or more independent variables is not usually included in the curriculum. So a Hamiltonian of the form
$$ -\frac{\hbar^2}{2m_e} \left ( \frac{\partial^2}{\partial x^2}+ \frac{\partial^2}{\partial y^2}+ \frac{\partial^2}{\partial z^2} \right ) -\frac{Ze^2}{r} $$ can not be referring to $r_A$ or $r_B$, but to $r = \sqrt{x^2+y^2+z^2}$. That is the radius from the origin in spherical polar coördinates, viz., $r,\vartheta,\varphi$. So, when Ellison writes $$ H\psi_{trial}=\left [ -\frac{\hbar^2}{2m}\nabla^2 -\frac{ Ze^2}{r_A} - \frac{ Ze^2}{r_B} \right ](1s_A+1s_B) $$one has the right to ask, does the student understand the difference between $r$ and $r_A$?

As one traces backwards the accumulated learning that was required to get to these points the student/reader has the right to ask 'what does this symbolism mean?'. After all, $r_A = \sqrt{x^2 + y^2 + (z- R/2)^2}$ and $r_B= \sqrt{x^2 + y^2 + (z+R/2)^2}$ so the LCAO proposed is a little complicated.

So, we return to the idea of third year chemistry majors studying physical chemistry for the first time and dealing with mathematics based on two years of standard calculus instruction. Having been out of classrooms for more that 12 years, I can no longer attest to what students have been exposed to, but my guess is that $\nabla$ is not one of symbols they've seen.

But I'm sure that they've never seen an equation of the form $Operator$ operating on $function$ yields a $number$ times $the\ same\ function$, i.e., $H\psi = E \psi$. Actually, most likely they've "seen" it, but never actually used it.


Following backwards the accumulated knowledge that these students have acquired is an amazing journey. Consider the gradient $$ \vec{\nabla} = \hat{i}\frac{\partial}{\partial x}+ \hat{j}\frac{\partial}{\partial y}+ \hat{k}\frac{\partial}{\partial z} $$ Does the student know this operator? Is it related to $\nabla^2$?
Where did we learn this?

And, relative to the diagram, what is $\nabla$ and $ \nabla^2$ in elliptical coördinates?

And what is an LCAO-MO in these elliptical coördinates?

As we trace backwards from the current state of the art, looking at the assumed knowledge required for understanding, we see the reverse process of educational curriculum development through the lens of practitioners. This enormous pyramid of learned techniques and facts has to be reverse engineered so that children can absorb this material and incorporate this knowledge into their armamentarium.

How we do this is the task of educators who do not know what their charges will need; the material they are presenting or the material they are omitting. The future will unfold, and leaving out a topic could easily warp understanding many years hence.

On the other hand, most of their charges will never use any of the mathematics they are taught!

Consider the backwards path from partial differential equations, through calculus, through advanced algebra, solid geometry, intermediate algebra, trigonometry, plane geometry, elementary algebra, arithmetic, and finally numbers, and more than finally, fingers and toes.

Can we really truncate this learning path?

It seems doubtful we can; but instead, we leave it to the child to drop off of the heirarchical tree. That seems to work in most cases, but the doors that are closed for these children are rarely re-opened. Perhaps this is the best a civilization can do.

Thursday, June 23, 2022

The ground state wavefunction expansion for Helium's electrons

On the Exact Helium Wave Function Expansion

Abstract

A $^1S$ wave function's expansion for 2 electron atoms and ions is obtained and the leading coëfficients are reported.

Introduction

The ground electronic state of Helium (and its isoelectronic ions) has been studied extensively since the original work of Hylleraas (E. A. Hylleraas, Uber den Grundzustand des Heliumatoms, Zeits. f. Physik 48, 469 (1928)). Absent an exact solution, efforts have been expended to find compact approximate wave functions which give increasingly better energy eigenvalues for the energy ( K. Rodriguez, G. Gasaneo, and D. Mitnik, Accurate and simple wavefunctions for the Helium isoelectronic sequence with correct cusp conditions, Journal of Physics B: Atomic, Molecular and Optical Physics 40, 3923 (2007).).

The $^1S$ wave function for Helium's two electrons is not a power series in $r_1, r_2$ and $r_{12}$, as shown by Bartlett, Gibbons and Dunn ( J. H. Bartlett Jr., J. J. Gibbons Jr., and C. G. Dunn, Phys. Rev. 47, 679 (1935)). who demonstrated that a unique solution for $\psi(r_1,r_2,r_{12})$ of the form $$ \psi = \sum_{i,j,k}C_{i,j,k}r_1^ir_2^jr_{12}^k $$ does not exist. They showed that the coëfficient of $\frac{r_2^2}{r_1r_{12}} \hookrightarrow C_{101} = 0$, that the coëfficients of $\frac{1}{r_1} \hookrightarrow 2C_{100}+C_{010}= 0$ and that the coëfficients of $\frac{r_{1}}{r_{12}} \hookrightarrow 5C_{101}-\frac{1}{2} C_{100} = 0$.

Fock (V. A. Fock, Izv. Akad. Nauk SSSR, Ser. Fiz. 18, 161 (1954).,V. A. Fock, On the Schrödinger equation of the Helium atom, Det Koneglige Norske Videnskabers Selskabs Forhandlinger 31, 138 (1958)., E. Z. Liverts and N. Barnea, Angular fock coefficients: Refinement and further development, Phys. Rev. A92, 42512 (2015).) showed that there must be logarithmic terms in the expansion, and gave the form the expansion had to take. Defining $R=\sqrt{r_1^2+r_2^2}$, he wrote (in current but mixed notation) \begin{eqnarray} \psi = 1 -Z (r_1+r_2) +\frac{1}{2}r_{12}+ \nonumber \\ R \left (\psi_{2,1} \ell n R + \psi _{2,0} \right ) + \nonumber \\ R^{1/2} \left (\psi_{5/2}R \ell n R + R\psi _{5/2,0} \right ) + \nonumber \\ R^2 \left (\psi_{3,2}\ell n^2 R + \psi_{3,1} \ell n R +\psi_{3,0} \right ) +\dots \end{eqnarray} with $Z=2$ for Helium. $\psi_{2,1}$ was shown by Fock to be a linear combination of $\cos \alpha$ and $\sin \alpha \cos \vartheta$ where $\cos \alpha \hookrightarrow r_1^2-r_2^2$ and $\sin \alpha \cos \vartheta \hookrightarrow 1-\frac{r_{12}^2}{r_1^2+r_2^2}$. Here $R^{1/2}\cos(\alpha/2)$ and $R^{1/2}\sin(\alpha/2)$ are equal to $r_1$ and $r_2$ respectively, while $r_{12}$ is equal to $R^{1/2}\sqrt{(1-\sin\alpha\cos\vartheta)}$.

It is hard to fit the Fock form coherently into the Bartlet et al. formulation of an $ Ansatz$ for the Schrödinger Equation's possible solution.

The idea that the coëfficients of $\psi_{2,1} $ are a linear combination of $\sin \alpha \sin \vartheta$ and $\cos\alpha$ is worrisome, as $\cos{\alpha}$ is an odd function of $r_1$ and $r_2$ and the ground state of 2-electron systems should be even with respect to these two variables. If the coëfficient of $\cos \alpha$ in $\psi_{2,1} $ is indeed zero, then $\psi_{2,1} =\frac{ r_1^2+r_2^2 - r_{12}^2}{r_1^2+r_2^2}$.

The $Ansatz$

The following expansion is proposed: \begin{eqnarray} 1 + C_{1,0,0}r_1 + C_{0,1,0}r_2 + C_{0,0,1}r_{12} + \nonumber \\ +C_{1,1,0}r_1r_2 + C_{1,0,1}r_1r_{12} + C_{0,1,1}r_2r_{12}+ \\ \nonumber constant* \left ( r_1r_{12}\ell n r_1r_{12} + r_2r_{12}\ell n r_2r_{12} \right ) +\dots \label{eqone} \end{eqnarray} as the first few terms. The last term shown in (Eqn. 1) mitigates the Bartlett, Gibbons and Dunn conundrum. This suggests the following $Ansatz$: \begin{eqnarray} \psi = \sum_{i,j,k,\ell}C_{i,j,k,\ell}r_1^ir_2^jr_{12}^k \left [ \left (r_1r_{12} \ell n r_1r_{12} \right)^\ell + \left (r_1r_{12} \ell n r_2r_{12} \right)^\ell \right ] \end{eqnarray} (with restrictions on $i,j,k$ and $\ell$), but it fails the Bartlett Gibbons and Dunn criterion. Instead, the following is proposed: \begin{eqnarray} \psi = \sum_{i,j,k=0}C_{i,j,k,0}r_1^ir_2^jr_{12}^k \nonumber \\ + \sum_{\{i,j,k\}=0,\ell=1}C_{i,j,k,\ell}r_1^ir_2^jr_{12}^k \left ( r_1r_{12}\left ( \ell n r_1r_{12} \right)^\ell + r_2r_{12} \left ( \ell n r_2r_{12} \right)^\ell \right ) \label{ansatz} \end{eqnarray} with $C_{0,0,0,0}=1$.

The Hamiltonian and Leading Terms in the Expansion

The Hamiltonian Operator used in the best calculation to date ( H. Nakashima and H. Nakatsujja, J. Chem. Phys. 127, 224104 (2007).) applicable to the ground state of the Helium-like atom's/ion's two electrons is: \begin{eqnarray} -\frac{1}{2 } \left ( \frac{1}{r_1^2} \frac{\partial \left (r_1^2\frac{\partial}{\partial r_1}\right ) }{\partial r_1} + \frac{1}{r_2^2} \frac{\partial\left ( r_2^2\frac{\partial}{\partial r_2}\right ) }{\partial r_2} \right )- \frac{1}{r_{12}^2} \frac{\partial\left ( r_{12}^2\frac{\partial}{\partial r_{12}}\right ) }{\partial r_{12}} \nonumber \\ - \frac{r_1^2-r_2^2+r_{12}^2}{2r_1r_{12}} \frac{\partial^2}{\partial r_{1}\partial r_{12}} - \frac{r_2^2-r_1^2+r_{12}^2}{2r_2r_{12}} \frac{\partial^2}{\partial r_{2}\partial r_{12}} \nonumber \\ -\frac{Z}{r_1} -\frac{Z}{r_2} +\frac{\lambda}{r_{12}} \label{ham} \end{eqnarray} where $\lambda = 1$ and $Z$ is the atomic number of the nucleus.

Substituting our $Ansatz$ into the Hamiltonian of the Schrödinger Equation $H\psi=E\psi$ and setting coëfficients to zero sequentially, we obtain $C_{1,0,0,0}=C_{0,1,0,0} = -Z$, and $C_{0,0,1,0}= \lambda /2$ as expected.

Results and Discussion

Table 1, Sequential coëfficients
Term Coëfficient
$\frac{r_1^2}{r_2r_{12}}$ $ C_{1,0,1,0}= -2*(C_{0,0,0,1}+C_{0,0,0,2})$
$\frac{r_2^2}{r_1r_{12}}$ $ C_{0,1,1,0}= -2*(C_{0,0,0,1}+C_{0,0,0,2})$
$\frac{1}{r_1}$, $\frac{1}{r_2}$ $C_{1,1,0,0}=Z^2$
$\frac{r_2^2\ell n(r_1r_{12})}{r_1r_{12}}$, $\frac{r_1^2\ell n(r_2r_{12})}{r_2r_{12}}$ $C_{0,0,0,1}=-(4C_{0,0,0,2}+6C_{0,0,0,3}) $
$\frac{r_2r_{12}}{r_1}$, $\frac{r_1r_{12}}{r_2}$ $C_{1,1,1,0}=-(12ZC_{0,0,0,2}+24ZC_{0,0,0,3})/3$
$\frac{r_{12}}{r_1}$,$\frac{r_{12}}{r_2}$ $ C_{0,0,0,2}=2(Z\lambda/2+3C_{0,0,0,3})$
Table 1 indicates the beginning sequence of coëfficients determined sequentially substituting terms of the expansion of the wave function $Ansatz$ (Eqn. \ref{ansatz}) into the Hamiltonian (Eqn. \ref{ham}) of the Schrödinger equation.

Demurral

The continuation of developments with respect to coëfficient recursion relationships, variational calculations based on wave function choices shaped by the results shown here, and the ultimate finding of simple functional forms for which this series is the expansion, exceeds the ability and timeline of the author.

It is not apparent what sequence one needs to solve the succeeding equations.


However, approximate calculations which include logarithmic terms such as those indicated above, should allow smaller expansions with increased accuracy and a well defined path for improvement. It is worth noting that literature statements that equate more accurate energy values (to more digits) to more accurate wave functions is not, in fact, true. The contrary is expected to be true however, i.e., the more accurate the wave function the better the eigenenergy.

Acknowledgements

The mathematics employed herein was done in part using SageMath/CoCalc.

SageMath/CoCalc code

code
Send email