Average Error: 19.8 → 8.9
Time: 25.8s
Precision: 64
\[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.396583466388814133251953653376858979069 \cdot 10^{134}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \left(\left(\left(\sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}} \cdot \sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}}\right) \cdot \left(\sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}} \cdot \frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}}\right)\right) \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b}\\ \end{array}\\ \mathbf{elif}\;b \le 2098867031.934578418731689453125:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{\left(\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}} - b}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \left(b - 2 \cdot \frac{a \cdot c}{b}\right)}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]
\begin{array}{l}
\mathbf{if}\;b \ge 0.0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\

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

\end{array}
\begin{array}{l}
\mathbf{if}\;b \le -1.396583466388814133251953653376858979069 \cdot 10^{134}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0.0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \left(\left(\left(\sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}} \cdot \sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}}\right) \cdot \left(\sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}} \cdot \frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}}\right)\right) \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b}\\

\end{array}\\

\mathbf{elif}\;b \le 2098867031.934578418731689453125:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0.0:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\

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

\end{array}\\

\mathbf{elif}\;b \ge 0.0:\\
\;\;\;\;\frac{\left(-b\right) - \left(b - 2 \cdot \frac{a \cdot c}{b}\right)}{2 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r35812 = b;
        double r35813 = 0.0;
        bool r35814 = r35812 >= r35813;
        double r35815 = -r35812;
        double r35816 = r35812 * r35812;
        double r35817 = 4.0;
        double r35818 = a;
        double r35819 = r35817 * r35818;
        double r35820 = c;
        double r35821 = r35819 * r35820;
        double r35822 = r35816 - r35821;
        double r35823 = sqrt(r35822);
        double r35824 = r35815 - r35823;
        double r35825 = 2.0;
        double r35826 = r35825 * r35818;
        double r35827 = r35824 / r35826;
        double r35828 = r35825 * r35820;
        double r35829 = r35815 + r35823;
        double r35830 = r35828 / r35829;
        double r35831 = r35814 ? r35827 : r35830;
        return r35831;
}

