Average Error: 34.6 → 8.4
Time: 25.4s
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 -1.6581383089037873 \cdot 10^{81}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le -3.3528823044057167 \cdot 10^{-206}:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \frac{1}{2 \cdot a}\\ \mathbf{elif}\;b \le 3.593830924265355 \cdot 10^{-35}:\\ \;\;\;\;\frac{\frac{1}{\frac{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{4 \cdot a}}{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 -1.6581383089037873 \cdot 10^{81}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

\mathbf{elif}\;b \le 3.593830924265355 \cdot 10^{-35}:\\
\;\;\;\;\frac{\frac{1}{\frac{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{4 \cdot a}}{c}}}{2 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r46682 = b;
        double r46683 = -r46682;
        double r46684 = r46682 * r46682;
        double r46685 = 4.0;
        double r46686 = a;
        double r46687 = r46685 * r46686;
        double r46688 = c;
        double r46689 = r46687 * r46688;
        double r46690 = r46684 - r46689;
        double r46691 = sqrt(r46690);
        double r46692 = r46683 + r46691;
        double r46693 = 2.0;
        double r46694 = r46693 * r46686;
        double r46695 = r46692 / r46694;
        return r46695;
}

double f(double a, double b, double c) {
        double r46696 = b;
        double r46697 = -1.6581383089037873e+81;
        bool r46698 = r46696 <= r46697;
        double r46699 = 1.0;
        double r46700 = c;
        double r46701 = r46700 / r46696;
        double r46702 = a;
        double r46703 = r46696 / r46702;
        double r46704 = r46701 - r46703;
        double r46705 = r46699 * r46704;
        double r46706 = -3.3528823044057167e-206;
        bool r46707 = r46696 <= r46706;
        double r46708 = -r46696;
        double r46709 = r46696 * r46696;
        double r46710 = 4.0;
        double r46711 = r46710 * r46702;
        double r46712 = r46711 * r46700;
        double r46713 = r46709 - r46712;
        double r46714 = sqrt(r46713);
        double r46715 = r46708 + r46714;
        double r46716 = 1.0;
        double r46717 = 2.0;
        double r46718 = r46717 * r46702;
        double r46719 = r46716 / r46718;
        double r46720 = r46715 * r46719;
        double r46721 = 3.593830924265355e-35;
        bool r46722 = r46696 <= r46721;
        double r46723 = r46708 - r46714;
        double r46724 = r46723 / r46711;
        double r46725 = r46724 / r46700;
        double r46726 = r46716 / r46725;
        double r46727 = r46726 / r46718;
        double r46728 = -1.0;
        double r46729 = r46728 * r46701;
        double r46730 = r46722 ? r46727 : r46729;
        double r46731 = r46707 ? r46720 : r46730;
        double r46732 = r46698 ? r46705 : r46731;
        return r46732;
}

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 < -1.6581383089037873e+81

    1. Initial program 43.9

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

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

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

    if -1.6581383089037873e+81 < b < -3.3528823044057167e-206

    1. Initial program 7.8

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

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

    if -3.3528823044057167e-206 < b < 3.593830924265355e-35

    1. Initial program 21.5

      \[\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-+21.7

      \[\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. Simplified17.5

      \[\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}\]
    5. Using strategy rm
    6. Applied clear-num17.6

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

      \[\leadsto \frac{\frac{1}{\color{blue}{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\]
    8. Using strategy rm
    9. Applied associate-/r*14.9

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

    if 3.593830924265355e-35 < b

    1. Initial program 55.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.6581383089037873 \cdot 10^{81}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le -3.3528823044057167 \cdot 10^{-206}:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \frac{1}{2 \cdot a}\\ \mathbf{elif}\;b \le 3.593830924265355 \cdot 10^{-35}:\\ \;\;\;\;\frac{\frac{1}{\frac{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{4 \cdot a}}{c}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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