Average Error: 33.4 → 8.9
Time: 1.4m
Precision: 64
\[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -7.366967137223396 \cdot 10^{+18}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -2.1155078366960404 \cdot 10^{-257}:\\ \;\;\;\;\frac{\frac{c \cdot a}{a}}{\sqrt{b_2 \cdot b_2 - c \cdot a} + \left(-b_2\right)}\\ \mathbf{elif}\;b_2 \le 1.0565541015735018 \cdot 10^{+110}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(b_2 \cdot -2\right))_*}{a}\\ \end{array}\]
double f(double a, double b_2, double c) {
        double r8036851 = b_2;
        double r8036852 = -r8036851;
        double r8036853 = r8036851 * r8036851;
        double r8036854 = a;
        double r8036855 = c;
        double r8036856 = r8036854 * r8036855;
        double r8036857 = r8036853 - r8036856;
        double r8036858 = sqrt(r8036857);
        double r8036859 = r8036852 - r8036858;
        double r8036860 = r8036859 / r8036854;
        return r8036860;
}

double f(double a, double b_2, double c) {
        double r8036861 = b_2;
        double r8036862 = -7.366967137223396e+18;
        bool r8036863 = r8036861 <= r8036862;
        double r8036864 = -0.5;
        double r8036865 = c;
        double r8036866 = r8036865 / r8036861;
        double r8036867 = r8036864 * r8036866;
        double r8036868 = -2.1155078366960404e-257;
        bool r8036869 = r8036861 <= r8036868;
        double r8036870 = a;
        double r8036871 = r8036865 * r8036870;
        double r8036872 = r8036871 / r8036870;
        double r8036873 = r8036861 * r8036861;
        double r8036874 = r8036873 - r8036871;
        double r8036875 = sqrt(r8036874);
        double r8036876 = -r8036861;
        double r8036877 = r8036875 + r8036876;
        double r8036878 = r8036872 / r8036877;
        double r8036879 = 1.0565541015735018e+110;
        bool r8036880 = r8036861 <= r8036879;
        double r8036881 = r8036876 - r8036875;
        double r8036882 = r8036881 / r8036870;
        double r8036883 = 0.5;
        double r8036884 = r8036861 / r8036865;
        double r8036885 = r8036870 / r8036884;
        double r8036886 = -2.0;
        double r8036887 = r8036861 * r8036886;
        double r8036888 = fma(r8036883, r8036885, r8036887);
        double r8036889 = r8036888 / r8036870;
        double r8036890 = r8036880 ? r8036882 : r8036889;
        double r8036891 = r8036869 ? r8036878 : r8036890;
        double r8036892 = r8036863 ? r8036867 : r8036891;
        return r8036892;
}

\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
\mathbf{if}\;b_2 \le -7.366967137223396 \cdot 10^{+18}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -2.1155078366960404 \cdot 10^{-257}:\\
\;\;\;\;\frac{\frac{c \cdot a}{a}}{\sqrt{b_2 \cdot b_2 - c \cdot a} + \left(-b_2\right)}\\

\mathbf{elif}\;b_2 \le 1.0565541015735018 \cdot 10^{+110}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(b_2 \cdot -2\right))_*}{a}\\

\end{array}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -7.366967137223396e+18

    1. Initial program 55.1

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around 0 55.1

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{{b_2}^{2} - a \cdot c}}}{a}\]
    3. Simplified55.1

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    4. Using strategy rm
    5. Applied div-inv55.1

      \[\leadsto \color{blue}{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
    6. Taylor expanded around -inf 5.4

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b_2}}\]

    if -7.366967137223396e+18 < b_2 < -2.1155078366960404e-257

    1. Initial program 28.8

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around 0 28.8

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{{b_2}^{2} - a \cdot c}}}{a}\]
    3. Simplified28.8

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    4. Using strategy rm
    5. Applied div-inv28.9

      \[\leadsto \color{blue}{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}}\]
    6. Using strategy rm
    7. Applied flip--29.0

      \[\leadsto \color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}} \cdot \frac{1}{a}\]
    8. Applied associate-*l/29.0

      \[\leadsto \color{blue}{\frac{\left(\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}}{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    9. Simplified17.5

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

    if -2.1155078366960404e-257 < b_2 < 1.0565541015735018e+110

    1. Initial program 9.7

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around 0 9.7

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{{b_2}^{2} - a \cdot c}}}{a}\]
    3. Simplified9.7

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

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{{b_2}^{2} - a \cdot c}}}{a}\]
    5. Simplified9.7

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

    if 1.0565541015735018e+110 < b_2

    1. Initial program 47.6

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around inf 10.2

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \frac{a \cdot c}{b_2} - 2 \cdot b_2}}{a}\]
    3. Simplified3.1

      \[\leadsto \frac{\color{blue}{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(-2 \cdot b_2\right))_*}}{a}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification8.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -7.366967137223396 \cdot 10^{+18}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -2.1155078366960404 \cdot 10^{-257}:\\ \;\;\;\;\frac{\frac{c \cdot a}{a}}{\sqrt{b_2 \cdot b_2 - c \cdot a} + \left(-b_2\right)}\\ \mathbf{elif}\;b_2 \le 1.0565541015735018 \cdot 10^{+110}:\\ \;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(b_2 \cdot -2\right))_*}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019102 +o rules:numerics
(FPCore (a b_2 c)
  :name "NMSE problem 3.2.1"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))