Average Error: 34.0 → 8.5
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 -6.95366867167606799833293235113613604366 \cdot 10^{101}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 7.134363685689718338729914266454193972897 \cdot 10^{-281}:\\ \;\;\;\;\frac{\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}}{2} \cdot \frac{\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}}{a}\\ \mathbf{elif}\;b \le 3.424603050151593475509461695672638978245 \cdot 10^{-29}:\\ \;\;\;\;\frac{\frac{1}{\frac{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{4 \cdot a}}{c}}}{2 \cdot a}\\ \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 -6.95366867167606799833293235113613604366 \cdot 10^{101}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

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

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

\end{array}
double f(double a, double b, double c) {
        double r46329 = b;
        double r46330 = -r46329;
        double r46331 = r46329 * r46329;
        double r46332 = 4.0;
        double r46333 = a;
        double r46334 = r46332 * r46333;
        double r46335 = c;
        double r46336 = r46334 * r46335;
        double r46337 = r46331 - r46336;
        double r46338 = sqrt(r46337);
        double r46339 = r46330 + r46338;
        double r46340 = 2.0;
        double r46341 = r46340 * r46333;
        double r46342 = r46339 / r46341;
        return r46342;
}

double f(double a, double b, double c) {
        double r46343 = b;
        double r46344 = -6.953668671676068e+101;
        bool r46345 = r46343 <= r46344;
        double r46346 = 1.0;
        double r46347 = c;
        double r46348 = r46347 / r46343;
        double r46349 = a;
        double r46350 = r46343 / r46349;
        double r46351 = r46348 - r46350;
        double r46352 = r46346 * r46351;
        double r46353 = 7.134363685689718e-281;
        bool r46354 = r46343 <= r46353;
        double r46355 = r46343 * r46343;
        double r46356 = 4.0;
        double r46357 = r46356 * r46349;
        double r46358 = r46357 * r46347;
        double r46359 = r46355 - r46358;
        double r46360 = sqrt(r46359);
        double r46361 = r46360 - r46343;
        double r46362 = sqrt(r46361);
        double r46363 = 2.0;
        double r46364 = r46362 / r46363;
        double r46365 = r46362 / r46349;
        double r46366 = r46364 * r46365;
        double r46367 = 3.4246030501515935e-29;
        bool r46368 = r46343 <= r46367;
        double r46369 = 1.0;
        double r46370 = -r46343;
        double r46371 = r46370 - r46360;
        double r46372 = r46371 / r46357;
        double r46373 = r46372 / r46347;
        double r46374 = r46369 / r46373;
        double r46375 = r46363 * r46349;
        double r46376 = r46374 / r46375;
        double r46377 = -1.0;
        double r46378 = r46377 * r46348;
        double r46379 = r46368 ? r46376 : r46378;
        double r46380 = r46354 ? r46366 : r46379;
        double r46381 = r46345 ? r46352 : r46380;
        return r46381;
}

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 < -6.953668671676068e+101

    1. Initial program 47.8

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

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

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

    if -6.953668671676068e+101 < b < 7.134363685689718e-281

    1. Initial program 8.8

      \[\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-sqr-sqrt9.1

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

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

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

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

    if 7.134363685689718e-281 < b < 3.4246030501515935e-29

    1. Initial program 24.4

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

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

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

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

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

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

    if 3.4246030501515935e-29 < b

    1. Initial program 54.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -6.95366867167606799833293235113613604366 \cdot 10^{101}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 7.134363685689718338729914266454193972897 \cdot 10^{-281}:\\ \;\;\;\;\frac{\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}}{2} \cdot \frac{\sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}}{a}\\ \mathbf{elif}\;b \le 3.424603050151593475509461695672638978245 \cdot 10^{-29}:\\ \;\;\;\;\frac{\frac{1}{\frac{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{4 \cdot a}}{c}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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