Recommended addition to solve_quadratic.c

Brian Gough bjg@network-theory.co.uk
Tue Nov 9 13:00:00 GMT 2004


Balk, L. David writes:
 > the 'a' term in a quadratic equation describing motion
 > can occasionally go to zero.  I noticed that solve_quadratic.c does
 > not handle or report an attempted divide-by-zero in that case.

Thanks, I've made a note of that -- I agree it can be handled more
gracefully.

 > I would also like to see equal roots returned as a 1 instead of a
 > 2, but I'm sure there is a lot of code that depends upon the
 > current behavior and the documentation would have to be changed.

I'd recommend comparing the two returned roots with a suitable
tolerance, or some other procedure appropriate to the problem... the
sign of the discriminant b^2-4ac is sensitive to numerical error.

-- 
Brian Gough

Network Theory Ltd,
Commercial support for GSL --- http://www.network-theory.co.uk/gsl/



More information about the Gsl-discuss mailing list