Average Error: 33.7 → 8.8
Time: 17.8s
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.739519777490095733488952130644039307968 \cdot 10^{139}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 1.034940633201112123069802876954999016687 \cdot 10^{-134}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{elif}\;b \le 1.942537531933752129700502847729005312685 \cdot 10^{102}:\\ \;\;\;\;\frac{\sqrt[3]{c \cdot \left(4 \cdot a\right)} \cdot \sqrt[3]{c \cdot \left(4 \cdot a\right)}}{2} \cdot \frac{\frac{\sqrt[3]{c \cdot \left(4 \cdot a\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{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.739519777490095733488952130644039307968 \cdot 10^{139}:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

\mathbf{elif}\;b \le 1.942537531933752129700502847729005312685 \cdot 10^{102}:\\
\;\;\;\;\frac{\sqrt[3]{c \cdot \left(4 \cdot a\right)} \cdot \sqrt[3]{c \cdot \left(4 \cdot a\right)}}{2} \cdot \frac{\frac{\sqrt[3]{c \cdot \left(4 \cdot a\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r41895 = b;
        double r41896 = -r41895;
        double r41897 = r41895 * r41895;
        double r41898 = 4.0;
        double r41899 = a;
        double r41900 = r41898 * r41899;
        double r41901 = c;
        double r41902 = r41900 * r41901;
        double r41903 = r41897 - r41902;
        double r41904 = sqrt(r41903);
        double r41905 = r41896 + r41904;
        double r41906 = 2.0;
        double r41907 = r41906 * r41899;
        double r41908 = r41905 / r41907;
        return r41908;
}

double f(double a, double b, double c) {
        double r41909 = b;
        double r41910 = -4.7395197774900957e+139;
        bool r41911 = r41909 <= r41910;
        double r41912 = 1.0;
        double r41913 = c;
        double r41914 = r41913 / r41909;
        double r41915 = a;
        double r41916 = r41909 / r41915;
        double r41917 = r41914 - r41916;
        double r41918 = r41912 * r41917;
        double r41919 = 1.0349406332011121e-134;
        bool r41920 = r41909 <= r41919;
        double r41921 = -r41909;
        double r41922 = r41909 * r41909;
        double r41923 = 4.0;
        double r41924 = r41923 * r41915;
        double r41925 = r41924 * r41913;
        double r41926 = r41922 - r41925;
        double r41927 = sqrt(r41926);
        double r41928 = r41921 + r41927;
        double r41929 = 2.0;
        double r41930 = r41929 * r41915;
        double r41931 = r41928 / r41930;
        double r41932 = 1.9425375319337521e+102;
        bool r41933 = r41909 <= r41932;
        double r41934 = r41913 * r41924;
        double r41935 = cbrt(r41934);
        double r41936 = r41935 * r41935;
        double r41937 = r41936 / r41929;
        double r41938 = r41921 - r41927;
        double r41939 = r41935 / r41938;
        double r41940 = r41939 / r41915;
        double r41941 = r41937 * r41940;
        double r41942 = -1.0;
        double r41943 = r41942 * r41914;
        double r41944 = r41933 ? r41941 : r41943;
        double r41945 = r41920 ? r41931 : r41944;
        double r41946 = r41911 ? r41918 : r41945;
        return r41946;
}

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 < -4.7395197774900957e+139

    1. Initial program 58.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Taylor expanded around -inf 2.5

      \[\leadsto \color{blue}{1 \cdot \frac{c}{b} - 1 \cdot \frac{b}{a}}\]
    3. Simplified2.5

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

    if -4.7395197774900957e+139 < b < 1.0349406332011121e-134

    1. Initial program 10.8

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied div-inv11.0

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

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

    if 1.0349406332011121e-134 < b < 1.9425375319337521e+102

    1. Initial program 39.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Using strategy rm
    3. Applied flip-+39.4

      \[\leadsto \frac{\color{blue}{\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}}}}{2 \cdot a}\]
    4. Simplified14.9

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

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

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

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

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

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

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

    if 1.9425375319337521e+102 < b

    1. Initial program 59.0

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
    2. Taylor expanded around inf 2.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -4.739519777490095733488952130644039307968 \cdot 10^{139}:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{elif}\;b \le 1.034940633201112123069802876954999016687 \cdot 10^{-134}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \mathbf{elif}\;b \le 1.942537531933752129700502847729005312685 \cdot 10^{102}:\\ \;\;\;\;\frac{\sqrt[3]{c \cdot \left(4 \cdot a\right)} \cdot \sqrt[3]{c \cdot \left(4 \cdot a\right)}}{2} \cdot \frac{\frac{\sqrt[3]{c \cdot \left(4 \cdot a\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{a}\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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