Average Error: 44.3 → 10.8
Time: 15.1s
Precision: 64
\[1.11022 \cdot 10^{-16} \lt a \lt 9.0072 \cdot 10^{15} \land 1.11022 \cdot 10^{-16} \lt b \lt 9.0072 \cdot 10^{15} \land 1.11022 \cdot 10^{-16} \lt c \lt 9.0072 \cdot 10^{15}\]
\[\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 0.0357101210953405454:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(c, 3 \cdot a, b \cdot b\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + 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 0.0357101210953405454:\\
\;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(c, 3 \cdot a, b \cdot b\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r97630 = b;
        double r97631 = -r97630;
        double r97632 = r97630 * r97630;
        double r97633 = 3.0;
        double r97634 = a;
        double r97635 = r97633 * r97634;
        double r97636 = c;
        double r97637 = r97635 * r97636;
        double r97638 = r97632 - r97637;
        double r97639 = sqrt(r97638);
        double r97640 = r97631 + r97639;
        double r97641 = r97640 / r97635;
        return r97641;
}

double f(double a, double b, double c) {
        double r97642 = b;
        double r97643 = 0.035710121095340545;
        bool r97644 = r97642 <= r97643;
        double r97645 = r97642 * r97642;
        double r97646 = c;
        double r97647 = 3.0;
        double r97648 = a;
        double r97649 = r97647 * r97648;
        double r97650 = fma(r97646, r97649, r97645);
        double r97651 = r97645 - r97650;
        double r97652 = r97649 * r97646;
        double r97653 = r97645 - r97652;
        double r97654 = sqrt(r97653);
        double r97655 = r97654 + r97642;
        double r97656 = r97651 / r97655;
        double r97657 = r97656 / r97649;
        double r97658 = -0.5;
        double r97659 = r97646 / r97642;
        double r97660 = r97658 * r97659;
        double r97661 = r97644 ? r97657 : r97660;
        return r97661;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 0.035710121095340545

    1. Initial program 21.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified21.3

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3 \cdot a}}\]
    3. Using strategy rm
    4. Applied flip--21.2

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

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

    if 0.035710121095340545 < b

    1. Initial program 47.1

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified47.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 0.0357101210953405454:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(c, 3 \cdot a, b \cdot b\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019195 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, medium range"
  :pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))