Average Error: 34.2 → 10.0
Time: 16.6s
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.074189026339084059840315861627273882188 \cdot 10^{154}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 1.61145084478121505718169973575148582501 \cdot 10^{-34}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \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 -1.074189026339084059840315861627273882188 \cdot 10^{154}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r82555 = b;
        double r82556 = -r82555;
        double r82557 = r82555 * r82555;
        double r82558 = 3.0;
        double r82559 = a;
        double r82560 = r82558 * r82559;
        double r82561 = c;
        double r82562 = r82560 * r82561;
        double r82563 = r82557 - r82562;
        double r82564 = sqrt(r82563);
        double r82565 = r82556 + r82564;
        double r82566 = r82565 / r82560;
        return r82566;
}

double f(double a, double b, double c) {
        double r82567 = b;
        double r82568 = -1.074189026339084e+154;
        bool r82569 = r82567 <= r82568;
        double r82570 = 0.5;
        double r82571 = c;
        double r82572 = r82571 / r82567;
        double r82573 = r82570 * r82572;
        double r82574 = 0.6666666666666666;
        double r82575 = a;
        double r82576 = r82567 / r82575;
        double r82577 = r82574 * r82576;
        double r82578 = r82573 - r82577;
        double r82579 = 1.611450844781215e-34;
        bool r82580 = r82567 <= r82579;
        double r82581 = r82567 * r82567;
        double r82582 = 3.0;
        double r82583 = r82575 * r82571;
        double r82584 = r82582 * r82583;
        double r82585 = r82581 - r82584;
        double r82586 = sqrt(r82585);
        double r82587 = r82586 - r82567;
        double r82588 = r82582 * r82575;
        double r82589 = r82587 / r82588;
        double r82590 = -0.5;
        double r82591 = r82590 * r82572;
        double r82592 = r82580 ? r82589 : r82591;
        double r82593 = r82569 ? r82578 : r82592;
        return r82593;
}

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.074189026339084e+154

    1. Initial program 64.0

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}}\]

    if -1.074189026339084e+154 < b < 1.611450844781215e-34

    1. Initial program 13.6

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{{b}^{2} - 3 \cdot \left(a \cdot c\right)}} - b}{3 \cdot a}\]
    4. Simplified13.7

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

    if 1.611450844781215e-34 < b

    1. Initial program 55.0

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.074189026339084059840315861627273882188 \cdot 10^{154}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 1.61145084478121505718169973575148582501 \cdot 10^{-34}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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