Average Error: 34.0 → 7.3
Time: 54.7s
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.157094219357017 \cdot 10^{+135}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 9.088113400659685 \cdot 10^{-185}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a \cdot 2}\\ \mathbf{elif}\;b \le 1.8091015183831773 \cdot 10^{+43}:\\ \;\;\;\;\frac{1}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b} \cdot \left(\sqrt{\frac{1}{2}} \cdot \left(\frac{c}{\frac{-1}{4}} \cdot \sqrt{\frac{1}{2}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]
\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.157094219357017 \cdot 10^{+135}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

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

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

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

\end{array}
double f(double a, double b, double c) {
        double r8479521 = b;
        double r8479522 = -r8479521;
        double r8479523 = r8479521 * r8479521;
        double r8479524 = 4.0;
        double r8479525 = a;
        double r8479526 = r8479524 * r8479525;
        double r8479527 = c;
        double r8479528 = r8479526 * r8479527;
        double r8479529 = r8479523 - r8479528;
        double r8479530 = sqrt(r8479529);
        double r8479531 = r8479522 + r8479530;
        double r8479532 = 2.0;
        double r8479533 = r8479532 * r8479525;
        double r8479534 = r8479531 / r8479533;
        return r8479534;
}

double f(double a, double b, double c) {
        double r8479535 = b;
        double r8479536 = -3.157094219357017e+135;
        bool r8479537 = r8479535 <= r8479536;
        double r8479538 = c;
        double r8479539 = r8479538 / r8479535;
        double r8479540 = a;
        double r8479541 = r8479535 / r8479540;
        double r8479542 = r8479539 - r8479541;
        double r8479543 = 9.088113400659685e-185;
        bool r8479544 = r8479535 <= r8479543;
        double r8479545 = r8479535 * r8479535;
        double r8479546 = r8479538 * r8479540;
        double r8479547 = 4.0;
        double r8479548 = r8479546 * r8479547;
        double r8479549 = r8479545 - r8479548;
        double r8479550 = sqrt(r8479549);
        double r8479551 = r8479550 - r8479535;
        double r8479552 = 2.0;
        double r8479553 = r8479540 * r8479552;
        double r8479554 = r8479551 / r8479553;
        double r8479555 = 1.8091015183831773e+43;
        bool r8479556 = r8479535 <= r8479555;
        double r8479557 = 1.0;
        double r8479558 = r8479550 + r8479535;
        double r8479559 = r8479557 / r8479558;
        double r8479560 = 0.5;
        double r8479561 = sqrt(r8479560);
        double r8479562 = -0.25;
        double r8479563 = r8479538 / r8479562;
        double r8479564 = r8479563 * r8479561;
        double r8479565 = r8479561 * r8479564;
        double r8479566 = r8479559 * r8479565;
        double r8479567 = -r8479539;
        double r8479568 = r8479556 ? r8479566 : r8479567;
        double r8479569 = r8479544 ? r8479554 : r8479568;
        double r8479570 = r8479537 ? r8479542 : r8479569;
        return r8479570;
}

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

Derivation

  1. Split input into 4 regimes
  2. if b < -3.157094219357017e+135

    1. Initial program 54.4

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

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

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

    if -3.157094219357017e+135 < b < 9.088113400659685e-185

    1. Initial program 10.8

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

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

    if 9.088113400659685e-185 < b < 1.8091015183831773e+43

    1. Initial program 34.4

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{0 - \left(c \cdot a\right) \cdot 4}{\frac{a}{\frac{1}{2}}}} \cdot \frac{1}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b}\]
    11. Using strategy rm
    12. Applied add-sqr-sqrt17.6

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

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

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

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

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

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

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

    if 1.8091015183831773e+43 < b

    1. Initial program 56.4

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    4. Simplified4.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.157094219357017 \cdot 10^{+135}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 9.088113400659685 \cdot 10^{-185}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a \cdot 2}\\ \mathbf{elif}\;b \le 1.8091015183831773 \cdot 10^{+43}:\\ \;\;\;\;\frac{1}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b} \cdot \left(\sqrt{\frac{1}{2}} \cdot \left(\frac{c}{\frac{-1}{4}} \cdot \sqrt{\frac{1}{2}}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Reproduce

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