Average Error: 32.8 → 10.4
Time: 32.3s
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.6239127264630285 \cdot 10^{-63}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 7.052614559736995 \cdot 10^{+62}:\\ \;\;\;\;\frac{1}{a} \cdot \mathsf{fma}\left(-1, b_2, \sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}} \cdot \left(-\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}}\right)\right) + \mathsf{fma}\left(-\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}}, \sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}}, \sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}}\right) \cdot \frac{1}{a}\\ \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.6239127264630285 \cdot 10^{-63}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

\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 r3036701 = b_2;
        double r3036702 = -r3036701;
        double r3036703 = r3036701 * r3036701;
        double r3036704 = a;
        double r3036705 = c;
        double r3036706 = r3036704 * r3036705;
        double r3036707 = r3036703 - r3036706;
        double r3036708 = sqrt(r3036707);
        double r3036709 = r3036702 - r3036708;
        double r3036710 = r3036709 / r3036704;
        return r3036710;
}

double f(double a, double b_2, double c) {
        double r3036711 = b_2;
        double r3036712 = -1.6239127264630285e-63;
        bool r3036713 = r3036711 <= r3036712;
        double r3036714 = -0.5;
        double r3036715 = c;
        double r3036716 = r3036715 / r3036711;
        double r3036717 = r3036714 * r3036716;
        double r3036718 = 7.052614559736995e+62;
        bool r3036719 = r3036711 <= r3036718;
        double r3036720 = 1.0;
        double r3036721 = a;
        double r3036722 = r3036720 / r3036721;
        double r3036723 = -1.0;
        double r3036724 = r3036711 * r3036711;
        double r3036725 = r3036715 * r3036721;
        double r3036726 = r3036724 - r3036725;
        double r3036727 = sqrt(r3036726);
        double r3036728 = sqrt(r3036727);
        double r3036729 = -r3036728;
        double r3036730 = r3036728 * r3036729;
        double r3036731 = fma(r3036723, r3036711, r3036730);
        double r3036732 = r3036722 * r3036731;
        double r3036733 = r3036728 * r3036728;
        double r3036734 = fma(r3036729, r3036728, r3036733);
        double r3036735 = r3036734 * r3036722;
        double r3036736 = r3036732 + r3036735;
        double r3036737 = 0.5;
        double r3036738 = -2.0;
        double r3036739 = r3036711 / r3036721;
        double r3036740 = r3036738 * r3036739;
        double r3036741 = fma(r3036737, r3036716, r3036740);
        double r3036742 = r3036719 ? r3036736 : r3036741;
        double r3036743 = r3036713 ? r3036717 : r3036742;
        return r3036743;
}

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.6239127264630285e-63

    1. Initial program 52.2

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

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

    if -1.6239127264630285e-63 < b_2 < 7.052614559736995e+62

    1. Initial program 13.9

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

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

      \[\leadsto \frac{1}{\color{blue}{a \cdot \frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\]
    6. Applied add-cube-cbrt14.1

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{a \cdot \frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    7. Applied times-frac14.1

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

      \[\leadsto \color{blue}{\frac{1}{a}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    9. Simplified14.0

      \[\leadsto \frac{1}{a} \cdot \color{blue}{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}\]
    10. Using strategy rm
    11. Applied add-sqr-sqrt14.0

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

      \[\leadsto \frac{1}{a} \cdot \left(\left(-b_2\right) - \color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}\right)\]
    13. Applied neg-mul-114.2

      \[\leadsto \frac{1}{a} \cdot \left(\color{blue}{-1 \cdot b_2} - \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}\right)\]
    14. Applied prod-diff14.3

      \[\leadsto \frac{1}{a} \cdot \color{blue}{\left(\mathsf{fma}\left(-1, b_2, -\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}\right) + \mathsf{fma}\left(-\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}, \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}, \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}\right)\right)}\]
    15. Applied distribute-lft-in14.3

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

    if 7.052614559736995e+62 < b_2

    1. Initial program 38.0

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

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

      \[\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 simplification10.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.6239127264630285 \cdot 10^{-63}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 7.052614559736995 \cdot 10^{+62}:\\ \;\;\;\;\frac{1}{a} \cdot \mathsf{fma}\left(-1, b_2, \sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}} \cdot \left(-\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}}\right)\right) + \mathsf{fma}\left(-\sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}}, \sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}}, \sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - c \cdot a}}\right) \cdot \frac{1}{a}\\ \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 2019158 +o rules:numerics
(FPCore (a b_2 c)
  :name "NMSE problem 3.2.1"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))