Average Error: 33.4 → 10.5
Time: 46.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 -3.4350120867177856 \cdot 10^{+86}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 9.022485597500134 \cdot 10^{-56}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{a} \cdot \frac{1}{2}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]
double f(double a, double b, double c) {
        double r4032984 = b;
        double r4032985 = -r4032984;
        double r4032986 = r4032984 * r4032984;
        double r4032987 = 4.0;
        double r4032988 = a;
        double r4032989 = r4032987 * r4032988;
        double r4032990 = c;
        double r4032991 = r4032989 * r4032990;
        double r4032992 = r4032986 - r4032991;
        double r4032993 = sqrt(r4032992);
        double r4032994 = r4032985 + r4032993;
        double r4032995 = 2.0;
        double r4032996 = r4032995 * r4032988;
        double r4032997 = r4032994 / r4032996;
        return r4032997;
}

double f(double a, double b, double c) {
        double r4032998 = b;
        double r4032999 = -3.4350120867177856e+86;
        bool r4033000 = r4032998 <= r4032999;
        double r4033001 = c;
        double r4033002 = r4033001 / r4032998;
        double r4033003 = a;
        double r4033004 = r4032998 / r4033003;
        double r4033005 = r4033002 - r4033004;
        double r4033006 = 9.022485597500134e-56;
        bool r4033007 = r4032998 <= r4033006;
        double r4033008 = r4032998 * r4032998;
        double r4033009 = 4.0;
        double r4033010 = r4033009 * r4033003;
        double r4033011 = r4033001 * r4033010;
        double r4033012 = r4033008 - r4033011;
        double r4033013 = sqrt(r4033012);
        double r4033014 = r4033013 - r4032998;
        double r4033015 = r4033014 / r4033003;
        double r4033016 = 0.5;
        double r4033017 = r4033015 * r4033016;
        double r4033018 = -r4033002;
        double r4033019 = r4033007 ? r4033017 : r4033018;
        double r4033020 = r4033000 ? r4033005 : r4033019;
        return r4033020;
}

\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 -3.4350120867177856 \cdot 10^{+86}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

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

\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 3 regimes
  2. if b < -3.4350120867177856e+86

    1. Initial program 41.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Taylor expanded around -inf 4.4

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

    if -3.4350120867177856e+86 < b < 9.022485597500134e-56

    1. Initial program 14.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied clear-num14.4

      \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot a}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity14.4

      \[\leadsto \frac{1}{\frac{2 \cdot a}{\left(-b\right) + \color{blue}{1 \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}\]
    6. Applied *-un-lft-identity14.4

      \[\leadsto \frac{1}{\frac{2 \cdot a}{\left(-\color{blue}{1 \cdot b}\right) + 1 \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\]
    7. Applied distribute-rgt-neg-in14.4

      \[\leadsto \frac{1}{\frac{2 \cdot a}{\color{blue}{1 \cdot \left(-b\right)} + 1 \cdot \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\]
    8. Applied distribute-lft-out14.4

      \[\leadsto \frac{1}{\frac{2 \cdot a}{\color{blue}{1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}}\]
    9. Applied times-frac14.4

      \[\leadsto \frac{1}{\color{blue}{\frac{2}{1} \cdot \frac{a}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}\]
    10. Applied add-cube-cbrt14.4

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{2}{1} \cdot \frac{a}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\]
    11. Applied times-frac14.4

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

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

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

    if 9.022485597500134e-56 < b

    1. Initial program 53.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Taylor expanded around inf 8.5

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    3. Simplified8.5

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

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

Reproduce

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