Average Error: 33.9 → 9.1
Time: 5.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.1259751240381662 \cdot 10^{137}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 4.65690860885773435 \cdot 10^{-153}:\\ \;\;\;\;1 \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\ \mathbf{elif}\;b \le 31296389.2947799377:\\ \;\;\;\;1 \cdot \frac{\frac{0 + 3 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \left(-0.5 \cdot \frac{c}{b}\right)\\ \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.1259751240381662 \cdot 10^{137}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\

\mathbf{elif}\;b \le 4.65690860885773435 \cdot 10^{-153}:\\
\;\;\;\;1 \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\

\mathbf{elif}\;b \le 31296389.2947799377:\\
\;\;\;\;1 \cdot \frac{\frac{0 + 3 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;1 \cdot \left(-0.5 \cdot \frac{c}{b}\right)\\

\end{array}
double f(double a, double b, double c) {
        double r115547 = b;
        double r115548 = -r115547;
        double r115549 = r115547 * r115547;
        double r115550 = 3.0;
        double r115551 = a;
        double r115552 = r115550 * r115551;
        double r115553 = c;
        double r115554 = r115552 * r115553;
        double r115555 = r115549 - r115554;
        double r115556 = sqrt(r115555);
        double r115557 = r115548 + r115556;
        double r115558 = r115557 / r115552;
        return r115558;
}

double f(double a, double b, double c) {
        double r115559 = b;
        double r115560 = -1.1259751240381662e+137;
        bool r115561 = r115559 <= r115560;
        double r115562 = 0.5;
        double r115563 = c;
        double r115564 = r115563 / r115559;
        double r115565 = r115562 * r115564;
        double r115566 = 0.6666666666666666;
        double r115567 = a;
        double r115568 = r115559 / r115567;
        double r115569 = r115566 * r115568;
        double r115570 = r115565 - r115569;
        double r115571 = 4.6569086088577344e-153;
        bool r115572 = r115559 <= r115571;
        double r115573 = 1.0;
        double r115574 = -r115559;
        double r115575 = r115559 * r115559;
        double r115576 = 3.0;
        double r115577 = r115576 * r115567;
        double r115578 = r115577 * r115563;
        double r115579 = r115575 - r115578;
        double r115580 = sqrt(r115579);
        double r115581 = r115574 + r115580;
        double r115582 = r115581 / r115577;
        double r115583 = r115573 * r115582;
        double r115584 = 31296389.294779938;
        bool r115585 = r115559 <= r115584;
        double r115586 = 0.0;
        double r115587 = r115567 * r115563;
        double r115588 = r115576 * r115587;
        double r115589 = r115586 + r115588;
        double r115590 = r115574 - r115580;
        double r115591 = r115589 / r115590;
        double r115592 = r115591 / r115577;
        double r115593 = r115573 * r115592;
        double r115594 = -0.5;
        double r115595 = r115594 * r115564;
        double r115596 = r115573 * r115595;
        double r115597 = r115585 ? r115593 : r115596;
        double r115598 = r115572 ? r115583 : r115597;
        double r115599 = r115561 ? r115570 : r115598;
        return r115599;
}

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 4 regimes
  2. if b < -1.1259751240381662e+137

    1. Initial program 56.5

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Taylor expanded around -inf 3.4

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

    if -1.1259751240381662e+137 < b < 4.6569086088577344e-153

    1. Initial program 10.9

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity10.9

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

    if 4.6569086088577344e-153 < b < 31296389.294779938

    1. Initial program 33.0

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity33.0

      \[\leadsto \color{blue}{1 \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}}\]
    4. Using strategy rm
    5. Applied flip-+33.1

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

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

    if 31296389.294779938 < b

    1. Initial program 55.9

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity55.9

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

      \[\leadsto 1 \cdot \color{blue}{\left(-0.5 \cdot \frac{c}{b}\right)}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification9.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.1259751240381662 \cdot 10^{137}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 4.65690860885773435 \cdot 10^{-153}:\\ \;\;\;\;1 \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\ \mathbf{elif}\;b \le 31296389.2947799377:\\ \;\;\;\;1 \cdot \frac{\frac{0 + 3 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \left(-0.5 \cdot \frac{c}{b}\right)\\ \end{array}\]

Reproduce

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