Average Error: 34.5 → 6.5
Time: 7.9s
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 -5.52306947897632778228201833866057110671 \cdot 10^{123}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le -8.219482842591944840806672041838142939496 \cdot 10^{-296}:\\ \;\;\;\;\frac{\sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2} \cdot \frac{\sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{a}\\ \mathbf{elif}\;b \le 1.372075260173852414460256827675964027367 \cdot 10^{126}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \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 -5.52306947897632778228201833866057110671 \cdot 10^{123}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

\mathbf{elif}\;b \le -8.219482842591944840806672041838142939496 \cdot 10^{-296}:\\
\;\;\;\;\frac{\sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2} \cdot \frac{\sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{a}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r60208 = b;
        double r60209 = -r60208;
        double r60210 = r60208 * r60208;
        double r60211 = 4.0;
        double r60212 = a;
        double r60213 = r60211 * r60212;
        double r60214 = c;
        double r60215 = r60213 * r60214;
        double r60216 = r60210 - r60215;
        double r60217 = sqrt(r60216);
        double r60218 = r60209 + r60217;
        double r60219 = 2.0;
        double r60220 = r60219 * r60212;
        double r60221 = r60218 / r60220;
        return r60221;
}

double f(double a, double b, double c) {
        double r60222 = b;
        double r60223 = -5.523069478976328e+123;
        bool r60224 = r60222 <= r60223;
        double r60225 = 1.0;
        double r60226 = c;
        double r60227 = r60226 / r60222;
        double r60228 = a;
        double r60229 = r60222 / r60228;
        double r60230 = r60227 - r60229;
        double r60231 = r60225 * r60230;
        double r60232 = -8.219482842591945e-296;
        bool r60233 = r60222 <= r60232;
        double r60234 = -r60222;
        double r60235 = r60222 * r60222;
        double r60236 = 4.0;
        double r60237 = r60236 * r60228;
        double r60238 = r60237 * r60226;
        double r60239 = r60235 - r60238;
        double r60240 = sqrt(r60239);
        double r60241 = r60234 + r60240;
        double r60242 = cbrt(r60241);
        double r60243 = r60242 * r60242;
        double r60244 = 2.0;
        double r60245 = r60243 / r60244;
        double r60246 = r60242 / r60228;
        double r60247 = r60245 * r60246;
        double r60248 = 1.3720752601738524e+126;
        bool r60249 = r60222 <= r60248;
        double r60250 = r60244 * r60226;
        double r60251 = r60234 - r60240;
        double r60252 = r60250 / r60251;
        double r60253 = -1.0;
        double r60254 = r60253 * r60227;
        double r60255 = r60249 ? r60252 : r60254;
        double r60256 = r60233 ? r60247 : r60255;
        double r60257 = r60224 ? r60231 : r60256;
        return r60257;
}

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 < -5.523069478976328e+123

    1. Initial program 54.0

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

      \[\leadsto \color{blue}{1 \cdot \frac{c}{b} - 1 \cdot \frac{b}{a}}\]
    3. Simplified2.9

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

    if -5.523069478976328e+123 < b < -8.219482842591945e-296

    1. Initial program 8.1

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

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

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

    if -8.219482842591945e-296 < b < 1.3720752601738524e+126

    1. Initial program 33.6

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

      \[\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. Simplified16.4

      \[\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-inv16.5

      \[\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/15.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. Simplified15.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}}\]
    10. Taylor expanded around 0 8.7

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

    if 1.3720752601738524e+126 < b

    1. Initial program 60.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -5.52306947897632778228201833866057110671 \cdot 10^{123}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le -8.219482842591944840806672041838142939496 \cdot 10^{-296}:\\ \;\;\;\;\frac{\sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2} \cdot \frac{\sqrt[3]{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{a}\\ \mathbf{elif}\;b \le 1.372075260173852414460256827675964027367 \cdot 10^{126}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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