Average Error: 28.7 → 14.9
Time: 16.1s
Precision: 64
\[1.0536712127723509 \cdot 10^{-08} \lt a \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt b \lt 94906265.62425156 \land 1.0536712127723509 \cdot 10^{-08} \lt c \lt 94906265.62425156\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -3.5237154995471856 \cdot 10^{-05}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)} \cdot \mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right) - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right) + b \cdot \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)}\right)}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \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}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -3.5237154995471856 \cdot 10^{-05}:\\
\;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)} \cdot \mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right) - b \cdot \left(b \cdot b\right)}{\mathsf{fma}\left(b, b, \mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right) + b \cdot \sqrt{\mathsf{fma}\left(b, b, \left(c \cdot a\right) \cdot -3\right)}\right)}}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r2703063 = b;
        double r2703064 = -r2703063;
        double r2703065 = r2703063 * r2703063;
        double r2703066 = 3.0;
        double r2703067 = a;
        double r2703068 = r2703066 * r2703067;
        double r2703069 = c;
        double r2703070 = r2703068 * r2703069;
        double r2703071 = r2703065 - r2703070;
        double r2703072 = sqrt(r2703071);
        double r2703073 = r2703064 + r2703072;
        double r2703074 = r2703073 / r2703068;
        return r2703074;
}

double f(double a, double b, double c) {
        double r2703075 = b;
        double r2703076 = r2703075 * r2703075;
        double r2703077 = 3.0;
        double r2703078 = a;
        double r2703079 = r2703077 * r2703078;
        double r2703080 = c;
        double r2703081 = r2703079 * r2703080;
        double r2703082 = r2703076 - r2703081;
        double r2703083 = sqrt(r2703082);
        double r2703084 = -r2703075;
        double r2703085 = r2703083 + r2703084;
        double r2703086 = r2703085 / r2703079;
        double r2703087 = -3.5237154995471856e-05;
        bool r2703088 = r2703086 <= r2703087;
        double r2703089 = r2703080 * r2703078;
        double r2703090 = -3.0;
        double r2703091 = r2703089 * r2703090;
        double r2703092 = fma(r2703075, r2703075, r2703091);
        double r2703093 = sqrt(r2703092);
        double r2703094 = r2703093 * r2703092;
        double r2703095 = r2703075 * r2703076;
        double r2703096 = r2703094 - r2703095;
        double r2703097 = r2703075 * r2703093;
        double r2703098 = r2703092 + r2703097;
        double r2703099 = fma(r2703075, r2703075, r2703098);
        double r2703100 = r2703096 / r2703099;
        double r2703101 = r2703100 / r2703079;
        double r2703102 = -0.5;
        double r2703103 = r2703080 / r2703075;
        double r2703104 = r2703102 * r2703103;
        double r2703105 = r2703088 ? r2703101 : r2703104;
        return r2703105;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)) < -3.5237154995471856e-05

    1. Initial program 16.6

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

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

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

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

    if -3.5237154995471856e-05 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

    1. Initial program 39.2

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

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

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

Reproduce

herbie shell --seed 2019158 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, narrow range"
  :pre (and (< 1.0536712127723509e-08 a 94906265.62425156) (< 1.0536712127723509e-08 b 94906265.62425156) (< 1.0536712127723509e-08 c 94906265.62425156))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))