Average Error: 33.7 → 6.8
Time: 7.2s
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.98276540088900058 \cdot 10^{134}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le -7.3863624694994112 \cdot 10^{-150}:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \frac{1}{2 \cdot a}\\ \mathbf{elif}\;b \le 3.1544842839057457 \cdot 10^{110}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{4 \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 -1.98276540088900058 \cdot 10^{134}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

\mathbf{elif}\;b \le 3.1544842839057457 \cdot 10^{110}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{4 \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 r43486 = b;
        double r43487 = -r43486;
        double r43488 = r43486 * r43486;
        double r43489 = 4.0;
        double r43490 = a;
        double r43491 = r43489 * r43490;
        double r43492 = c;
        double r43493 = r43491 * r43492;
        double r43494 = r43488 - r43493;
        double r43495 = sqrt(r43494);
        double r43496 = r43487 + r43495;
        double r43497 = 2.0;
        double r43498 = r43497 * r43490;
        double r43499 = r43496 / r43498;
        return r43499;
}

double f(double a, double b, double c) {
        double r43500 = b;
        double r43501 = -1.9827654008890006e+134;
        bool r43502 = r43500 <= r43501;
        double r43503 = 1.0;
        double r43504 = c;
        double r43505 = r43504 / r43500;
        double r43506 = a;
        double r43507 = r43500 / r43506;
        double r43508 = r43505 - r43507;
        double r43509 = r43503 * r43508;
        double r43510 = -7.386362469499411e-150;
        bool r43511 = r43500 <= r43510;
        double r43512 = -r43500;
        double r43513 = r43500 * r43500;
        double r43514 = 4.0;
        double r43515 = r43514 * r43506;
        double r43516 = r43515 * r43504;
        double r43517 = r43513 - r43516;
        double r43518 = sqrt(r43517);
        double r43519 = r43512 + r43518;
        double r43520 = 1.0;
        double r43521 = 2.0;
        double r43522 = r43521 * r43506;
        double r43523 = r43520 / r43522;
        double r43524 = r43519 * r43523;
        double r43525 = 3.154484283905746e+110;
        bool r43526 = r43500 <= r43525;
        double r43527 = r43520 / r43521;
        double r43528 = r43514 * r43504;
        double r43529 = r43512 - r43518;
        double r43530 = r43528 / r43529;
        double r43531 = r43527 * r43530;
        double r43532 = -1.0;
        double r43533 = r43532 * r43505;
        double r43534 = r43526 ? r43531 : r43533;
        double r43535 = r43511 ? r43524 : r43534;
        double r43536 = r43502 ? r43509 : r43535;
        return r43536;
}

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.9827654008890006e+134

    1. Initial program 56.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.1

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

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

    if -1.9827654008890006e+134 < b < -7.386362469499411e-150

    1. Initial program 5.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-inv5.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}}\]

    if -7.386362469499411e-150 < b < 3.154484283905746e+110

    1. Initial program 28.7

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

      \[\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. Simplified17.0

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

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

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

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

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

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

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

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

    if 3.154484283905746e+110 < b

    1. Initial program 60.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.98276540088900058 \cdot 10^{134}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le -7.3863624694994112 \cdot 10^{-150}:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \frac{1}{2 \cdot a}\\ \mathbf{elif}\;b \le 3.1544842839057457 \cdot 10^{110}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{4 \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 2020047 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))