Average Error: 34.1 → 7.1
Time: 8.0s
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.32792716898209886 \cdot 10^{29}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le -1.0853211705499398 \cdot 10^{-278}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-\sqrt[3]{b_2} \cdot \sqrt[3]{b_2}, \sqrt[3]{b_2}, \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{a}\\ \mathbf{elif}\;b_2 \le 1.67192499022346934 \cdot 10^{111}:\\ \;\;\;\;1 \cdot \left(\frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot c\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \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.32792716898209886 \cdot 10^{29}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\

\mathbf{elif}\;b_2 \le -1.0853211705499398 \cdot 10^{-278}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-\sqrt[3]{b_2} \cdot \sqrt[3]{b_2}, \sqrt[3]{b_2}, \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{a}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r28067 = b_2;
        double r28068 = -r28067;
        double r28069 = r28067 * r28067;
        double r28070 = a;
        double r28071 = c;
        double r28072 = r28070 * r28071;
        double r28073 = r28069 - r28072;
        double r28074 = sqrt(r28073);
        double r28075 = r28068 + r28074;
        double r28076 = r28075 / r28070;
        return r28076;
}

double f(double a, double b_2, double c) {
        double r28077 = b_2;
        double r28078 = -1.3279271689820989e+29;
        bool r28079 = r28077 <= r28078;
        double r28080 = 0.5;
        double r28081 = c;
        double r28082 = r28081 / r28077;
        double r28083 = r28080 * r28082;
        double r28084 = 2.0;
        double r28085 = a;
        double r28086 = r28077 / r28085;
        double r28087 = r28084 * r28086;
        double r28088 = r28083 - r28087;
        double r28089 = -1.0853211705499398e-278;
        bool r28090 = r28077 <= r28089;
        double r28091 = cbrt(r28077);
        double r28092 = r28091 * r28091;
        double r28093 = -r28092;
        double r28094 = r28077 * r28077;
        double r28095 = r28085 * r28081;
        double r28096 = r28094 - r28095;
        double r28097 = sqrt(r28096);
        double r28098 = fma(r28093, r28091, r28097);
        double r28099 = r28098 / r28085;
        double r28100 = 1.6719249902234693e+111;
        bool r28101 = r28077 <= r28100;
        double r28102 = 1.0;
        double r28103 = -r28077;
        double r28104 = r28103 - r28097;
        double r28105 = r28102 / r28104;
        double r28106 = r28105 * r28081;
        double r28107 = r28102 * r28106;
        double r28108 = -0.5;
        double r28109 = r28108 * r28082;
        double r28110 = r28101 ? r28107 : r28109;
        double r28111 = r28090 ? r28099 : r28110;
        double r28112 = r28079 ? r28088 : r28111;
        return r28112;
}

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.3279271689820989e+29

    1. Initial program 35.8

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

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

    if -1.3279271689820989e+29 < b_2 < -1.0853211705499398e-278

    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 add-cube-cbrt9.5

      \[\leadsto \frac{\left(-\color{blue}{\left(\sqrt[3]{b_2} \cdot \sqrt[3]{b_2}\right) \cdot \sqrt[3]{b_2}}\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    4. Applied distribute-lft-neg-in9.5

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

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

    if -1.0853211705499398e-278 < b_2 < 1.6719249902234693e+111

    1. Initial program 32.0

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

      \[\leadsto \frac{\frac{\color{blue}{0 + a \cdot c}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity16.4

      \[\leadsto \frac{\frac{0 + a \cdot c}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{\color{blue}{1 \cdot a}}\]
    7. Applied associate-/r*16.4

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

      \[\leadsto \frac{\color{blue}{\frac{a}{\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{c}}}}{a}\]
    9. Using strategy rm
    10. Applied associate-/r/15.3

      \[\leadsto \frac{\color{blue}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot c}}{a}\]
    11. Applied associate-/l*24.3

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

      \[\leadsto \frac{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{\color{blue}{a \cdot \frac{1}{c}}}\]
    14. Applied div-inv24.4

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

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

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

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

    if 1.6719249902234693e+111 < b_2

    1. Initial program 60.0

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

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b_2}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification7.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.32792716898209886 \cdot 10^{29}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le -1.0853211705499398 \cdot 10^{-278}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-\sqrt[3]{b_2} \cdot \sqrt[3]{b_2}, \sqrt[3]{b_2}, \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{a}\\ \mathbf{elif}\;b_2 \le 1.67192499022346934 \cdot 10^{111}:\\ \;\;\;\;1 \cdot \left(\frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot c\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

herbie shell --seed 2020081 +o rules:numerics
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  :precision binary64
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))