Average Error: 34.2 → 11.9
Time: 10.7s
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.3358786167585806 \cdot 10^{154}:\\ \;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{2 \cdot a}\\ \mathbf{elif}\;b \le 4.8356294076712185 \cdot 10^{-189}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{elif}\;b \le 2.74946073861296753 \cdot 10^{159}:\\ \;\;\;\;\frac{\frac{4 \cdot \left(a \cdot c\right)}{2 \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{4 \cdot \left(a \cdot c\right)}{\left(-b\right) - \left(b - 2 \cdot \frac{a \cdot c}{b}\right)} \cdot \frac{1}{2 \cdot a}\\ \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.3358786167585806 \cdot 10^{154}:\\
\;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{2 \cdot a}\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{4 \cdot \left(a \cdot c\right)}{\left(-b\right) - \left(b - 2 \cdot \frac{a \cdot c}{b}\right)} \cdot \frac{1}{2 \cdot a}\\

\end{array}
double f(double a, double b, double c) {
        double r43272 = b;
        double r43273 = -r43272;
        double r43274 = r43272 * r43272;
        double r43275 = 4.0;
        double r43276 = a;
        double r43277 = r43275 * r43276;
        double r43278 = c;
        double r43279 = r43277 * r43278;
        double r43280 = r43274 - r43279;
        double r43281 = sqrt(r43280);
        double r43282 = r43273 + r43281;
        double r43283 = 2.0;
        double r43284 = r43283 * r43276;
        double r43285 = r43282 / r43284;
        return r43285;
}

double f(double a, double b, double c) {
        double r43286 = b;
        double r43287 = -1.3358786167585806e+154;
        bool r43288 = r43286 <= r43287;
        double r43289 = 2.0;
        double r43290 = a;
        double r43291 = c;
        double r43292 = r43290 * r43291;
        double r43293 = r43292 / r43286;
        double r43294 = r43289 * r43293;
        double r43295 = 2.0;
        double r43296 = r43295 * r43286;
        double r43297 = r43294 - r43296;
        double r43298 = r43289 * r43290;
        double r43299 = r43297 / r43298;
        double r43300 = 4.8356294076712185e-189;
        bool r43301 = r43286 <= r43300;
        double r43302 = -r43286;
        double r43303 = r43286 * r43286;
        double r43304 = 4.0;
        double r43305 = r43304 * r43290;
        double r43306 = r43305 * r43291;
        double r43307 = r43303 - r43306;
        double r43308 = sqrt(r43307);
        double r43309 = r43302 + r43308;
        double r43310 = r43309 / r43298;
        double r43311 = 2.7494607386129675e+159;
        bool r43312 = r43286 <= r43311;
        double r43313 = r43304 * r43292;
        double r43314 = r43313 / r43298;
        double r43315 = r43302 - r43308;
        double r43316 = r43314 / r43315;
        double r43317 = r43286 - r43294;
        double r43318 = r43302 - r43317;
        double r43319 = r43313 / r43318;
        double r43320 = 1.0;
        double r43321 = r43320 / r43298;
        double r43322 = r43319 * r43321;
        double r43323 = r43312 ? r43316 : r43322;
        double r43324 = r43301 ? r43310 : r43323;
        double r43325 = r43288 ? r43299 : r43324;
        return r43325;
}

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.3358786167585806e+154

    1. Initial program 64.0

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

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

    if -1.3358786167585806e+154 < b < 4.8356294076712185e-189

    1. Initial program 10.4

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

    if 4.8356294076712185e-189 < b < 2.7494607386129675e+159

    1. Initial program 38.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 flip-+38.0

      \[\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.2

      \[\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 div-inv15.2

      \[\leadsto \color{blue}{\frac{0 + 4 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \frac{1}{2 \cdot a}}\]
    7. Using strategy rm
    8. Applied associate-*l/13.2

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

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

    if 2.7494607386129675e+159 < b

    1. Initial program 64.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 flip-+64.0

      \[\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. Simplified37.7

      \[\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 div-inv37.7

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

      \[\leadsto \frac{0 + 4 \cdot \left(a \cdot c\right)}{\left(-b\right) - \color{blue}{\left(b - 2 \cdot \frac{a \cdot c}{b}\right)}} \cdot \frac{1}{2 \cdot a}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification11.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.3358786167585806 \cdot 10^{154}:\\ \;\;\;\;\frac{2 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{2 \cdot a}\\ \mathbf{elif}\;b \le 4.8356294076712185 \cdot 10^{-189}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{elif}\;b \le 2.74946073861296753 \cdot 10^{159}:\\ \;\;\;\;\frac{\frac{4 \cdot \left(a \cdot c\right)}{2 \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{4 \cdot \left(a \cdot c\right)}{\left(-b\right) - \left(b - 2 \cdot \frac{a \cdot c}{b}\right)} \cdot \frac{1}{2 \cdot a}\\ \end{array}\]

Reproduce

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