Average Error: 33.9 → 6.8
Time: 5.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 -9.2687136888592249 \cdot 10^{150}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le -1.2249666784418393 \cdot 10^{-279}:\\ \;\;\;\;\frac{\sqrt{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{\frac{a}{\sqrt{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\\ \mathbf{elif}\;b_2 \le 4.3957752798560445 \cdot 10^{108}:\\ \;\;\;\;1 \cdot \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 -9.2687136888592249 \cdot 10^{150}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\

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

\mathbf{elif}\;b_2 \le 4.3957752798560445 \cdot 10^{108}:\\
\;\;\;\;1 \cdot \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 r20732 = b_2;
        double r20733 = -r20732;
        double r20734 = r20732 * r20732;
        double r20735 = a;
        double r20736 = c;
        double r20737 = r20735 * r20736;
        double r20738 = r20734 - r20737;
        double r20739 = sqrt(r20738);
        double r20740 = r20733 + r20739;
        double r20741 = r20740 / r20735;
        return r20741;
}

double f(double a, double b_2, double c) {
        double r20742 = b_2;
        double r20743 = -9.268713688859225e+150;
        bool r20744 = r20742 <= r20743;
        double r20745 = 0.5;
        double r20746 = c;
        double r20747 = r20746 / r20742;
        double r20748 = r20745 * r20747;
        double r20749 = 2.0;
        double r20750 = a;
        double r20751 = r20742 / r20750;
        double r20752 = r20749 * r20751;
        double r20753 = r20748 - r20752;
        double r20754 = -1.2249666784418393e-279;
        bool r20755 = r20742 <= r20754;
        double r20756 = -r20742;
        double r20757 = r20742 * r20742;
        double r20758 = r20750 * r20746;
        double r20759 = r20757 - r20758;
        double r20760 = sqrt(r20759);
        double r20761 = r20756 + r20760;
        double r20762 = sqrt(r20761);
        double r20763 = r20750 / r20762;
        double r20764 = r20762 / r20763;
        double r20765 = 4.3957752798560445e+108;
        bool r20766 = r20742 <= r20765;
        double r20767 = 1.0;
        double r20768 = r20756 - r20760;
        double r20769 = r20746 / r20768;
        double r20770 = r20767 * r20769;
        double r20771 = -0.5;
        double r20772 = r20771 * r20747;
        double r20773 = r20766 ? r20770 : r20772;
        double r20774 = r20755 ? r20764 : r20773;
        double r20775 = r20744 ? r20753 : r20774;
        return r20775;
}

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 < -9.268713688859225e+150

    1. Initial program 61.5

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

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

    if -9.268713688859225e+150 < b_2 < -1.2249666784418393e-279

    1. Initial program 8.2

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt8.5

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

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

    if -1.2249666784418393e-279 < b_2 < 4.3957752798560445e+108

    1. Initial program 31.4

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip-+31.4

      \[\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.6

      \[\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 *-un-lft-identity16.6

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

      \[\leadsto \frac{\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)}}{a}\]
    8. Applied times-frac16.6

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

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

      \[\leadsto \frac{1 \cdot \color{blue}{\frac{a}{\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{c}}}}{a}\]
    11. Using strategy rm
    12. Applied clear-num14.7

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

      \[\leadsto \frac{1}{\color{blue}{\frac{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{c}}}\]
    14. Using strategy rm
    15. Applied *-un-lft-identity9.7

      \[\leadsto \frac{1}{\frac{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}{\color{blue}{1 \cdot c}}}\]
    16. Applied times-frac9.7

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{1} \cdot \frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{c}}}\]
    17. Applied add-cube-cbrt9.7

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{1}{1} \cdot \frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{c}}\]
    18. Applied times-frac9.7

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

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

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

    if 4.3957752798560445e+108 < b_2

    1. Initial program 60.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -9.2687136888592249 \cdot 10^{150}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le -1.2249666784418393 \cdot 10^{-279}:\\ \;\;\;\;\frac{\sqrt{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}{\frac{a}{\sqrt{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}}}\\ \mathbf{elif}\;b_2 \le 4.3957752798560445 \cdot 10^{108}:\\ \;\;\;\;1 \cdot \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 2020062 +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))