Average Error: 33.0 → 6.6
Time: 54.6s
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.6132838954875548 \cdot 10^{+123}:\\ \;\;\;\;\frac{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(b_2 \cdot -2\right))_*}{a}\\ \mathbf{elif}\;b_2 \le 8.739177505388864 \cdot 10^{-295}:\\ \;\;\;\;\frac{1}{a} \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)\\ \mathbf{elif}\;b_2 \le 1.3663379345323562 \cdot 10^{+91}:\\ \;\;\;\;\frac{-c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + 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 -1.6132838954875548 \cdot 10^{+123}:\\
\;\;\;\;\frac{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(b_2 \cdot -2\right))_*}{a}\\

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

\mathbf{elif}\;b_2 \le 1.3663379345323562 \cdot 10^{+91}:\\
\;\;\;\;\frac{-c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\\

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

\end{array}
double f(double a, double b_2, double c) {
        double r1747552 = b_2;
        double r1747553 = -r1747552;
        double r1747554 = r1747552 * r1747552;
        double r1747555 = a;
        double r1747556 = c;
        double r1747557 = r1747555 * r1747556;
        double r1747558 = r1747554 - r1747557;
        double r1747559 = sqrt(r1747558);
        double r1747560 = r1747553 + r1747559;
        double r1747561 = r1747560 / r1747555;
        return r1747561;
}

double f(double a, double b_2, double c) {
        double r1747562 = b_2;
        double r1747563 = -1.6132838954875548e+123;
        bool r1747564 = r1747562 <= r1747563;
        double r1747565 = 0.5;
        double r1747566 = a;
        double r1747567 = c;
        double r1747568 = r1747562 / r1747567;
        double r1747569 = r1747566 / r1747568;
        double r1747570 = -2.0;
        double r1747571 = r1747562 * r1747570;
        double r1747572 = fma(r1747565, r1747569, r1747571);
        double r1747573 = r1747572 / r1747566;
        double r1747574 = 8.739177505388864e-295;
        bool r1747575 = r1747562 <= r1747574;
        double r1747576 = 1.0;
        double r1747577 = r1747576 / r1747566;
        double r1747578 = r1747562 * r1747562;
        double r1747579 = r1747566 * r1747567;
        double r1747580 = r1747578 - r1747579;
        double r1747581 = sqrt(r1747580);
        double r1747582 = r1747581 - r1747562;
        double r1747583 = r1747577 * r1747582;
        double r1747584 = 1.3663379345323562e+91;
        bool r1747585 = r1747562 <= r1747584;
        double r1747586 = -r1747567;
        double r1747587 = r1747581 + r1747562;
        double r1747588 = r1747586 / r1747587;
        double r1747589 = -0.5;
        double r1747590 = r1747567 / r1747562;
        double r1747591 = r1747589 * r1747590;
        double r1747592 = r1747585 ? r1747588 : r1747591;
        double r1747593 = r1747575 ? r1747583 : r1747592;
        double r1747594 = r1747564 ? r1747573 : r1747593;
        return r1747594;
}

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.6132838954875548e+123

    1. Initial program 49.2

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

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

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

      \[\leadsto \frac{\color{blue}{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(-2 \cdot b_2\right))_*}}{a}\]

    if -1.6132838954875548e+123 < b_2 < 8.739177505388864e-295

    1. Initial program 8.8

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

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

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

    if 8.739177505388864e-295 < b_2 < 1.3663379345323562e+91

    1. Initial program 32.6

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity32.6

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)}}{a}\]
    5. Applied associate-/l*32.6

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

      \[\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}}}}\]
    8. Applied associate-/r/32.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)}}\]
    9. Applied add-sqr-sqrt32.7

      \[\leadsto \frac{\color{blue}{\sqrt{1} \cdot \sqrt{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)}\]
    10. Applied times-frac32.8

      \[\leadsto \color{blue}{\frac{\sqrt{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{1}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}\]
    11. Simplified16.2

      \[\leadsto \color{blue}{\frac{0 - a \cdot c}{a}} \cdot \frac{\sqrt{1}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    12. Simplified16.2

      \[\leadsto \frac{0 - a \cdot c}{a} \cdot \color{blue}{\frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}\]
    13. Taylor expanded around -inf 9.2

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

      \[\leadsto \color{blue}{\left(-c\right)} \cdot \frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    15. Using strategy rm
    16. Applied distribute-lft-neg-out9.2

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

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

    if 1.3663379345323562e+91 < b_2

    1. Initial program 58.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.6132838954875548 \cdot 10^{+123}:\\ \;\;\;\;\frac{(\frac{1}{2} \cdot \left(\frac{a}{\frac{b_2}{c}}\right) + \left(b_2 \cdot -2\right))_*}{a}\\ \mathbf{elif}\;b_2 \le 8.739177505388864 \cdot 10^{-295}:\\ \;\;\;\;\frac{1}{a} \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)\\ \mathbf{elif}\;b_2 \le 1.3663379345323562 \cdot 10^{+91}:\\ \;\;\;\;\frac{-c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

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