Average Error: 44.1 → 11.1
Time: 17.0s
Precision: 64
\[1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt a \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt b \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt c \lt 9007199254740992\]
\[\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 0.03274390987930671931271930930051894392818:\\ \;\;\;\;\frac{\frac{\frac{\left(b \cdot b - a \cdot \left(c \cdot 4\right)\right) \cdot \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)} - \left(b \cdot b\right) \cdot b}{\left(b \cdot b - a \cdot \left(c \cdot 4\right)\right) + \left(b \cdot \sqrt{b \cdot b - a \cdot \left(c \cdot 4\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 0.03274390987930671931271930930051894392818:\\
\;\;\;\;\frac{\frac{\frac{\left(b \cdot b - a \cdot \left(c \cdot 4\right)\right) \cdot \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)} - \left(b \cdot b\right) \cdot b}{\left(b \cdot b - a \cdot \left(c \cdot 4\right)\right) + \left(b \cdot \sqrt{b \cdot b - a \cdot \left(c \cdot 4\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 r1886822 = b;
        double r1886823 = -r1886822;
        double r1886824 = r1886822 * r1886822;
        double r1886825 = 4.0;
        double r1886826 = a;
        double r1886827 = r1886825 * r1886826;
        double r1886828 = c;
        double r1886829 = r1886827 * r1886828;
        double r1886830 = r1886824 - r1886829;
        double r1886831 = sqrt(r1886830);
        double r1886832 = r1886823 + r1886831;
        double r1886833 = 2.0;
        double r1886834 = r1886833 * r1886826;
        double r1886835 = r1886832 / r1886834;
        return r1886835;
}

double f(double a, double b, double c) {
        double r1886836 = b;
        double r1886837 = 0.03274390987930672;
        bool r1886838 = r1886836 <= r1886837;
        double r1886839 = r1886836 * r1886836;
        double r1886840 = a;
        double r1886841 = c;
        double r1886842 = 4.0;
        double r1886843 = r1886841 * r1886842;
        double r1886844 = r1886840 * r1886843;
        double r1886845 = r1886839 - r1886844;
        double r1886846 = sqrt(r1886845);
        double r1886847 = r1886845 * r1886846;
        double r1886848 = r1886839 * r1886836;
        double r1886849 = r1886847 - r1886848;
        double r1886850 = r1886836 * r1886846;
        double r1886851 = r1886850 + r1886839;
        double r1886852 = r1886845 + r1886851;
        double r1886853 = r1886849 / r1886852;
        double r1886854 = r1886853 / r1886840;
        double r1886855 = 2.0;
        double r1886856 = r1886854 / r1886855;
        double r1886857 = -2.0;
        double r1886858 = r1886841 / r1886836;
        double r1886859 = r1886857 * r1886858;
        double r1886860 = r1886859 / r1886855;
        double r1886861 = r1886838 ? r1886856 : r1886860;
        return r1886861;
}

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

    1. Initial program 22.5

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

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

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

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

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

    if 0.03274390987930672 < b

    1. Initial program 47.0

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

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

      \[\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 0.03274390987930671931271930930051894392818:\\ \;\;\;\;\frac{\frac{\frac{\left(b \cdot b - a \cdot \left(c \cdot 4\right)\right) \cdot \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)} - \left(b \cdot b\right) \cdot b}{\left(b \cdot b - a \cdot \left(c \cdot 4\right)\right) + \left(b \cdot \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)} + b \cdot b\right)}}{a}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot \frac{c}{b}}{2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019170 
(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.0 a) c)))) (* 2.0 a)))