Average Error: 34.5 → 9.1
Time: 6.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.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 r51737 = b;
        double r51738 = -r51737;
        double r51739 = r51737 * r51737;
        double r51740 = 4.0;
        double r51741 = a;
        double r51742 = r51740 * r51741;
        double r51743 = c;
        double r51744 = r51742 * r51743;
        double r51745 = r51739 - r51744;
        double r51746 = sqrt(r51745);
        double r51747 = r51738 + r51746;
        double r51748 = 2.0;
        double r51749 = r51748 * r51741;
        double r51750 = r51747 / r51749;
        return r51750;
}

double f(double a, double b, double c) {
        double r51751 = b;
        double r51752 = -1.8572382657132166e+109;
        bool r51753 = r51751 <= r51752;
        double r51754 = 1.0;
        double r51755 = c;
        double r51756 = r51755 / r51751;
        double r51757 = a;
        double r51758 = r51751 / r51757;
        double r51759 = r51756 - r51758;
        double r51760 = r51754 * r51759;
        double r51761 = 4.501804305446481e-104;
        bool r51762 = r51751 <= r51761;
        double r51763 = 1.0;
        double r51764 = 2.0;
        double r51765 = r51764 * r51757;
        double r51766 = -r51751;
        double r51767 = r51751 * r51751;
        double r51768 = 4.0;
        double r51769 = r51768 * r51757;
        double r51770 = r51769 * r51755;
        double r51771 = r51767 - r51770;
        double r51772 = sqrt(r51771);
        double r51773 = r51766 + r51772;
        double r51774 = r51765 / r51773;
        double r51775 = r51763 / r51774;
        double r51776 = 6.20818462961119e+88;
        bool r51777 = r51751 <= r51776;
        double r51778 = r51766 - r51772;
        double r51779 = r51757 * r51755;
        double r51780 = r51778 / r51779;
        double r51781 = r51768 / r51780;
        double r51782 = r51763 * r51781;
        double r51783 = r51763 / r51765;
        double r51784 = r51782 * r51783;
        double r51785 = -1.0;
        double r51786 = r51785 * r51756;
        double r51787 = r51777 ? r51784 : r51786;
        double r51788 = r51762 ? r51775 : r51787;
        double r51789 = r51753 ? r51760 : r51788;
        return r51789;
}

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 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))