Average Error: 34.5 → 6.7
Time: 9.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 -1.02458994604675516 \cdot 10^{154}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.87487110304695476 \cdot 10^{-219}:\\ \;\;\;\;\frac{c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\\ \mathbf{elif}\;b_2 \le 9.3479963141541371 \cdot 10^{42}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\\ \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 -1.02458994604675516 \cdot 10^{154}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

\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 r18722 = b_2;
        double r18723 = -r18722;
        double r18724 = r18722 * r18722;
        double r18725 = a;
        double r18726 = c;
        double r18727 = r18725 * r18726;
        double r18728 = r18724 - r18727;
        double r18729 = sqrt(r18728);
        double r18730 = r18723 - r18729;
        double r18731 = r18730 / r18725;
        return r18731;
}

double f(double a, double b_2, double c) {
        double r18732 = b_2;
        double r18733 = -1.0245899460467552e+154;
        bool r18734 = r18732 <= r18733;
        double r18735 = -0.5;
        double r18736 = c;
        double r18737 = r18736 / r18732;
        double r18738 = r18735 * r18737;
        double r18739 = 1.8748711030469548e-219;
        bool r18740 = r18732 <= r18739;
        double r18741 = a;
        double r18742 = r18736 * r18741;
        double r18743 = -r18742;
        double r18744 = fma(r18732, r18732, r18743);
        double r18745 = sqrt(r18744);
        double r18746 = r18745 - r18732;
        double r18747 = r18736 / r18746;
        double r18748 = 9.347996314154137e+42;
        bool r18749 = r18732 <= r18748;
        double r18750 = 1.0;
        double r18751 = -r18732;
        double r18752 = r18732 * r18732;
        double r18753 = r18741 * r18736;
        double r18754 = r18752 - r18753;
        double r18755 = sqrt(r18754);
        double r18756 = r18751 - r18755;
        double r18757 = r18741 / r18756;
        double r18758 = r18750 / r18757;
        double r18759 = 0.5;
        double r18760 = r18732 / r18741;
        double r18761 = -2.0;
        double r18762 = r18760 * r18761;
        double r18763 = fma(r18737, r18759, r18762);
        double r18764 = r18749 ? r18758 : r18763;
        double r18765 = r18740 ? r18747 : r18764;
        double r18766 = r18734 ? r18738 : r18765;
        return r18766;
}

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.0245899460467552e+154

    1. Initial program 64.0

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

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

    if -1.0245899460467552e+154 < b_2 < 1.8748711030469548e-219

    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. Simplified15.5

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

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

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

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

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

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

    if 1.8748711030469548e-219 < b_2 < 9.347996314154137e+42

    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 clear-num8.8

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

    if 9.347996314154137e+42 < b_2

    1. Initial program 37.1

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

      \[\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. Simplified60.8

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

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

      \[\leadsto \color{blue}{\frac{b_2 \cdot \left(b_2 - b_2\right) + a \cdot c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2} \cdot \frac{1}{a}}\]
    8. Taylor expanded around inf 5.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.02458994604675516 \cdot 10^{154}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.87487110304695476 \cdot 10^{-219}:\\ \;\;\;\;\frac{c}{\sqrt{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right)} - b_2}\\ \mathbf{elif}\;b_2 \le 9.3479963141541371 \cdot 10^{42}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\\ \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 2020043 +o rules:numerics
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))