Average Error: 34.4 → 10.5
Time: 16.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 -2.221067196710922123169723133116561516447 \cdot 10^{149}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 3.142311858008121469027865121070306475283 \cdot 10^{-35}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - 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 -2.221067196710922123169723133116561516447 \cdot 10^{149}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\

\mathbf{elif}\;b_2 \le 3.142311858008121469027865121070306475283 \cdot 10^{-35}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - 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 r772258 = b_2;
        double r772259 = -r772258;
        double r772260 = r772258 * r772258;
        double r772261 = a;
        double r772262 = c;
        double r772263 = r772261 * r772262;
        double r772264 = r772260 - r772263;
        double r772265 = sqrt(r772264);
        double r772266 = r772259 + r772265;
        double r772267 = r772266 / r772261;
        return r772267;
}

double f(double a, double b_2, double c) {
        double r772268 = b_2;
        double r772269 = -2.221067196710922e+149;
        bool r772270 = r772268 <= r772269;
        double r772271 = 0.5;
        double r772272 = c;
        double r772273 = r772272 / r772268;
        double r772274 = r772271 * r772273;
        double r772275 = a;
        double r772276 = r772268 / r772275;
        double r772277 = 2.0;
        double r772278 = r772276 * r772277;
        double r772279 = r772274 - r772278;
        double r772280 = 3.1423118580081215e-35;
        bool r772281 = r772268 <= r772280;
        double r772282 = r772268 * r772268;
        double r772283 = r772272 * r772275;
        double r772284 = r772282 - r772283;
        double r772285 = sqrt(r772284);
        double r772286 = r772285 - r772268;
        double r772287 = r772286 / r772275;
        double r772288 = -0.5;
        double r772289 = r772273 * r772288;
        double r772290 = r772281 ? r772287 : r772289;
        double r772291 = r772270 ? r772279 : r772290;
        return r772291;
}

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 < -2.221067196710922e+149

    1. Initial program 62.3

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around -inf 2.7

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

    if -2.221067196710922e+149 < b_2 < 3.1423118580081215e-35

    1. Initial program 14.5

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity14.5

      \[\leadsto \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{\color{blue}{1 \cdot a}}\]
    5. Applied associate-/r*14.5

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{1}}{a}}\]
    6. Simplified14.5

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

    if 3.1423118580081215e-35 < b_2

    1. Initial program 54.4

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

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around inf 7.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -2.221067196710922123169723133116561516447 \cdot 10^{149}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 3.142311858008121469027865121070306475283 \cdot 10^{-35}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

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