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

Thursday, December 2, 2021

Navigator

The Navigator Object

The appName property returns the application name of the browser:

Strange enough, "Netscape" is the application name for IE11, Chrome, Firefox, and Safari.

Wednesday, October 20, 2021

Computer Assisted Learning revisited

Web pages devoted to problems which are clones of hard copy pages, are just as likely to be successful in enhancing learning as their predecessors, i.e., not very effective. Learning from the written word is not part of current dogma, hence teachers, tutors, etc..


Videos of chalk boards should be as effective as lectures in affecting learning i.e., not very effective. Passive web instruments are little better than last century text books in enhancing self learning. Passive web instruments are little better than lectures. 


Pedagogically, one should be searching for problems on web pages which require reader input to achieve solutions, with instantaneous grading of student inputs, and possible help in overcoming error inputs. Interactive web pages make the motivated learner learn, while leaving the unmotivated learner in stupid city. 


Those interactive web pages that exist are primarily multiple-choice queries, a scheme invented to ease the burden of hand grading examinations, and not subject to part credit variances in grading schemes. But multiple-choice responses warp the thinking of students, i.e., enhance gamesmanship, and rarely guarantee that students know what they claim to know. In a world which never presents multiple-choice problems to anything in reality, training children to pass such examinations is tantamount to malpractice. 


Clearly, constructed responses are preferable to multiple choice ones, as they offer no subliminal hints concerning the “right” answer. Constructed response questions are the closest thing to perfect assessment tools as exist. 


Using cgi-bin programming (in my case using Perl, and chemistry examples), I have created pages and pages of constructed response questions in physical chemistry and freshman chemistry including some  new chemical equilibrium problems which illustrate the constructed response question approach. These examples are just the tip of the iceberg, as better handling of potential student incorrect responses offers unlimited possibilities for improvement. See:

https://chemphys.uconn.edu/~chem12x/cgi-bin/sophiakp1a.pl

and

https://chemphys.uconn.edu/~chem12x/cgi-bin/sophiakp2.pl


At this time of the covid remote learning environment we have exactly the right time to create tools for self learning which will enhance future self learning especially when our students have left school. No graduates/adults can expect teachers to answer their questions and grade their learning. Adulthood demands a modus operandi of self learning and self validation of learning which far exceeds what is available today. 


These ideas are offered in the hope of encouraging Computer Assisted Learning as a primary way of using remote on-line STEM instruction for interactive problem solving everywhere in the quantitative domain. 


For web authors of teaching materials who have public_html access but not cgi-bin access, php alternatives to Perl should be easy to develop. My attempt is currently underway.

Tuesday, November 10, 2020

Sophiakp1.pl source code

Sophiakp1.pl; constructed response Kp problem source code

This is the code for one of the chemical equilibrium problems presented on the web site: https://chemphys.uconn.edu/~chem12x/cgi-bin/sophiakp1.pl. It goes without saying (althought it is being said) that I am not a professional programmer, and that therefore the code presented is not a template. It is loaded with debugging detrious which may or may not be relevant.

The purpose of releasing the code is to suggest a scheme whereby a professional programmer can create computer assisted learning modules. S/he should regard the following lines as an effort to suggest approaches, rather than a prescription.

The code is centered on CGI.pm, which has been declared obsolete by Perl authors and managers. I have yet to find a substitute for CGI.pm for allowing perl code to be included in web forms in a transparent manner, and suggest that anyone preparing to use the following code as a suggeestion, should have his/her system administratopr install CGI.pm, since it is no longer included in the standard Perl library.

To make it abundently clear, CGI.pm allows one to write Perl code, which resides in the executable directory public_html/cgi-bin/ on a standard Unix server of web pages. The public_html directory contains (HTML sourced) web pages which can be loaded directly, while Perl programs located in cgi-bin need to be executed.

We start with the preliminary code:

#!/usr/local/bin/perl -- -*-perl-*-
#
# This is sophiakp1(Computer Assisted Learning, CAL1)
#
require  "CleanUp.pl";
require "top.pl";
require "JSCRIPT.js";
use CGI;
use CGI qw/:standard *table start_ul/;
use CGI::Carp qw(fatalsToBrowser);
#
use CAT2p4pchem;
use CGRutils3;
use lib '/home/cdavid/perl5/lib/perl5';
use Mail::Mailer;

