Average Error: 34.3 → 9.8
Time: 5.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 -1.369694371126339229257094016308893237032 \cdot 10^{-83}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 9.826999448380506319382023302894593276333 \cdot 10^{96}:\\ \;\;\;\;\frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}} \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 -1.369694371126339229257094016308893237032 \cdot 10^{-83}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r19272 = b_2;
        double r19273 = -r19272;
        double r19274 = r19272 * r19272;
        double r19275 = a;
        double r19276 = c;
        double r19277 = r19275 * r19276;
        double r19278 = r19274 - r19277;
        double r19279 = sqrt(r19278);
        double r19280 = r19273 + r19279;
        double r19281 = r19280 / r19275;
        return r19281;
}

double f(double a, double b_2, double c) {
        double r19282 = b_2;
        double r19283 = -1.3696943711263392e-83;
        bool r19284 = r19282 <= r19283;
        double r19285 = 0.5;
        double r19286 = c;
        double r19287 = r19286 / r19282;
        double r19288 = r19285 * r19287;
        double r19289 = 2.0;
        double r19290 = a;
        double r19291 = r19282 / r19290;
        double r19292 = r19289 * r19291;
        double r19293 = r19288 - r19292;
        double r19294 = 9.826999448380506e+96;
        bool r19295 = r19282 <= r19294;
        double r19296 = 1.0;
        double r19297 = -r19282;
        double r19298 = r19282 * r19282;
        double r19299 = r19290 * r19286;
        double r19300 = r19298 - r19299;
        double r19301 = sqrt(r19300);
        double r19302 = r19297 - r19301;
        double r19303 = r19296 / r19302;
        double r19304 = r19303 * r19286;
        double r19305 = -0.5;
        double r19306 = r19305 * r19287;
        double r19307 = r19295 ? r19304 : r19306;
        double r19308 = r19284 ? r19293 : r19307;
        return r19308;
}

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.3696943711263392e-83

    1. Initial program 26.1

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

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

    if -1.3696943711263392e-83 < b_2 < 9.826999448380506e+96

    1. Initial program 26.4

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

      \[\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. Simplified17.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 *-un-lft-identity17.5

      \[\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-identity17.5

      \[\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-frac17.5

      \[\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. Simplified17.5

      \[\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. Simplified16.0

      \[\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-num16.0

      \[\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. Simplified12.3

      \[\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 div-inv12.4

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

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

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

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

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

    if 9.826999448380506e+96 < b_2

    1. Initial program 59.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.369694371126339229257094016308893237032 \cdot 10^{-83}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 9.826999448380506319382023302894593276333 \cdot 10^{96}:\\ \;\;\;\;\frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot c\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

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