Average Error: 34.1 → 16.8
Time: 4.7s
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.56941706508999029 \cdot 10^{163}:\\ \;\;\;\;\frac{\left(-b\right) + \left(1.5 \cdot \frac{a \cdot c}{b} - b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 2.4075552977241297 \cdot 10^{38}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - {\left(3 \cdot \left(a \cdot c\right)\right)}^{1}}}{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.56941706508999029 \cdot 10^{163}:\\
\;\;\;\;\frac{\left(-b\right) + \left(1.5 \cdot \frac{a \cdot c}{b} - b\right)}{3 \cdot a}\\

\mathbf{elif}\;b \le 2.4075552977241297 \cdot 10^{38}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - {\left(3 \cdot \left(a \cdot c\right)\right)}^{1}}}{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 r104591 = b;
        double r104592 = -r104591;
        double r104593 = r104591 * r104591;
        double r104594 = 3.0;
        double r104595 = a;
        double r104596 = r104594 * r104595;
        double r104597 = c;
        double r104598 = r104596 * r104597;
        double r104599 = r104593 - r104598;
        double r104600 = sqrt(r104599);
        double r104601 = r104592 + r104600;
        double r104602 = r104601 / r104596;
        return r104602;
}

double f(double a, double b, double c) {
        double r104603 = b;
        double r104604 = -1.5694170650899903e+163;
        bool r104605 = r104603 <= r104604;
        double r104606 = -r104603;
        double r104607 = 1.5;
        double r104608 = a;
        double r104609 = c;
        double r104610 = r104608 * r104609;
        double r104611 = r104610 / r104603;
        double r104612 = r104607 * r104611;
        double r104613 = r104612 - r104603;
        double r104614 = r104606 + r104613;
        double r104615 = 3.0;
        double r104616 = r104615 * r104608;
        double r104617 = r104614 / r104616;
        double r104618 = 2.4075552977241297e+38;
        bool r104619 = r104603 <= r104618;
        double r104620 = r104603 * r104603;
        double r104621 = r104615 * r104610;
        double r104622 = 1.0;
        double r104623 = pow(r104621, r104622);
        double r104624 = r104620 - r104623;
        double r104625 = sqrt(r104624);
        double r104626 = r104606 + r104625;
        double r104627 = r104626 / r104616;
        double r104628 = -1.5;
        double r104629 = r104628 * r104611;
        double r104630 = r104629 / r104616;
        double r104631 = r104619 ? r104627 : r104630;
        double r104632 = r104605 ? r104617 : r104631;
        return r104632;
}

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.5694170650899903e+163

    1. Initial program 64.0

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

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

    if -1.5694170650899903e+163 < b < 2.4075552977241297e+38

    1. Initial program 17.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 pow117.9

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot \color{blue}{{c}^{1}}}}{3 \cdot a}\]
    4. Applied pow117.9

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot \color{blue}{{a}^{1}}\right) \cdot {c}^{1}}}{3 \cdot a}\]
    5. Applied pow117.9

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(\color{blue}{{3}^{1}} \cdot {a}^{1}\right) \cdot {c}^{1}}}{3 \cdot a}\]
    6. Applied pow-prod-down17.9

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{{\left(3 \cdot a\right)}^{1}} \cdot {c}^{1}}}{3 \cdot a}\]
    7. Applied pow-prod-down17.9

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

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

    if 2.4075552977241297e+38 < b

    1. Initial program 56.6

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

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification16.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.56941706508999029 \cdot 10^{163}:\\ \;\;\;\;\frac{\left(-b\right) + \left(1.5 \cdot \frac{a \cdot c}{b} - b\right)}{3 \cdot a}\\ \mathbf{elif}\;b \le 2.4075552977241297 \cdot 10^{38}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - {\left(3 \cdot \left(a \cdot c\right)\right)}^{1}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \end{array}\]

Reproduce

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