Average Error: 33.7 → 6.7
Time: 10.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 -3.12428337420519208 \cdot 10^{57}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le -1.273959369302109 \cdot 10^{-247}:\\ \;\;\;\;\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{elif}\;b_2 \le 4.1445535679869069 \cdot 10^{60}:\\ \;\;\;\;\frac{c}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \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 -3.12428337420519208 \cdot 10^{57}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\

\mathbf{elif}\;b_2 \le -1.273959369302109 \cdot 10^{-247}:\\
\;\;\;\;\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r18549 = b_2;
        double r18550 = -r18549;
        double r18551 = r18549 * r18549;
        double r18552 = a;
        double r18553 = c;
        double r18554 = r18552 * r18553;
        double r18555 = r18551 - r18554;
        double r18556 = sqrt(r18555);
        double r18557 = r18550 + r18556;
        double r18558 = r18557 / r18552;
        return r18558;
}

double f(double a, double b_2, double c) {
        double r18559 = b_2;
        double r18560 = -3.124283374205192e+57;
        bool r18561 = r18559 <= r18560;
        double r18562 = 0.5;
        double r18563 = c;
        double r18564 = r18563 / r18559;
        double r18565 = r18562 * r18564;
        double r18566 = 2.0;
        double r18567 = a;
        double r18568 = r18559 / r18567;
        double r18569 = r18566 * r18568;
        double r18570 = r18565 - r18569;
        double r18571 = -1.273959369302109e-247;
        bool r18572 = r18559 <= r18571;
        double r18573 = -r18559;
        double r18574 = r18559 * r18559;
        double r18575 = r18567 * r18563;
        double r18576 = r18574 - r18575;
        double r18577 = sqrt(r18576);
        double r18578 = r18573 + r18577;
        double r18579 = r18578 / r18567;
        double r18580 = 4.144553567986907e+60;
        bool r18581 = r18559 <= r18580;
        double r18582 = r18573 - r18577;
        double r18583 = r18563 / r18582;
        double r18584 = -0.5;
        double r18585 = r18584 * r18564;
        double r18586 = r18581 ? r18583 : r18585;
        double r18587 = r18572 ? r18579 : r18586;
        double r18588 = r18561 ? r18570 : r18587;
        return r18588;
}

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 4 regimes
  2. if b_2 < -3.124283374205192e+57

    1. Initial program 39.4

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

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

    if -3.124283374205192e+57 < b_2 < -1.273959369302109e-247

    1. Initial program 8.1

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

    if -1.273959369302109e-247 < b_2 < 4.144553567986907e+60

    1. Initial program 28.1

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip-+28.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. Simplified16.5

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

      \[\leadsto \color{blue}{\frac{0 + a \cdot c}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \frac{1}{a}}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity16.6

      \[\leadsto \frac{0 + a \cdot c}{\color{blue}{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}} \cdot \frac{1}{a}\]
    9. Applied *-un-lft-identity16.6

      \[\leadsto \frac{\color{blue}{1 \cdot \left(0 + a \cdot c\right)}}{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)} \cdot \frac{1}{a}\]
    10. Applied times-frac16.6

      \[\leadsto \color{blue}{\left(\frac{1}{1} \cdot \frac{0 + a \cdot c}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}\right)} \cdot \frac{1}{a}\]
    11. Applied associate-*l*16.6

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

      \[\leadsto \frac{1}{1} \cdot \color{blue}{\frac{\frac{a \cdot c}{a}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\]
    13. Taylor expanded around 0 9.7

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

    if 4.144553567986907e+60 < b_2

    1. Initial program 58.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -3.12428337420519208 \cdot 10^{57}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le -1.273959369302109 \cdot 10^{-247}:\\ \;\;\;\;\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\ \mathbf{elif}\;b_2 \le 4.1445535679869069 \cdot 10^{60}:\\ \;\;\;\;\frac{c}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

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