Average Error: 33.1 → 9.9
Time: 26.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.031133968044182 \cdot 10^{+117}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 2.2889595342575282 \cdot 10^{-33}:\\ \;\;\;\;\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 -3.031133968044182 \cdot 10^{+117}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\

\mathbf{elif}\;b_2 \le 2.2889595342575282 \cdot 10^{-33}:\\
\;\;\;\;\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 r741218 = b_2;
        double r741219 = -r741218;
        double r741220 = r741218 * r741218;
        double r741221 = a;
        double r741222 = c;
        double r741223 = r741221 * r741222;
        double r741224 = r741220 - r741223;
        double r741225 = sqrt(r741224);
        double r741226 = r741219 + r741225;
        double r741227 = r741226 / r741221;
        return r741227;
}

double f(double a, double b_2, double c) {
        double r741228 = b_2;
        double r741229 = -3.031133968044182e+117;
        bool r741230 = r741228 <= r741229;
        double r741231 = 0.5;
        double r741232 = c;
        double r741233 = r741232 / r741228;
        double r741234 = r741231 * r741233;
        double r741235 = a;
        double r741236 = r741228 / r741235;
        double r741237 = 2.0;
        double r741238 = r741236 * r741237;
        double r741239 = r741234 - r741238;
        double r741240 = 2.2889595342575282e-33;
        bool r741241 = r741228 <= r741240;
        double r741242 = r741228 * r741228;
        double r741243 = r741232 * r741235;
        double r741244 = r741242 - r741243;
        double r741245 = sqrt(r741244);
        double r741246 = r741245 - r741228;
        double r741247 = r741246 / r741235;
        double r741248 = -0.5;
        double r741249 = r741233 * r741248;
        double r741250 = r741241 ? r741247 : r741249;
        double r741251 = r741230 ? r741239 : r741250;
        return r741251;
}

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.031133968044182e+117

    1. Initial program 48.7

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{{b_2}^{2} - a \cdot c}} - b_2}{a}\]
    4. Simplified48.7

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

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

    if -3.031133968044182e+117 < b_2 < 2.2889595342575282e-33

    1. Initial program 14.1

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{{b_2}^{2} - a \cdot c}} - b_2}{a}\]
    4. Simplified14.1

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

    if 2.2889595342575282e-33 < b_2

    1. Initial program 53.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -3.031133968044182 \cdot 10^{+117}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 2.2889595342575282 \cdot 10^{-33}:\\ \;\;\;\;\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 2019107 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))