Average Error: 34.3 → 14.6
Time: 22.0s
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 r87264 = b;
        double r87265 = -r87264;
        double r87266 = r87264 * r87264;
        double r87267 = 3.0;
        double r87268 = a;
        double r87269 = r87267 * r87268;
        double r87270 = c;
        double r87271 = r87269 * r87270;
        double r87272 = r87266 - r87271;
        double r87273 = sqrt(r87272);
        double r87274 = r87265 + r87273;
        double r87275 = r87274 / r87269;
        return r87275;
}

double f(double a, double b, double c) {
        double r87276 = b;
        double r87277 = -1.7188907543362147e+100;
        bool r87278 = r87276 <= r87277;
        double r87279 = -2.0;
        double r87280 = r87279 * r87276;
        double r87281 = 3.0;
        double r87282 = a;
        double r87283 = r87281 * r87282;
        double r87284 = r87280 / r87283;
        double r87285 = 2.915997880138567e-60;
        bool r87286 = r87276 <= r87285;
        double r87287 = r87276 * r87276;
        double r87288 = c;
        double r87289 = r87283 * r87288;
        double r87290 = r87287 - r87289;
        double r87291 = sqrt(r87290);
        double r87292 = r87291 - r87276;
        double r87293 = sqrt(r87292);
        double r87294 = r87293 * r87293;
        double r87295 = r87294 / r87283;
        double r87296 = -1.5;
        double r87297 = r87282 * r87288;
        double r87298 = r87297 / r87276;
        double r87299 = r87296 * r87298;
        double r87300 = r87299 / r87283;
        double r87301 = r87286 ? r87295 : r87300;
        double r87302 = r87278 ? r87284 : r87301;
        return r87302;
}

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)))