Average Error: 34.0 → 7.2
Time: 27.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 -3.575938583654324 \cdot 10^{+94}:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \left(\frac{a}{b} \cdot c - b\right)}\\ \mathbf{elif}\;b \le 4.0232110844075136 \cdot 10^{-262}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}\\ \mathbf{elif}\;b \le 2.6656023684116586 \cdot 10^{+55}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a}\\ \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 -3.575938583654324 \cdot 10^{+94}:\\
\;\;\;\;\frac{2 \cdot c}{2 \cdot \left(\frac{a}{b} \cdot c - b\right)}\\

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

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

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

\end{array}
double f(double a, double b, double c) {
        double r2588382 = b;
        double r2588383 = -r2588382;
        double r2588384 = r2588382 * r2588382;
        double r2588385 = 4.0;
        double r2588386 = a;
        double r2588387 = c;
        double r2588388 = r2588386 * r2588387;
        double r2588389 = r2588385 * r2588388;
        double r2588390 = r2588384 - r2588389;
        double r2588391 = sqrt(r2588390);
        double r2588392 = r2588383 - r2588391;
        double r2588393 = 2.0;
        double r2588394 = r2588393 * r2588386;
        double r2588395 = r2588392 / r2588394;
        return r2588395;
}

double f(double a, double b, double c) {
        double r2588396 = b;
        double r2588397 = -3.575938583654324e+94;
        bool r2588398 = r2588396 <= r2588397;
        double r2588399 = 2.0;
        double r2588400 = c;
        double r2588401 = r2588399 * r2588400;
        double r2588402 = a;
        double r2588403 = r2588402 / r2588396;
        double r2588404 = r2588403 * r2588400;
        double r2588405 = r2588404 - r2588396;
        double r2588406 = r2588399 * r2588405;
        double r2588407 = r2588401 / r2588406;
        double r2588408 = 4.0232110844075136e-262;
        bool r2588409 = r2588396 <= r2588408;
        double r2588410 = -r2588396;
        double r2588411 = r2588396 * r2588396;
        double r2588412 = 4.0;
        double r2588413 = r2588402 * r2588400;
        double r2588414 = r2588412 * r2588413;
        double r2588415 = r2588411 - r2588414;
        double r2588416 = sqrt(r2588415);
        double r2588417 = r2588410 + r2588416;
        double r2588418 = r2588401 / r2588417;
        double r2588419 = 2.6656023684116586e+55;
        bool r2588420 = r2588396 <= r2588419;
        double r2588421 = 0.5;
        double r2588422 = r2588410 - r2588416;
        double r2588423 = r2588422 / r2588402;
        double r2588424 = r2588421 * r2588423;
        double r2588425 = r2588410 / r2588402;
        double r2588426 = r2588420 ? r2588424 : r2588425;
        double r2588427 = r2588409 ? r2588418 : r2588426;
        double r2588428 = r2588398 ? r2588407 : r2588427;
        return r2588428;
}

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.0
Target21.3
Herbie7.2
\[\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 < -3.575938583654324e+94

    1. Initial program 58.9

      \[\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-identity58.9

      \[\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-identity58.9

      \[\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--58.9

      \[\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*58.9

      \[\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--59.0

      \[\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/59.0

      \[\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*59.0

      \[\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. Simplified30.3

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

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

      \[\leadsto \frac{2 \cdot c}{\color{blue}{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}\]
    14. Simplified2.5

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

    if -3.575938583654324e+94 < b < 4.0232110844075136e-262

    1. Initial program 30.8

      \[\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-identity30.8

      \[\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-identity30.8

      \[\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--30.8

      \[\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*30.8

      \[\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--31.0

      \[\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/31.0

      \[\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*31.0

      \[\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. Simplified16.1

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

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

    if 4.0232110844075136e-262 < b < 2.6656023684116586e+55

    1. Initial program 9.0

      \[\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-identity9.0

      \[\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-identity9.0

      \[\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--9.0

      \[\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*9.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 *-un-lft-identity9.2

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

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

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

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

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

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

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

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

    if 2.6656023684116586e+55 < b

    1. Initial program 37.1

      \[\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-identity37.1

      \[\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-identity37.1

      \[\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--37.1

      \[\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*37.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. Taylor expanded around 0 6.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.575938583654324 \cdot 10^{+94}:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \left(\frac{a}{b} \cdot c - b\right)}\\ \mathbf{elif}\;b \le 4.0232110844075136 \cdot 10^{-262}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}\\ \mathbf{elif}\;b \le 2.6656023684116586 \cdot 10^{+55}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-b}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019141 
(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)))