Average Error: 18.6 → 6.7
Time: 22.0s
Precision: 64
\[\begin{array}{l} \mathbf{if}\;b \ge 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 -2.723731815549707 \cdot 10^{+89}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\left(\left(\frac{\left(-b\right) - \left(b - \frac{a \cdot 2}{\frac{b}{c}}\right)}{a \cdot 2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\left(\frac{a \cdot 2}{\frac{b}{c}} - b\right) + \left(-b\right)}\\ \end{array}\\ \mathbf{elif}\;b \le -1.165097522778907 \cdot 10^{-308}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\frac{b \cdot \left(-b \cdot b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \left(b \cdot b - \left(4 \cdot a\right) \cdot c\right)}{b \cdot b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\\ \mathbf{elif}\;b \le 1.559394358097289 \cdot 10^{+69}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt[3]{\left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \left(\left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)\right)}}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\left(\frac{a \cdot 2}{\frac{b}{c}} - b\right) + \left(-b\right)}\\ \end{array}\]
\begin{array}{l}
\mathbf{if}\;b \ge 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 -2.723731815549707 \cdot 10^{+89}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\left(\left(\frac{\left(-b\right) - \left(b - \frac{a \cdot 2}{\frac{b}{c}}\right)}{a \cdot 2}\right)\right)\\

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

\end{array}\\

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

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

\end{array}\\

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

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

\end{array}\\

\mathbf{elif}\;b \ge 0:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r545947 = b;
        double r545948 = 0.0;
        bool r545949 = r545947 >= r545948;
        double r545950 = -r545947;
        double r545951 = r545947 * r545947;
        double r545952 = 4.0;
        double r545953 = a;
        double r545954 = r545952 * r545953;
        double r545955 = c;
        double r545956 = r545954 * r545955;
        double r545957 = r545951 - r545956;
        double r545958 = sqrt(r545957);
        double r545959 = r545950 - r545958;
        double r545960 = 2.0;
        double r545961 = r545960 * r545953;
        double r545962 = r545959 / r545961;
        double r545963 = r545960 * r545955;
        double r545964 = r545950 + r545958;
        double r545965 = r545963 / r545964;
        double r545966 = r545949 ? r545962 : r545965;
        return r545966;
}

