Average Error: 33.8 → 9.8
Time: 10.5s
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 -7.93152454634661985 \cdot 10^{153}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 2.0569776426586135 \cdot 10^{-106}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2}}{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 -7.93152454634661985 \cdot 10^{153}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r56733 = b;
        double r56734 = -r56733;
        double r56735 = r56733 * r56733;
        double r56736 = 4.0;
        double r56737 = a;
        double r56738 = r56736 * r56737;
        double r56739 = c;
        double r56740 = r56738 * r56739;
        double r56741 = r56735 - r56740;
        double r56742 = sqrt(r56741);
        double r56743 = r56734 + r56742;
        double r56744 = 2.0;
        double r56745 = r56744 * r56737;
        double r56746 = r56743 / r56745;
        return r56746;
}

double f(double a, double b, double c) {
        double r56747 = b;
        double r56748 = -7.93152454634662e+153;
        bool r56749 = r56747 <= r56748;
        double r56750 = 1.0;
        double r56751 = c;
        double r56752 = r56751 / r56747;
        double r56753 = a;
        double r56754 = r56747 / r56753;
        double r56755 = r56752 - r56754;
        double r56756 = r56750 * r56755;
        double r56757 = 2.0569776426586135e-106;
        bool r56758 = r56747 <= r56757;
        double r56759 = r56747 * r56747;
        double r56760 = 4.0;
        double r56761 = r56760 * r56753;
        double r56762 = r56761 * r56751;
        double r56763 = r56759 - r56762;
        double r56764 = sqrt(r56763);
        double r56765 = r56764 - r56747;
        double r56766 = 2.0;
        double r56767 = r56765 / r56766;
        double r56768 = r56767 / r56753;
        double r56769 = -1.0;
        double r56770 = r56769 * r56752;
        double r56771 = r56758 ? r56768 : r56770;
        double r56772 = r56749 ? r56756 : r56771;
        return r56772;
}

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 < -7.93152454634662e+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{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2}}{a}}\]
    3. Using strategy rm
    4. Applied clear-num63.8

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

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

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

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

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

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

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

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

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

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

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

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

    if -7.93152454634662e+153 < b < 2.0569776426586135e-106

    1. Initial program 11.2

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.0569776426586135e-106 < 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{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{2}}{a}}\]
    3. Taylor expanded around inf 10.3

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

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

Reproduce

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