Average Error: 34.6 → 9.6
Time: 19.1s
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 -1.437435364032730355974086758797848392144 \cdot 10^{115}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 3.590122721216626986933896112813355870936 \cdot 10^{-73}:\\ \;\;\;\;\frac{c}{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, -2 \cdot \frac{b_2}{a}\right)\\ \end{array}\]
\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
\mathbf{if}\;b_2 \le -1.437435364032730355974086758797848392144 \cdot 10^{115}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le 3.590122721216626986933896112813355870936 \cdot 10^{-73}:\\
\;\;\;\;\frac{c}{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, -2 \cdot \frac{b_2}{a}\right)\\

\end{array}
double f(double a, double b_2, double c) {
        double r63045 = b_2;
        double r63046 = -r63045;
        double r63047 = r63045 * r63045;
        double r63048 = a;
        double r63049 = c;
        double r63050 = r63048 * r63049;
        double r63051 = r63047 - r63050;
        double r63052 = sqrt(r63051);
        double r63053 = r63046 - r63052;
        double r63054 = r63053 / r63048;
        return r63054;
}

double f(double a, double b_2, double c) {
        double r63055 = b_2;
        double r63056 = -1.4374353640327304e+115;
        bool r63057 = r63055 <= r63056;
        double r63058 = -0.5;
        double r63059 = c;
        double r63060 = r63059 / r63055;
        double r63061 = r63058 * r63060;
        double r63062 = 3.590122721216627e-73;
        bool r63063 = r63055 <= r63062;
        double r63064 = -r63059;
        double r63065 = a;
        double r63066 = r63055 * r63055;
        double r63067 = fma(r63064, r63065, r63066);
        double r63068 = sqrt(r63067);
        double r63069 = r63068 - r63055;
        double r63070 = r63059 / r63069;
        double r63071 = 0.5;
        double r63072 = -2.0;
        double r63073 = r63055 / r63065;
        double r63074 = r63072 * r63073;
        double r63075 = fma(r63071, r63060, r63074);
        double r63076 = r63063 ? r63070 : r63075;
        double r63077 = r63057 ? r63061 : r63076;
        return r63077;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b_2 < -1.4374353640327304e+115

    1. Initial program 60.8

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

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

    if -1.4374353640327304e+115 < b_2 < 3.590122721216627e-73

    1. Initial program 26.0

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--28.9

      \[\leadsto \frac{\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}}}}{a}\]
    4. Simplified17.8

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

      \[\leadsto \frac{\frac{0 + a \cdot c}{\color{blue}{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied div-inv17.8

      \[\leadsto \color{blue}{\frac{0 + a \cdot c}{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2} \cdot \frac{1}{a}}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity17.8

      \[\leadsto \frac{0 + a \cdot c}{\color{blue}{1 \cdot \left(\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2\right)}} \cdot \frac{1}{a}\]
    10. Applied *-un-lft-identity17.8

      \[\leadsto \frac{\color{blue}{1 \cdot \left(0 + a \cdot c\right)}}{1 \cdot \left(\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2\right)} \cdot \frac{1}{a}\]
    11. Applied times-frac17.8

      \[\leadsto \color{blue}{\left(\frac{1}{1} \cdot \frac{0 + a \cdot c}{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2}\right)} \cdot \frac{1}{a}\]
    12. Applied associate-*l*17.8

      \[\leadsto \color{blue}{\frac{1}{1} \cdot \left(\frac{0 + a \cdot c}{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2} \cdot \frac{1}{a}\right)}\]
    13. Simplified17.2

      \[\leadsto \frac{1}{1} \cdot \color{blue}{\frac{\frac{c \cdot a}{a}}{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2}}\]
    14. Using strategy rm
    15. Applied *-un-lft-identity17.2

      \[\leadsto \frac{1}{1} \cdot \frac{\frac{c \cdot a}{a}}{\color{blue}{1 \cdot \left(\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2\right)}}\]
    16. Applied *-un-lft-identity17.2

      \[\leadsto \frac{1}{1} \cdot \frac{\color{blue}{1 \cdot \frac{c \cdot a}{a}}}{1 \cdot \left(\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2\right)}\]
    17. Applied times-frac17.2

      \[\leadsto \frac{1}{1} \cdot \color{blue}{\left(\frac{1}{1} \cdot \frac{\frac{c \cdot a}{a}}{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2}\right)}\]
    18. Simplified17.2

      \[\leadsto \frac{1}{1} \cdot \left(\color{blue}{1} \cdot \frac{\frac{c \cdot a}{a}}{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2}\right)\]
    19. Simplified12.2

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

    if 3.590122721216627e-73 < b_2

    1. Initial program 27.9

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, -2 \cdot \frac{b_2}{a}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.437435364032730355974086758797848392144 \cdot 10^{115}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 3.590122721216626986933896112813355870936 \cdot 10^{-73}:\\ \;\;\;\;\frac{c}{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{2}, \frac{c}{b_2}, -2 \cdot \frac{b_2}{a}\right)\\ \end{array}\]

Reproduce

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