Average Error: 34.5 → 9.1
Time: 14.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 -2.297624534318876743725099723501638614139 \cdot 10^{152}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 6.210794185865198272056827421865632618505 \cdot 10^{-173}:\\ \;\;\;\;\frac{1}{3} \cdot \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{a}\\ \mathbf{elif}\;b \le 1213697253.043575286865234375:\\ \;\;\;\;\frac{\frac{c \cdot \left(3 \cdot a\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{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 -2.297624534318876743725099723501638614139 \cdot 10^{152}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\

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

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

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

\end{array}
double f(double a, double b, double c) {
        double r79163 = b;
        double r79164 = -r79163;
        double r79165 = r79163 * r79163;
        double r79166 = 3.0;
        double r79167 = a;
        double r79168 = r79166 * r79167;
        double r79169 = c;
        double r79170 = r79168 * r79169;
        double r79171 = r79165 - r79170;
        double r79172 = sqrt(r79171);
        double r79173 = r79164 + r79172;
        double r79174 = r79173 / r79168;
        return r79174;
}

double f(double a, double b, double c) {
        double r79175 = b;
        double r79176 = -2.2976245343188767e+152;
        bool r79177 = r79175 <= r79176;
        double r79178 = 0.5;
        double r79179 = c;
        double r79180 = r79179 / r79175;
        double r79181 = r79178 * r79180;
        double r79182 = 0.6666666666666666;
        double r79183 = a;
        double r79184 = r79175 / r79183;
        double r79185 = r79182 * r79184;
        double r79186 = r79181 - r79185;
        double r79187 = 6.210794185865198e-173;
        bool r79188 = r79175 <= r79187;
        double r79189 = 1.0;
        double r79190 = 3.0;
        double r79191 = r79189 / r79190;
        double r79192 = r79175 * r79175;
        double r79193 = r79190 * r79183;
        double r79194 = r79193 * r79179;
        double r79195 = r79192 - r79194;
        double r79196 = sqrt(r79195);
        double r79197 = r79196 - r79175;
        double r79198 = r79197 / r79183;
        double r79199 = r79191 * r79198;
        double r79200 = 1213697253.0435753;
        bool r79201 = r79175 <= r79200;
        double r79202 = r79179 * r79193;
        double r79203 = -r79175;
        double r79204 = r79203 - r79196;
        double r79205 = r79202 / r79204;
        double r79206 = r79205 / r79193;
        double r79207 = -0.5;
        double r79208 = r79207 * r79180;
        double r79209 = r79201 ? r79206 : r79208;
        double r79210 = r79188 ? r79199 : r79209;
        double r79211 = r79177 ? r79186 : r79210;
        return r79211;
}

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 < -2.2976245343188767e+152

    1. Initial program 63.3

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

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

    if -2.2976245343188767e+152 < b < 6.210794185865198e-173

    1. Initial program 10.8

      \[\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.8

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

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

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

    if 6.210794185865198e-173 < b < 1213697253.0435753

    1. Initial program 32.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 flip-+32.1

      \[\leadsto \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}\]
    4. Simplified18.0

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

    if 1213697253.0435753 < b

    1. Initial program 56.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.297624534318876743725099723501638614139 \cdot 10^{152}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 6.210794185865198272056827421865632618505 \cdot 10^{-173}:\\ \;\;\;\;\frac{1}{3} \cdot \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{a}\\ \mathbf{elif}\;b \le 1213697253.043575286865234375:\\ \;\;\;\;\frac{\frac{c \cdot \left(3 \cdot a\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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