Average Error: 33.5 → 10.7
Time: 54.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 -2.4578910493759983 \cdot 10^{+114}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\ \mathbf{elif}\;b \le 4.877869729426102 \cdot 10^{-129}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} - \frac{b}{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}\;b \le -2.4578910493759983 \cdot 10^{+114}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\

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

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

\end{array}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r18629544 = b;
        double r18629545 = -r18629544;
        double r18629546 = r18629544 * r18629544;
        double r18629547 = 3.0;
        double r18629548 = a;
        double r18629549 = r18629547 * r18629548;
        double r18629550 = c;
        double r18629551 = r18629549 * r18629550;
        double r18629552 = r18629546 - r18629551;
        double r18629553 = sqrt(r18629552);
        double r18629554 = r18629545 + r18629553;
        double r18629555 = r18629554 / r18629549;
        return r18629555;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r18629556 = b;
        double r18629557 = -2.4578910493759983e+114;
        bool r18629558 = r18629556 <= r18629557;
        double r18629559 = 0.5;
        double r18629560 = c;
        double r18629561 = r18629560 / r18629556;
        double r18629562 = r18629559 * r18629561;
        double r18629563 = a;
        double r18629564 = r18629556 / r18629563;
        double r18629565 = 0.6666666666666666;
        double r18629566 = r18629564 * r18629565;
        double r18629567 = r18629562 - r18629566;
        double r18629568 = 4.877869729426102e-129;
        bool r18629569 = r18629556 <= r18629568;
        double r18629570 = r18629556 * r18629556;
        double r18629571 = 3.0;
        double r18629572 = r18629571 * r18629563;
        double r18629573 = r18629572 * r18629560;
        double r18629574 = r18629570 - r18629573;
        double r18629575 = sqrt(r18629574);
        double r18629576 = r18629575 / r18629572;
        double r18629577 = r18629556 / r18629572;
        double r18629578 = r18629576 - r18629577;
        double r18629579 = -0.5;
        double r18629580 = r18629579 * r18629561;
        double r18629581 = r18629569 ? r18629578 : r18629580;
        double r18629582 = r18629558 ? r18629567 : r18629581;
        return r18629582;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if b < -2.4578910493759983e+114

    1. Initial program 48.2

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

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

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

    if -2.4578910493759983e+114 < b < 4.877869729426102e-129

    1. Initial program 11.6

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

      \[\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 div-sub11.6

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

    if 4.877869729426102e-129 < b

    1. Initial program 49.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.4578910493759983 \cdot 10^{+114}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\ \mathbf{elif}\;b \le 4.877869729426102 \cdot 10^{-129}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} - \frac{b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019128 
(FPCore (a b c d)
  :name "Cubic critical"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))