Average Error: 33.8 → 10.3
Time: 15.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 -4.91962817906715367126033645969528543778 \cdot 10^{153}:\\ \;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1\\ \mathbf{elif}\;b \le 2.071930020515770918527743961403466592109 \cdot 10^{-74}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{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 -4.91962817906715367126033645969528543778 \cdot 10^{153}:\\
\;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r36207 = b;
        double r36208 = -r36207;
        double r36209 = r36207 * r36207;
        double r36210 = 4.0;
        double r36211 = a;
        double r36212 = r36210 * r36211;
        double r36213 = c;
        double r36214 = r36212 * r36213;
        double r36215 = r36209 - r36214;
        double r36216 = sqrt(r36215);
        double r36217 = r36208 + r36216;
        double r36218 = 2.0;
        double r36219 = r36218 * r36211;
        double r36220 = r36217 / r36219;
        return r36220;
}

double f(double a, double b, double c) {
        double r36221 = b;
        double r36222 = -4.919628179067154e+153;
        bool r36223 = r36221 <= r36222;
        double r36224 = c;
        double r36225 = r36224 / r36221;
        double r36226 = a;
        double r36227 = r36221 / r36226;
        double r36228 = r36225 - r36227;
        double r36229 = 1.0;
        double r36230 = r36228 * r36229;
        double r36231 = 2.071930020515771e-74;
        bool r36232 = r36221 <= r36231;
        double r36233 = r36221 * r36221;
        double r36234 = 4.0;
        double r36235 = r36234 * r36226;
        double r36236 = r36235 * r36224;
        double r36237 = r36233 - r36236;
        double r36238 = sqrt(r36237);
        double r36239 = r36238 - r36221;
        double r36240 = 2.0;
        double r36241 = r36240 * r36226;
        double r36242 = r36239 / r36241;
        double r36243 = -1.0;
        double r36244 = r36243 * r36225;
        double r36245 = r36232 ? r36242 : r36244;
        double r36246 = r36223 ? r36230 : r36245;
        return r36246;
}

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 3 regimes
  2. if b < -4.919628179067154e+153

    1. Initial program 63.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified63.8

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2 \cdot a}}\]
    3. Using strategy rm
    4. Applied clear-num63.8

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

      \[\leadsto \frac{1}{\color{blue}{1 \cdot \frac{2 \cdot a}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}}}\]
    7. Applied add-cube-cbrt63.8

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

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

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

      \[\leadsto 1 \cdot \color{blue}{\left(\frac{1}{2 \cdot a} \cdot \left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b\right)\right)}\]
    11. Using strategy rm
    12. Applied pow163.8

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

      \[\leadsto 1 \cdot \left(\color{blue}{{\left(\frac{1}{2 \cdot a}\right)}^{1}} \cdot {\left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b\right)}^{1}\right)\]
    14. Applied pow-prod-down63.8

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

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

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

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

    if -4.919628179067154e+153 < b < 2.071930020515771e-74

    1. Initial program 12.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified12.8

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

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

      \[\leadsto \frac{1}{\color{blue}{1 \cdot \frac{2 \cdot a}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}}}\]
    7. Applied add-cube-cbrt13.0

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

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

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

      \[\leadsto 1 \cdot \color{blue}{\left(\frac{1}{2 \cdot a} \cdot \left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b\right)\right)}\]
    11. Using strategy rm
    12. Applied pow112.9

      \[\leadsto 1 \cdot \left(\frac{1}{2 \cdot a} \cdot \color{blue}{{\left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b\right)}^{1}}\right)\]
    13. Applied pow112.9

      \[\leadsto 1 \cdot \left(\color{blue}{{\left(\frac{1}{2 \cdot a}\right)}^{1}} \cdot {\left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b\right)}^{1}\right)\]
    14. Applied pow-prod-down12.9

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

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

    if 2.071930020515771e-74 < b

    1. Initial program 53.2

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Simplified53.2

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2 \cdot a}}\]
    3. Using strategy rm
    4. Applied clear-num53.2

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

      \[\leadsto \frac{1}{\color{blue}{1 \cdot \frac{2 \cdot a}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}}}\]
    7. Applied add-cube-cbrt53.2

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

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

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

      \[\leadsto 1 \cdot \color{blue}{\left(\frac{1}{2 \cdot a} \cdot \left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b\right)\right)}\]
    11. Using strategy rm
    12. Applied pow153.2

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

      \[\leadsto 1 \cdot \left(\color{blue}{{\left(\frac{1}{2 \cdot a}\right)}^{1}} \cdot {\left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b\right)}^{1}\right)\]
    14. Applied pow-prod-down53.2

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

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

      \[\leadsto 1 \cdot {\color{blue}{\left(-1 \cdot \frac{c}{b}\right)}}^{1}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -4.91962817906715367126033645969528543778 \cdot 10^{153}:\\ \;\;\;\;\left(\frac{c}{b} - \frac{b}{a}\right) \cdot 1\\ \mathbf{elif}\;b \le 2.071930020515770918527743961403466592109 \cdot 10^{-74}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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