Average Error: 34.3 → 14.6
Time: 23.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 -1.718890754336214657908312726050790423755 \cdot 10^{100}:\\ \;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\ \mathbf{elif}\;b \le 2.915997880138567162583249308597050640656 \cdot 10^{-60}:\\ \;\;\;\;\frac{\sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b} \cdot \sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \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.718890754336214657908312726050790423755 \cdot 10^{100}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\

\end{array}
double f(double a, double b, double c) {
        double r80233 = b;
        double r80234 = -r80233;
        double r80235 = r80233 * r80233;
        double r80236 = 3.0;
        double r80237 = a;
        double r80238 = r80236 * r80237;
        double r80239 = c;
        double r80240 = r80238 * r80239;
        double r80241 = r80235 - r80240;
        double r80242 = sqrt(r80241);
        double r80243 = r80234 + r80242;
        double r80244 = r80243 / r80238;
        return r80244;
}

double f(double a, double b, double c) {
        double r80245 = b;
        double r80246 = -1.7188907543362147e+100;
        bool r80247 = r80245 <= r80246;
        double r80248 = -2.0;
        double r80249 = r80248 * r80245;
        double r80250 = 3.0;
        double r80251 = a;
        double r80252 = r80250 * r80251;
        double r80253 = r80249 / r80252;
        double r80254 = 2.915997880138567e-60;
        bool r80255 = r80245 <= r80254;
        double r80256 = r80245 * r80245;
        double r80257 = c;
        double r80258 = r80252 * r80257;
        double r80259 = r80256 - r80258;
        double r80260 = sqrt(r80259);
        double r80261 = r80260 - r80245;
        double r80262 = sqrt(r80261);
        double r80263 = r80262 * r80262;
        double r80264 = r80263 / r80252;
        double r80265 = -1.5;
        double r80266 = r80251 * r80257;
        double r80267 = r80266 / r80245;
        double r80268 = r80265 * r80267;
        double r80269 = r80268 / r80252;
        double r80270 = r80255 ? r80264 : r80269;
        double r80271 = r80247 ? r80253 : r80270;
        return r80271;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if b < -1.7188907543362147e+100

    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. Using strategy rm
    4. Applied add-cube-cbrt47.2

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

      \[\leadsto \frac{\color{blue}{\sqrt{\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \sqrt{\sqrt[3]{b \cdot b - \left(3 \cdot a\right) \cdot c}}} - b}{3 \cdot a}\]
    6. Applied fma-neg47.2

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

      \[\leadsto \frac{\color{blue}{-2 \cdot b}}{3 \cdot a}\]
    8. Simplified4.1

      \[\leadsto \frac{\color{blue}{-2 \cdot b}}{3 \cdot a}\]

    if -1.7188907543362147e+100 < b < 2.915997880138567e-60

    1. Initial program 13.9

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

      \[\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 add-sqr-sqrt14.3

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

    if 2.915997880138567e-60 < b

    1. Initial program 53.9

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

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

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification14.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.718890754336214657908312726050790423755 \cdot 10^{100}:\\ \;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\ \mathbf{elif}\;b \le 2.915997880138567162583249308597050640656 \cdot 10^{-60}:\\ \;\;\;\;\frac{\sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b} \cdot \sqrt{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019323 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))