Average Error: 34.8 → 8.9
Time: 5.7s
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 -3.38405533627000167 \cdot 10^{63}:\\ \;\;\;\;{\left(-1 \cdot \frac{c}{b}\right)}^{1}\\ \mathbf{elif}\;b \le -1.35946401585134441 \cdot 10^{-202}:\\ \;\;\;\;1 \cdot \frac{\frac{4 \cdot \left(a \cdot c\right)}{2 \cdot a}}{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}\\ \mathbf{elif}\;b \le 3.75207925944336851 \cdot 10^{124}:\\ \;\;\;\;{\left(\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;{\left(1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\right)}^{1}\\ \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 -3.38405533627000167 \cdot 10^{63}:\\
\;\;\;\;{\left(-1 \cdot \frac{c}{b}\right)}^{1}\\

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

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

\mathbf{else}:\\
\;\;\;\;{\left(1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\right)}^{1}\\

\end{array}
double f(double a, double b, double c) {
        double r81129 = b;
        double r81130 = -r81129;
        double r81131 = r81129 * r81129;
        double r81132 = 4.0;
        double r81133 = a;
        double r81134 = c;
        double r81135 = r81133 * r81134;
        double r81136 = r81132 * r81135;
        double r81137 = r81131 - r81136;
        double r81138 = sqrt(r81137);
        double r81139 = r81130 - r81138;
        double r81140 = 2.0;
        double r81141 = r81140 * r81133;
        double r81142 = r81139 / r81141;
        return r81142;
}

double f(double a, double b, double c) {
        double r81143 = b;
        double r81144 = -3.384055336270002e+63;
        bool r81145 = r81143 <= r81144;
        double r81146 = -1.0;
        double r81147 = c;
        double r81148 = r81147 / r81143;
        double r81149 = r81146 * r81148;
        double r81150 = 1.0;
        double r81151 = pow(r81149, r81150);
        double r81152 = -1.3594640158513444e-202;
        bool r81153 = r81143 <= r81152;
        double r81154 = 4.0;
        double r81155 = a;
        double r81156 = r81155 * r81147;
        double r81157 = r81154 * r81156;
        double r81158 = 2.0;
        double r81159 = r81158 * r81155;
        double r81160 = r81157 / r81159;
        double r81161 = r81143 * r81143;
        double r81162 = r81161 - r81157;
        double r81163 = sqrt(r81162);
        double r81164 = r81163 - r81143;
        double r81165 = r81160 / r81164;
        double r81166 = r81150 * r81165;
        double r81167 = 3.7520792594433685e+124;
        bool r81168 = r81143 <= r81167;
        double r81169 = -r81143;
        double r81170 = r81169 - r81163;
        double r81171 = r81170 / r81159;
        double r81172 = pow(r81171, r81150);
        double r81173 = 1.0;
        double r81174 = r81143 / r81155;
        double r81175 = r81148 - r81174;
        double r81176 = r81173 * r81175;
        double r81177 = pow(r81176, r81150);
        double r81178 = r81168 ? r81172 : r81177;
        double r81179 = r81153 ? r81166 : r81178;
        double r81180 = r81145 ? r81151 : r81179;
        return r81180;
}

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

Original34.8
Target21.2
Herbie8.9
\[\begin{array}{l} \mathbf{if}\;b \lt 0.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 < -3.384055336270002e+63

    1. Initial program 57.7

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

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

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

      \[\leadsto \color{blue}{{\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}^{1}} \cdot {\left(\frac{1}{2 \cdot a}\right)}^{1}\]
    7. Applied pow-prod-down57.7

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

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

      \[\leadsto {\color{blue}{\left(-1 \cdot \frac{c}{b}\right)}}^{1}\]

    if -3.384055336270002e+63 < b < -1.3594640158513444e-202

    1. Initial program 35.3

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

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

      \[\leadsto \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)}}} \cdot \frac{1}{2 \cdot a}\]
    6. Simplified17.6

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

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

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

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

      \[\leadsto \color{blue}{\left(\frac{1}{1} \cdot \frac{0 + 1 \cdot \left(4 \cdot \left(a \cdot c\right)\right)}{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}\right)} \cdot \frac{1}{2 \cdot a}\]
    12. Applied associate-*l*17.6

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

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

    if -1.3594640158513444e-202 < b < 3.7520792594433685e+124

    1. Initial program 10.7

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

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

      \[\leadsto \left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot \color{blue}{{\left(\frac{1}{2 \cdot a}\right)}^{1}}\]
    6. Applied pow110.8

      \[\leadsto \color{blue}{{\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}^{1}} \cdot {\left(\frac{1}{2 \cdot a}\right)}^{1}\]
    7. Applied pow-prod-down10.8

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

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

    if 3.7520792594433685e+124 < b

    1. Initial program 54.3

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

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

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

      \[\leadsto \color{blue}{{\left(\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)}^{1}} \cdot {\left(\frac{1}{2 \cdot a}\right)}^{1}\]
    7. Applied pow-prod-down54.3

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

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

      \[\leadsto {\color{blue}{\left(1 \cdot \frac{c}{b} - 1 \cdot \frac{b}{a}\right)}}^{1}\]
    10. Simplified3.2

      \[\leadsto {\color{blue}{\left(1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\right)}}^{1}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification8.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.38405533627000167 \cdot 10^{63}:\\ \;\;\;\;{\left(-1 \cdot \frac{c}{b}\right)}^{1}\\ \mathbf{elif}\;b \le -1.35946401585134441 \cdot 10^{-202}:\\ \;\;\;\;1 \cdot \frac{\frac{4 \cdot \left(a \cdot c\right)}{2 \cdot a}}{\sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)} - b}\\ \mathbf{elif}\;b \le 3.75207925944336851 \cdot 10^{124}:\\ \;\;\;\;{\left(\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;{\left(1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\right)}^{1}\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< b 0.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)))