Average Error: 19.0 → 6.8
Time: 1.1m
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 -1.6124744946043857 \cdot 10^{+143}:\\ \;\;\;\;\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(\frac{2 \cdot c}{\frac{b}{a}} - b\right) + \left(-b\right)}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \le 1.0661746528175936 \cdot 10^{+79}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\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}}}\\ \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}{\left(a \cdot \frac{c}{b} - b\right) \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\sqrt[3]{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \left(b \cdot b - \left(4 \cdot a\right) \cdot c\right)}} \cdot \sqrt{\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 -1.6124744946043857 \cdot 10^{+143}:\\
\;\;\;\;\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(\frac{2 \cdot c}{\frac{b}{a}} - b\right) + \left(-b\right)}{2 \cdot a}\\

\end{array}\\

\mathbf{elif}\;b \le 1.0661746528175936 \cdot 10^{+79}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{2 \cdot c}{\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}}}\\

\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}{\left(a \cdot \frac{c}{b} - b\right) \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{\sqrt[3]{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \left(b \cdot b - \left(4 \cdot a\right) \cdot c\right)}} \cdot \sqrt{\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 r2879941 = b;
        double r2879942 = 0.0;
        bool r2879943 = r2879941 >= r2879942;
        double r2879944 = 2.0;
        double r2879945 = c;
        double r2879946 = r2879944 * r2879945;
        double r2879947 = -r2879941;
        double r2879948 = r2879941 * r2879941;
        double r2879949 = 4.0;
        double r2879950 = a;
        double r2879951 = r2879949 * r2879950;
        double r2879952 = r2879951 * r2879945;
        double r2879953 = r2879948 - r2879952;
        double r2879954 = sqrt(r2879953);
        double r2879955 = r2879947 - r2879954;
        double r2879956 = r2879946 / r2879955;
        double r2879957 = r2879947 + r2879954;
        double r2879958 = r2879944 * r2879950;
        double r2879959 = r2879957 / r2879958;
        double r2879960 = r2879943 ? r2879956 : r2879959;
        return r2879960;
}

double f(double a, double b, double c) {
        double r2879961 = b;
        double r2879962 = -1.6124744946043857e+143;
        bool r2879963 = r2879961 <= r2879962;
        double r2879964 = 0.0;
        bool r2879965 = r2879961 >= r2879964;
        double r2879966 = 2.0;
        double r2879967 = c;
        double r2879968 = r2879966 * r2879967;
        double r2879969 = -r2879961;
        double r2879970 = r2879961 * r2879961;
        double r2879971 = 4.0;
        double r2879972 = a;
        double r2879973 = r2879971 * r2879972;
        double r2879974 = r2879973 * r2879967;
        double r2879975 = r2879970 - r2879974;
        double r2879976 = sqrt(r2879975);
        double r2879977 = r2879969 - r2879976;
        double r2879978 = r2879968 / r2879977;
        double r2879979 = r2879961 / r2879972;
        double r2879980 = r2879968 / r2879979;
        double r2879981 = r2879980 - r2879961;
        double r2879982 = r2879981 + r2879969;
        double r2879983 = r2879966 * r2879972;
        double r2879984 = r2879982 / r2879983;
        double r2879985 = r2879965 ? r2879978 : r2879984;
        double r2879986 = 1.0661746528175936e+79;
        bool r2879987 = r2879961 <= r2879986;
        double r2879988 = sqrt(r2879976);
        double r2879989 = r2879988 * r2879988;
        double r2879990 = r2879969 - r2879989;
        double r2879991 = r2879968 / r2879990;
        double r2879992 = r2879976 + r2879969;
        double r2879993 = r2879992 / r2879983;
        double r2879994 = r2879965 ? r2879991 : r2879993;
        double r2879995 = r2879967 / r2879961;
        double r2879996 = r2879972 * r2879995;
        double r2879997 = r2879996 - r2879961;
        double r2879998 = r2879997 * r2879966;
        double r2879999 = r2879968 / r2879998;
        double r2880000 = r2879976 * r2879975;
        double r2880001 = cbrt(r2880000);
        double r2880002 = sqrt(r2880001);
        double r2880003 = r2880002 * r2879988;
        double r2880004 = r2880003 + r2879969;
        double r2880005 = r2880004 / r2879983;
        double r2880006 = r2879965 ? r2879999 : r2880005;
        double r2880007 = r2879987 ? r2879994 : r2880006;
        double r2880008 = r2879963 ? r2879985 : r2880007;
        return r2880008;
}

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.6124744946043857e+143

    1. Initial program 57.1

      \[\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 11.8

      \[\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) + \left(2 \cdot \frac{a \cdot c}{b} - b\right)}{2 \cdot a}\\ \end{array}\]
    3. Simplified2.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) + \left(\frac{2 \cdot c}{\frac{b}{a}} - b\right)}{2 \cdot a}\\ \end{array}\]

    if -1.6124744946043857e+143 < b < 1.0661746528175936e+79

    1. Initial program 8.9

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

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

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

    if 1.0661746528175936e+79 < b

    1. Initial program 26.8

      \[\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 7.0

      \[\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. Simplified3.2

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\color{blue}{\left(a \cdot \frac{c}{b} - 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}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt3.2

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(a \cdot \frac{c}{b} - b\right) \cdot 2}\\ \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}\]
    6. Using strategy rm
    7. Applied add-cbrt-cube3.2

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

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

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

Reproduce

herbie shell --seed 2019125 
(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))))