Average Error: 34.5 → 10.7
Time: 18.3s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -2.221067196710922123169723133116561516447 \cdot 10^{149}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(c \cdot \frac{a}{b}, 1.5, b \cdot -2\right)}{3}}{a}\\ \mathbf{elif}\;b \le 2.898348930695269343280527497904161468201 \cdot 10^{-35}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(c \cdot 3\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le -2.221067196710922123169723133116561516447 \cdot 10^{149}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(c \cdot \frac{a}{b}, 1.5, b \cdot -2\right)}{3}}{a}\\

\mathbf{elif}\;b \le 2.898348930695269343280527497904161468201 \cdot 10^{-35}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(c \cdot 3\right)} - b}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r4735705 = b;
        double r4735706 = -r4735705;
        double r4735707 = r4735705 * r4735705;
        double r4735708 = 3.0;
        double r4735709 = a;
        double r4735710 = r4735708 * r4735709;
        double r4735711 = c;
        double r4735712 = r4735710 * r4735711;
        double r4735713 = r4735707 - r4735712;
        double r4735714 = sqrt(r4735713);
        double r4735715 = r4735706 + r4735714;
        double r4735716 = r4735715 / r4735710;
        return r4735716;
}

double f(double a, double b, double c) {
        double r4735717 = b;
        double r4735718 = -2.221067196710922e+149;
        bool r4735719 = r4735717 <= r4735718;
        double r4735720 = c;
        double r4735721 = a;
        double r4735722 = r4735721 / r4735717;
        double r4735723 = r4735720 * r4735722;
        double r4735724 = 1.5;
        double r4735725 = -2.0;
        double r4735726 = r4735717 * r4735725;
        double r4735727 = fma(r4735723, r4735724, r4735726);
        double r4735728 = 3.0;
        double r4735729 = r4735727 / r4735728;
        double r4735730 = r4735729 / r4735721;
        double r4735731 = 2.8983489306952693e-35;
        bool r4735732 = r4735717 <= r4735731;
        double r4735733 = r4735717 * r4735717;
        double r4735734 = r4735720 * r4735728;
        double r4735735 = r4735721 * r4735734;
        double r4735736 = r4735733 - r4735735;
        double r4735737 = sqrt(r4735736);
        double r4735738 = r4735737 - r4735717;
        double r4735739 = r4735728 * r4735721;
        double r4735740 = r4735738 / r4735739;
        double r4735741 = -0.5;
        double r4735742 = r4735720 / r4735717;
        double r4735743 = r4735741 * r4735742;
        double r4735744 = r4735732 ? r4735740 : r4735743;
        double r4735745 = r4735719 ? r4735730 : r4735744;
        return r4735745;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 3 regimes
  2. if b < -2.221067196710922e+149

    1. Initial program 62.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied associate-/r*62.3

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

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}}{a}\]
    5. Taylor expanded around -inf 11.1

      \[\leadsto \frac{\frac{\color{blue}{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}}{3}}{a}\]
    6. Simplified3.0

      \[\leadsto \frac{\frac{\color{blue}{\mathsf{fma}\left(c \cdot \frac{a}{b}, 1.5, -2 \cdot b\right)}}{3}}{a}\]

    if -2.221067196710922e+149 < b < 2.8983489306952693e-35

    1. Initial program 14.7

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

      \[\leadsto \color{blue}{\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \frac{1}{3 \cdot a}}\]
    4. Using strategy rm
    5. Applied associate-*r/14.7

      \[\leadsto \color{blue}{\frac{\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot 1}{3 \cdot a}}\]
    6. Simplified14.8

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

    if 2.8983489306952693e-35 < b

    1. Initial program 54.4

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.221067196710922123169723133116561516447 \cdot 10^{149}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(c \cdot \frac{a}{b}, 1.5, b \cdot -2\right)}{3}}{a}\\ \mathbf{elif}\;b \le 2.898348930695269343280527497904161468201 \cdot 10^{-35}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - a \cdot \left(c \cdot 3\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019171 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))