Average Error: 34.0 → 30.1
Time: 44.8s
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 1.599460360788912 \cdot 10^{+41}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(\left(\sqrt{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)}}\right), \left(\sqrt{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)}}\right), \left(-b\right)\right)}{2}}{a}\\ \mathbf{else}:\\ \;\;\;\;0\\ \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 1.599460360788912 \cdot 10^{+41}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(\left(\sqrt{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)}}\right), \left(\sqrt{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)}}\right), \left(-b\right)\right)}{2}}{a}\\

\mathbf{else}:\\
\;\;\;\;0\\

\end{array}
double f(double a, double b, double c) {
        double r4682405 = b;
        double r4682406 = -r4682405;
        double r4682407 = r4682405 * r4682405;
        double r4682408 = 4.0;
        double r4682409 = a;
        double r4682410 = r4682408 * r4682409;
        double r4682411 = c;
        double r4682412 = r4682410 * r4682411;
        double r4682413 = r4682407 - r4682412;
        double r4682414 = sqrt(r4682413);
        double r4682415 = r4682406 + r4682414;
        double r4682416 = 2.0;
        double r4682417 = r4682416 * r4682409;
        double r4682418 = r4682415 / r4682417;
        return r4682418;
}

double f(double a, double b, double c) {
        double r4682419 = b;
        double r4682420 = 1.599460360788912e+41;
        bool r4682421 = r4682419 <= r4682420;
        double r4682422 = c;
        double r4682423 = -4.0;
        double r4682424 = a;
        double r4682425 = r4682423 * r4682424;
        double r4682426 = r4682419 * r4682419;
        double r4682427 = fma(r4682422, r4682425, r4682426);
        double r4682428 = sqrt(r4682427);
        double r4682429 = sqrt(r4682428);
        double r4682430 = -r4682419;
        double r4682431 = fma(r4682429, r4682429, r4682430);
        double r4682432 = 2.0;
        double r4682433 = r4682431 / r4682432;
        double r4682434 = r4682433 / r4682424;
        double r4682435 = 0.0;
        double r4682436 = r4682421 ? r4682434 : r4682435;
        return r4682436;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 1.599460360788912e+41

    1. Initial program 24.6

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

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)} - b}{2}}{a}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt24.9

      \[\leadsto \frac{\frac{\color{blue}{\sqrt{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)}}} - b}{2}}{a}\]
    5. Applied fma-neg24.9

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

    if 1.599460360788912e+41 < b

    1. Initial program 56.3

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

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)} - b}{2}}{a}}\]
    3. Taylor expanded around 0 42.6

      \[\leadsto \color{blue}{0}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification30.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 1.599460360788912 \cdot 10^{+41}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(\left(\sqrt{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)}}\right), \left(\sqrt{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)}}\right), \left(-b\right)\right)}{2}}{a}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]

Reproduce

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