Average Error: 34.4 → 10.2
Time: 21.3s
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.763315479739403460017265344144602342789 \cdot 10^{89}:\\ \;\;\;\;\mathsf{fma}\left(\frac{b_2}{a}, -2, \frac{c \cdot \frac{1}{2}}{b_2}\right)\\ \mathbf{elif}\;b_2 \le 9.136492990928292133394320076175633285536 \cdot 10^{-23}:\\ \;\;\;\;\frac{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{\frac{1}{2}} - b_2}{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 -1.763315479739403460017265344144602342789 \cdot 10^{89}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b_2}{a}, -2, \frac{c \cdot \frac{1}{2}}{b_2}\right)\\

\mathbf{elif}\;b_2 \le 9.136492990928292133394320076175633285536 \cdot 10^{-23}:\\
\;\;\;\;\frac{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{\frac{1}{2}} - b_2}{a}\\

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

\end{array}
double f(double a, double b_2, double c) {
        double r652274 = b_2;
        double r652275 = -r652274;
        double r652276 = r652274 * r652274;
        double r652277 = a;
        double r652278 = c;
        double r652279 = r652277 * r652278;
        double r652280 = r652276 - r652279;
        double r652281 = sqrt(r652280);
        double r652282 = r652275 + r652281;
        double r652283 = r652282 / r652277;
        return r652283;
}

double f(double a, double b_2, double c) {
        double r652284 = b_2;
        double r652285 = -1.7633154797394035e+89;
        bool r652286 = r652284 <= r652285;
        double r652287 = a;
        double r652288 = r652284 / r652287;
        double r652289 = -2.0;
        double r652290 = c;
        double r652291 = 0.5;
        double r652292 = r652290 * r652291;
        double r652293 = r652292 / r652284;
        double r652294 = fma(r652288, r652289, r652293);
        double r652295 = 9.136492990928292e-23;
        bool r652296 = r652284 <= r652295;
        double r652297 = r652284 * r652284;
        double r652298 = r652287 * r652290;
        double r652299 = r652297 - r652298;
        double r652300 = pow(r652299, r652291);
        double r652301 = r652300 - r652284;
        double r652302 = r652301 / r652287;
        double r652303 = -0.5;
        double r652304 = r652290 / r652284;
        double r652305 = r652303 * r652304;
        double r652306 = r652296 ? r652302 : r652305;
        double r652307 = r652286 ? r652294 : r652306;
        return r652307;
}

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 < -1.7633154797394035e+89

    1. Initial program 45.7

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

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

      \[\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{b_2}{a}, -2, \frac{\frac{1}{2} \cdot c}{b_2}\right)}\]

    if -1.7633154797394035e+89 < b_2 < 9.136492990928292e-23

    1. Initial program 15.0

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{\left(\sqrt[3]{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt[3]{b_2 \cdot b_2 - a \cdot c}\right) \cdot \sqrt[3]{b_2 \cdot b_2 - a \cdot c}}} - b_2}{a}\]
    5. Using strategy rm
    6. Applied pow1/317.5

      \[\leadsto \frac{\sqrt{\left(\sqrt[3]{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt[3]{b_2 \cdot b_2 - a \cdot c}\right) \cdot \color{blue}{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{\frac{1}{3}}}} - b_2}{a}\]
    7. Applied pow1/318.2

      \[\leadsto \frac{\sqrt{\left(\sqrt[3]{b_2 \cdot b_2 - a \cdot c} \cdot \color{blue}{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{\frac{1}{3}}}\right) \cdot {\left(b_2 \cdot b_2 - a \cdot c\right)}^{\frac{1}{3}}} - b_2}{a}\]
    8. Applied pow1/318.6

      \[\leadsto \frac{\sqrt{\left(\color{blue}{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{\frac{1}{3}}} \cdot {\left(b_2 \cdot b_2 - a \cdot c\right)}^{\frac{1}{3}}\right) \cdot {\left(b_2 \cdot b_2 - a \cdot c\right)}^{\frac{1}{3}}} - b_2}{a}\]
    9. Applied pow-prod-up18.6

      \[\leadsto \frac{\sqrt{\color{blue}{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{\left(\frac{1}{3} + \frac{1}{3}\right)}} \cdot {\left(b_2 \cdot b_2 - a \cdot c\right)}^{\frac{1}{3}}} - b_2}{a}\]
    10. Applied pow-prod-up15.0

      \[\leadsto \frac{\sqrt{\color{blue}{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{\left(\left(\frac{1}{3} + \frac{1}{3}\right) + \frac{1}{3}\right)}}} - b_2}{a}\]
    11. Applied sqrt-pow115.0

      \[\leadsto \frac{\color{blue}{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{\left(\frac{\left(\frac{1}{3} + \frac{1}{3}\right) + \frac{1}{3}}{2}\right)}} - b_2}{a}\]
    12. Simplified15.0

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

    if 9.136492990928292e-23 < b_2

    1. Initial program 55.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.763315479739403460017265344144602342789 \cdot 10^{89}:\\ \;\;\;\;\mathsf{fma}\left(\frac{b_2}{a}, -2, \frac{c \cdot \frac{1}{2}}{b_2}\right)\\ \mathbf{elif}\;b_2 \le 9.136492990928292133394320076175633285536 \cdot 10^{-23}:\\ \;\;\;\;\frac{{\left(b_2 \cdot b_2 - a \cdot c\right)}^{\frac{1}{2}} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

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