Average Error: 34.4 → 10.2
Time: 21.1s
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}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 9.136492990928292133394320076175633285536 \cdot 10^{-23}:\\ \;\;\;\;\frac{{\left(b_2 \cdot b_2 - c \cdot a\right)}^{\frac{1}{2}} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{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}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r845567 = b_2;
        double r845568 = -r845567;
        double r845569 = r845567 * r845567;
        double r845570 = a;
        double r845571 = c;
        double r845572 = r845570 * r845571;
        double r845573 = r845569 - r845572;
        double r845574 = sqrt(r845573);
        double r845575 = r845568 + r845574;
        double r845576 = r845575 / r845570;
        return r845576;
}

double f(double a, double b_2, double c) {
        double r845577 = b_2;
        double r845578 = -1.7633154797394035e+89;
        bool r845579 = r845577 <= r845578;
        double r845580 = 0.5;
        double r845581 = c;
        double r845582 = r845581 / r845577;
        double r845583 = r845580 * r845582;
        double r845584 = a;
        double r845585 = r845577 / r845584;
        double r845586 = 2.0;
        double r845587 = r845585 * r845586;
        double r845588 = r845583 - r845587;
        double r845589 = 9.136492990928292e-23;
        bool r845590 = r845577 <= r845589;
        double r845591 = r845577 * r845577;
        double r845592 = r845581 * r845584;
        double r845593 = r845591 - r845592;
        double r845594 = pow(r845593, r845580);
        double r845595 = r845594 - r845577;
        double r845596 = r845595 / r845584;
        double r845597 = -0.5;
        double r845598 = r845582 * r845597;
        double r845599 = r845590 ? r845596 : r845598;
        double r845600 = r845579 ? r845588 : r845599;
        return r845600;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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}}\]

    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}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 9.136492990928292133394320076175633285536 \cdot 10^{-23}:\\ \;\;\;\;\frac{{\left(b_2 \cdot b_2 - c \cdot a\right)}^{\frac{1}{2}} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

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