Average Error: 28.5 → 16.5
Time: 16.7s
Precision: 64
\[1.0536712127723509 \cdot 10^{-08} \lt a \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt b \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt c \lt 94906265.62425156\]
\[\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 5152.464935290847:\\ \;\;\;\;\frac{\frac{\frac{\left(b \cdot b + a \cdot \left(-4 \cdot c\right)\right) \cdot \sqrt{b \cdot b + a \cdot \left(-4 \cdot c\right)} - \left(b \cdot b\right) \cdot b}{\left(b \cdot b + a \cdot \left(-4 \cdot c\right)\right) + \left(b \cdot \sqrt{b \cdot b + a \cdot \left(-4 \cdot c\right)} + 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 5152.464935290847:\\
\;\;\;\;\frac{\frac{\frac{\left(b \cdot b + a \cdot \left(-4 \cdot c\right)\right) \cdot \sqrt{b \cdot b + a \cdot \left(-4 \cdot c\right)} - \left(b \cdot b\right) \cdot b}{\left(b \cdot b + a \cdot \left(-4 \cdot c\right)\right) + \left(b \cdot \sqrt{b \cdot b + a \cdot \left(-4 \cdot c\right)} + 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 r1638561 = b;
        double r1638562 = -r1638561;
        double r1638563 = r1638561 * r1638561;
        double r1638564 = 4.0;
        double r1638565 = a;
        double r1638566 = r1638564 * r1638565;
        double r1638567 = c;
        double r1638568 = r1638566 * r1638567;
        double r1638569 = r1638563 - r1638568;
        double r1638570 = sqrt(r1638569);
        double r1638571 = r1638562 + r1638570;
        double r1638572 = 2.0;
        double r1638573 = r1638572 * r1638565;
        double r1638574 = r1638571 / r1638573;
        return r1638574;
}

double f(double a, double b, double c) {
        double r1638575 = b;
        double r1638576 = 5152.464935290847;
        bool r1638577 = r1638575 <= r1638576;
        double r1638578 = r1638575 * r1638575;
        double r1638579 = a;
        double r1638580 = -4.0;
        double r1638581 = c;
        double r1638582 = r1638580 * r1638581;
        double r1638583 = r1638579 * r1638582;
        double r1638584 = r1638578 + r1638583;
        double r1638585 = sqrt(r1638584);
        double r1638586 = r1638584 * r1638585;
        double r1638587 = r1638578 * r1638575;
        double r1638588 = r1638586 - r1638587;
        double r1638589 = r1638575 * r1638585;
        double r1638590 = r1638589 + r1638578;
        double r1638591 = r1638584 + r1638590;
        double r1638592 = r1638588 / r1638591;
        double r1638593 = r1638592 / r1638579;
        double r1638594 = 2.0;
        double r1638595 = r1638593 / r1638594;
        double r1638596 = -2.0;
        double r1638597 = r1638581 / r1638575;
        double r1638598 = r1638596 * r1638597;
        double r1638599 = r1638598 / r1638594;
        double r1638600 = r1638577 ? r1638595 : r1638599;
        return r1638600;
}

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 < 5152.464935290847

    1. Initial program 18.7

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

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

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

      \[\leadsto \frac{\frac{\frac{\color{blue}{\sqrt{b \cdot b + \left(-4 \cdot c\right) \cdot a} \cdot \left(b \cdot b + \left(-4 \cdot c\right) \cdot a\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. Simplified18.1

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

    if 5152.464935290847 < b

    1. Initial program 37.9

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

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

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

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

Reproduce

herbie shell --seed 2019168 
(FPCore (a b c)
  :name "Quadratic roots, narrow range"
  :pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))