Average Error: 33.7 → 10.1
Time: 7.5s
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{-2 \cdot b_2}{a}\\ \mathbf{elif}\;b_2 \le 3.84613441880260993 \cdot 10^{-81}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - 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 -3.12428337420519208 \cdot 10^{57}:\\
\;\;\;\;\frac{-2 \cdot b_2}{a}\\

\mathbf{elif}\;b_2 \le 3.84613441880260993 \cdot 10^{-81}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - 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 r15719 = b_2;
        double r15720 = -r15719;
        double r15721 = r15719 * r15719;
        double r15722 = a;
        double r15723 = c;
        double r15724 = r15722 * r15723;
        double r15725 = r15721 - r15724;
        double r15726 = sqrt(r15725);
        double r15727 = r15720 + r15726;
        double r15728 = r15727 / r15722;
        return r15728;
}

double f(double a, double b_2, double c) {
        double r15729 = b_2;
        double r15730 = -3.124283374205192e+57;
        bool r15731 = r15729 <= r15730;
        double r15732 = -2.0;
        double r15733 = r15732 * r15729;
        double r15734 = a;
        double r15735 = r15733 / r15734;
        double r15736 = 3.84613441880261e-81;
        bool r15737 = r15729 <= r15736;
        double r15738 = r15729 * r15729;
        double r15739 = c;
        double r15740 = r15734 * r15739;
        double r15741 = r15738 - r15740;
        double r15742 = sqrt(r15741);
        double r15743 = r15742 - r15729;
        double r15744 = r15743 / r15734;
        double r15745 = -0.5;
        double r15746 = r15739 / r15729;
        double r15747 = r15745 * r15746;
        double r15748 = r15737 ? r15744 : r15747;
        double r15749 = r15731 ? r15735 : r15748;
        return r15749;
}

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 < -3.124283374205192e+57

    1. Initial program 39.4

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

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

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

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

      \[\leadsto \color{blue}{{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right)}^{1}} \cdot {\left(\frac{1}{a}\right)}^{1}\]
    8. Applied pow-prod-down39.5

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

      \[\leadsto {\color{blue}{\left(\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\right)}}^{1}\]
    10. Using strategy rm
    11. Applied add-cube-cbrt39.6

      \[\leadsto {\left(\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}\right)}^{1}\]
    12. Applied sqrt-prod39.6

      \[\leadsto {\left(\frac{\color{blue}{\sqrt{\sqrt[3]{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt[3]{b_2 \cdot b_2 - a \cdot c}} \cdot \sqrt{\sqrt[3]{b_2 \cdot b_2 - a \cdot c}}} - b_2}{a}\right)}^{1}\]
    13. Applied fma-neg39.6

      \[\leadsto {\left(\frac{\color{blue}{\mathsf{fma}\left(\sqrt{\sqrt[3]{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt[3]{b_2 \cdot b_2 - a \cdot c}}, \sqrt{\sqrt[3]{b_2 \cdot b_2 - a \cdot c}}, -b_2\right)}}{a}\right)}^{1}\]
    14. Taylor expanded around -inf 5.6

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

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

    if -3.124283374205192e+57 < b_2 < 3.84613441880261e-81

    1. Initial program 12.7

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

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

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Using strategy rm
    6. Applied pow112.8

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

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

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

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

    if 3.84613441880261e-81 < b_2

    1. Initial program 52.9

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

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

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Using strategy rm
    6. Applied pow152.9

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

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

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

      \[\leadsto {\color{blue}{\left(\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\right)}}^{1}\]
    10. Taylor expanded around inf 9.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -3.12428337420519208 \cdot 10^{57}:\\ \;\;\;\;\frac{-2 \cdot b_2}{a}\\ \mathbf{elif}\;b_2 \le 3.84613441880260993 \cdot 10^{-81}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

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