bug-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gsl] Simplifiying gsl_poly_solve_quadratic()


From: James Ward
Subject: [Bug-gsl] Simplifiying gsl_poly_solve_quadratic()
Date: Tue, 5 Apr 2011 19:51:48 -0400

In gsl_poly_solve_quadratic(), you could replace the complicated:

if (b == 0)
        {
          double r = fabs (0.5 * sqrt (disc) / a);
          *x0 = -r;
          *x1 =  r;
        }

with the simpler:

if (b == 0)
        {
          double r = sqrt (-c / a);
          *x0 = -r;
          *x1 =  r;
        }

you could also move the assignment of disc after the linear case,

disc = b * b - 4 * a * c;

since disc is not used in the linear case.

Best wishes,

Jim Ward



reply via email to

[Prev in Thread] Current Thread [Next in Thread]