Average Error: 32.8 → 6.4
Time: 15.4s
Precision: 64
\[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.1214768270116103 \cdot 10^{+154}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le 1.199441090208904 \cdot 10^{-250}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} + \left(-b\right)}\\ \mathbf{elif}\;b \le 3.3389954009657566 \cdot 10^{+124}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array}\]
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le -1.1214768270116103 \cdot 10^{+154}:\\
\;\;\;\;\frac{-c}{b}\\

\mathbf{elif}\;b \le 1.199441090208904 \cdot 10^{-250}:\\
\;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} + \left(-b\right)}\\

\mathbf{elif}\;b \le 3.3389954009657566 \cdot 10^{+124}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\

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

\end{array}
double f(double a, double b, double c) {
        double r1231906 = b;
        double r1231907 = -r1231906;
        double r1231908 = r1231906 * r1231906;
        double r1231909 = 4.0;
        double r1231910 = a;
        double r1231911 = c;
        double r1231912 = r1231910 * r1231911;
        double r1231913 = r1231909 * r1231912;
        double r1231914 = r1231908 - r1231913;
        double r1231915 = sqrt(r1231914);
        double r1231916 = r1231907 - r1231915;
        double r1231917 = 2.0;
        double r1231918 = r1231917 * r1231910;
        double r1231919 = r1231916 / r1231918;
        return r1231919;
}

double f(double a, double b, double c) {
        double r1231920 = b;
        double r1231921 = -1.1214768270116103e+154;
        bool r1231922 = r1231920 <= r1231921;
        double r1231923 = c;
        double r1231924 = -r1231923;
        double r1231925 = r1231924 / r1231920;
        double r1231926 = 1.199441090208904e-250;
        bool r1231927 = r1231920 <= r1231926;
        double r1231928 = 2.0;
        double r1231929 = r1231928 * r1231923;
        double r1231930 = r1231920 * r1231920;
        double r1231931 = 4.0;
        double r1231932 = a;
        double r1231933 = r1231923 * r1231932;
        double r1231934 = r1231931 * r1231933;
        double r1231935 = r1231930 - r1231934;
        double r1231936 = sqrt(r1231935);
        double r1231937 = -r1231920;
        double r1231938 = r1231936 + r1231937;
        double r1231939 = r1231929 / r1231938;
        double r1231940 = 3.3389954009657566e+124;
        bool r1231941 = r1231920 <= r1231940;
        double r1231942 = r1231937 - r1231936;
        double r1231943 = r1231932 * r1231928;
        double r1231944 = r1231942 / r1231943;
        double r1231945 = r1231937 / r1231932;
        double r1231946 = r1231941 ? r1231944 : r1231945;
        double r1231947 = r1231927 ? r1231939 : r1231946;
        double r1231948 = r1231922 ? r1231925 : r1231947;
        return r1231948;
}

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

Target

Original32.8
Target20.1
Herbie6.4
\[\begin{array}{l} \mathbf{if}\;b \lt 0:\\ \;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\\ \end{array}\]

Derivation

  1. Split input into 4 regimes
  2. if b < -1.1214768270116103e+154

    1. Initial program 62.9

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

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

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

    if -1.1214768270116103e+154 < b < 1.199441090208904e-250

    1. Initial program 32.2

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity32.2

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

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

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}}{2 \cdot a}\]
    6. Applied associate-/l*32.2

      \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot a}{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}}\]
    7. Using strategy rm
    8. Applied flip--32.3

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

      \[\leadsto \frac{1}{\color{blue}{\frac{2 \cdot a}{\left(-b\right) \cdot \left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} \cdot \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}}\]
    10. Applied associate-/r*32.4

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

      \[\leadsto \frac{\color{blue}{\frac{\frac{1}{2} \cdot \left(b \cdot b - \left(b \cdot b - 4 \cdot \left(a \cdot c\right)\right)\right)}{a}}}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}\]
    12. Taylor expanded around 0 8.4

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

    if 1.199441090208904e-250 < b < 3.3389954009657566e+124

    1. Initial program 7.8

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

    if 3.3389954009657566e+124 < b

    1. Initial program 50.5

      \[\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity50.5

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

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

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}}{2 \cdot a}\]
    6. Applied associate-/l*50.6

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

      \[\leadsto \color{blue}{-1 \cdot \frac{b}{a}}\]
    8. Simplified3.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.1214768270116103 \cdot 10^{+154}:\\ \;\;\;\;\frac{-c}{b}\\ \mathbf{elif}\;b \le 1.199441090208904 \cdot 10^{-250}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} + \left(-b\right)}\\ \mathbf{elif}\;b \le 3.3389954009657566 \cdot 10^{+124}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019128 
(FPCore (a b c)
  :name "quadm (p42, negative)"

  :herbie-target
  (if (< b 0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))

  (/ (- (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))