Average Error: 34.1 → 9.9
Time: 23.8s
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.32337788234514 \cdot 10^{-89}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 5.121074390969514 \cdot 10^{+149}:\\ \;\;\;\;-\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{b_2}{a}, -2, \frac{\frac{1}{2}}{\frac{b_2}{c}}\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 -4.32337788234514 \cdot 10^{-89}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r3011680 = b_2;
        double r3011681 = -r3011680;
        double r3011682 = r3011680 * r3011680;
        double r3011683 = a;
        double r3011684 = c;
        double r3011685 = r3011683 * r3011684;
        double r3011686 = r3011682 - r3011685;
        double r3011687 = sqrt(r3011686);
        double r3011688 = r3011681 - r3011687;
        double r3011689 = r3011688 / r3011683;
        return r3011689;
}

double f(double a, double b_2, double c) {
        double r3011690 = b_2;
        double r3011691 = -4.32337788234514e-89;
        bool r3011692 = r3011690 <= r3011691;
        double r3011693 = -0.5;
        double r3011694 = c;
        double r3011695 = r3011694 / r3011690;
        double r3011696 = r3011693 * r3011695;
        double r3011697 = 5.121074390969514e+149;
        bool r3011698 = r3011690 <= r3011697;
        double r3011699 = r3011690 * r3011690;
        double r3011700 = a;
        double r3011701 = r3011694 * r3011700;
        double r3011702 = r3011699 - r3011701;
        double r3011703 = sqrt(r3011702);
        double r3011704 = r3011703 + r3011690;
        double r3011705 = r3011704 / r3011700;
        double r3011706 = -r3011705;
        double r3011707 = r3011690 / r3011700;
        double r3011708 = -2.0;
        double r3011709 = 0.5;
        double r3011710 = r3011690 / r3011694;
        double r3011711 = r3011709 / r3011710;
        double r3011712 = fma(r3011707, r3011708, r3011711);
        double r3011713 = r3011698 ? r3011706 : r3011712;
        double r3011714 = r3011692 ? r3011696 : r3011713;
        return r3011714;
}

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 < -4.32337788234514e-89

    1. Initial program 52.3

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

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

    if -4.32337788234514e-89 < b_2 < 5.121074390969514e+149

    1. Initial program 12.3

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity12.3

      \[\leadsto \frac{\left(-b_2\right) - \color{blue}{1 \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    4. Applied *-un-lft-identity12.3

      \[\leadsto \frac{\left(-\color{blue}{1 \cdot b_2}\right) - 1 \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    5. Applied distribute-rgt-neg-in12.3

      \[\leadsto \frac{\color{blue}{1 \cdot \left(-b_2\right)} - 1 \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    6. Applied distribute-lft-out--12.3

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

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

      \[\leadsto \frac{1}{\color{blue}{a \cdot \frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    10. Applied *-un-lft-identity12.5

      \[\leadsto \frac{\color{blue}{1 \cdot 1}}{a \cdot \frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    11. Applied times-frac12.5

      \[\leadsto \color{blue}{\frac{1}{a} \cdot \frac{1}{\frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    12. Simplified12.4

      \[\leadsto \frac{1}{a} \cdot \color{blue}{\left(-\left(b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)\right)}\]
    13. Using strategy rm
    14. Applied distribute-rgt-neg-out12.4

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

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

    if 5.121074390969514e+149 < b_2

    1. Initial program 59.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -4.32337788234514 \cdot 10^{-89}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 5.121074390969514 \cdot 10^{+149}:\\ \;\;\;\;-\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{b_2}{a}, -2, \frac{\frac{1}{2}}{\frac{b_2}{c}}\right)\\ \end{array}\]

Reproduce

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