zriddrp480()

double zriddrp480(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:

A much more powerful algorithm for finding zeros of a function is Ridder's method. This method works with the same basic information as the bisection method and so can be called in exactly the same way, but requires far fewer function evaluations to reach the same accuracy.

Make the same modifications to zriddr() that you made to rtbis() to produce a function of the above prototype in ``p480.c'' and ``p480.h''. Be sure print out the final number of iterations needed and final function value.

Finally, the numerical recipes routine zriddr() also has a small bug: for wildly varying functions such as func_Schrodinger(), zriddr() sometimes returns too early. To fix this, replace the code fragment

if (fabs(xnew-ans) <= xacc) ...
in zriddrp480() with
if (fabs(xl-xh) <= xacc) ... .

To test your function, uncomment out the lines labeled ``Test of zriddrp480()'' in ``Edebug.c'', and verify that zriddrp480() returns the same results as rtbisp480(), but with far fewer function calls.

Tomas Arias 2006-02-13