Average Error: 28.2 → 16.7
Time: 49.9s
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 398.48379084321107:\\ \;\;\;\;\frac{\left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right) \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - \left(b \cdot b\right) \cdot b}{\left(2 \cdot a\right) \cdot \left(\left(b \cdot b + b \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\right) + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\right)}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]
double f(double a, double b, double c) {
        double r6029597 = b;
        double r6029598 = -r6029597;
        double r6029599 = r6029597 * r6029597;
        double r6029600 = 4.0;
        double r6029601 = a;
        double r6029602 = r6029600 * r6029601;
        double r6029603 = c;
        double r6029604 = r6029602 * r6029603;
        double r6029605 = r6029599 - r6029604;
        double r6029606 = sqrt(r6029605);
        double r6029607 = r6029598 + r6029606;
        double r6029608 = 2.0;
        double r6029609 = r6029608 * r6029601;
        double r6029610 = r6029607 / r6029609;
        return r6029610;
}

double f(double a, double b, double c) {
        double r6029611 = b;
        double r6029612 = 398.48379084321107;
        bool r6029613 = r6029611 <= r6029612;
        double r6029614 = r6029611 * r6029611;
        double r6029615 = 4.0;
        double r6029616 = c;
        double r6029617 = a;
        double r6029618 = r6029616 * r6029617;
        double r6029619 = r6029615 * r6029618;
        double r6029620 = r6029614 - r6029619;
        double r6029621 = sqrt(r6029620);
        double r6029622 = r6029620 * r6029621;
        double r6029623 = r6029614 * r6029611;
        double r6029624 = r6029622 - r6029623;
        double r6029625 = 2.0;
        double r6029626 = r6029625 * r6029617;
        double r6029627 = r6029611 * r6029621;
        double r6029628 = r6029614 + r6029627;
        double r6029629 = r6029621 * r6029621;
        double r6029630 = r6029628 + r6029629;
        double r6029631 = r6029626 * r6029630;
        double r6029632 = r6029624 / r6029631;
        double r6029633 = r6029616 / r6029611;
        double r6029634 = -r6029633;
        double r6029635 = r6029613 ? r6029632 : r6029634;
        return r6029635;
}

\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 398.48379084321107:\\
\;\;\;\;\frac{\left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right) \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - \left(b \cdot b\right) \cdot b}{\left(2 \cdot a\right) \cdot \left(\left(b \cdot b + b \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\right) + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\right)}\\

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

\end{array}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 398.48379084321107

    1. Initial program 16.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified16.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 flip3--16.4

      \[\leadsto \frac{\color{blue}{\frac{{\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}\right)}^{3} - {b}^{3}}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + \left(b \cdot b + \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} \cdot b\right)}}}{2 \cdot a}\]
    5. Applied associate-/l/16.4

      \[\leadsto \color{blue}{\frac{{\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}\right)}^{3} - {b}^{3}}{\left(2 \cdot a\right) \cdot \left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + \left(b \cdot b + \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} \cdot b\right)\right)}}\]
    6. Simplified15.7

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

    if 398.48379084321107 < b

    1. Initial program 35.1

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    4. Simplified17.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 398.48379084321107:\\ \;\;\;\;\frac{\left(b \cdot b - 4 \cdot \left(c \cdot a\right)\right) \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - \left(b \cdot b\right) \cdot b}{\left(2 \cdot a\right) \cdot \left(\left(b \cdot b + b \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\right) + \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} \cdot \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}\right)}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019102 
(FPCore (a b c)
  :name "Quadratic roots, narrow range"
  :pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))