double f(double a, double b, double c) {
        double r35832 = b;
        double r35833 = -1.3965834663888141e+134;
        bool r35834 = r35832 <= r35833;
        double r35835 = 0.0;
        bool r35836 = r35832 >= r35835;
        double r35837 = -r35832;
        double r35838 = r35832 * r35832;
        double r35839 = 4.0;
        double r35840 = a;
        double r35841 = r35839 * r35840;
        double r35842 = c;
        double r35843 = r35841 * r35842;
        double r35844 = r35838 - r35843;
        double r35845 = sqrt(r35844);
        double r35846 = r35837 - r35845;
        double r35847 = 2.0;
        double r35848 = r35847 * r35840;
        double r35849 = r35846 / r35848;
        double r35850 = r35847 * r35842;
        double r35851 = cbrt(r35832);
        double r35852 = r35851 * r35851;
        double r35853 = r35840 / r35852;
        double r35854 = cbrt(r35853);
        double r35855 = r35854 * r35854;
        double r35856 = cbrt(r35842);
        double r35857 = r35856 * r35856;
        double r35858 = cbrt(r35851);
        double r35859 = r35858 * r35858;
        double r35860 = r35857 / r35859;
        double r35861 = r35854 * r35860;
        double r35862 = r35855 * r35861;
        double r35863 = r35856 / r35858;
        double r35864 = r35862 * r35863;
        double r35865 = r35847 * r35864;
        double r35866 = r35865 - r35832;
        double r35867 = r35866 - r35832;
        double r35868 = r35850 / r35867;
        double r35869 = r35836 ? r35849 : r35868;
        double r35870 = 2098867031.9345784;
        bool r35871 = r35832 <= r35870;
        double r35872 = cbrt(r35844);
        double r35873 = r35872 * r35872;
        double r35874 = r35873 * r35872;
        double r35875 = sqrt(r35874);
        double r35876 = r35875 - r35832;
        double r35877 = r35850 / r35876;
        double r35878 = r35836 ? r35849 : r35877;
        double r35879 = r35840 * r35842;
        double r35880 = r35879 / r35832;
        double r35881 = r35847 * r35880;
        double r35882 = r35832 - r35881;
        double r35883 = r35837 - r35882;
        double r35884 = r35883 / r35848;
        double r35885 = r35845 - r35832;
        double r35886 = r35850 / r35885;
        double r35887 = r35836 ? r35884 : r35886;
        double r35888 = r35871 ? r35878 : r35887;
        double r35889 = r35834 ? r35869 : r35888;
        return r35889;
}

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 < -1.3965834663888141e+134

    1. Initial program 34.1

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    2. Simplified34.1

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}}\]
    3. Taylor expanded around -inf 6.2

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\color{blue}{2 \cdot c}}{\left(2 \cdot \frac{a \cdot c}{b} - b\right) - b}\\ \end{array}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt6.2

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \frac{a \cdot c}{\left(\sqrt[3]{b} \cdot \sqrt[3]{b}\right) \cdot \sqrt[3]{b}} - b\right) - b}\\ \end{array}\]
    6. Applied times-frac1.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \frac{c}{\sqrt[3]{b}}\right) - b\right) - b}\\ \end{array}\]
    7. Using strategy rm
    8. Applied add-cube-cbrt1.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \frac{c}{\left(\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}\right) \cdot \sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b}\\ \end{array}\]
    9. Applied add-cube-cbrt1.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \frac{\left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right) \cdot \sqrt[3]{c}}{\left(\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}\right) \cdot \sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b}\\ \end{array}\]
    10. Applied times-frac1.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \left(\frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}} \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right)\right) - b\right) - b}\\ \end{array}\]
    11. Applied associate-*r*1.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \left(\left(\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}} \cdot \frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}}\right) \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b}\\ \end{array}\]
    12. Using strategy rm
    13. Applied add-cube-cbrt1.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \left(\left(\left(\left(\sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}} \cdot \sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}}\right) \cdot \sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}}\right) \cdot \frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}}\right) \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b}\\ \end{array}\]
    14. Applied associate-*l*1.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \left(\left(\left(\sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}} \cdot \sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}}\right) \cdot \left(\sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}} \cdot \frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}}\right)\right) \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b}\\ \end{array}\]

    if -1.3965834663888141e+134 < b < 2098867031.9345784

    1. Initial program 9.7

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    2. Simplified9.7

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt9.9

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{\color{blue}{2} \cdot c}{\sqrt{\left(\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}} - b}\\ \end{array}\]

    if 2098867031.9345784 < b

    1. Initial program 32.3

      \[\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\]
    2. Simplified32.3

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}}\]
    3. Taylor expanded around inf 12.2

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \color{blue}{\left(b - 2 \cdot \frac{a \cdot c}{b}\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification8.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.396583466388814133251953653376858979069 \cdot 10^{134}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(2 \cdot \left(\left(\left(\sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}} \cdot \sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}}\right) \cdot \left(\sqrt[3]{\frac{a}{\sqrt[3]{b} \cdot \sqrt[3]{b}}} \cdot \frac{\sqrt[3]{c} \cdot \sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}} \cdot \sqrt[3]{\sqrt[3]{b}}}\right)\right) \cdot \frac{\sqrt[3]{c}}{\sqrt[3]{\sqrt[3]{b}}}\right) - b\right) - b}\\ \end{array}\\ \mathbf{elif}\;b \le 2098867031.934578418731689453125:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{\left(\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}} - b}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;\frac{\left(-b\right) - \left(b - 2 \cdot \frac{a \cdot c}{b}\right)}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019209 
(FPCore (a b c)
  :name "jeff quadratic root 1"
  :precision binary64
  (if (>= b 0.0) (/ (- (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)) (/ (* 2 c) (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))))))