Average Error: 34.0 → 6.8
Time: 19.4s
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 -3.727723973148742563324153150500151191249 \cdot 10^{105}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.364529283357116165462040672443911208369 \cdot 10^{-246}:\\ \;\;\;\;\frac{c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\\ \mathbf{elif}\;b_2 \le 4.198650993474429809884798868723112488797 \cdot 10^{74}:\\ \;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2}{a} \cdot -2\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 -3.727723973148742563324153150500151191249 \cdot 10^{105}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r90001 = b_2;
        double r90002 = -r90001;
        double r90003 = r90001 * r90001;
        double r90004 = a;
        double r90005 = c;
        double r90006 = r90004 * r90005;
        double r90007 = r90003 - r90006;
        double r90008 = sqrt(r90007);
        double r90009 = r90002 - r90008;
        double r90010 = r90009 / r90004;
        return r90010;
}

double f(double a, double b_2, double c) {
        double r90011 = b_2;
        double r90012 = -3.7277239731487426e+105;
        bool r90013 = r90011 <= r90012;
        double r90014 = -0.5;
        double r90015 = c;
        double r90016 = r90015 / r90011;
        double r90017 = r90014 * r90016;
        double r90018 = 1.3645292833571162e-246;
        bool r90019 = r90011 <= r90018;
        double r90020 = a;
        double r90021 = r90015 * r90020;
        double r90022 = -r90021;
        double r90023 = fma(r90011, r90011, r90022);
        double r90024 = sqrt(r90023);
        double r90025 = r90024 - r90011;
        double r90026 = r90015 / r90025;
        double r90027 = 4.19865099347443e+74;
        bool r90028 = r90011 <= r90027;
        double r90029 = -r90011;
        double r90030 = r90029 / r90020;
        double r90031 = r90011 * r90011;
        double r90032 = r90020 * r90015;
        double r90033 = r90031 - r90032;
        double r90034 = sqrt(r90033);
        double r90035 = r90034 / r90020;
        double r90036 = r90030 - r90035;
        double r90037 = 0.5;
        double r90038 = r90011 / r90020;
        double r90039 = -2.0;
        double r90040 = r90038 * r90039;
        double r90041 = fma(r90016, r90037, r90040);
        double r90042 = r90028 ? r90036 : r90041;
        double r90043 = r90019 ? r90026 : r90042;
        double r90044 = r90013 ? r90017 : r90043;
        return r90044;
}

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 < -3.7277239731487426e+105

    1. Initial program 59.9

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

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

    if -3.7277239731487426e+105 < b_2 < 1.3645292833571162e-246

    1. Initial program 30.7

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

      \[\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. Simplified15.7

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

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

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

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

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

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

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

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

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

    if 1.3645292833571162e-246 < b_2 < 4.19865099347443e+74

    1. Initial program 9.3

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

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

    if 4.19865099347443e+74 < b_2

    1. Initial program 41.8

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

      \[\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. Simplified61.3

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 \cdot \left(1 \cdot \color{blue}{\frac{1}{\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}{c}}}\right)\]
    16. Taylor expanded around inf 5.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -3.727723973148742563324153150500151191249 \cdot 10^{105}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.364529283357116165462040672443911208369 \cdot 10^{-246}:\\ \;\;\;\;\frac{c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\\ \mathbf{elif}\;b_2 \le 4.198650993474429809884798868723112488797 \cdot 10^{74}:\\ \;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2}{a} \cdot -2\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019322 +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))