Average Error: 34.2 → 12.5
Time: 5.3s
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 5.22428457242377 \cdot 10^{-176}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{elif}\;b \le 8.145866994051403 \cdot 10^{82}:\\ \;\;\;\;\frac{1 \cdot \frac{4}{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot c}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{0 + 4 \cdot \left(a \cdot c\right)}{\left(-b\right) - \left(b - 2 \cdot \frac{a \cdot c}{b}\right)}}{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 5.22428457242377 \cdot 10^{-176}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r53444 = b;
        double r53445 = -r53444;
        double r53446 = r53444 * r53444;
        double r53447 = 4.0;
        double r53448 = a;
        double r53449 = r53447 * r53448;
        double r53450 = c;
        double r53451 = r53449 * r53450;
        double r53452 = r53446 - r53451;
        double r53453 = sqrt(r53452);
        double r53454 = r53445 + r53453;
        double r53455 = 2.0;
        double r53456 = r53455 * r53448;
        double r53457 = r53454 / r53456;
        return r53457;
}

double f(double a, double b, double c) {
        double r53458 = b;
        double r53459 = -1.3358786167585806e+154;
        bool r53460 = r53458 <= r53459;
        double r53461 = 2.0;
        double r53462 = a;
        double r53463 = c;
        double r53464 = r53462 * r53463;
        double r53465 = r53464 / r53458;
        double r53466 = r53461 * r53465;
        double r53467 = 2.0;
        double r53468 = r53467 * r53458;
        double r53469 = r53466 - r53468;
        double r53470 = r53461 * r53462;
        double r53471 = r53469 / r53470;
        double r53472 = 5.22428457242377e-176;
        bool r53473 = r53458 <= r53472;
        double r53474 = -r53458;
        double r53475 = r53458 * r53458;
        double r53476 = 4.0;
        double r53477 = r53476 * r53462;
        double r53478 = r53477 * r53463;
        double r53479 = r53475 - r53478;
        double r53480 = sqrt(r53479);
        double r53481 = r53474 + r53480;
        double r53482 = r53481 / r53470;
        double r53483 = 8.145866994051403e+82;
        bool r53484 = r53458 <= r53483;
        double r53485 = 1.0;
        double r53486 = r53474 - r53480;
        double r53487 = r53486 / r53464;
        double r53488 = r53476 / r53487;
        double r53489 = r53485 * r53488;
        double r53490 = r53489 / r53470;
        double r53491 = 0.0;
        double r53492 = r53476 * r53464;
        double r53493 = r53491 + r53492;
        double r53494 = r53458 - r53466;
        double r53495 = r53474 - r53494;
        double r53496 = r53493 / r53495;
        double r53497 = r53496 / r53470;
        double r53498 = r53484 ? r53490 : r53497;
        double r53499 = r53473 ? r53482 : r53498;
        double r53500 = r53460 ? r53471 : r53499;
        return r53500;
}

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 < 5.22428457242377e-176

    1. Initial program 10.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 add-exp-log14.3

      \[\leadsto \frac{\color{blue}{e^{\log \left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}}{2 \cdot a}\]
    4. Using strategy rm
    5. Applied rem-exp-log10.6

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

    if 5.22428457242377e-176 < b < 8.145866994051403e+82

    1. Initial program 35.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 add-exp-log37.7

      \[\leadsto \frac{\color{blue}{e^{\log \left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}}{2 \cdot a}\]
    4. Using strategy rm
    5. Applied flip-+37.7

      \[\leadsto \frac{e^{\log \color{blue}{\left(\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}}\right)}}}{2 \cdot a}\]
    6. Applied log-div64.0

      \[\leadsto \frac{e^{\color{blue}{\log \left(\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}\right) - \log \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}}{2 \cdot a}\]
    7. Applied exp-diff64.0

      \[\leadsto \frac{\color{blue}{\frac{e^{\log \left(\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}\right)}}{e^{\log \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}}}{2 \cdot a}\]
    8. Simplified64.0

      \[\leadsto \frac{\frac{\color{blue}{0 + 4 \cdot \left(a \cdot c\right)}}{e^{\log \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}}{2 \cdot a}\]
    9. Simplified15.8

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{1} \cdot \frac{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}\]
    14. Simplified15.8

      \[\leadsto \frac{\color{blue}{1} \cdot \frac{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}\]
    15. Simplified15.9

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

    if 8.145866994051403e+82 < b

    1. Initial program 58.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 add-exp-log58.4

      \[\leadsto \frac{\color{blue}{e^{\log \left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}}{2 \cdot a}\]
    4. Using strategy rm
    5. Applied flip-+58.4

      \[\leadsto \frac{e^{\log \color{blue}{\left(\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}}\right)}}}{2 \cdot a}\]
    6. Applied log-div64.0

      \[\leadsto \frac{e^{\color{blue}{\log \left(\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}\right) - \log \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}}{2 \cdot a}\]
    7. Applied exp-diff64.0

      \[\leadsto \frac{\color{blue}{\frac{e^{\log \left(\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}\right)}}{e^{\log \left(\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)}}}}{2 \cdot a}\]
    8. Simplified64.0

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

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

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

    \[\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 5.22428457242377 \cdot 10^{-176}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{elif}\;b \le 8.145866994051403 \cdot 10^{82}:\\ \;\;\;\;\frac{1 \cdot \frac{4}{\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot c}}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{0 + 4 \cdot \left(a \cdot c\right)}{\left(-b\right) - \left(b - 2 \cdot \frac{a \cdot c}{b}\right)}}{2 \cdot a}\\ \end{array}\]

Reproduce

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