Average Error: 33.5 → 9.9
Time: 19.5s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -2.9400015506354064 \cdot 10^{+93}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 2.5928684081554055 \cdot 10^{-64}:\\ \;\;\;\;\frac{\sqrt{\left(-4 \cdot c\right) \cdot a + b \cdot b} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le -2.9400015506354064 \cdot 10^{+93}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

\mathbf{elif}\;b \le 2.5928684081554055 \cdot 10^{-64}:\\
\;\;\;\;\frac{\sqrt{\left(-4 \cdot c\right) \cdot a + b \cdot b} - b}{a \cdot 2}\\

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

\end{array}
double f(double b, double a, double c) {
        double r2157353 = b;
        double r2157354 = -r2157353;
        double r2157355 = r2157353 * r2157353;
        double r2157356 = 4.0;
        double r2157357 = a;
        double r2157358 = r2157356 * r2157357;
        double r2157359 = c;
        double r2157360 = r2157358 * r2157359;
        double r2157361 = r2157355 - r2157360;
        double r2157362 = sqrt(r2157361);
        double r2157363 = r2157354 + r2157362;
        double r2157364 = 2.0;
        double r2157365 = r2157364 * r2157357;
        double r2157366 = r2157363 / r2157365;
        return r2157366;
}

double f(double b, double a, double c) {
        double r2157367 = b;
        double r2157368 = -2.9400015506354064e+93;
        bool r2157369 = r2157367 <= r2157368;
        double r2157370 = c;
        double r2157371 = r2157370 / r2157367;
        double r2157372 = a;
        double r2157373 = r2157367 / r2157372;
        double r2157374 = r2157371 - r2157373;
        double r2157375 = 2.5928684081554055e-64;
        bool r2157376 = r2157367 <= r2157375;
        double r2157377 = -4.0;
        double r2157378 = r2157377 * r2157370;
        double r2157379 = r2157378 * r2157372;
        double r2157380 = r2157367 * r2157367;
        double r2157381 = r2157379 + r2157380;
        double r2157382 = sqrt(r2157381);
        double r2157383 = r2157382 - r2157367;
        double r2157384 = 2.0;
        double r2157385 = r2157372 * r2157384;
        double r2157386 = r2157383 / r2157385;
        double r2157387 = -r2157371;
        double r2157388 = r2157376 ? r2157386 : r2157387;
        double r2157389 = r2157369 ? r2157374 : r2157388;
        return r2157389;
}

Error

Bits error versus b

Bits error versus a

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.9400015506354064e+93

    1. Initial program 43.7

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified43.7

      \[\leadsto \color{blue}{\frac{\sqrt{a \cdot \left(-4 \cdot c\right) + b \cdot b} - b}{a \cdot 2}}\]
    3. Taylor expanded around 0 43.7

      \[\leadsto \frac{\sqrt{\color{blue}{{b}^{2} - 4 \cdot \left(a \cdot c\right)}} - b}{a \cdot 2}\]
    4. Simplified43.7

      \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b + \left(c \cdot -4\right) \cdot a}} - b}{a \cdot 2}\]
    5. Taylor expanded around -inf 3.3

      \[\leadsto \color{blue}{\frac{c}{b} - \frac{b}{a}}\]

    if -2.9400015506354064e+93 < b < 2.5928684081554055e-64

    1. Initial program 12.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified12.8

      \[\leadsto \color{blue}{\frac{\sqrt{a \cdot \left(-4 \cdot c\right) + b \cdot b} - b}{a \cdot 2}}\]
    3. Taylor expanded around 0 12.8

      \[\leadsto \frac{\sqrt{\color{blue}{{b}^{2} - 4 \cdot \left(a \cdot c\right)}} - b}{a \cdot 2}\]
    4. Simplified12.8

      \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b + \left(c \cdot -4\right) \cdot a}} - b}{a \cdot 2}\]

    if 2.5928684081554055e-64 < b

    1. Initial program 53.0

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified53.0

      \[\leadsto \color{blue}{\frac{\sqrt{a \cdot \left(-4 \cdot c\right) + b \cdot b} - b}{a \cdot 2}}\]
    3. Taylor expanded around 0 53.0

      \[\leadsto \frac{\sqrt{\color{blue}{{b}^{2} - 4 \cdot \left(a \cdot c\right)}} - b}{a \cdot 2}\]
    4. Simplified53.0

      \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b + \left(c \cdot -4\right) \cdot a}} - b}{a \cdot 2}\]
    5. Taylor expanded around inf 9.2

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    6. Simplified9.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.9400015506354064 \cdot 10^{+93}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 2.5928684081554055 \cdot 10^{-64}:\\ \;\;\;\;\frac{\sqrt{\left(-4 \cdot c\right) \cdot a + b \cdot b} - b}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (b a c)
  :name "(-b + sqrt(b*b - 4*a*c)) / (2*a)"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))