Average Error: 34.2 → 10.4
Time: 14.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 -4.12310353364421125 \cdot 10^{95}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2 \cdot -2}{a}\right)\\ \mathbf{elif}\;b_2 \le 3.446447862996811 \cdot 10^{-75}:\\ \;\;\;\;\frac{1}{\frac{a}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}\\ \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 -4.12310353364421125 \cdot 10^{95}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2 \cdot -2}{a}\right)\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r16747 = b_2;
        double r16748 = -r16747;
        double r16749 = r16747 * r16747;
        double r16750 = a;
        double r16751 = c;
        double r16752 = r16750 * r16751;
        double r16753 = r16749 - r16752;
        double r16754 = sqrt(r16753);
        double r16755 = r16748 + r16754;
        double r16756 = r16755 / r16750;
        return r16756;
}

double f(double a, double b_2, double c) {
        double r16757 = b_2;
        double r16758 = -4.123103533644211e+95;
        bool r16759 = r16757 <= r16758;
        double r16760 = c;
        double r16761 = r16760 / r16757;
        double r16762 = 0.5;
        double r16763 = -2.0;
        double r16764 = r16757 * r16763;
        double r16765 = a;
        double r16766 = r16764 / r16765;
        double r16767 = fma(r16761, r16762, r16766);
        double r16768 = 3.446447862996811e-75;
        bool r16769 = r16757 <= r16768;
        double r16770 = 1.0;
        double r16771 = r16760 * r16765;
        double r16772 = -r16771;
        double r16773 = fma(r16757, r16757, r16772);
        double r16774 = sqrt(r16773);
        double r16775 = r16774 - r16757;
        double r16776 = r16765 / r16775;
        double r16777 = r16770 / r16776;
        double r16778 = -0.5;
        double r16779 = r16778 * r16761;
        double r16780 = r16769 ? r16777 : r16779;
        double r16781 = r16759 ? r16767 : r16780;
        return r16781;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b_2 < -4.123103533644211e+95

    1. Initial program 47.3

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified47.3

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around -inf 3.8

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

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

    if -4.123103533644211e+95 < b_2 < 3.446447862996811e-75

    1. Initial program 13.3

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified13.3

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied clear-num13.4

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    5. Using strategy rm
    6. Applied clear-num13.4

      \[\leadsto \color{blue}{\frac{1}{\frac{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{1}}}\]
    7. Simplified13.4

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

    if 3.446447862996811e-75 < b_2

    1. Initial program 52.5

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around inf 9.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -4.12310353364421125 \cdot 10^{95}:\\ \;\;\;\;\mathsf{fma}\left(\frac{c}{b_2}, \frac{1}{2}, \frac{b_2 \cdot -2}{a}\right)\\ \mathbf{elif}\;b_2 \le 3.446447862996811 \cdot 10^{-75}:\\ \;\;\;\;\frac{1}{\frac{a}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

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