Average Error: 34.1 → 6.5
Time: 5.1s
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.7431685240570133 \cdot 10^{102}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 1.0417939395900796 \cdot 10^{-259}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{elif}\;b \le 9.37351117144741807 \cdot 10^{103}:\\ \;\;\;\;\frac{\frac{1}{2}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \left(4 \cdot c\right)\\ \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.7431685240570133 \cdot 10^{102}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

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

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

\end{array}
double f(double a, double b, double c) {
        double r51230 = b;
        double r51231 = -r51230;
        double r51232 = r51230 * r51230;
        double r51233 = 4.0;
        double r51234 = a;
        double r51235 = r51233 * r51234;
        double r51236 = c;
        double r51237 = r51235 * r51236;
        double r51238 = r51232 - r51237;
        double r51239 = sqrt(r51238);
        double r51240 = r51231 + r51239;
        double r51241 = 2.0;
        double r51242 = r51241 * r51234;
        double r51243 = r51240 / r51242;
        return r51243;
}

double f(double a, double b, double c) {
        double r51244 = b;
        double r51245 = -1.7431685240570133e+102;
        bool r51246 = r51244 <= r51245;
        double r51247 = 1.0;
        double r51248 = c;
        double r51249 = r51248 / r51244;
        double r51250 = a;
        double r51251 = r51244 / r51250;
        double r51252 = r51249 - r51251;
        double r51253 = r51247 * r51252;
        double r51254 = 1.0417939395900796e-259;
        bool r51255 = r51244 <= r51254;
        double r51256 = -r51244;
        double r51257 = r51244 * r51244;
        double r51258 = 4.0;
        double r51259 = r51258 * r51250;
        double r51260 = r51259 * r51248;
        double r51261 = r51257 - r51260;
        double r51262 = sqrt(r51261);
        double r51263 = r51256 + r51262;
        double r51264 = 2.0;
        double r51265 = r51264 * r51250;
        double r51266 = r51263 / r51265;
        double r51267 = 9.373511171447418e+103;
        bool r51268 = r51244 <= r51267;
        double r51269 = 1.0;
        double r51270 = r51269 / r51264;
        double r51271 = r51256 - r51262;
        double r51272 = r51270 / r51271;
        double r51273 = r51258 * r51248;
        double r51274 = r51272 * r51273;
        double r51275 = -1.0;
        double r51276 = r51275 * r51249;
        double r51277 = r51268 ? r51274 : r51276;
        double r51278 = r51255 ? r51266 : r51277;
        double r51279 = r51246 ? r51253 : r51278;
        return r51279;
}

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.7431685240570133e+102

    1. Initial program 47.5

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

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

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

    if -1.7431685240570133e+102 < b < 1.0417939395900796e-259

    1. Initial program 9.7

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

    if 1.0417939395900796e-259 < b < 9.373511171447418e+103

    1. Initial program 34.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-+35.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. Simplified17.0

      \[\leadsto \frac{\frac{\color{blue}{0 + 4 \cdot \left(a \cdot c\right)}}{\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.3

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

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

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

      \[\leadsto \frac{1}{\left(\frac{2}{4} \cdot \color{blue}{\frac{1}{c}}\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}\]
    11. Using strategy rm
    12. Applied frac-times8.3

      \[\leadsto \frac{1}{\color{blue}{\frac{2 \cdot 1}{4 \cdot c}} \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}\]
    13. Applied associate-*l/8.2

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(2 \cdot 1\right) \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}{4 \cdot c}}}\]
    14. Applied associate-/r/7.8

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

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

    if 9.373511171447418e+103 < b

    1. Initial program 59.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.7431685240570133 \cdot 10^{102}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 1.0417939395900796 \cdot 10^{-259}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{elif}\;b \le 9.37351117144741807 \cdot 10^{103}:\\ \;\;\;\;\frac{\frac{1}{2}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \left(4 \cdot c\right)\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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