Average Error: 34.4 → 9.1
Time: 19.0s
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.297624534318876743725099723501638614139 \cdot 10^{152}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 7.752932492055353784538521387722087830871 \cdot 10^{-90}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{elif}\;b \le 683389336.59924924373626708984375:\\ \;\;\;\;\frac{\frac{\left(4 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \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.297624534318876743725099723501638614139 \cdot 10^{152}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

\mathbf{elif}\;b \le 683389336.59924924373626708984375:\\
\;\;\;\;\frac{\frac{\left(4 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r34578 = b;
        double r34579 = -r34578;
        double r34580 = r34578 * r34578;
        double r34581 = 4.0;
        double r34582 = a;
        double r34583 = r34581 * r34582;
        double r34584 = c;
        double r34585 = r34583 * r34584;
        double r34586 = r34580 - r34585;
        double r34587 = sqrt(r34586);
        double r34588 = r34579 + r34587;
        double r34589 = 2.0;
        double r34590 = r34589 * r34582;
        double r34591 = r34588 / r34590;
        return r34591;
}

double f(double a, double b, double c) {
        double r34592 = b;
        double r34593 = -2.2976245343188767e+152;
        bool r34594 = r34592 <= r34593;
        double r34595 = 1.0;
        double r34596 = c;
        double r34597 = r34596 / r34592;
        double r34598 = a;
        double r34599 = r34592 / r34598;
        double r34600 = r34597 - r34599;
        double r34601 = r34595 * r34600;
        double r34602 = 7.752932492055354e-90;
        bool r34603 = r34592 <= r34602;
        double r34604 = -r34592;
        double r34605 = r34592 * r34592;
        double r34606 = 4.0;
        double r34607 = r34606 * r34598;
        double r34608 = r34607 * r34596;
        double r34609 = r34605 - r34608;
        double r34610 = sqrt(r34609);
        double r34611 = r34604 + r34610;
        double r34612 = 2.0;
        double r34613 = r34612 * r34598;
        double r34614 = r34611 / r34613;
        double r34615 = 683389336.5992492;
        bool r34616 = r34592 <= r34615;
        double r34617 = r34604 - r34610;
        double r34618 = r34608 / r34617;
        double r34619 = r34618 / r34613;
        double r34620 = -1.0;
        double r34621 = r34620 * r34597;
        double r34622 = r34616 ? r34619 : r34621;
        double r34623 = r34603 ? r34614 : r34622;
        double r34624 = r34594 ? r34601 : r34623;
        return r34624;
}

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 4 regimes
  2. if b < -2.2976245343188767e+152

    1. Initial program 63.3

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

      \[\leadsto \color{blue}{1 \cdot \frac{c}{b} - 1 \cdot \frac{b}{a}}\]
    3. Simplified2.2

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

    if -2.2976245343188767e+152 < b < 7.752932492055354e-90

    1. Initial program 11.9

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

    if 7.752932492055354e-90 < b < 683389336.5992492

    1. Initial program 39.9

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied flip-+40.0

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

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

    if 683389336.5992492 < b

    1. Initial program 56.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.297624534318876743725099723501638614139 \cdot 10^{152}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 7.752932492055353784538521387722087830871 \cdot 10^{-90}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{elif}\;b \le 683389336.59924924373626708984375:\\ \;\;\;\;\frac{\frac{\left(4 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019209 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))