Average Error: 33.0 → 10.8
Time: 17.8s
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 -2.782434836873191 \cdot 10^{+41}:\\ \;\;\;\;\mathsf{fma}\left(-2, \frac{b_2}{a}, \frac{c}{b_2} \cdot \frac{1}{2}\right)\\ \mathbf{elif}\;b_2 \le 1.990519652731023 \cdot 10^{-106}:\\ \;\;\;\;\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}\\ \mathbf{elif}\;b_2 \le 1.0350377446088803 \cdot 10^{-69}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 3.325219738594455 \cdot 10^{-21}:\\ \;\;\;\;\frac{1}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2} \cdot \frac{b_2 \cdot b_2 - \mathsf{fma}\left(a, c, b_2 \cdot b_2\right)}{a}\\ \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 -2.782434836873191 \cdot 10^{+41}:\\
\;\;\;\;\mathsf{fma}\left(-2, \frac{b_2}{a}, \frac{c}{b_2} \cdot \frac{1}{2}\right)\\

\mathbf{elif}\;b_2 \le 1.990519652731023 \cdot 10^{-106}:\\
\;\;\;\;\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}\\

\mathbf{elif}\;b_2 \le 1.0350377446088803 \cdot 10^{-69}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r748700 = b_2;
        double r748701 = -r748700;
        double r748702 = r748700 * r748700;
        double r748703 = a;
        double r748704 = c;
        double r748705 = r748703 * r748704;
        double r748706 = r748702 - r748705;
        double r748707 = sqrt(r748706);
        double r748708 = r748701 + r748707;
        double r748709 = r748708 / r748703;
        return r748709;
}

double f(double a, double b_2, double c) {
        double r748710 = b_2;
        double r748711 = -2.782434836873191e+41;
        bool r748712 = r748710 <= r748711;
        double r748713 = -2.0;
        double r748714 = a;
        double r748715 = r748710 / r748714;
        double r748716 = c;
        double r748717 = r748716 / r748710;
        double r748718 = 0.5;
        double r748719 = r748717 * r748718;
        double r748720 = fma(r748713, r748715, r748719);
        double r748721 = 1.990519652731023e-106;
        bool r748722 = r748710 <= r748721;
        double r748723 = 1.0;
        double r748724 = r748710 * r748710;
        double r748725 = r748716 * r748714;
        double r748726 = r748724 - r748725;
        double r748727 = sqrt(r748726);
        double r748728 = r748727 - r748710;
        double r748729 = r748714 / r748728;
        double r748730 = r748723 / r748729;
        double r748731 = 1.0350377446088803e-69;
        bool r748732 = r748710 <= r748731;
        double r748733 = -0.5;
        double r748734 = r748733 * r748717;
        double r748735 = 3.325219738594455e-21;
        bool r748736 = r748710 <= r748735;
        double r748737 = r748727 + r748710;
        double r748738 = r748723 / r748737;
        double r748739 = fma(r748714, r748716, r748724);
        double r748740 = r748724 - r748739;
        double r748741 = r748740 / r748714;
        double r748742 = r748738 * r748741;
        double r748743 = r748736 ? r748742 : r748734;
        double r748744 = r748732 ? r748734 : r748743;
        double r748745 = r748722 ? r748730 : r748744;
        double r748746 = r748712 ? r748720 : r748745;
        return r748746;
}

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 < -2.782434836873191e+41

    1. Initial program 34.1

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

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

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

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

    if -2.782434836873191e+41 < b_2 < 1.990519652731023e-106

    1. Initial program 12.8

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity12.9

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

    if 1.990519652731023e-106 < b_2 < 1.0350377446088803e-69 or 3.325219738594455e-21 < b_2

    1. Initial program 53.0

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

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

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

    if 1.0350377446088803e-69 < b_2 < 3.325219738594455e-21

    1. Initial program 35.5

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

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

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

      \[\leadsto \frac{1}{\frac{a}{\color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}}}\]
    7. Applied associate-/r/35.7

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2} \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}}\]
    8. Applied add-cube-cbrt35.7

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}} \cdot \frac{\sqrt[3]{1}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}\]
    10. Simplified35.6

      \[\leadsto \color{blue}{\frac{b_2 \cdot b_2 - \mathsf{fma}\left(a, c, b_2 \cdot b_2\right)}{a}} \cdot \frac{\sqrt[3]{1}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    11. Simplified35.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2.782434836873191 \cdot 10^{+41}:\\ \;\;\;\;\mathsf{fma}\left(-2, \frac{b_2}{a}, \frac{c}{b_2} \cdot \frac{1}{2}\right)\\ \mathbf{elif}\;b_2 \le 1.990519652731023 \cdot 10^{-106}:\\ \;\;\;\;\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}}\\ \mathbf{elif}\;b_2 \le 1.0350377446088803 \cdot 10^{-69}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 3.325219738594455 \cdot 10^{-21}:\\ \;\;\;\;\frac{1}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2} \cdot \frac{b_2 \cdot b_2 - \mathsf{fma}\left(a, c, b_2 \cdot b_2\right)}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

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