double f(double a, double b, double c) {
        double r545967 = b;
        double r545968 = -2.723731815549707e+89;
        bool r545969 = r545967 <= r545968;
        double r545970 = 0.0;
        bool r545971 = r545967 >= r545970;
        double r545972 = -r545967;
        double r545973 = a;
        double r545974 = 2.0;
        double r545975 = r545973 * r545974;
        double r545976 = c;
        double r545977 = r545967 / r545976;
        double r545978 = r545975 / r545977;
        double r545979 = r545967 - r545978;
        double r545980 = r545972 - r545979;
        double r545981 = r545980 / r545975;
        double r545982 = /* ERROR: no posit support in C */;
        double r545983 = /* ERROR: no posit support in C */;
        double r545984 = r545976 * r545974;
        double r545985 = r545978 - r545967;
        double r545986 = r545985 + r545972;
        double r545987 = r545984 / r545986;
        double r545988 = r545971 ? r545983 : r545987;
        double r545989 = -1.165097522778907e-308;
        bool r545990 = r545967 <= r545989;
        double r545991 = r545967 * r545967;
        double r545992 = -r545991;
        double r545993 = r545967 * r545992;
        double r545994 = 4.0;
        double r545995 = r545994 * r545973;
        double r545996 = r545995 * r545976;
        double r545997 = r545991 - r545996;
        double r545998 = sqrt(r545997);
        double r545999 = r545998 * r545997;
        double r546000 = r545993 - r545999;
        double r546001 = r545998 - r545967;
        double r546002 = r545998 * r546001;
        double r546003 = r545991 + r546002;
        double r546004 = r546000 / r546003;
        double r546005 = r546004 / r545975;
        double r546006 = r545972 + r545998;
        double r546007 = r545984 / r546006;
        double r546008 = r545971 ? r546005 : r546007;
        double r546009 = 1.559394358097289e+69;
        bool r546010 = r545967 <= r546009;
        double r546011 = r545972 - r545998;
        double r546012 = r546011 / r545975;
        double r546013 = r546006 * r546006;
        double r546014 = r546006 * r546013;
        double r546015 = cbrt(r546014);
        double r546016 = r545984 / r546015;
        double r546017 = r545971 ? r546012 : r546016;
        double r546018 = r545976 / r545967;
        double r546019 = r545967 / r545973;
        double r546020 = r546018 - r546019;
        double r546021 = r545971 ? r546020 : r545987;
        double r546022 = r546010 ? r546017 : r546021;
        double r546023 = r545990 ? r546008 : r546022;
        double r546024 = r545969 ? r545988 : r546023;
        return r546024;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b < -2.723731815549707e+89

    1. Initial program 27.1

      \[\begin{array}{l} \mathbf{if}\;b \ge 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. Taylor expanded around -inf 6.1

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 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}{\color{blue}{\left(-b\right) + \left(\frac{2 \cdot a}{\frac{b}{c}} - b\right)}}\\ \end{array}\]
    4. Taylor expanded around inf 2.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 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}{\left(-b\right) + \left(\frac{2 \cdot a}{\frac{b}{c}} - b\right)}\\ \end{array}\]
    5. Simplified2.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \color{blue}{\left(b - \frac{2 \cdot a}{\frac{b}{c}}\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \left(\frac{2 \cdot a}{\frac{b}{c}} - b\right)}\\ \end{array}\]
    6. Using strategy rm
    7. Applied insert-posit162.7

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

    if -2.723731815549707e+89 < b < -1.165097522778907e-308

    1. Initial program 8.7

      \[\begin{array}{l} \mathbf{if}\;b \ge 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. Using strategy rm
    3. Applied flip3--8.7

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

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

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

    if -1.165097522778907e-308 < b < 1.559394358097289e+69

    1. Initial program 9.2

      \[\begin{array}{l} \mathbf{if}\;b \ge 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. Using strategy rm
    3. Applied add-cbrt-cube9.2

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

    if 1.559394358097289e+69 < b

    1. Initial program 38.9

      \[\begin{array}{l} \mathbf{if}\;b \ge 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. Taylor expanded around -inf 38.9

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 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}{\color{blue}{\left(-b\right) + \left(\frac{2 \cdot a}{\frac{b}{c}} - b\right)}}\\ \end{array}\]
    4. Taylor expanded around inf 9.3

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 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}{\left(-b\right) + \left(\frac{2 \cdot a}{\frac{b}{c}} - b\right)}\\ \end{array}\]
    5. Simplified4.9

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \color{blue}{\left(b - \frac{2 \cdot a}{\frac{b}{c}}\right)}}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) + \left(\frac{2 \cdot a}{\frac{b}{c}} - b\right)}\\ \end{array}\]
    6. Taylor expanded around 0 4.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.723731815549707 \cdot 10^{+89}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\left(\left(\frac{\left(-b\right) - \left(b - \frac{a \cdot 2}{\frac{b}{c}}\right)}{a \cdot 2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\left(\frac{a \cdot 2}{\frac{b}{c}} - b\right) + \left(-b\right)}\\ \end{array}\\ \mathbf{elif}\;b \le -1.165097522778907 \cdot 10^{-308}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\frac{b \cdot \left(-b \cdot b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \left(b \cdot b - \left(4 \cdot a\right) \cdot c\right)}{b \cdot b + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} \cdot \left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b\right)}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \end{array}\\ \mathbf{elif}\;b \le 1.559394358097289 \cdot 10^{+69}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{a \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\sqrt[3]{\left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \left(\left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right) \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}\right)\right)}}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot 2}{\left(\frac{a \cdot 2}{\frac{b}{c}} - b\right) + \left(-b\right)}\\ \end{array}\]

Reproduce

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