Average Error: 33.5 → 10.7
Time: 14.1s
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 r1898541 = b;
        double r1898542 = -r1898541;
        double r1898543 = r1898541 * r1898541;
        double r1898544 = 3.0;
        double r1898545 = a;
        double r1898546 = r1898544 * r1898545;
        double r1898547 = c;
        double r1898548 = r1898546 * r1898547;
        double r1898549 = r1898543 - r1898548;
        double r1898550 = sqrt(r1898549);
        double r1898551 = r1898542 + r1898550;
        double r1898552 = r1898551 / r1898546;
        return r1898552;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r1898553 = b;
        double r1898554 = -2.4578910493759983e+114;
        bool r1898555 = r1898553 <= r1898554;
        double r1898556 = 0.5;
        double r1898557 = c;
        double r1898558 = r1898557 / r1898553;
        double r1898559 = r1898556 * r1898558;
        double r1898560 = a;
        double r1898561 = r1898553 / r1898560;
        double r1898562 = 0.6666666666666666;
        double r1898563 = r1898561 * r1898562;
        double r1898564 = r1898559 - r1898563;
        double r1898565 = 4.877869729426102e-129;
        bool r1898566 = r1898553 <= r1898565;
        double r1898567 = r1898553 * r1898553;
        double r1898568 = 3.0;
        double r1898569 = r1898568 * r1898560;
        double r1898570 = r1898569 * r1898557;
        double r1898571 = r1898567 - r1898570;
        double r1898572 = sqrt(r1898571);
        double r1898573 = r1898572 / r1898569;
        double r1898574 = r1898553 / r1898569;
        double r1898575 = r1898573 - r1898574;
        double r1898576 = -0.5;
        double r1898577 = r1898576 * r1898558;
        double r1898578 = r1898566 ? r1898575 : r1898577;
        double r1898579 = r1898555 ? r1898564 : r1898578;
        return r1898579;
}

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