Vote Details for "Math_Numerical_RootFinding" by jmcastagnetto

» Details
» Comment
Code looks good, but some minor things can be improved:

- Instead of using 'mixed' in the documentation, you might want to use PEAR_Error|float (yes, I am guilty of using 'mixed' too :-)

- Some validation for the options will be good, in particular for when the function to be evaluated is assigned

- The bisection code should make sure that the extremes in the ranges have opposite signs, otherwise there might not be a root at all in the given interval. Similar test must be done for the 'false position' and the 'secant' methods

- I would not initialize the '$_root' var with -999999, better use null, so you can test with is_null() to make sure that no root was found.

- The intermediate points in the bisection method are *not* roots, just approximations, so I am not sure if there should be a $_rootList array (and associated method). Similar for regula falsi (false position) and secant

- Not sure about the convergence of the algorithm in the 'false position' as implemented. Usually you work from the lower limit up, assuming linearity

- I like the divergence test in the secant method, although I am not sure if there is a need to keep all intermediate interpolations, or just the last 2 for comparison, also the divergence method is always testing the same three entries, no matter how many iterations have happened or you are just looking at divergence at the beginning of the iterations? I would think that you will do it continuously

- Similar comment on the divergency testing for the Newton-Raphson method

- The fixed point method docs might want to indicate that it is not strictly a method to find the zeros but to find the values for which f(x) = x. Also, why is this not calling one of the other methods?

- Might want to put references to online sources for the algorithms: e.g. pages linked from, or
from the 'Numerical Recipes in C' (, etc.

- Might want to also look into some of the variations that are more robust (e.g. Ridder's method, Brent's method).