Average Error: 34.0 → 29.9
Time: 1.1m
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 4.1432508585428765 \cdot 10^{+166}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)} - b}{2} \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;0\\ \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 4.1432508585428765 \cdot 10^{+166}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)} - b}{2} \cdot \frac{1}{a}\\

\mathbf{else}:\\
\;\;\;\;0\\

\end{array}
double f(double a, double b, double c) {
        double r4046955 = b;
        double r4046956 = -r4046955;
        double r4046957 = r4046955 * r4046955;
        double r4046958 = 4.0;
        double r4046959 = a;
        double r4046960 = r4046958 * r4046959;
        double r4046961 = c;
        double r4046962 = r4046960 * r4046961;
        double r4046963 = r4046957 - r4046962;
        double r4046964 = sqrt(r4046963);
        double r4046965 = r4046956 + r4046964;
        double r4046966 = 2.0;
        double r4046967 = r4046966 * r4046959;
        double r4046968 = r4046965 / r4046967;
        return r4046968;
}

double f(double a, double b, double c) {
        double r4046969 = b;
        double r4046970 = 4.1432508585428765e+166;
        bool r4046971 = r4046969 <= r4046970;
        double r4046972 = c;
        double r4046973 = -4.0;
        double r4046974 = a;
        double r4046975 = r4046973 * r4046974;
        double r4046976 = r4046969 * r4046969;
        double r4046977 = fma(r4046972, r4046975, r4046976);
        double r4046978 = sqrt(r4046977);
        double r4046979 = r4046978 - r4046969;
        double r4046980 = 2.0;
        double r4046981 = r4046979 / r4046980;
        double r4046982 = 1.0;
        double r4046983 = r4046982 / r4046974;
        double r4046984 = r4046981 * r4046983;
        double r4046985 = 0.0;
        double r4046986 = r4046971 ? r4046984 : r4046985;
        return r4046986;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 4.1432508585428765e+166

    1. Initial program 28.3

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

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)} - b}{2}}{a}}\]
    3. Using strategy rm
    4. Applied div-inv28.4

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

    if 4.1432508585428765e+166 < b

    1. Initial program 62.9

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

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)} - b}{2}}{a}}\]
    3. Using strategy rm
    4. Applied div-inv62.9

      \[\leadsto \color{blue}{\frac{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)} - b}{2} \cdot \frac{1}{a}}\]
    5. Taylor expanded around 0 37.8

      \[\leadsto \color{blue}{0}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification29.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 4.1432508585428765 \cdot 10^{+166}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(c, \left(-4 \cdot a\right), \left(b \cdot b\right)\right)} - b}{2} \cdot \frac{1}{a}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]

Reproduce

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