Average Error: 34.5 → 8.9
Time: 16.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 -1.857238265713216596268581045781308602833 \cdot 10^{109}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 8.706117685651469092807044052871735370705 \cdot 10^{-130}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}}\\ \mathbf{elif}\;b \le 16056697633982866014018962968901844992:\\ \;\;\;\;\frac{1}{\left(2 \cdot a\right) \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\left(4 \cdot a\right) \cdot c}}\\ \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.857238265713216596268581045781308602833 \cdot 10^{109}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

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

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

\end{array}
double f(double a, double b, double c) {
        double r43409 = b;
        double r43410 = -r43409;
        double r43411 = r43409 * r43409;
        double r43412 = 4.0;
        double r43413 = a;
        double r43414 = r43412 * r43413;
        double r43415 = c;
        double r43416 = r43414 * r43415;
        double r43417 = r43411 - r43416;
        double r43418 = sqrt(r43417);
        double r43419 = r43410 + r43418;
        double r43420 = 2.0;
        double r43421 = r43420 * r43413;
        double r43422 = r43419 / r43421;
        return r43422;
}

double f(double a, double b, double c) {
        double r43423 = b;
        double r43424 = -1.8572382657132166e+109;
        bool r43425 = r43423 <= r43424;
        double r43426 = 1.0;
        double r43427 = c;
        double r43428 = r43427 / r43423;
        double r43429 = a;
        double r43430 = r43423 / r43429;
        double r43431 = r43428 - r43430;
        double r43432 = r43426 * r43431;
        double r43433 = 8.706117685651469e-130;
        bool r43434 = r43423 <= r43433;
        double r43435 = 1.0;
        double r43436 = 2.0;
        double r43437 = r43436 * r43429;
        double r43438 = r43423 * r43423;
        double r43439 = 4.0;
        double r43440 = r43439 * r43429;
        double r43441 = r43440 * r43427;
        double r43442 = r43438 - r43441;
        double r43443 = sqrt(r43442);
        double r43444 = r43443 - r43423;
        double r43445 = r43437 / r43444;
        double r43446 = r43435 / r43445;
        double r43447 = 1.6056697633982866e+37;
        bool r43448 = r43423 <= r43447;
        double r43449 = -r43423;
        double r43450 = r43449 - r43443;
        double r43451 = r43450 / r43441;
        double r43452 = r43437 * r43451;
        double r43453 = r43435 / r43452;
        double r43454 = -1.0;
        double r43455 = r43454 * r43428;
        double r43456 = r43448 ? r43453 : r43455;
        double r43457 = r43434 ? r43446 : r43456;
        double r43458 = r43425 ? r43432 : r43457;
        return r43458;
}

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.8572382657132166e+109

    1. Initial program 50.1

      \[\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.8572382657132166e+109 < b < 8.706117685651469e-130

    1. Initial program 11.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 clear-num11.6

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

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

    if 8.706117685651469e-130 < b < 1.6056697633982866e+37

    1. Initial program 37.3

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

      \[\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. Simplified16.8

      \[\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-num16.9

      \[\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. Simplified16.9

      \[\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 *-un-lft-identity16.9

      \[\leadsto \frac{\frac{1}{\color{blue}{1 \cdot \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}\]
    10. Applied *-un-lft-identity16.9

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot 1}}{1 \cdot \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}\]
    11. Applied times-frac16.9

      \[\leadsto \frac{\color{blue}{\frac{1}{1} \cdot \frac{1}{\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}\]
    12. Applied associate-/l*17.0

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

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

    if 1.6056697633982866e+37 < b

    1. Initial program 57.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.857238265713216596268581045781308602833 \cdot 10^{109}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 8.706117685651469092807044052871735370705 \cdot 10^{-130}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}}\\ \mathbf{elif}\;b \le 16056697633982866014018962968901844992:\\ \;\;\;\;\frac{1}{\left(2 \cdot a\right) \cdot \frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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