Average Error: 34.4 → 15.2
Time: 4.4s
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.3587793572260194 \cdot 10^{154}:\\ \;\;\;\;\frac{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{3 \cdot a}\\ \mathbf{elif}\;b \le 5.3334140180454647 \cdot 10^{-15}:\\ \;\;\;\;\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.3587793572260194 \cdot 10^{154}:\\
\;\;\;\;\frac{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{3 \cdot a}\\

\mathbf{elif}\;b \le 5.3334140180454647 \cdot 10^{-15}:\\
\;\;\;\;\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 r116107 = b;
        double r116108 = -r116107;
        double r116109 = r116107 * r116107;
        double r116110 = 3.0;
        double r116111 = a;
        double r116112 = r116110 * r116111;
        double r116113 = c;
        double r116114 = r116112 * r116113;
        double r116115 = r116109 - r116114;
        double r116116 = sqrt(r116115);
        double r116117 = r116108 + r116116;
        double r116118 = r116117 / r116112;
        return r116118;
}

double f(double a, double b, double c) {
        double r116119 = b;
        double r116120 = -1.3587793572260194e+154;
        bool r116121 = r116119 <= r116120;
        double r116122 = 1.5;
        double r116123 = a;
        double r116124 = c;
        double r116125 = r116123 * r116124;
        double r116126 = r116125 / r116119;
        double r116127 = r116122 * r116126;
        double r116128 = 2.0;
        double r116129 = r116128 * r116119;
        double r116130 = r116127 - r116129;
        double r116131 = 3.0;
        double r116132 = r116131 * r116123;
        double r116133 = r116130 / r116132;
        double r116134 = 5.333414018045465e-15;
        bool r116135 = r116119 <= r116134;
        double r116136 = -r116119;
        double r116137 = r116119 * r116119;
        double r116138 = r116131 * r116125;
        double r116139 = 1.0;
        double r116140 = pow(r116138, r116139);
        double r116141 = r116137 - r116140;
        double r116142 = sqrt(r116141);
        double r116143 = r116136 + r116142;
        double r116144 = r116143 / r116132;
        double r116145 = -1.5;
        double r116146 = r116145 * r116126;
        double r116147 = r116146 / r116132;
        double r116148 = r116135 ? r116144 : r116147;
        double r116149 = r116121 ? r116133 : r116148;
        return r116149;
}

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.3587793572260194e+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. Taylor expanded around -inf 10.7

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

    if -1.3587793572260194e+154 < b < 5.333414018045465e-15

    1. Initial program 14.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 pow114.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 pow114.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 pow114.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-down14.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-down14.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. Simplified15.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 5.333414018045465e-15 < b

    1. Initial program 55.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.3587793572260194 \cdot 10^{154}:\\ \;\;\;\;\frac{1.5 \cdot \frac{a \cdot c}{b} - 2 \cdot b}{3 \cdot a}\\ \mathbf{elif}\;b \le 5.3334140180454647 \cdot 10^{-15}:\\ \;\;\;\;\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 2020059 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))