Average Error: 33.5 → 10.0
Time: 12.0s
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.478406535480561669630649836752919254545 \cdot 10^{60}:\\ \;\;\;\;\frac{1}{2} \cdot \left(2 \cdot \frac{c}{b} - 2 \cdot \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 2.175674080408202904737521150531781836244 \cdot 10^{-169}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{a}\\ \mathbf{elif}\;b \le 3.705250296078930544323375298653357812472 \cdot 10^{-110} \lor \neg \left(b \le 29494967590524297216\right):\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{\frac{-\left(4 \cdot a\right) \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}{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.478406535480561669630649836752919254545 \cdot 10^{60}:\\
\;\;\;\;\frac{1}{2} \cdot \left(2 \cdot \frac{c}{b} - 2 \cdot \frac{b}{a}\right)\\

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

\mathbf{elif}\;b \le 3.705250296078930544323375298653357812472 \cdot 10^{-110} \lor \neg \left(b \le 29494967590524297216\right):\\
\;\;\;\;-1 \cdot \frac{c}{b}\\

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

\end{array}
double f(double a, double b, double c) {
        double r37555 = b;
        double r37556 = -r37555;
        double r37557 = r37555 * r37555;
        double r37558 = 4.0;
        double r37559 = a;
        double r37560 = r37558 * r37559;
        double r37561 = c;
        double r37562 = r37560 * r37561;
        double r37563 = r37557 - r37562;
        double r37564 = sqrt(r37563);
        double r37565 = r37556 + r37564;
        double r37566 = 2.0;
        double r37567 = r37566 * r37559;
        double r37568 = r37565 / r37567;
        return r37568;
}

double f(double a, double b, double c) {
        double r37569 = b;
        double r37570 = -1.4784065354805617e+60;
        bool r37571 = r37569 <= r37570;
        double r37572 = 1.0;
        double r37573 = 2.0;
        double r37574 = r37572 / r37573;
        double r37575 = c;
        double r37576 = r37575 / r37569;
        double r37577 = r37573 * r37576;
        double r37578 = 2.0;
        double r37579 = a;
        double r37580 = r37569 / r37579;
        double r37581 = r37578 * r37580;
        double r37582 = r37577 - r37581;
        double r37583 = r37574 * r37582;
        double r37584 = 2.175674080408203e-169;
        bool r37585 = r37569 <= r37584;
        double r37586 = r37569 * r37569;
        double r37587 = 4.0;
        double r37588 = r37587 * r37579;
        double r37589 = r37588 * r37575;
        double r37590 = r37586 - r37589;
        double r37591 = sqrt(r37590);
        double r37592 = r37591 - r37569;
        double r37593 = r37592 / r37579;
        double r37594 = r37574 * r37593;
        double r37595 = 3.7052502960789305e-110;
        bool r37596 = r37569 <= r37595;
        double r37597 = 2.9494967590524297e+19;
        bool r37598 = r37569 <= r37597;
        double r37599 = !r37598;
        bool r37600 = r37596 || r37599;
        double r37601 = -1.0;
        double r37602 = r37601 * r37576;
        double r37603 = -r37589;
        double r37604 = r37591 + r37569;
        double r37605 = r37603 / r37604;
        double r37606 = r37605 / r37579;
        double r37607 = r37574 * r37606;
        double r37608 = r37600 ? r37602 : r37607;
        double r37609 = r37585 ? r37594 : r37608;
        double r37610 = r37571 ? r37583 : r37609;
        return r37610;
}

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.4784065354805617e+60

    1. Initial program 39.0

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

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

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

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

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

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

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

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

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

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

    if -1.4784065354805617e+60 < b < 2.175674080408203e-169

    1. Initial program 10.7

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

      \[\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-num10.9

      \[\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-identity10.9

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

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

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

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

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

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

    if 2.175674080408203e-169 < b < 3.7052502960789305e-110 or 2.9494967590524297e+19 < b

    1. Initial program 52.0

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]

    if 3.7052502960789305e-110 < b < 2.9494967590524297e+19

    1. Initial program 37.3

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

      \[\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-num37.3

      \[\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-identity37.3

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.478406535480561669630649836752919254545 \cdot 10^{60}:\\ \;\;\;\;\frac{1}{2} \cdot \left(2 \cdot \frac{c}{b} - 2 \cdot \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 2.175674080408202904737521150531781836244 \cdot 10^{-169}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{a}\\ \mathbf{elif}\;b \le 3.705250296078930544323375298653357812472 \cdot 10^{-110} \lor \neg \left(b \le 29494967590524297216\right):\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{\frac{-\left(4 \cdot a\right) \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + b}}{a}\\ \end{array}\]

Reproduce

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