Average Error: 32.7 → 10.1
Time: 18.4s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -2.34601621878688 \cdot 10^{+118}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 1.3115303715225787 \cdot 10^{-131}:\\ \;\;\;\;\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b\right) \cdot \frac{1}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le -2.34601621878688 \cdot 10^{+118}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

\mathbf{elif}\;b \le 1.3115303715225787 \cdot 10^{-131}:\\
\;\;\;\;\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b\right) \cdot \frac{1}{a \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\

\end{array}
double f(double a, double b, double c) {
        double r2009413 = b;
        double r2009414 = -r2009413;
        double r2009415 = r2009413 * r2009413;
        double r2009416 = 4.0;
        double r2009417 = a;
        double r2009418 = r2009416 * r2009417;
        double r2009419 = c;
        double r2009420 = r2009418 * r2009419;
        double r2009421 = r2009415 - r2009420;
        double r2009422 = sqrt(r2009421);
        double r2009423 = r2009414 + r2009422;
        double r2009424 = 2.0;
        double r2009425 = r2009424 * r2009417;
        double r2009426 = r2009423 / r2009425;
        return r2009426;
}

double f(double a, double b, double c) {
        double r2009427 = b;
        double r2009428 = -2.34601621878688e+118;
        bool r2009429 = r2009427 <= r2009428;
        double r2009430 = c;
        double r2009431 = r2009430 / r2009427;
        double r2009432 = a;
        double r2009433 = r2009427 / r2009432;
        double r2009434 = r2009431 - r2009433;
        double r2009435 = 1.3115303715225787e-131;
        bool r2009436 = r2009427 <= r2009435;
        double r2009437 = r2009427 * r2009427;
        double r2009438 = r2009430 * r2009432;
        double r2009439 = 4.0;
        double r2009440 = r2009438 * r2009439;
        double r2009441 = r2009437 - r2009440;
        double r2009442 = sqrt(r2009441);
        double r2009443 = r2009442 - r2009427;
        double r2009444 = 1.0;
        double r2009445 = 2.0;
        double r2009446 = r2009432 * r2009445;
        double r2009447 = r2009444 / r2009446;
        double r2009448 = r2009443 * r2009447;
        double r2009449 = -r2009431;
        double r2009450 = r2009436 ? r2009448 : r2009449;
        double r2009451 = r2009429 ? r2009434 : r2009450;
        return r2009451;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if b < -2.34601621878688e+118

    1. Initial program 48.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified48.8

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{2 \cdot a}}\]
    3. Taylor expanded around -inf 3.1

      \[\leadsto \color{blue}{\frac{c}{b} - \frac{b}{a}}\]

    if -2.34601621878688e+118 < b < 1.3115303715225787e-131

    1. Initial program 10.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified10.7

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{2 \cdot a}}\]
    3. Using strategy rm
    4. Applied div-inv10.8

      \[\leadsto \color{blue}{\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b\right) \cdot \frac{1}{2 \cdot a}}\]

    if 1.3115303715225787e-131 < b

    1. Initial program 50.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified50.3

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{2 \cdot a}}\]
    3. Using strategy rm
    4. Applied div-inv50.4

      \[\leadsto \color{blue}{\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b\right) \cdot \frac{1}{2 \cdot a}}\]
    5. Taylor expanded around inf 11.7

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    6. Simplified11.7

      \[\leadsto \color{blue}{-\frac{c}{b}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.34601621878688 \cdot 10^{+118}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 1.3115303715225787 \cdot 10^{-131}:\\ \;\;\;\;\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b\right) \cdot \frac{1}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019134 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))