Average Error: 33.8 → 6.5
Time: 37.5s
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 -4.1061641587957725 \cdot 10^{+142}:\\ \;\;\;\;\frac{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(b_2 \cdot -2\right))_*}{a}\\ \mathbf{elif}\;b_2 \le 5.6646816643665726 \cdot 10^{-285}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 1.4653326993720654 \cdot 10^{+110}:\\ \;\;\;\;-\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{(\left(c \cdot \frac{a}{b_2}\right) \cdot \frac{-1}{2} + \left(b_2 \cdot 2\right))_*}\\ \end{array}\]
double f(double a, double b_2, double c) {
        double r1176915 = b_2;
        double r1176916 = -r1176915;
        double r1176917 = r1176915 * r1176915;
        double r1176918 = a;
        double r1176919 = c;
        double r1176920 = r1176918 * r1176919;
        double r1176921 = r1176917 - r1176920;
        double r1176922 = sqrt(r1176921);
        double r1176923 = r1176916 + r1176922;
        double r1176924 = r1176923 / r1176918;
        return r1176924;
}

double f(double a, double b_2, double c) {
        double r1176925 = b_2;
        double r1176926 = -4.1061641587957725e+142;
        bool r1176927 = r1176925 <= r1176926;
        double r1176928 = 0.5;
        double r1176929 = a;
        double r1176930 = c;
        double r1176931 = r1176925 / r1176930;
        double r1176932 = r1176929 / r1176931;
        double r1176933 = -2.0;
        double r1176934 = r1176925 * r1176933;
        double r1176935 = fma(r1176928, r1176932, r1176934);
        double r1176936 = r1176935 / r1176929;
        double r1176937 = 5.6646816643665726e-285;
        bool r1176938 = r1176925 <= r1176937;
        double r1176939 = r1176925 * r1176925;
        double r1176940 = r1176929 * r1176930;
        double r1176941 = r1176939 - r1176940;
        double r1176942 = sqrt(r1176941);
        double r1176943 = r1176942 - r1176925;
        double r1176944 = r1176943 / r1176929;
        double r1176945 = 1.4653326993720654e+110;
        bool r1176946 = r1176925 <= r1176945;
        double r1176947 = r1176942 + r1176925;
        double r1176948 = r1176930 / r1176947;
        double r1176949 = -r1176948;
        double r1176950 = -r1176930;
        double r1176951 = r1176929 / r1176925;
        double r1176952 = r1176930 * r1176951;
        double r1176953 = -0.5;
        double r1176954 = 2.0;
        double r1176955 = r1176925 * r1176954;
        double r1176956 = fma(r1176952, r1176953, r1176955);
        double r1176957 = r1176950 / r1176956;
        double r1176958 = r1176946 ? r1176949 : r1176957;
        double r1176959 = r1176938 ? r1176944 : r1176958;
        double r1176960 = r1176927 ? r1176936 : r1176959;
        return r1176960;
}

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

\mathbf{elif}\;b_2 \le 5.6646816643665726 \cdot 10^{-285}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\

\mathbf{elif}\;b_2 \le 1.4653326993720654 \cdot 10^{+110}:\\
\;\;\;\;-\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\\

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

\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 < -4.1061641587957725e+142

    1. Initial program 56.5

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified56.5

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around -inf 10.9

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \frac{a \cdot c}{b_2} - 2 \cdot b_2}}{a}\]
    4. Simplified2.7

      \[\leadsto \frac{\color{blue}{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(-2 \cdot b_2\right))_*}}{a}\]

    if -4.1061641587957725e+142 < b_2 < 5.6646816643665726e-285

    1. Initial program 9.0

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified9.0

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]

    if 5.6646816643665726e-285 < b_2 < 1.4653326993720654e+110

    1. Initial program 33.5

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified33.5

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-inv33.5

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}} \cdot \frac{1}{a}\]
    7. Applied associate-*l/33.6

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

      \[\leadsto \frac{\color{blue}{\frac{0 - a \cdot c}{a}}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    9. Using strategy rm
    10. Applied sub0-neg15.8

      \[\leadsto \frac{\frac{\color{blue}{-a \cdot c}}{a}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    11. Applied distribute-frac-neg15.8

      \[\leadsto \frac{\color{blue}{-\frac{a \cdot c}{a}}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    12. Simplified8.6

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

    if 1.4653326993720654e+110 < b_2

    1. Initial program 59.7

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified59.7

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied div-inv59.7

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}} \cdot \frac{1}{a}\]
    7. Applied associate-*l/59.8

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

      \[\leadsto \frac{\color{blue}{\frac{0 - a \cdot c}{a}}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    9. Using strategy rm
    10. Applied sub0-neg32.3

      \[\leadsto \frac{\frac{\color{blue}{-a \cdot c}}{a}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    11. Applied distribute-frac-neg32.3

      \[\leadsto \frac{\color{blue}{-\frac{a \cdot c}{a}}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    12. Simplified31.7

      \[\leadsto \frac{-\color{blue}{c}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    13. Taylor expanded around inf 6.4

      \[\leadsto \frac{-c}{\color{blue}{2 \cdot b_2 - \frac{1}{2} \cdot \frac{a \cdot c}{b_2}}}\]
    14. Simplified2.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -4.1061641587957725 \cdot 10^{+142}:\\ \;\;\;\;\frac{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(b_2 \cdot -2\right))_*}{a}\\ \mathbf{elif}\;b_2 \le 5.6646816643665726 \cdot 10^{-285}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{elif}\;b_2 \le 1.4653326993720654 \cdot 10^{+110}:\\ \;\;\;\;-\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-c}{(\left(c \cdot \frac{a}{b_2}\right) \cdot \frac{-1}{2} + \left(b_2 \cdot 2\right))_*}\\ \end{array}\]

Reproduce

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