Average Error: 34.5 → 9.1
Time: 6.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 4.501804305446481092604277222732251047398 \cdot 10^{-104}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \mathbf{elif}\;b \le 6.208184629611190047399823307861607564099 \cdot 10^{88}:\\ \;\;\;\;\left(1 \cdot \frac{4}{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot c}}\right) \cdot \frac{1}{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.857238265713216596268581045781308602833 \cdot 10^{109}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

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

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

\end{array}
double f(double a, double b, double c) {
        double r58527 = b;
        double r58528 = -r58527;
        double r58529 = r58527 * r58527;
        double r58530 = 4.0;
        double r58531 = a;
        double r58532 = r58530 * r58531;
        double r58533 = c;
        double r58534 = r58532 * r58533;
        double r58535 = r58529 - r58534;
        double r58536 = sqrt(r58535);
        double r58537 = r58528 + r58536;
        double r58538 = 2.0;
        double r58539 = r58538 * r58531;
        double r58540 = r58537 / r58539;
        return r58540;
}

double f(double a, double b, double c) {
        double r58541 = b;
        double r58542 = -1.8572382657132166e+109;
        bool r58543 = r58541 <= r58542;
        double r58544 = 1.0;
        double r58545 = c;
        double r58546 = r58545 / r58541;
        double r58547 = a;
        double r58548 = r58541 / r58547;
        double r58549 = r58546 - r58548;
        double r58550 = r58544 * r58549;
        double r58551 = 4.501804305446481e-104;
        bool r58552 = r58541 <= r58551;
        double r58553 = 1.0;
        double r58554 = 2.0;
        double r58555 = r58554 * r58547;
        double r58556 = -r58541;
        double r58557 = r58541 * r58541;
        double r58558 = 4.0;
        double r58559 = r58558 * r58547;
        double r58560 = r58559 * r58545;
        double r58561 = r58557 - r58560;
        double r58562 = sqrt(r58561);
        double r58563 = r58556 + r58562;
        double r58564 = r58555 / r58563;
        double r58565 = r58553 / r58564;
        double r58566 = 6.20818462961119e+88;
        bool r58567 = r58541 <= r58566;
        double r58568 = r58556 - r58562;
        double r58569 = r58547 * r58545;
        double r58570 = r58568 / r58569;
        double r58571 = r58558 / r58570;
        double r58572 = r58553 * r58571;
        double r58573 = r58553 / r58555;
        double r58574 = r58572 * r58573;
        double r58575 = -1.0;
        double r58576 = r58575 * r58546;
        double r58577 = r58567 ? r58574 : r58576;
        double r58578 = r58552 ? r58565 : r58577;
        double r58579 = r58543 ? r58550 : r58578;
        return r58579;
}

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 < 4.501804305446481e-104

    1. Initial program 11.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 clear-num12.0

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

    if 4.501804305446481e-104 < b < 6.20818462961119e+88

    1. Initial program 41.4

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

      \[\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. Simplified15.6

      \[\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 *-un-lft-identity15.6

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{1} \cdot \frac{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}\]
    9. Simplified15.6

      \[\leadsto \frac{\color{blue}{1} \cdot \frac{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}\]
    10. Simplified15.9

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

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

    if 6.20818462961119e+88 < b

    1. Initial program 59.4

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

      \[\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 -1.857238265713216596268581045781308602833 \cdot 10^{109}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 4.501804305446481092604277222732251047398 \cdot 10^{-104}:\\ \;\;\;\;\frac{1}{\frac{2 \cdot a}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \mathbf{elif}\;b \le 6.208184629611190047399823307861607564099 \cdot 10^{88}:\\ \;\;\;\;\left(1 \cdot \frac{4}{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot c}}\right) \cdot \frac{1}{2 \cdot a}\\ \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)))