$query = new CGI;
$qCAT = new CAT2p4pchem;
$qCGR = new CGRutils3;
$debug = 1;# set to zero to remove print statements

The real work starts here

$first = 1;#ignore box check first time
prin
print $query-&header;
$title = "Sophia's K<sub>p</sub> I. C. E. page";
print $query-&start_html($title);

$global_debug="false";
srand;
top();
$redz = "<font color=red>z</font>";
print "<h1>$title</h1>";
$scriptname = $query->script_name();#this gives the question name

$rnoby3 = $qCAT->rno(3)/3;
$temp_rno = $qCAT->rno(3)/3;
$qCAT->save_vars($query,'rnoby3',\$rnoby3);#save list for this variable
$qCAT->save_vars($query,'temp_rno',\$temp_rno);#save list for this variable

We have defined peripheral constants and we are ready to start the form which will be used to

  1. get the student's e-mail address, which we use to lock the screen until something is given,
  2. create the Perl variables for the problem at hand,
  3. state the problem,
  4. accept a student's response.

print $query->start_form();
$student_id = "?";
print <<EOD;
Messages for the author concerning errors, mistakes, bad grammar, etc., can be sent
<a href="mailto:my.name\@uni.edu?subject=Sophiakp1%comment.">to my.name\@uni.edu using your own mail handler.</a> .
EOD
print "<hr>";

$var11 = 10*$qCAT->rno(3)+5;#create random number with two digits behind decimal point
$qCAT->save_vars($query,'var11',\$var11);#save list for this variable
$var12 = 10*$qCAT->rno(3)+$var11;#create random number with two digits behind decimal point
$qCAT->save_vars($query,'var12',\$var12);#save list for this variable
$var13 = 10*$qCAT->rno(3)+$var12;#create random number with two digits behind decimal point
$qCAT->save_vars($query,'var13',\$var13);#save list for this variable


$var11string = sprintf "%5.2f", $var11;
$var12string = sprintf "%5.2f", $var12;
$var13string = sprintf "%5.2f", $var13;
$var21 = "2*z";
$var23 = "-2*z";
$var31 = $var11string."+2*z";
$var32 = $var12string."+z";
$var33 = $var13string."-2*z";


$varz = $var13*$qCAT->rno(3)/3;
$qCAT->save_vars($query,'varz',\$varz);#save list for this variable
$varzstring = sprintf "%5.2f", $varz;
$answerKpusingQp = Qp(($var13-2*$varz), ($var11+2*$varz),($var12+$varz));
$error = 0;
$student_id = "?";
print "To unlock this page, please enter your e-mail address:",  $query->textfield( -name=>'student_id',-default=>'?',-size=>40,-maxlength=>50);
$qCAT->save_vars($query,'student_id',\$student_id);#save
print <<EOF;
<br>
The equilibrium constant for the reaction of NO(g) with O<sub>2</sub>(g) to
form NO<sub>2</sub>(g) is unknown.
EOF

The following code gives the Kp expression as long as this site (sciweavers)  stays alive.

print <<EOF;
<center>
<img src="http://www.sciweavers.org/tex2img.php?eq=NO%28g%29%20%2B%20%0A%20%5Cfrac%7B1%7D%7B2%7DO_2%28g%29%20%5Crightleftharpoons%0ANO_2%28g%29%20&bc=White&fc=Black&im=jpg&fs=12&ff=arev&edit=0" align="center" border="0" alt="NO(g) +  \frac{1}{2}O_2(g) \rightleftharpoonsNO_2(g) " width="221" height="43" />
</center>
In a recent experiment,  the initial pressure of NO(g) was $var11, while the initial pressure of
O<sub>2</sub>(g) was $var12, and the initial pressure of NO<sub>2</sub>(g) was
$var13.
Please fill in the following tableau (remember to include the '*' sign when multiplying): 
EOF

We've stated the problem (at least part of it) and now we are going to switch from text to a table, i.e., use HTML explicitly. Here is where the discussion of separating the HTML from the Perl makes no sense to me. The HTML flows perfectly, and templating it makes no sense, since the next problem will require a different kind of table, with its own coding.

The tableau code follows, with the table entries indicating the box indexing scheme which will be lost as the student fills in the boxes. Perhaps coding these (x,y) couples into the table with persistence, would be preferable, but this works as the simplest way of beginning.

