Average Error: 28.8 → 16.3
Time: 13.0s
Precision: 64
\[1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt a \lt 94906265.62425155937671661376953125 \land 1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt b \lt 94906265.62425155937671661376953125 \land 1.053671212772350866701172186984739043147 \cdot 10^{-8} \lt c \lt 94906265.62425155937671661376953125\]
\[\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 1459.466396695320781873306259512901306152:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \left(3 \cdot a\right) \cdot c\right)}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{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 1459.466396695320781873306259512901306152:\\
\;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \left(3 \cdot a\right) \cdot c\right)}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r101615 = b;
        double r101616 = -r101615;
        double r101617 = r101615 * r101615;
        double r101618 = 3.0;
        double r101619 = a;
        double r101620 = r101618 * r101619;
        double r101621 = c;
        double r101622 = r101620 * r101621;
        double r101623 = r101617 - r101622;
        double r101624 = sqrt(r101623);
        double r101625 = r101616 + r101624;
        double r101626 = r101625 / r101620;
        return r101626;
}

double f(double a, double b, double c) {
        double r101627 = b;
        double r101628 = 1459.4663966953208;
        bool r101629 = r101627 <= r101628;
        double r101630 = r101627 * r101627;
        double r101631 = 3.0;
        double r101632 = a;
        double r101633 = r101631 * r101632;
        double r101634 = c;
        double r101635 = r101633 * r101634;
        double r101636 = fma(r101627, r101627, r101635);
        double r101637 = r101630 - r101636;
        double r101638 = r101632 * r101634;
        double r101639 = r101631 * r101638;
        double r101640 = r101630 - r101639;
        double r101641 = sqrt(r101640);
        double r101642 = r101627 + r101641;
        double r101643 = r101637 / r101642;
        double r101644 = r101643 / r101633;
        double r101645 = -0.5;
        double r101646 = r101634 / r101627;
        double r101647 = r101645 * r101646;
        double r101648 = r101629 ? r101644 : r101647;
        return r101648;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 18.0

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

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

      \[\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. Simplified17.1

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

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

    if 1459.4663966953208 < b

    1. Initial program 37.0

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

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

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

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

Reproduce

herbie shell --seed 2019304 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :precision binary64
  :pre (and (< 1.05367121277235087e-8 a 94906265.6242515594) (< 1.05367121277235087e-8 b 94906265.6242515594) (< 1.05367121277235087e-8 c 94906265.6242515594))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))