Average Error: 33.8 → 9.6
Time: 15.6s
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.0775171197265305 \cdot 10^{+143}:\\ \;\;\;\;\frac{\frac{-2 \cdot b}{2}}{a}\\ \mathbf{elif}\;b \le 1.3635892865650846 \cdot 10^{-93}:\\ \;\;\;\;\frac{\frac{1}{2}}{a} \cdot \left(\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b\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.0775171197265305 \cdot 10^{+143}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{2}}{a}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r1553892 = b;
        double r1553893 = -r1553892;
        double r1553894 = r1553892 * r1553892;
        double r1553895 = 4.0;
        double r1553896 = a;
        double r1553897 = r1553895 * r1553896;
        double r1553898 = c;
        double r1553899 = r1553897 * r1553898;
        double r1553900 = r1553894 - r1553899;
        double r1553901 = sqrt(r1553900);
        double r1553902 = r1553893 + r1553901;
        double r1553903 = 2.0;
        double r1553904 = r1553903 * r1553896;
        double r1553905 = r1553902 / r1553904;
        return r1553905;
}

double f(double a, double b, double c) {
        double r1553906 = b;
        double r1553907 = -3.0775171197265305e+143;
        bool r1553908 = r1553906 <= r1553907;
        double r1553909 = -2.0;
        double r1553910 = r1553909 * r1553906;
        double r1553911 = 2.0;
        double r1553912 = r1553910 / r1553911;
        double r1553913 = a;
        double r1553914 = r1553912 / r1553913;
        double r1553915 = 1.3635892865650846e-93;
        bool r1553916 = r1553906 <= r1553915;
        double r1553917 = 0.5;
        double r1553918 = r1553917 / r1553913;
        double r1553919 = r1553906 * r1553906;
        double r1553920 = 4.0;
        double r1553921 = c;
        double r1553922 = r1553921 * r1553913;
        double r1553923 = r1553920 * r1553922;
        double r1553924 = r1553919 - r1553923;
        double r1553925 = sqrt(r1553924);
        double r1553926 = r1553925 - r1553906;
        double r1553927 = r1553918 * r1553926;
        double r1553928 = r1553921 / r1553906;
        double r1553929 = -r1553928;
        double r1553930 = r1553916 ? r1553927 : r1553929;
        double r1553931 = r1553908 ? r1553914 : r1553930;
        return r1553931;
}

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 3 regimes
  2. if b < -3.0775171197265305e+143

    1. Initial program 56.9

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

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

      \[\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)}}}{2}}{a}\]
    5. Simplified62.1

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

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

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

    if -3.0775171197265305e+143 < b < 1.3635892865650846e-93

    1. Initial program 11.5

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

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{2}}{a}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity11.5

      \[\leadsto \frac{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{2}}{\color{blue}{1 \cdot a}}\]
    5. Applied div-inv11.5

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

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

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

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

    if 1.3635892865650846e-93 < b

    1. Initial program 52.4

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

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

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

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

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

Reproduce

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