Average Error: 34.5 → 9.6
Time: 35.1s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4.0 \cdot a\right) \cdot c}}{2.0 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -2.3213399824345094 \cdot 10^{+149}:\\ \;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1.0\\ \mathbf{elif}\;b \le 1.1804820682342164 \cdot 10^{-93}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot 4.0\right) \cdot a} - b}{a \cdot 2.0}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -1.0\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4.0 \cdot a\right) \cdot c}}{2.0 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le -2.3213399824345094 \cdot 10^{+149}:\\
\;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1.0\\

\mathbf{elif}\;b \le 1.1804820682342164 \cdot 10^{-93}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot 4.0\right) \cdot a} - b}{a \cdot 2.0}\\

\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -1.0\\

\end{array}
double f(double a, double b, double c) {
        double r2017039 = b;
        double r2017040 = -r2017039;
        double r2017041 = r2017039 * r2017039;
        double r2017042 = 4.0;
        double r2017043 = a;
        double r2017044 = r2017042 * r2017043;
        double r2017045 = c;
        double r2017046 = r2017044 * r2017045;
        double r2017047 = r2017041 - r2017046;
        double r2017048 = sqrt(r2017047);
        double r2017049 = r2017040 + r2017048;
        double r2017050 = 2.0;
        double r2017051 = r2017050 * r2017043;
        double r2017052 = r2017049 / r2017051;
        return r2017052;
}

double f(double a, double b, double c) {
        double r2017053 = b;
        double r2017054 = -2.3213399824345094e+149;
        bool r2017055 = r2017053 <= r2017054;
        double r2017056 = c;
        double r2017057 = r2017056 / r2017053;
        double r2017058 = a;
        double r2017059 = r2017053 / r2017058;
        double r2017060 = r2017057 - r2017059;
        double r2017061 = 1.0;
        double r2017062 = r2017060 * r2017061;
        double r2017063 = 1.1804820682342164e-93;
        bool r2017064 = r2017053 <= r2017063;
        double r2017065 = r2017053 * r2017053;
        double r2017066 = 4.0;
        double r2017067 = r2017056 * r2017066;
        double r2017068 = r2017067 * r2017058;
        double r2017069 = r2017065 - r2017068;
        double r2017070 = sqrt(r2017069);
        double r2017071 = r2017070 - r2017053;
        double r2017072 = 2.0;
        double r2017073 = r2017058 * r2017072;
        double r2017074 = r2017071 / r2017073;
        double r2017075 = -1.0;
        double r2017076 = r2017057 * r2017075;
        double r2017077 = r2017064 ? r2017074 : r2017076;
        double r2017078 = r2017055 ? r2017062 : r2017077;
        return r2017078;
}

Error

Bits error versus a

Bits error versus b

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.3213399824345094e+149

    1. Initial program 62.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4.0 \cdot a\right) \cdot c}}{2.0 \cdot a}\]
    2. Using strategy rm
    3. Applied div-inv62.6

      \[\leadsto \color{blue}{\left(\left(-b\right) + \sqrt{b \cdot b - \left(4.0 \cdot a\right) \cdot c}\right) \cdot \frac{1}{2.0 \cdot a}}\]
    4. Taylor expanded around -inf 2.8

      \[\leadsto \color{blue}{1.0 \cdot \frac{c}{b} - 1.0 \cdot \frac{b}{a}}\]
    5. Simplified2.8

      \[\leadsto \color{blue}{\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1.0}\]

    if -2.3213399824345094e+149 < b < 1.1804820682342164e-93

    1. Initial program 11.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4.0 \cdot a\right) \cdot c}}{2.0 \cdot a}\]
    2. Using strategy rm
    3. Applied div-inv11.8

      \[\leadsto \color{blue}{\left(\left(-b\right) + \sqrt{b \cdot b - \left(4.0 \cdot a\right) \cdot c}\right) \cdot \frac{1}{2.0 \cdot a}}\]
    4. Using strategy rm
    5. Applied associate-*r/11.6

      \[\leadsto \color{blue}{\frac{\left(\left(-b\right) + \sqrt{b \cdot b - \left(4.0 \cdot a\right) \cdot c}\right) \cdot 1}{2.0 \cdot a}}\]
    6. Simplified11.6

      \[\leadsto \frac{\color{blue}{\sqrt{b \cdot b - a \cdot \left(c \cdot 4.0\right)} - b}}{2.0 \cdot a}\]

    if 1.1804820682342164e-93 < b

    1. Initial program 52.9

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4.0 \cdot a\right) \cdot c}}{2.0 \cdot a}\]
    2. Taylor expanded around inf 9.1

      \[\leadsto \color{blue}{-1.0 \cdot \frac{c}{b}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification9.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.3213399824345094 \cdot 10^{+149}:\\ \;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1.0\\ \mathbf{elif}\;b \le 1.1804820682342164 \cdot 10^{-93}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot 4.0\right) \cdot a} - b}{a \cdot 2.0}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -1.0\\ \end{array}\]

Reproduce

herbie shell --seed 2019165 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))