Average Error: 34.4 → 8.4
Time: 44.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 -3.234164035284793 \cdot 10^{+22}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -2.4242286502051438 \cdot 10^{-135}:\\ \;\;\;\;\frac{\frac{a \cdot c + \left(b_2 \cdot b_2 - b_2 \cdot b_2\right)}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}\\ \mathbf{elif}\;b_2 \le 1.7205132563858266 \cdot 10^{+103}:\\ \;\;\;\;\frac{1}{a} \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{b_2}{a}, -2, \frac{c}{b_2} \cdot \frac{1}{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 -3.234164035284793 \cdot 10^{+22}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\mathbf{elif}\;b_2 \le -2.4242286502051438 \cdot 10^{-135}:\\
\;\;\;\;\frac{\frac{a \cdot c + \left(b_2 \cdot b_2 - b_2 \cdot b_2\right)}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b_2}{a}, -2, \frac{c}{b_2} \cdot \frac{1}{2}\right)\\

\end{array}
double f(double a, double b_2, double c) {
        double r1042826 = b_2;
        double r1042827 = -r1042826;
        double r1042828 = r1042826 * r1042826;
        double r1042829 = a;
        double r1042830 = c;
        double r1042831 = r1042829 * r1042830;
        double r1042832 = r1042828 - r1042831;
        double r1042833 = sqrt(r1042832);
        double r1042834 = r1042827 - r1042833;
        double r1042835 = r1042834 / r1042829;
        return r1042835;
}

double f(double a, double b_2, double c) {
        double r1042836 = b_2;
        double r1042837 = -3.234164035284793e+22;
        bool r1042838 = r1042836 <= r1042837;
        double r1042839 = -0.5;
        double r1042840 = c;
        double r1042841 = r1042840 / r1042836;
        double r1042842 = r1042839 * r1042841;
        double r1042843 = -2.4242286502051438e-135;
        bool r1042844 = r1042836 <= r1042843;
        double r1042845 = a;
        double r1042846 = r1042845 * r1042840;
        double r1042847 = r1042836 * r1042836;
        double r1042848 = r1042847 - r1042847;
        double r1042849 = r1042846 + r1042848;
        double r1042850 = r1042847 - r1042846;
        double r1042851 = sqrt(r1042850);
        double r1042852 = r1042851 - r1042836;
        double r1042853 = r1042849 / r1042852;
        double r1042854 = r1042853 / r1042845;
        double r1042855 = 1.7205132563858266e+103;
        bool r1042856 = r1042836 <= r1042855;
        double r1042857 = 1.0;
        double r1042858 = r1042857 / r1042845;
        double r1042859 = -r1042836;
        double r1042860 = r1042859 - r1042851;
        double r1042861 = r1042858 * r1042860;
        double r1042862 = r1042836 / r1042845;
        double r1042863 = -2.0;
        double r1042864 = 0.5;
        double r1042865 = r1042841 * r1042864;
        double r1042866 = fma(r1042862, r1042863, r1042865);
        double r1042867 = r1042856 ? r1042861 : r1042866;
        double r1042868 = r1042844 ? r1042854 : r1042867;
        double r1042869 = r1042838 ? r1042842 : r1042868;
        return r1042869;
}

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 < -3.234164035284793e+22

    1. Initial program 56.6

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

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

    if -3.234164035284793e+22 < b_2 < -2.4242286502051438e-135

    1. Initial program 36.2

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

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

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

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

    if -2.4242286502051438e-135 < b_2 < 1.7205132563858266e+103

    1. Initial program 11.1

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

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

    if 1.7205132563858266e+103 < b_2

    1. Initial program 47.4

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -3.234164035284793 \cdot 10^{+22}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le -2.4242286502051438 \cdot 10^{-135}:\\ \;\;\;\;\frac{\frac{a \cdot c + \left(b_2 \cdot b_2 - b_2 \cdot b_2\right)}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}\\ \mathbf{elif}\;b_2 \le 1.7205132563858266 \cdot 10^{+103}:\\ \;\;\;\;\frac{1}{a} \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{b_2}{a}, -2, \frac{c}{b_2} \cdot \frac{1}{2}\right)\\ \end{array}\]

Reproduce

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