Average Error: 44.1 → 11.1
Time: 16.0s
Precision: 64
\[1.1102230246251565 \cdot 10^{-16} \lt a \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt b \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt c \lt 9007199254740992.0\]
\[\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 1.6209007775013438 \cdot 10^{-05}:\\ \;\;\;\;\frac{\frac{\frac{\left(b \cdot b + \left(-4 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} - \left(b \cdot b\right) \cdot b}{\left(b \cdot b + \left(-4 \cdot a\right) \cdot c\right) + \left(b \cdot \sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} + b \cdot b\right)}}{a}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot \frac{c}{b}}{2}\\ \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 1.6209007775013438 \cdot 10^{-05}:\\
\;\;\;\;\frac{\frac{\frac{\left(b \cdot b + \left(-4 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} - \left(b \cdot b\right) \cdot b}{\left(b \cdot b + \left(-4 \cdot a\right) \cdot c\right) + \left(b \cdot \sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} + b \cdot b\right)}}{a}}{2}\\

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

\end{array}
double f(double a, double b, double c) {
        double r1768577 = b;
        double r1768578 = -r1768577;
        double r1768579 = r1768577 * r1768577;
        double r1768580 = 4.0;
        double r1768581 = a;
        double r1768582 = r1768580 * r1768581;
        double r1768583 = c;
        double r1768584 = r1768582 * r1768583;
        double r1768585 = r1768579 - r1768584;
        double r1768586 = sqrt(r1768585);
        double r1768587 = r1768578 + r1768586;
        double r1768588 = 2.0;
        double r1768589 = r1768588 * r1768581;
        double r1768590 = r1768587 / r1768589;
        return r1768590;
}

double f(double a, double b, double c) {
        double r1768591 = b;
        double r1768592 = 1.6209007775013438e-05;
        bool r1768593 = r1768591 <= r1768592;
        double r1768594 = r1768591 * r1768591;
        double r1768595 = -4.0;
        double r1768596 = a;
        double r1768597 = r1768595 * r1768596;
        double r1768598 = c;
        double r1768599 = r1768597 * r1768598;
        double r1768600 = r1768594 + r1768599;
        double r1768601 = sqrt(r1768600);
        double r1768602 = r1768600 * r1768601;
        double r1768603 = r1768594 * r1768591;
        double r1768604 = r1768602 - r1768603;
        double r1768605 = r1768591 * r1768601;
        double r1768606 = r1768605 + r1768594;
        double r1768607 = r1768600 + r1768606;
        double r1768608 = r1768604 / r1768607;
        double r1768609 = r1768608 / r1768596;
        double r1768610 = 2.0;
        double r1768611 = r1768609 / r1768610;
        double r1768612 = -2.0;
        double r1768613 = r1768598 / r1768591;
        double r1768614 = r1768612 * r1768613;
        double r1768615 = r1768614 / r1768610;
        double r1768616 = r1768593 ? r1768611 : r1768615;
        return r1768616;
}

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 2 regimes
  2. if b < 1.6209007775013438e-05

    1. Initial program 17.6

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

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

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

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

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

    if 1.6209007775013438e-05 < b

    1. Initial program 45.5

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 1.6209007775013438 \cdot 10^{-05}:\\ \;\;\;\;\frac{\frac{\frac{\left(b \cdot b + \left(-4 \cdot a\right) \cdot c\right) \cdot \sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} - \left(b \cdot b\right) \cdot b}{\left(b \cdot b + \left(-4 \cdot a\right) \cdot c\right) + \left(b \cdot \sqrt{b \cdot b + \left(-4 \cdot a\right) \cdot c} + b \cdot b\right)}}{a}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot \frac{c}{b}}{2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019158 
(FPCore (a b c)
  :name "Quadratic roots, medium range"
  :pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))