print  "<center>";
print table({-border=>undef},
  caption('I.C.E. Table'),
  Tr({-align=>'CENTER',-valign=>'TOP'},
    [
    th(['', 'P<sub>NO</sub>','P<sub>O<sub>2</sub></sub>','P<sub>NO<sub>2</sub></sub>']),
    td(['Initial' ,
      $query->textfield( -name=>'box11',
        -default=>'1,1',
        -size=>5,
        -maxlength=>7
      ),
      $query->textfield(-name=>'box12',
        -default=>'1,2',
        -size=>5,
      -maxlength=>7),
      $query->textfield(-name=>'box13',
        -default=>'1,3',
        -size=>5,
      -maxlength=>7),
    ]),
    td(['Change' ,
      $query->textfield(-name=>'box21',
        -default=>'2,1',
        -size=>5,
      -maxlength=>7),
      $redz,
      $query->textfield(-name=>'box23',
        -default=>'2,3',
        -size=>5,
      -maxlength=>7),
    ]),
    td(['Equilibium'   ,
      $query->textfield(-name=>'box31',
        -default=>'3,1',
        -size=>5,
      -maxlength=>9),
      $query->textfield(-name=>'box32',
        -default=>'3,2',
        -size=>5,
      -maxlength=>9),
      $query->textfield(-name=>'box33',
        -default=>'3,3',
        -size=>5,
      -maxlength=>9)
    ])
  ] )
);

When the submit button is pressed, the contents of the boxes are assigned to Perl variables:

$ans11 = $query->param('box11');
$ans12 = $query->param('box12');
$ans13 = $query->param('box13');
$ans21 = $query->param('box21');
$ans22 = $query->param('box22');
$ans23 = $query->param('box23');
$ans31 = $query->param('box31');
$ans32 = $query->param('box32');
$ans33 = $query->param('box33');

