Average Error: 33.5 → 9.9
Time: 20.2s
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 r1489504 = b;
        double r1489505 = -r1489504;
        double r1489506 = r1489504 * r1489504;
        double r1489507 = 4.0;
        double r1489508 = a;
        double r1489509 = r1489507 * r1489508;
        double r1489510 = c;
        double r1489511 = r1489509 * r1489510;
        double r1489512 = r1489506 - r1489511;
        double r1489513 = sqrt(r1489512);
        double r1489514 = r1489505 + r1489513;
        double r1489515 = 2.0;
        double r1489516 = r1489515 * r1489508;
        double r1489517 = r1489514 / r1489516;
        return r1489517;
}

double f(double b, double a, double c) {
        double r1489518 = b;
        double r1489519 = -2.9400015506354064e+93;
        bool r1489520 = r1489518 <= r1489519;
        double r1489521 = c;
        double r1489522 = r1489521 / r1489518;
        double r1489523 = a;
        double r1489524 = r1489518 / r1489523;
        double r1489525 = r1489522 - r1489524;
        double r1489526 = 2.5928684081554055e-64;
        bool r1489527 = r1489518 <= r1489526;
        double r1489528 = -4.0;
        double r1489529 = r1489528 * r1489521;
        double r1489530 = r1489529 * r1489523;
        double r1489531 = r1489518 * r1489518;
        double r1489532 = r1489530 + r1489531;
        double r1489533 = sqrt(r1489532);
        double r1489534 = r1489533 - r1489518;
        double r1489535 = 2.0;
        double r1489536 = r1489523 * r1489535;
        double r1489537 = r1489534 / r1489536;
        double r1489538 = -r1489522;
        double r1489539 = r1489527 ? r1489537 : r1489538;
        double r1489540 = r1489520 ? r1489525 : r1489539;
        return r1489540;
}

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)))