Average Error: 34.0 → 6.5
Time: 16.7s
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.077239628548905378565124203356585166888 \cdot 10^{154}:\\ \;\;\;\;\frac{c}{-2 \cdot b_2}\\ \mathbf{elif}\;b_2 \le 3.657998399682531790024702628233707002655 \cdot 10^{-302}:\\ \;\;\;\;\frac{c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\\ \mathbf{elif}\;b_2 \le 3.361636799726259566012474460441175928147 \cdot 10^{93}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \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.077239628548905378565124203356585166888 \cdot 10^{154}:\\
\;\;\;\;\frac{c}{-2 \cdot b_2}\\

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

\mathbf{elif}\;b_2 \le 3.361636799726259566012474460441175928147 \cdot 10^{93}:\\
\;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\\

\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\

\end{array}
double f(double a, double b_2, double c) {
        double r60890 = b_2;
        double r60891 = -r60890;
        double r60892 = r60890 * r60890;
        double r60893 = a;
        double r60894 = c;
        double r60895 = r60893 * r60894;
        double r60896 = r60892 - r60895;
        double r60897 = sqrt(r60896);
        double r60898 = r60891 - r60897;
        double r60899 = r60898 / r60893;
        return r60899;
}

double f(double a, double b_2, double c) {
        double r60900 = b_2;
        double r60901 = -1.0772396285489054e+154;
        bool r60902 = r60900 <= r60901;
        double r60903 = c;
        double r60904 = -2.0;
        double r60905 = r60904 * r60900;
        double r60906 = r60903 / r60905;
        double r60907 = 3.657998399682532e-302;
        bool r60908 = r60900 <= r60907;
        double r60909 = a;
        double r60910 = r60903 * r60909;
        double r60911 = -r60910;
        double r60912 = fma(r60900, r60900, r60911);
        double r60913 = sqrt(r60912);
        double r60914 = r60913 - r60900;
        double r60915 = r60903 / r60914;
        double r60916 = 3.3616367997262596e+93;
        bool r60917 = r60900 <= r60916;
        double r60918 = 1.0;
        double r60919 = -r60900;
        double r60920 = r60900 * r60900;
        double r60921 = r60909 * r60903;
        double r60922 = r60920 - r60921;
        double r60923 = sqrt(r60922);
        double r60924 = r60919 - r60923;
        double r60925 = r60909 / r60924;
        double r60926 = r60918 / r60925;
        double r60927 = r60900 / r60909;
        double r60928 = r60904 * r60927;
        double r60929 = r60917 ? r60926 : r60928;
        double r60930 = r60908 ? r60915 : r60929;
        double r60931 = r60902 ? r60906 : r60930;
        return r60931;
}

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 < -1.0772396285489054e+154

    1. Initial program 64.0

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

      \[\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. Simplified37.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. Simplified37.8

      \[\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-identity37.8

      \[\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-identity37.8

      \[\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-identity37.8

      \[\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-frac37.8

      \[\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-frac37.8

      \[\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. Simplified37.8

      \[\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. Simplified37.6

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

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

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

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

      \[\leadsto 1 \cdot \left(\frac{c}{\color{blue}{-2 \cdot b_2}} \cdot 1\right)\]
    19. Simplified1.8

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

    if -1.0772396285489054e+154 < b_2 < 3.657998399682532e-302

    1. Initial program 34.6

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

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

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

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

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

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

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

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

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

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

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

    if 3.657998399682532e-302 < b_2 < 3.3616367997262596e+93

    1. Initial program 8.9

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

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

    if 3.3616367997262596e+93 < b_2

    1. Initial program 45.2

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip--62.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. Simplified62.0

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

      \[\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-identity62.0

      \[\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-identity62.0

      \[\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-identity62.0

      \[\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-frac62.0

      \[\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-frac62.0

      \[\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. Simplified62.0

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.077239628548905378565124203356585166888 \cdot 10^{154}:\\ \;\;\;\;\frac{c}{-2 \cdot b_2}\\ \mathbf{elif}\;b_2 \le 3.657998399682531790024702628233707002655 \cdot 10^{-302}:\\ \;\;\;\;\frac{c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\\ \mathbf{elif}\;b_2 \le 3.361636799726259566012474460441175928147 \cdot 10^{93}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;-2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

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