Average Error: 34.0 → 9.0
Time: 18.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 -8.035809894237901445931970544225072398237 \cdot 10^{152}:\\ \;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1\\ \mathbf{elif}\;b \le 3.243927964746086489471681708926883768814 \cdot 10^{-167}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a} - b}{a \cdot 2}\\ \mathbf{elif}\;b \le 1.092314858884959904180796965245633627496 \cdot 10^{-13}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - b \cdot b\right) + c \cdot \left(4 \cdot a\right)}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}}{a \cdot 2}\\ \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 -8.035809894237901445931970544225072398237 \cdot 10^{152}:\\
\;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1\\

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

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

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

\end{array}
double f(double a, double b, double c) {
        double r2081378 = b;
        double r2081379 = -r2081378;
        double r2081380 = r2081378 * r2081378;
        double r2081381 = 4.0;
        double r2081382 = a;
        double r2081383 = r2081381 * r2081382;
        double r2081384 = c;
        double r2081385 = r2081383 * r2081384;
        double r2081386 = r2081380 - r2081385;
        double r2081387 = sqrt(r2081386);
        double r2081388 = r2081379 + r2081387;
        double r2081389 = 2.0;
        double r2081390 = r2081389 * r2081382;
        double r2081391 = r2081388 / r2081390;
        return r2081391;
}

double f(double a, double b, double c) {
        double r2081392 = b;
        double r2081393 = -8.035809894237901e+152;
        bool r2081394 = r2081392 <= r2081393;
        double r2081395 = c;
        double r2081396 = r2081395 / r2081392;
        double r2081397 = a;
        double r2081398 = r2081392 / r2081397;
        double r2081399 = r2081396 - r2081398;
        double r2081400 = 1.0;
        double r2081401 = r2081399 * r2081400;
        double r2081402 = 3.2439279647460865e-167;
        bool r2081403 = r2081392 <= r2081402;
        double r2081404 = r2081392 * r2081392;
        double r2081405 = 4.0;
        double r2081406 = r2081395 * r2081405;
        double r2081407 = r2081406 * r2081397;
        double r2081408 = r2081404 - r2081407;
        double r2081409 = sqrt(r2081408);
        double r2081410 = r2081409 - r2081392;
        double r2081411 = 2.0;
        double r2081412 = r2081397 * r2081411;
        double r2081413 = r2081410 / r2081412;
        double r2081414 = 1.0923148588849599e-13;
        bool r2081415 = r2081392 <= r2081414;
        double r2081416 = r2081404 - r2081404;
        double r2081417 = r2081405 * r2081397;
        double r2081418 = r2081395 * r2081417;
        double r2081419 = r2081416 + r2081418;
        double r2081420 = -r2081392;
        double r2081421 = r2081404 - r2081418;
        double r2081422 = sqrt(r2081421);
        double r2081423 = r2081420 - r2081422;
        double r2081424 = r2081419 / r2081423;
        double r2081425 = r2081424 / r2081412;
        double r2081426 = -1.0;
        double r2081427 = r2081426 * r2081396;
        double r2081428 = r2081415 ? r2081425 : r2081427;
        double r2081429 = r2081403 ? r2081413 : r2081428;
        double r2081430 = r2081394 ? r2081401 : r2081429;
        return r2081430;
}

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 < -8.035809894237901e+152

    1. Initial program 63.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 div-inv63.6

      \[\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. Using strategy rm
    5. Applied associate-*r/63.6

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

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

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

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

    if -8.035809894237901e+152 < b < 3.2439279647460865e-167

    1. Initial program 10.5

      \[\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-inv10.6

      \[\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. Using strategy rm
    5. Applied associate-*r/10.5

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

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

    if 3.2439279647460865e-167 < b < 1.0923148588849599e-13

    1. Initial program 30.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 flip-+31.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. Simplified18.4

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

    if 1.0923148588849599e-13 < b

    1. Initial program 55.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -8.035809894237901445931970544225072398237 \cdot 10^{152}:\\ \;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1\\ \mathbf{elif}\;b \le 3.243927964746086489471681708926883768814 \cdot 10^{-167}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a} - b}{a \cdot 2}\\ \mathbf{elif}\;b \le 1.092314858884959904180796965245633627496 \cdot 10^{-13}:\\ \;\;\;\;\frac{\frac{\left(b \cdot b - b \cdot b\right) + c \cdot \left(4 \cdot a\right)}{\left(-b\right) - \sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)}}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019169 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))