#begin judging box answers:
if($query->param('student_id') ne "?"){

In order to unlock the screen, we force the "?" to have been changed.

Then each box is checked and the error messages printed.

  if (grade_student_txt_against_correct($ans11,$var11,"Does not seem right ","z") == 0){
    print "<br>box 1,1 appears to be wrong";
    $error = 1;
  }else{print"box 1,1 appears to be right <br>";}
  if (grade_student_txt_against_correct($ans12,$var12,"Does not seem right ","z") == 0){
    print "<br>box 1,2 appears to be wrong ";
    $error = 1;
  }else{print"box 1,2 appears to be right <br>";}
  if (grade_student_txt_against_correct($ans13,$var13,"Does not seem right ","z") == 0){
    print "<br>box 1,3 appears to be wrong ";
    $error = 1;
  }else{print"box 1,3 appears to be right <br>";}
  if (grade_student_txt_against_correct($ans21,$var21,"Does not seem right ","z") == 0){
    print "<br>box 2,1 appears to be wrong ";
    $error = 1;
  }else{print"box 2,1 appears to be right <br>";}
  if (grade_student_txt_against_correct($ans23,$var23,"Does not seem right ","z") == 0){
    print "<br>box 2,3 appears to be wrong ";
    $error = 1;
  }else{print"box 2,3 appears to be right <br>";}
  if (grade_student_txt_against_correct($ans31,$var31,"Does not seem right ","z") == 0){
    print "<br>box 3,1 appears to be wrong ";
    $error = 1;
  }else{print"box 3,1 appears to be right <br>";}
  if (grade_student_txt_against_correct($ans32,$var32,"Does not seem right ","z") == 0){
    print "<br>box 3,2 appears to be wrong ";
    $error = 1;
  }else{print"box 3,2 appears to be right <br>";}
  if (grade_student_txt_against_correct($ans33,$var33,"Does not seem right ","z") == 0){
    print "<br>box 3,3 appears to be wrong ";
    $error = 1;
  }else{print"box 3,3 appears to be right<br> ";}
  $first = 0;#enable box checking
#
  print "<hr>";
  
  
  $ans11 = $query->param('box11');
  $ans12 = $query->param('box12');
  $ans13 = $query->param('box13');
  $ans21 = $query->param('box21');
  $ans22 = $query->param('box22');
  $ans23 = $query->param('box23');
  $ans31 = $query->param('box31');
  $ans32 = $query->param('box32');
  $ans33 = $query->param('box33');
  $NO2_eq = $ans13-2*$varz;
  $NO_eq = $ans11+2*$varz;
  $O2_eq = $ans12+$varz;
# NO_2 then NO and then O_2
  $Kp_correct = &Qp($NO2_eq,$NO_eq,$O2_eq);
  $ans = $Kp_correct;

When all boxes are correct, we present the real problem.

  if ($error == 0) {
    print "<br>If the value of  $redz  = $varzstring , what is the value of
    K<sub>p</sub>?  ";
#=========start
    my $ret = $qCAT->qnd($query,'t0',$ans,2,$filename,'');#to be extended

Above is the request for a student numerical answer. The function qnd is a 3 significant figure comparer.  $qCAT points at CAT2p4pchem.pm which contains a set of support subroutines that are commonly used in this kind of work. The text for CAT2p4pchem.pm is included in these posts elsewhere.

    if($ret == 0){ #here if answer wrong
      print "<img src=../icons/RAIN_LINE.gif>";
      print "
      <br>Do you want to see how this problem is done (or at least a hint)?
      If so, please check this box (and resubmit) ",$query->checkbox('to')," enable this feature.
      ";

The text of help, is solely in the programmer's discretion.

      if ($query->param('to') eq 'on'){
        print <<EOF;
        <br>
        Once the boxes are correctly filled in, the
        the equilibrium pressure of NO<sub>2</sub> = $NO2_eq,
        the equilibrium pressure of NO = $NO_eq,
        and the equilibrium pressure of O<sub>2</sub>  = $O2_eq.
        Knowing $redz one can compute these values, and substitute them into
        the K<sub>p</sub> expression to finish the problem.
EOF
      }
      
    }
    else {
#here if answer right

Again, when the student gets the answer correct, the programmer can "reward" him/her as s/he sees fit. In our case here, while the question is being circulated in a campaign to get Perl based cgi-bin modules to be added to all computer assisted learning modules, the "reward" text is aimed at educators rather than students.

      print "Great";
      print <<EOF;
      <br>This is the ultimate formulation of computer assisted learning that I can produce.
      It offers no help whatsoever in terms of filling in the boxes in the tableau, but tells students when they are wrong.
      Suggestions about interventions when students make mistakes would certainly be appreciated.
EOF
$student_id = $query->param('student_id');
    print "<br><img src=../icons/RAIN_LINE.gif><br>";

When the student gets the right answer, the programmer needs to record this event. This can be done by adding remarks to a database of student activity, (as one `can record wrong responses, for analysis and improvement purposes).

In this case, I wanted to monitor whether or not anyone (i.e., an educator visiting the site) had actually carried out the computation required to finish the problem, hence the use of an e-mail to me.

    $mailer = new Mail::Mailer;
    $email = 'carl.david@uconn.edu';
    $mailer->open( {
        To       => $email,
        From     => 'The Webmaster <chem12x@chemphys.uconn.edu>',
        Subject  => 'Web Site Feedback using Mail::Mailer'
    } );
    
    print $mailer <<END_OF_MESSAGE;
    This is the Mail::Mailer message sent by $student_id using the page $scriptname.
END_OF_MESSAGE
    };
  }
}
$first = 0;
$qCAT->save_vars($query,'first',\$first);#save list for this variable
print $query->submit;

print $qusery->end_form;

This calculator (below) can easily be omitted.

&JSCRIPT();
print $query->end_html;


This is specific to the chemistry problem.

sub Qp{
# NO_2 then NO and then O_2
#print "dump  = ";print Dumper(@_);print "<br>";
  
  return(($_[0])/(($_[1])*sqrt($_[2])));
}

This is a constructed response evaluating subroutine, which in our case is being used for the box fillin section of the problem.

sub grade_student_txt_against_correct
#note no input in this subroutine
# calling sequence, required!!!!!
{
#      my ($query) = $_[1];# this seems to work only in the newer version of CGI.pm
# this is a subroutine which gets a query, an answer, a student answer, and a list
# of variables and returns 1 (True) if the student answer is OK, and 0 (False) otherwise.
#      my $q = $_[2];#passing unique textual identifier
#
  $total_args = scalar(@_);
  
  my $student = $_[0];#passing a student answwer
  my $correct = $_[1];#passing the correct answer
  my $error_response = $_[2];#response for a wrong answer
  my $variables1 = $_[3];#passing list of variables
  my $dump = 0;
  $variables = $variables1;
#print "<br>inside subroutine, global_debug = $global_debug";
  if ( $global_debug eq "true"){$dump = 1};
  if($dump){
    print "<br> total_args = $total_args";
    print "<br> student = $student";
    print "<br> correct = $correct";
    print "<br> variables = $variables";
  }
#      if ($query->param($q)ne ''){
  my $ans1 = $student;
  
  my $saved_stu_ans1 = $ans1;
  if($dump){
    print "<br> ans1 = $ans1";
    print "<br> saved_stu_ans1= $saved_stu_ans1";
  }
  $escape = '?!';
  if(substr($ans1,0,length($escape)) eq $escape){print "<br> test mode, answer expected = $correct";}
  
  &CleanUp($ans1);
  &CleanUp2($ans1);#someone else's attempt, lost reference
  &CleanUp($correct);
  if($dump){
    print "<br> ans1 (after CleanUp)   = $ans1";
    print "<br> saved_stu_ans1 (after CleanUp)  = $correct";
  }
  $var = $variables1;
  if($dump){
    print "<br> substitution variable var = $var";
  }
  $rno = 1+rand();
  $ans1 =~ s/$var/$rno/gi;
  $correct =~ s/$var/$rno/g;
  if($dump){
    print "<br> rno = $rnob";
    print "<br> after substitution variable var = $var";
    print "<br> after a cycle of substitutions, ans1 = $ans1, and correct = $correct";
  }
  if($dump){
    print "<br> criterion = ",abs(eval($correct)-eval($ans1));
    print "<br> correct = ",eval($correct);
    print "<br> ans1 = ",eval($ans1);
  }

This is the core of the scheme. The expressions, with the same random variable in both the student's and the author's answer are compared.

  if(abs(eval($correct) -eval( $ans1)) < 0.0001){
    print "<img src=../icons/check.gif>";
    return 1
  }
  else{
    print "<br><img src=../icons/checkno.gif>";
#print "<br>You did not submit a correct answer.<br>";
    print $error_response;
    return 0
  }
#      }#end of if param
  if($global_debug eq "true"){ $dump = 0; $global_debug = "false"};
}#end of subroutine  grade_student_txt_against_correct

sub CleanUp2{#Author's name and address unfortunately lost. Not my code.
  $_ = shift;
  s/\-+(.*)/\1/g;
  s/(.*)[ \t]+\-(.*)/\1\2/g;
  tr/\$\'\`\"\<\>\/\;\!\|/_/;
  return($_);
}


The above code, along with libraries found here, is sufficient to get a programmer started on coding Computer Assisted Learning/Testing materials in any STEM subject. 


 That the work is harder than composing passive html pages is obvious. I have failed repeatedly over the past 20 years in interesting anyone in doing this, despite papers written, examples displayed, and blog posts/linkedin/facebook propaganda intended to incite someone, anyone, to join in rigorizing STEM education.


As usual, the mathematicians are ahead of us;   ixl.com is a site offering constructed math problems.

Our offering is https://chemphys.uconn.edu/~chem12x/cgi-bin/sophiakp1.pl which is one of several of these problems which illustrate how rigorous CAT/L is. The last of them in essence presents a spreadsheet to the student for exploration of the approach to equilibrium:https://chemphys.uconn.edu/~chem12x/cgi-bin/sophiakp2.pl. These are freshman chemistry specific, but illustrative of what can be done.

https://chemphys.uconn.edu/~cdavid/book.html is a site with Perl code, intended to teach how to write CAT/L programs on the web for teachers.

Sunday, October 4, 2020

Quantum Mechanical Commutators and Maxima

The following code represents obtaining the commutator of the square of the angular momentum vector and the down-ladder operator both associated with the H-atom electronic energy level quantum mechanics. It is a simple example of using the non-commutative algebra parts of Maxima to do computations.

reset() + kill(all);

dotscrules:true$
Lxsq:Lx.Lx$
Lysq: Ly.Ly$
Lzsq: Lz.Lz$
Lsq: Lxsq+Lysq+Lzsq$

Aminus:(Ax-%i*Ay);
AminusLsq : Aminus.Lsq$
LsqAminus : Lsq.Aminus$
print ("expanded initial form")$
comm:(AminusLsq-LsqAminus),expand;
comm: substitute(Lx.Lx.Ax =Lx.Ax.Lx,comm)$
comm: substitute(Ly.Ly.Ay =Ly.Ay.Ly,comm)$
comm: substitute(Lz.Lz.Az =Lz.Az.Lz,comm)$
comm: substitute(Ax.Lx.Lx =Lx.Ax.Lx,comm)$
comm: substitute(Ay.Ly.Ly =Ly.Ay.Ly,comm)$
print ("expanded after i,i exchanged form")$
comm: substitute(Az.Lz.Lz =Lz.Az.Lz,comm);

/*AyLz−LzAy=i hbarAx*/
 print("1 z-y  LzAyLz" )$
comm: substitute(%i*Lz.(Lz.Ay) =%i*(Lz.(Ay.Lz)-%i*%hbar*Lz.Ax),comm),expand;
comm: substitute(%i*Ay.(Lz^^2) =%i*(Lz.(Ay.Lz)+%i*%hbar*Ax.Lz),comm),expand;

/*AyLx−LxAy=−i hbarAz*/
print ("2 x-y *Lx(Lx.Ay) ")$
comm: substitute(Lx.Lx.Ay =(Lx.(Ay.Lx)+%i*%hbar*Lx.Az),comm),expand;
comm: substitute(%i*Ay.Lx^^2 =%i*(Lx.Ay.Lx-%i*%hbar*Az.Lx),comm),expand;

/*AxLy−LyAx=i hbarAz*/
print ("3  x-y *Ly(Ly.Ax) ")$
comm:substitute(Ax.Ly^^2=Ly.Ax.Ly+%i*%hbar*Az.Ly,comm),expand;
comm:substitute((Ly^^2).Ax=Ly.Ax.Ly-%i*%hbar*Ly.Az,comm),expand;

/*AxLz−LzAx=−i hbarAy*/
print("4 x-z Lz.(Lz.Ax)  : ")$
comm: substitute(((Lz^^2).Ax) =Lz.(Ax.Lz)+%i*%hbar*Lz.Ay,comm),expand;
comm: substitute((Ax.Lz^^2) =Lz.Ax.Lz-%i*%hbar*Ay.Lz,comm),expand;


comm:comm/%hbar$
comm:expand(comm);
tex(%);

maxima using SageMath

This article deals with using Maxima under CoCalc (earlier SageMath).

The reason for this usage is that wxMaxima does not print properly, and I needed to print some incorrect code to find my error(s) in peace and quiet. Using the starting line "%maxima", which tells SageMath that the following code is to be passed to Maxima, one gets an immediate error with code which is longer than about 20 lines.

Sage Help (Stein) acknowledges that there is a programming error in Sage causing this problem, He suggested a work-around, which is used below. With the workaround, there still are several pitfalls. Comments are not accepted, blank lines fail also. No spaces, no comments, no $ terminators, only ;. Further, the maxima command tex(); fails.

In spite of the problems, it is worth passing this information along until wxMaxima maintainers fix the printing bug.

Here is an example of how to structure your Maxima code for SageMath(CoCalc):


 def maxima2(s):
      print(maxima.eval(s, allow_use_file=False))
 %maxima2
dotscrules:true;
Lxsq:Lx.Lx;
Lysq: Ly.Ly;
Lzsq: Lz.Lz;
Lsq: Lxsq+Lysq+Lzsq;
Lminus : Lx - %i*Ly;
Aminus:(Ax-%i*Ay);
AminusLsq : Aminus.Lsq;

etc..


Friday, April 17, 2020

Peer review problems

The Harmonic Oscillator
Peer reviewed articles are the “ gold standard” for readers seeking true facts- until they aren’t.

My tale of woe has its origins in 1965-6 when I published an article which I revisited last year preparatory to adding material to Wikipedia. Much to my shame and chagrin, the article had a severe error in it. Since it was in a peer-reviewed, referee-ed journal, the reader has the right to expect that its contents were correct, which they weren't! What to do?

An erratum could be submitted to the journal, but who would ever find it if they stumbled on the original article?

Since the article had only been cited once in 50+ years, it is safe to say it will die the natural death most unimportant published papers succumb to. But there is a lesson to be learned from it, one which, in this anti-science, anti-fact age might be worth learning. Peer review is fundamentally flawed.

Peer review is the process by which editors ask “learned” members of the same research community to read and assess the question- should this manuscript be published in our journal? For experimental work, the referee usually can not take the time or make the expenditure required to actually reproduce the findings, so s/he usually attempts an educated guess as to the veracity of the work based on, well, I’m not exactly sure what. Reasonableness? Plausibility? The author’s address and/or credentials?

For Computational submissions, such as modelling, the same lack of ability to reproduce the results in the submitted paper implies that there is an act of faith taking place when the referee accepts the submission. Even if given the source code, reading such code is a Herculean task, and debugging it and checking the assumptions hidden in the code is asking too much of volunteer referees and makes it impossible to certify that the code is “correct” and the results trust-able. Perhaps the results seem plausible. Perhaps the computer “predictions” match in some way the experimental data. Perhaps the “predictions” match the referee’s prejudices.

For traditional mathematics of the “paper and pencil” variety, refereeing means validating, i.e., re-proving that the assertions are true.

 Which brings me back to my (erroneous) paper. The paper “looks” right.  The error is not subtle, but hidden in an inverted plus-or-minus ($\mp$) sign. I think I proved the top sign equation but assumed the minus sign results; and the resultant equation pair seemed OK.
 Here is the equation:
 \begin{equation*}
[A_\pm  , L^2 ] =  \mp 2 \hbar^2 A_\pm  \mp 2 \hbar A_\pm L_z \pm
2 \hbar A_z L_\pm
\label{eqn1}
\end{equation*}
Since all the notes for writing this paper are gone, there is no way to reconstruct how this error occurred, but it is apparent that reading the equation does not raise suspicions about its veracity. As you can see, our error equation is the second half of equation 10.

However, further down in the paper, there’s a notational error which is apparent, obvious, and inexcusable. I wrote ``It can be shown that $A_-$ lowers $|\ell^*,\ell^*>$ to $|\ell^*-1,\ell^*-1>$'', where $\ell^*$ is the maximum value of $\ell$. This is absolutely false! That the referee missed it (and that I actually typed it) is just beyond belief. Even a casual reader of this particular paper with a shred of knowledge of the physics involved, will realize immediately that my notation is wrong.
Notice that a few lines above, I wrote $|\ell,-\ell> \rightarrow |\ell +1,-\ell - 1>$. So, how could it be that a referee didn’t catch this error.

Back then, copious publication was the requirement for promotion, tenure, and (to a certain degree) salary increases. At that time, the need for external funding of research was building and had not become the all consuming driving force for academic success that it now is. Then, publications indicated a measure of progress, while now, they reflect successful fulfillment of promises made in supported proposals. Since referee-ing of manuscripts was an unpaid, extracurricular activity, referees had as their sole reward the advanced knowledge of what was going to be published. Some scholars would ask their graduate students to read the manuscripts for them

Although not onerous, refereeing was not rewarded or appreciated, and was not usually included in annual activity reports. In theory, it was one’s professional responsibility but in practice, it was just a burden. Whether this remains true today is unknown to me.

But the system failed then, and one suspects, is even less likely to succeed now. As in almost all human activities, trust trumps proof. There is no guarantee mthat something written down, even if in a peer-reviewed journal, is correct/true.

So how do we get to “truth” in science? For experimental work, replication of methodology as precursor to some other project generally leads to verification (or condemnation). For theoretical work, the same holds true, except the details differ.

Only in mathematics do we get certainty. Consider the childhood exercise of adding up the integers from 1 to say 10. Every educated adult knows (or can know) that the answer is (10)(11)/2. The proof is to write the sum out twice, once backwards, and add them together, i.e.,

1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10

10 + 9 + 8  + 7 + 6 + 5 + 4 + 3 + 2 + 1

===========================, so adding

11+11+11+11+11... etc.

 i.e., 10 terms each of value 11. The double count has to be corrected, and there we are with the incredible Gaussian (is the story about the young Gauss true?) derivation of
 $$
 \frac{n*(n+1)}{2}
 $$
 true here, in China, on the Moon, on Alpha Centauri, at the creation of the universe, at the death of the universe, forever! Now that’s TRUE. Certainly!

The dross falls away- buried and forgotten in the avalanche of papers. The real, the “true”, appears to emerge naturally over time. A system based on honesty and integrity stumbles on.