Average Error: 43.8 → 11.1
Time: 6.6s
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 1.7936624356974993 \cdot 10^{-4}:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, c \cdot \left(3 \cdot a\right)\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 1.7936624356974993 \cdot 10^{-4}:\\
\;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, c \cdot \left(3 \cdot a\right)\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 r63180 = b;
        double r63181 = -r63180;
        double r63182 = r63180 * r63180;
        double r63183 = 3.0;
        double r63184 = a;
        double r63185 = r63183 * r63184;
        double r63186 = c;
        double r63187 = r63185 * r63186;
        double r63188 = r63182 - r63187;
        double r63189 = sqrt(r63188);
        double r63190 = r63181 + r63189;
        double r63191 = r63190 / r63185;
        return r63191;
}

double f(double a, double b, double c) {
        double r63192 = b;
        double r63193 = 0.00017936624356974993;
        bool r63194 = r63192 <= r63193;
        double r63195 = r63192 * r63192;
        double r63196 = c;
        double r63197 = 3.0;
        double r63198 = a;
        double r63199 = r63197 * r63198;
        double r63200 = r63196 * r63199;
        double r63201 = fma(r63192, r63192, r63200);
        double r63202 = r63195 - r63201;
        double r63203 = r63199 * r63196;
        double r63204 = r63195 - r63203;
        double r63205 = sqrt(r63204);
        double r63206 = r63205 + r63192;
        double r63207 = r63202 / r63206;
        double r63208 = r63207 / r63199;
        double r63209 = -0.5;
        double r63210 = r63196 / r63192;
        double r63211 = r63209 * r63210;
        double r63212 = r63194 ? r63208 : r63211;
        return r63212;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

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

    1. Initial program 18.4

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

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

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

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

    if 0.00017936624356974993 < b

    1. Initial program 45.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 1.7936624356974993 \cdot 10^{-4}:\\ \;\;\;\;\frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, c \cdot \left(3 \cdot a\right)\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 2020047 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, medium range"
  :precision binary64
  :pre (and (< 1.11022e-16 a 9.0072e+15) (< 1.11022e-16 b 9.0072e+15) (< 1.11022e-16 c 9.0072e+15))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))