Average Error: 34.1 → 16.8
Time: 4.8s
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 r106144 = b;
        double r106145 = -r106144;
        double r106146 = r106144 * r106144;
        double r106147 = 3.0;
        double r106148 = a;
        double r106149 = r106147 * r106148;
        double r106150 = c;
        double r106151 = r106149 * r106150;
        double r106152 = r106146 - r106151;
        double r106153 = sqrt(r106152);
        double r106154 = r106145 + r106153;
        double r106155 = r106154 / r106149;
        return r106155;
}

double f(double a, double b, double c) {
        double r106156 = b;
        double r106157 = -1.5694170650899903e+163;
        bool r106158 = r106156 <= r106157;
        double r106159 = -r106156;
        double r106160 = 1.5;
        double r106161 = a;
        double r106162 = c;
        double r106163 = r106161 * r106162;
        double r106164 = r106163 / r106156;
        double r106165 = r106160 * r106164;
        double r106166 = r106165 - r106156;
        double r106167 = r106159 + r106166;
        double r106168 = 3.0;
        double r106169 = r106168 * r106161;
        double r106170 = r106167 / r106169;
        double r106171 = 2.4075552977241297e+38;
        bool r106172 = r106156 <= r106171;
        double r106173 = r106156 * r106156;
        double r106174 = r106168 * r106163;
        double r106175 = 1.0;
        double r106176 = pow(r106174, r106175);
        double r106177 = r106173 - r106176;
        double r106178 = sqrt(r106177);
        double r106179 = r106159 + r106178;
        double r106180 = r106179 / r106169;
        double r106181 = -1.5;
        double r106182 = r106181 * r106164;
        double r106183 = r106182 / r106169;
        double r106184 = r106172 ? r106180 : r106183;
        double r106185 = r106158 ? r106170 : r106184;
        return r106185;
}

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