next up previous contents
Next: func_Schrodinger() Up: Schrödinger energy solver Previous: Schrödinger energy solver

rtbisp480()

double rtbisp480(double (*func)(double,int,double [],double [],double[],int),
                 double x1, double x2, double xacc,
                 int match, double V[], double r[], double dr[], int N)

Return value:

Input:

Modify the Numerical Recipes bisection routine rtbis() (NR 9.1) to produce a routine of the above prototype in ``p480.c''. (Don't forget to add the prototype to ``p480.h''!) You should modify rtbis so that it (1) accepts and then (2) passes to all calls to *func (which will actually be func_Schrodinger in our case) the additional arguments match, V[], r[], dr[] and N (to define the physical potential and grid information ). Also, make sure to remember to convert rtbis() to double precision, for which you should also double the value of JMAX.

So that we can study the working of our code, modify the routine so that it prints out the final number of iterations and the final function value just before it returns rtb, with a print statement of the form

printf("   (%d iterations in rtbisp480, func=%e)\n",j,fmid);

Finally, the numerical recipes routine rtbis() has a small bug: If one of your two initial guesses x1 or x2 for the solution gives f(x)=0, the routine prints an error message and halts the program. Modify rtbisp480() to test for these conditions and to return the appropriate value, x1 or x2, as the solution (as well as to print out that zero iterations were required to find the solution).



Tomas Arias
Mon Feb 18 16:02:23 EST 2002