Average Error: 33.6 → 10.4
Time: 17.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 -2.1144981103869975 \cdot 10^{+131}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 4.5810084990875205 \cdot 10^{-68}:\\ \;\;\;\;\frac{1}{\frac{a}{\frac{\sqrt{\left(a \cdot -4\right) \cdot c + b \cdot b} - b}{2}}}\\ \mathbf{else}:\\ \;\;\;\;-\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 -2.1144981103869975 \cdot 10^{+131}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r2366174 = b;
        double r2366175 = -r2366174;
        double r2366176 = r2366174 * r2366174;
        double r2366177 = 4.0;
        double r2366178 = a;
        double r2366179 = r2366177 * r2366178;
        double r2366180 = c;
        double r2366181 = r2366179 * r2366180;
        double r2366182 = r2366176 - r2366181;
        double r2366183 = sqrt(r2366182);
        double r2366184 = r2366175 + r2366183;
        double r2366185 = 2.0;
        double r2366186 = r2366185 * r2366178;
        double r2366187 = r2366184 / r2366186;
        return r2366187;
}

double f(double a, double b, double c) {
        double r2366188 = b;
        double r2366189 = -2.1144981103869975e+131;
        bool r2366190 = r2366188 <= r2366189;
        double r2366191 = c;
        double r2366192 = r2366191 / r2366188;
        double r2366193 = a;
        double r2366194 = r2366188 / r2366193;
        double r2366195 = r2366192 - r2366194;
        double r2366196 = 4.5810084990875205e-68;
        bool r2366197 = r2366188 <= r2366196;
        double r2366198 = 1.0;
        double r2366199 = -4.0;
        double r2366200 = r2366193 * r2366199;
        double r2366201 = r2366200 * r2366191;
        double r2366202 = r2366188 * r2366188;
        double r2366203 = r2366201 + r2366202;
        double r2366204 = sqrt(r2366203);
        double r2366205 = r2366204 - r2366188;
        double r2366206 = 2.0;
        double r2366207 = r2366205 / r2366206;
        double r2366208 = r2366193 / r2366207;
        double r2366209 = r2366198 / r2366208;
        double r2366210 = -r2366192;
        double r2366211 = r2366197 ? r2366209 : r2366210;
        double r2366212 = r2366190 ? r2366195 : r2366211;
        return r2366212;
}

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 3 regimes
  2. if b < -2.1144981103869975e+131

    1. Initial program 53.8

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

      \[\leadsto \color{blue}{\frac{c}{b} - \frac{b}{a}}\]

    if -2.1144981103869975e+131 < b < 4.5810084990875205e-68

    1. Initial program 13.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 div-inv13.5

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

      \[\leadsto \left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \color{blue}{\frac{\frac{1}{2}}{a}}\]
    5. Using strategy rm
    6. Applied associate-*r/13.3

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

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

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

    if 4.5810084990875205e-68 < b

    1. Initial program 52.0

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied div-inv52.0

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

      \[\leadsto \left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \color{blue}{\frac{\frac{1}{2}}{a}}\]
    5. Using strategy rm
    6. Applied associate-*r/52.0

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

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{c \cdot \left(-4 \cdot a\right) + b \cdot b} - b}{2}}}{a}\]
    8. Taylor expanded around 0 51.9

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

      \[\leadsto \frac{\frac{\sqrt{\color{blue}{b \cdot b - 4 \cdot \left(a \cdot c\right)}} - b}{2}}{a}\]
    10. Taylor expanded around inf 9.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.1144981103869975 \cdot 10^{+131}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 4.5810084990875205 \cdot 10^{-68}:\\ \;\;\;\;\frac{1}{\frac{a}{\frac{\sqrt{\left(a \cdot -4\right) \cdot c + b \cdot b} - b}{2}}}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Reproduce

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