next up previous contents
Next: ``zriddrp480'' Up: Solving Schrödinger's equation Previous: ``rtbisp480''

``main''

            .
            .
            .
read N from keyboard
            .
            .
            .
/* Set up change of variables grid */
for (k=0; k<=N; k++) { 
  u=((double) k)/((double) N);
  r[k]=1./(1.-u)-1.-u-u*u;
  dr[k]=1./(1.-u)/(1.-u)-1.-2*u;
  Veff[k]=-1./r[k];
}
Veff[0]=0.; dr[N]=0; /* Prevents NaN errors at origin and infinity */

kmatch=0; /* kmatch is just a dummy argument for now */
E1=-1.; E2=-0.25; /* 1s state is in between here */

/* Call solver */
E=rtbisp480(func_Schrodinger,E1,E2,1e-15, 
    kmatch,Veff,r,dr,N);

printf("N=%6d E=%20.15f\n",N,E); /* Give result to all digits */
            .
            .
            .

Write a main program along the lines above which solves and prints out to 15 digits the 1s energy of the hydrogen atom ( tex2html_wrap_inline152 ).

Note: Be certain to accept N as input from the keyboard so that we can study the convergence properties of the solution in lab.



Tomas Arias
Wed Feb 16 12:12:49 EST 2000