Average Error: 34.0 → 9.2
Time: 25.2s
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 -5.260570947330360464594776218624123716053 \cdot 10^{-14}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.607074818869120297163406991470356321958 \cdot 10^{-204}:\\ \;\;\;\;\frac{\frac{c \cdot a}{\mathsf{fma}\left(\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}, \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}, -b_2\right)}}{a}\\ \mathbf{elif}\;b_2 \le 1.673851663574979563728921105654267462341 \cdot 10^{107}:\\ \;\;\;\;\frac{-\left(b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{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 -5.260570947330360464594776218624123716053 \cdot 10^{-14}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

\mathbf{elif}\;b_2 \le 1.673851663574979563728921105654267462341 \cdot 10^{107}:\\
\;\;\;\;\frac{-\left(b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{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 r2436629 = b_2;
        double r2436630 = -r2436629;
        double r2436631 = r2436629 * r2436629;
        double r2436632 = a;
        double r2436633 = c;
        double r2436634 = r2436632 * r2436633;
        double r2436635 = r2436631 - r2436634;
        double r2436636 = sqrt(r2436635);
        double r2436637 = r2436630 - r2436636;
        double r2436638 = r2436637 / r2436632;
        return r2436638;
}

double f(double a, double b_2, double c) {
        double r2436639 = b_2;
        double r2436640 = -5.2605709473303605e-14;
        bool r2436641 = r2436639 <= r2436640;
        double r2436642 = -0.5;
        double r2436643 = c;
        double r2436644 = r2436643 / r2436639;
        double r2436645 = r2436642 * r2436644;
        double r2436646 = -1.6070748188691203e-204;
        bool r2436647 = r2436639 <= r2436646;
        double r2436648 = a;
        double r2436649 = r2436643 * r2436648;
        double r2436650 = r2436639 * r2436639;
        double r2436651 = r2436648 * r2436643;
        double r2436652 = r2436650 - r2436651;
        double r2436653 = sqrt(r2436652);
        double r2436654 = sqrt(r2436653);
        double r2436655 = -r2436639;
        double r2436656 = fma(r2436654, r2436654, r2436655);
        double r2436657 = r2436649 / r2436656;
        double r2436658 = r2436657 / r2436648;
        double r2436659 = 1.6738516635749796e+107;
        bool r2436660 = r2436639 <= r2436659;
        double r2436661 = r2436639 + r2436653;
        double r2436662 = -r2436661;
        double r2436663 = r2436662 / r2436648;
        double r2436664 = 0.5;
        double r2436665 = r2436639 / r2436648;
        double r2436666 = -2.0;
        double r2436667 = r2436665 * r2436666;
        double r2436668 = fma(r2436644, r2436664, r2436667);
        double r2436669 = r2436660 ? r2436663 : r2436668;
        double r2436670 = r2436647 ? r2436658 : r2436669;
        double r2436671 = r2436641 ? r2436645 : r2436670;
        return r2436671;
}

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 < -5.2605709473303605e-14

    1. Initial program 55.9

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

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

    if -5.2605709473303605e-14 < b_2 < -1.6070748188691203e-204

    1. Initial program 30.0

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt30.0

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    4. Applied sqrt-prod30.3

      \[\leadsto \frac{\left(-b_2\right) - \color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    5. Using strategy rm
    6. Applied flip--30.3

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

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

      \[\leadsto \frac{\frac{0 + a \cdot c}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    9. Using strategy rm
    10. Applied add-sqr-sqrt18.7

      \[\leadsto \frac{\frac{0 + a \cdot c}{\sqrt{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}} - b_2}}{a}\]
    11. Applied sqrt-prod18.9

      \[\leadsto \frac{\frac{0 + a \cdot c}{\color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}} - b_2}}{a}\]
    12. Applied fma-neg18.9

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

    if -1.6070748188691203e-204 < b_2 < 1.6738516635749796e+107

    1. Initial program 10.7

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt10.7

      \[\leadsto \frac{\left(-b_2\right) - \sqrt{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    4. Applied sqrt-prod10.9

      \[\leadsto \frac{\left(-b_2\right) - \color{blue}{\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    5. Using strategy rm
    6. Applied neg-sub010.9

      \[\leadsto \frac{\color{blue}{\left(0 - b_2\right)} - \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    7. Applied associate--l-10.9

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

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

    if 1.6738516635749796e+107 < b_2

    1. Initial program 48.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -5.260570947330360464594776218624123716053 \cdot 10^{-14}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -1.607074818869120297163406991470356321958 \cdot 10^{-204}:\\ \;\;\;\;\frac{\frac{c \cdot a}{\mathsf{fma}\left(\sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}, \sqrt{\sqrt{b_2 \cdot b_2 - a \cdot c}}, -b_2\right)}}{a}\\ \mathbf{elif}\;b_2 \le 1.673851663574979563728921105654267462341 \cdot 10^{107}:\\ \;\;\;\;\frac{-\left(b_2 + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{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 2019173 +o rules:numerics
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))