Average Error: 34.0 → 9.5
Time: 6.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 -7305451620439275194790110408477452101747000:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \le -8.466933224916020404836136928197301032481 \cdot 10^{-96}:\\ \;\;\;\;\frac{\frac{1}{2} \cdot \left(\left({b}^{2} - {b}^{2}\right) + \left(4 \cdot a\right) \cdot c\right)}{a} \cdot \frac{1}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{elif}\;b \le -5.358830408552924876342396298354647853638 \cdot 10^{-132}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \le 6.326287366549382745037046972324082366467 \cdot 10^{74}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \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 -7305451620439275194790110408477452101747000:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\

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

\mathbf{elif}\;b \le -5.358830408552924876342396298354647853638 \cdot 10^{-132}:\\
\;\;\;\;-1 \cdot \frac{c}{b}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r74367 = b;
        double r74368 = -r74367;
        double r74369 = r74367 * r74367;
        double r74370 = 4.0;
        double r74371 = a;
        double r74372 = c;
        double r74373 = r74371 * r74372;
        double r74374 = r74370 * r74373;
        double r74375 = r74369 - r74374;
        double r74376 = sqrt(r74375);
        double r74377 = r74368 - r74376;
        double r74378 = 2.0;
        double r74379 = r74378 * r74371;
        double r74380 = r74377 / r74379;
        return r74380;
}

double f(double a, double b, double c) {
        double r74381 = b;
        double r74382 = -7.305451620439275e+42;
        bool r74383 = r74381 <= r74382;
        double r74384 = -1.0;
        double r74385 = c;
        double r74386 = r74385 / r74381;
        double r74387 = r74384 * r74386;
        double r74388 = -8.46693322491602e-96;
        bool r74389 = r74381 <= r74388;
        double r74390 = 1.0;
        double r74391 = 2.0;
        double r74392 = r74390 / r74391;
        double r74393 = 2.0;
        double r74394 = pow(r74381, r74393);
        double r74395 = r74394 - r74394;
        double r74396 = 4.0;
        double r74397 = a;
        double r74398 = r74396 * r74397;
        double r74399 = r74398 * r74385;
        double r74400 = r74395 + r74399;
        double r74401 = r74392 * r74400;
        double r74402 = r74401 / r74397;
        double r74403 = -r74381;
        double r74404 = r74381 * r74381;
        double r74405 = r74404 - r74399;
        double r74406 = sqrt(r74405);
        double r74407 = r74403 + r74406;
        double r74408 = r74390 / r74407;
        double r74409 = r74402 * r74408;
        double r74410 = -5.358830408552925e-132;
        bool r74411 = r74381 <= r74410;
        double r74412 = 6.326287366549383e+74;
        bool r74413 = r74381 <= r74412;
        double r74414 = r74403 - r74406;
        double r74415 = r74391 * r74397;
        double r74416 = r74414 / r74415;
        double r74417 = 1.0;
        double r74418 = r74381 / r74397;
        double r74419 = r74386 - r74418;
        double r74420 = r74417 * r74419;
        double r74421 = r74413 ? r74416 : r74420;
        double r74422 = r74411 ? r74387 : r74421;
        double r74423 = r74389 ? r74409 : r74422;
        double r74424 = r74383 ? r74387 : r74423;
        return r74424;
}

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
Target20.9
Herbie9.5
\[\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 < -7.305451620439275e+42 or -8.46693322491602e-96 < b < -5.358830408552925e-132

    1. Initial program 54.2

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

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

    if -7.305451620439275e+42 < b < -8.46693322491602e-96

    1. Initial program 41.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 associate-*r*41.7

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

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

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

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

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

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

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

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

    if -5.358830408552925e-132 < b < 6.326287366549383e+74

    1. Initial program 11.6

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

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

    if 6.326287366549383e+74 < b

    1. Initial program 41.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -7305451620439275194790110408477452101747000:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \le -8.466933224916020404836136928197301032481 \cdot 10^{-96}:\\ \;\;\;\;\frac{\frac{1}{2} \cdot \left(\left({b}^{2} - {b}^{2}\right) + \left(4 \cdot a\right) \cdot c\right)}{a} \cdot \frac{1}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{elif}\;b \le -5.358830408552924876342396298354647853638 \cdot 10^{-132}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \mathbf{elif}\;b \le 6.326287366549382745037046972324082366467 \cdot 10^{74}:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \end{array}\]

Reproduce

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