Average Error: 19.6 → 6.9
Time: 16.6s
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 -3.359953003549156817553996908233908949771 \cdot 10^{103}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\\ \mathbf{elif}\;b \le 2.460281345538029934427192008281020146764 \cdot 10^{67}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\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}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt[3]{\frac{2}{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{c}}} \cdot \sqrt[3]{\frac{2}{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{c}}}\right) \cdot \sqrt[3]{\frac{2}{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{c}}}\\ \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 -3.359953003549156817553996908233908949771 \cdot 10^{103}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0.0:\\
\;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\

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

\end{array}\\

\mathbf{elif}\;b \le 2.460281345538029934427192008281020146764 \cdot 10^{67}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0.0:\\
\;\;\;\;\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}\\

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

\end{array}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r55934 = b;
        double r55935 = 0.0;
        bool r55936 = r55934 >= r55935;
        double r55937 = -r55934;
        double r55938 = r55934 * r55934;
        double r55939 = 4.0;
        double r55940 = a;
        double r55941 = r55939 * r55940;
        double r55942 = c;
        double r55943 = r55941 * r55942;
        double r55944 = r55938 - r55943;
        double r55945 = sqrt(r55944);
        double r55946 = r55937 - r55945;
        double r55947 = 2.0;
        double r55948 = r55947 * r55940;
        double r55949 = r55946 / r55948;
        double r55950 = r55947 * r55942;
        double r55951 = r55937 + r55945;
        double r55952 = r55950 / r55951;
        double r55953 = r55936 ? r55949 : r55952;
        return r55953;
}

double f(double a, double b, double c) {
        double r55954 = b;
        double r55955 = -3.359953003549157e+103;
        bool r55956 = r55954 <= r55955;
        double r55957 = 0.0;
        bool r55958 = r55954 >= r55957;
        double r55959 = 1.0;
        double r55960 = c;
        double r55961 = r55960 / r55954;
        double r55962 = a;
        double r55963 = r55954 / r55962;
        double r55964 = r55961 - r55963;
        double r55965 = r55959 * r55964;
        double r55966 = -1.0;
        double r55967 = r55966 * r55961;
        double r55968 = r55958 ? r55965 : r55967;
        double r55969 = 2.46028134553803e+67;
        bool r55970 = r55954 <= r55969;
        double r55971 = -r55954;
        double r55972 = r55954 * r55954;
        double r55973 = 4.0;
        double r55974 = r55973 * r55962;
        double r55975 = r55974 * r55960;
        double r55976 = r55972 - r55975;
        double r55977 = sqrt(r55976);
        double r55978 = sqrt(r55977);
        double r55979 = r55978 * r55978;
        double r55980 = r55971 - r55979;
        double r55981 = 2.0;
        double r55982 = r55981 * r55962;
        double r55983 = r55980 / r55982;
        double r55984 = r55981 * r55960;
        double r55985 = r55977 - r55954;
        double r55986 = r55984 / r55985;
        double r55987 = r55958 ? r55983 : r55986;
        double r55988 = r55985 / r55960;
        double r55989 = r55981 / r55988;
        double r55990 = cbrt(r55989);
        double r55991 = r55990 * r55990;
        double r55992 = r55991 * r55990;
        double r55993 = r55958 ? r55965 : r55992;
        double r55994 = r55970 ? r55987 : r55993;
        double r55995 = r55956 ? r55968 : r55994;
        return r55995;
}

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.359953003549157e+103

    1. Initial program 29.8

      \[\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. Simplified29.8

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

      \[\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}\]
    4. Taylor expanded around 0 29.8

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\color{blue}{1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]
    6. Using strategy rm
    7. Applied associate-/l*30.1

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

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

    if -3.359953003549157e+103 < b < 2.46028134553803e+67

    1. Initial program 8.9

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

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

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

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

    if 2.46028134553803e+67 < b

    1. Initial program 40.5

      \[\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. Simplified40.5

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

      \[\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}\]
    4. Taylor expanded around 0 5.5

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\color{blue}{1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\]
    6. Using strategy rm
    7. Applied associate-/l*5.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.359953003549156817553996908233908949771 \cdot 10^{103}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;-1 \cdot \frac{c}{b}\\ \end{array}\\ \mathbf{elif}\;b \le 2.460281345538029934427192008281020146764 \cdot 10^{67}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0.0:\\ \;\;\;\;\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}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}\\ \end{array}\\ \mathbf{elif}\;b \ge 0.0:\\ \;\;\;\;1 \cdot \left(\frac{c}{b} - \frac{b}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt[3]{\frac{2}{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{c}}} \cdot \sqrt[3]{\frac{2}{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{c}}}\right) \cdot \sqrt[3]{\frac{2}{\frac{\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b}{c}}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019304 +o rules:numerics
(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)))))))