Average Error: 34.1 → 6.7
Time: 16.9s
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 -2.794763793747313808439492098028999694334 \cdot 10^{48}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.343096751709779633653539836064556904256 \cdot 10^{-234}:\\ \;\;\;\;\frac{1}{\sqrt{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2}} \cdot \left(\frac{a}{a} \cdot \frac{c}{\sqrt{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2}}\right)\\ \mathbf{elif}\;b_2 \le 1.302994705082702092687429648637938290449 \cdot 10^{103}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{{b_2}^{2} - c \cdot a}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot 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 -2.794763793747313808439492098028999694334 \cdot 10^{48}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r65679 = b_2;
        double r65680 = -r65679;
        double r65681 = r65679 * r65679;
        double r65682 = a;
        double r65683 = c;
        double r65684 = r65682 * r65683;
        double r65685 = r65681 - r65684;
        double r65686 = sqrt(r65685);
        double r65687 = r65680 - r65686;
        double r65688 = r65687 / r65682;
        return r65688;
}

double f(double a, double b_2, double c) {
        double r65689 = b_2;
        double r65690 = -2.7947637937473138e+48;
        bool r65691 = r65689 <= r65690;
        double r65692 = -0.5;
        double r65693 = c;
        double r65694 = r65693 / r65689;
        double r65695 = r65692 * r65694;
        double r65696 = -1.3430967517097796e-234;
        bool r65697 = r65689 <= r65696;
        double r65698 = 1.0;
        double r65699 = -r65693;
        double r65700 = a;
        double r65701 = r65689 * r65689;
        double r65702 = fma(r65699, r65700, r65701);
        double r65703 = sqrt(r65702);
        double r65704 = r65703 - r65689;
        double r65705 = sqrt(r65704);
        double r65706 = r65698 / r65705;
        double r65707 = r65700 / r65700;
        double r65708 = r65693 / r65705;
        double r65709 = r65707 * r65708;
        double r65710 = r65706 * r65709;
        double r65711 = 1.302994705082702e+103;
        bool r65712 = r65689 <= r65711;
        double r65713 = -r65689;
        double r65714 = 2.0;
        double r65715 = pow(r65689, r65714);
        double r65716 = r65693 * r65700;
        double r65717 = r65715 - r65716;
        double r65718 = sqrt(r65717);
        double r65719 = r65713 - r65718;
        double r65720 = r65700 / r65719;
        double r65721 = r65698 / r65720;
        double r65722 = -2.0;
        double r65723 = r65722 * r65689;
        double r65724 = r65723 / r65700;
        double r65725 = r65712 ? r65721 : r65724;
        double r65726 = r65697 ? r65710 : r65725;
        double r65727 = r65691 ? r65695 : r65726;
        return r65727;
}

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 < -2.7947637937473138e+48

    1. Initial program 57.3

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

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

    if -2.7947637937473138e+48 < b_2 < -1.3430967517097796e-234

    1. Initial program 33.1

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

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

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

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

      \[\leadsto \frac{\frac{0 + a \cdot c}{{\left(\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2\right)}^{1}}}{\color{blue}{1 \cdot a}}\]
    10. Applied add-sqr-sqrt17.5

      \[\leadsto \frac{\frac{0 + a \cdot c}{{\color{blue}{\left(\sqrt{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2} \cdot \sqrt{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2}\right)}}^{1}}}{1 \cdot a}\]
    11. Applied unpow-prod-down17.5

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

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

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

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

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

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

    if -1.3430967517097796e-234 < b_2 < 1.302994705082702e+103

    1. Initial program 9.5

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

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

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

    if 1.302994705082702e+103 < b_2

    1. Initial program 47.7

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

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

      \[\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. Taylor expanded around 0 3.3

      \[\leadsto \frac{\color{blue}{-2 \cdot b_2}}{a}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2.794763793747313808439492098028999694334 \cdot 10^{48}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.343096751709779633653539836064556904256 \cdot 10^{-234}:\\ \;\;\;\;\frac{1}{\sqrt{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2}} \cdot \left(\frac{a}{a} \cdot \frac{c}{\sqrt{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2}}\right)\\ \mathbf{elif}\;b_2 \le 1.302994705082702092687429648637938290449 \cdot 10^{103}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{{b_2}^{2} - c \cdot a}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot b_2}{a}\\ \end{array}\]

Reproduce

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