Average Error: 34.1 → 10.2
Time: 31.2s
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.2287897258283204 \cdot 10^{-38}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 1.4954103314709843 \cdot 10^{+136}:\\ \;\;\;\;\frac{-c}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}\\ \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 -3.2287897258283204 \cdot 10^{-38}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\

\mathbf{elif}\;b_2 \le 1.4954103314709843 \cdot 10^{+136}:\\
\;\;\;\;\frac{-c}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}\\

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

\end{array}
double f(double a, double b_2, double c) {
        double r1024030 = b_2;
        double r1024031 = -r1024030;
        double r1024032 = r1024030 * r1024030;
        double r1024033 = a;
        double r1024034 = c;
        double r1024035 = r1024033 * r1024034;
        double r1024036 = r1024032 - r1024035;
        double r1024037 = sqrt(r1024036);
        double r1024038 = r1024031 + r1024037;
        double r1024039 = r1024038 / r1024033;
        return r1024039;
}

double f(double a, double b_2, double c) {
        double r1024040 = b_2;
        double r1024041 = -3.2287897258283204e-38;
        bool r1024042 = r1024040 <= r1024041;
        double r1024043 = 0.5;
        double r1024044 = c;
        double r1024045 = r1024044 / r1024040;
        double r1024046 = r1024043 * r1024045;
        double r1024047 = a;
        double r1024048 = r1024040 / r1024047;
        double r1024049 = 2.0;
        double r1024050 = r1024048 * r1024049;
        double r1024051 = r1024046 - r1024050;
        double r1024052 = 1.4954103314709843e+136;
        bool r1024053 = r1024040 <= r1024052;
        double r1024054 = -r1024044;
        double r1024055 = r1024040 * r1024040;
        double r1024056 = r1024044 * r1024047;
        double r1024057 = r1024055 - r1024056;
        double r1024058 = sqrt(r1024057);
        double r1024059 = r1024058 + r1024040;
        double r1024060 = r1024054 / r1024059;
        double r1024061 = -0.5;
        double r1024062 = r1024045 * r1024061;
        double r1024063 = r1024053 ? r1024060 : r1024062;
        double r1024064 = r1024042 ? r1024051 : r1024063;
        return r1024064;
}

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.2287897258283204e-38

    1. Initial program 28.2

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

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

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

    if -3.2287897258283204e-38 < b_2 < 1.4954103314709843e+136

    1. Initial program 26.7

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

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

      \[\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 flip--30.9

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}} \cdot \frac{1}{a}\]
    7. Applied associate-*l/30.9

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

      \[\leadsto \frac{\color{blue}{\frac{0 - a \cdot c}{a}}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    9. Using strategy rm
    10. Applied sub0-neg17.6

      \[\leadsto \frac{\frac{\color{blue}{-a \cdot c}}{a}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    11. Applied distribute-frac-neg17.6

      \[\leadsto \frac{\color{blue}{-\frac{a \cdot c}{a}}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\]
    12. Simplified13.4

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

    if 1.4954103314709843e+136 < b_2

    1. Initial program 61.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -3.2287897258283204 \cdot 10^{-38}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 1.4954103314709843 \cdot 10^{+136}:\\ \;\;\;\;\frac{-c}{\sqrt{b_2 \cdot b_2 - c \cdot a} + b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

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