Average Error: 19.6 → 7.0
Time: 20.8s
Precision: 64
\[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le -3.396811349079212 \cdot 10^{+61}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \left(\frac{a}{b} \cdot c - b\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \le 2.1204777706881932 \cdot 10^{+74}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left|\sqrt[3]{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt[3]{\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{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \left(\frac{a}{b} \cdot c - b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a}\\ \end{array}\]
\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\

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

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

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

\end{array}\\

\mathbf{elif}\;b \le 2.1204777706881932 \cdot 10^{+74}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left|\sqrt[3]{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt[3]{\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{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\

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

\end{array}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r880914 = b;
        double r880915 = 0.0;
        bool r880916 = r880914 >= r880915;
        double r880917 = 2.0;
        double r880918 = c;
        double r880919 = r880917 * r880918;
        double r880920 = -r880914;
        double r880921 = r880914 * r880914;
        double r880922 = 4.0;
        double r880923 = a;
        double r880924 = r880922 * r880923;
        double r880925 = r880924 * r880918;
        double r880926 = r880921 - r880925;
        double r880927 = sqrt(r880926);
        double r880928 = r880920 - r880927;
        double r880929 = r880919 / r880928;
        double r880930 = r880920 + r880927;
        double r880931 = r880917 * r880923;
        double r880932 = r880930 / r880931;
        double r880933 = r880916 ? r880929 : r880932;
        return r880933;
}

double f(double a, double b, double c) {
        double r880934 = b;
        double r880935 = -3.396811349079212e+61;
        bool r880936 = r880934 <= r880935;
        double r880937 = 0.0;
        bool r880938 = r880934 >= r880937;
        double r880939 = 2.0;
        double r880940 = c;
        double r880941 = r880939 * r880940;
        double r880942 = -r880934;
        double r880943 = r880934 * r880934;
        double r880944 = 4.0;
        double r880945 = a;
        double r880946 = r880944 * r880945;
        double r880947 = r880946 * r880940;
        double r880948 = r880943 - r880947;
        double r880949 = sqrt(r880948);
        double r880950 = r880942 - r880949;
        double r880951 = r880941 / r880950;
        double r880952 = r880945 / r880934;
        double r880953 = r880952 * r880940;
        double r880954 = r880953 - r880934;
        double r880955 = r880939 * r880954;
        double r880956 = r880939 * r880945;
        double r880957 = r880955 / r880956;
        double r880958 = r880938 ? r880951 : r880957;
        double r880959 = 2.1204777706881932e+74;
        bool r880960 = r880934 <= r880959;
        double r880961 = cbrt(r880948);
        double r880962 = cbrt(r880961);
        double r880963 = r880961 * r880961;
        double r880964 = cbrt(r880963);
        double r880965 = r880962 * r880964;
        double r880966 = fabs(r880965);
        double r880967 = sqrt(r880961);
        double r880968 = r880966 * r880967;
        double r880969 = r880942 - r880968;
        double r880970 = r880941 / r880969;
        double r880971 = r880949 + r880942;
        double r880972 = r880971 / r880956;
        double r880973 = r880938 ? r880970 : r880972;
        double r880974 = r880941 / r880955;
        double r880975 = r880938 ? r880974 : r880972;
        double r880976 = r880960 ? r880973 : r880975;
        double r880977 = r880936 ? r880958 : r880976;
        return r880977;
}

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 < -3.396811349079212e+61

    1. Initial program 37.6

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt37.6

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\\ \end{array}\]
    5. Taylor expanded around -inf 9.6

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

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

    if -3.396811349079212e+61 < b < 2.1204777706881932e+74

    1. Initial program 9.5

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\color{blue}{\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}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    4. Applied sqrt-prod9.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{\sqrt{\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}} \cdot \sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    5. Simplified9.8

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left|\sqrt[3]{\color{blue}{\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}}}\right| \cdot \sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    8. Applied cbrt-prod9.9

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left|\color{blue}{\sqrt[3]{\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}} \cdot \sqrt[3]{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\right| \cdot \sqrt{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]

    if 2.1204777706881932e+74 < b

    1. Initial program 27.2

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Taylor expanded around inf 6.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.396811349079212 \cdot 10^{+61}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot \left(\frac{a}{b} \cdot c - b\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \le 2.1204777706881932 \cdot 10^{+74}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \left|\sqrt[3]{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}} \cdot \sqrt[3]{\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{\sqrt[3]{b \cdot b - \left(4 \cdot a\right) \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{2 \cdot \left(\frac{a}{b} \cdot c - b\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} + \left(-b\right)}{2 \cdot a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019130 
(FPCore (a b c)
  :name "jeff quadratic root 2"
  (if (>= b 0) (/ (* 2 c) (- (- b) (sqrt (- (* b b) (* (* 4 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))))