Average Error: 34.5 → 6.7
Time: 9.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 -2.61268387266151013 \cdot 10^{141}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 2.5402182456312607 \cdot 10^{-243}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 2.8568501197790958 \cdot 10^{109}:\\ \;\;\;\;\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{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.61268387266151013 \cdot 10^{141}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r79793 = b_2;
        double r79794 = -r79793;
        double r79795 = r79793 * r79793;
        double r79796 = a;
        double r79797 = c;
        double r79798 = r79796 * r79797;
        double r79799 = r79795 - r79798;
        double r79800 = sqrt(r79799);
        double r79801 = r79794 - r79800;
        double r79802 = r79801 / r79796;
        return r79802;
}

double f(double a, double b_2, double c) {
        double r79803 = b_2;
        double r79804 = -2.61268387266151e+141;
        bool r79805 = r79803 <= r79804;
        double r79806 = -0.5;
        double r79807 = c;
        double r79808 = r79807 / r79803;
        double r79809 = r79806 * r79808;
        double r79810 = 2.5402182456312607e-243;
        bool r79811 = r79803 <= r79810;
        double r79812 = r79803 * r79803;
        double r79813 = a;
        double r79814 = r79813 * r79807;
        double r79815 = r79812 - r79814;
        double r79816 = sqrt(r79815);
        double r79817 = r79816 - r79803;
        double r79818 = r79807 / r79817;
        double r79819 = 2.8568501197790958e+109;
        bool r79820 = r79803 <= r79819;
        double r79821 = -r79803;
        double r79822 = r79821 - r79816;
        double r79823 = 1.0;
        double r79824 = r79823 / r79813;
        double r79825 = r79822 * r79824;
        double r79826 = -2.0;
        double r79827 = r79826 * r79803;
        double r79828 = r79827 / r79813;
        double r79829 = r79820 ? r79825 : r79828;
        double r79830 = r79811 ? r79818 : r79829;
        double r79831 = r79805 ? r79809 : r79830;
        return r79831;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -2.61268387266151e+141

    1. Initial program 62.7

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

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

    if -2.61268387266151e+141 < b_2 < 2.5402182456312607e-243

    1. Initial program 32.8

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

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

      \[\leadsto \frac{\frac{a \cdot c + b_2 \cdot \left(b_2 - b_2\right)}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied div-inv15.9

      \[\leadsto \color{blue}{\frac{a \cdot c + b_2 \cdot \left(b_2 - b_2\right)}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2} \cdot \frac{1}{a}}\]
    8. Using strategy rm
    9. Applied associate-*l/14.6

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

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

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

    if 2.5402182456312607e-243 < b_2 < 2.8568501197790958e+109

    1. Initial program 8.7

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

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

    if 2.8568501197790958e+109 < b_2

    1. Initial program 49.0

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

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

      \[\leadsto \frac{\frac{a \cdot c + b_2 \cdot \left(b_2 - b_2\right)}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Taylor expanded around 0 3.6

      \[\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.61268387266151013 \cdot 10^{141}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 2.5402182456312607 \cdot 10^{-243}:\\ \;\;\;\;\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\\ \mathbf{elif}\;b_2 \le 2.8568501197790958 \cdot 10^{109}:\\ \;\;\;\;\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot b_2}{a}\\ \end{array}\]

Reproduce

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