Average Error: 34.6 → 10.8
Time: 31.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 -1.696450214497464500793437434731557128325 \cdot 10^{75}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 7.923524897992036987166355557663274472861 \cdot 10^{-153}:\\ \;\;\;\;\frac{1}{3 \cdot a} \cdot \left(\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)} - b\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \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.696450214497464500793437434731557128325 \cdot 10^{75}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r5020159 = b;
        double r5020160 = -r5020159;
        double r5020161 = r5020159 * r5020159;
        double r5020162 = 3.0;
        double r5020163 = a;
        double r5020164 = r5020162 * r5020163;
        double r5020165 = c;
        double r5020166 = r5020164 * r5020165;
        double r5020167 = r5020161 - r5020166;
        double r5020168 = sqrt(r5020167);
        double r5020169 = r5020160 + r5020168;
        double r5020170 = r5020169 / r5020164;
        return r5020170;
}

double f(double a, double b, double c) {
        double r5020171 = b;
        double r5020172 = -1.6964502144974645e+75;
        bool r5020173 = r5020171 <= r5020172;
        double r5020174 = 0.5;
        double r5020175 = c;
        double r5020176 = r5020175 / r5020171;
        double r5020177 = r5020174 * r5020176;
        double r5020178 = 0.6666666666666666;
        double r5020179 = a;
        double r5020180 = r5020171 / r5020179;
        double r5020181 = r5020178 * r5020180;
        double r5020182 = r5020177 - r5020181;
        double r5020183 = 7.923524897992037e-153;
        bool r5020184 = r5020171 <= r5020183;
        double r5020185 = 1.0;
        double r5020186 = 3.0;
        double r5020187 = r5020186 * r5020179;
        double r5020188 = r5020185 / r5020187;
        double r5020189 = r5020171 * r5020171;
        double r5020190 = r5020175 * r5020187;
        double r5020191 = r5020189 - r5020190;
        double r5020192 = sqrt(r5020191);
        double r5020193 = r5020192 - r5020171;
        double r5020194 = r5020188 * r5020193;
        double r5020195 = -0.5;
        double r5020196 = r5020176 * r5020195;
        double r5020197 = r5020184 ? r5020194 : r5020196;
        double r5020198 = r5020173 ? r5020182 : r5020197;
        return r5020198;
}

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.6964502144974645e+75

    1. Initial program 42.1

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified42.1

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

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

    if -1.6964502144974645e+75 < b < 7.923524897992037e-153

    1. Initial program 11.3

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified11.3

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}}\]
    3. Using strategy rm
    4. Applied div-inv11.4

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

    if 7.923524897992037e-153 < b

    1. Initial program 50.5

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Simplified50.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.696450214497464500793437434731557128325 \cdot 10^{75}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 7.923524897992036987166355557663274472861 \cdot 10^{-153}:\\ \;\;\;\;\frac{1}{3 \cdot a} \cdot \left(\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)} - b\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot -0.5\\ \end{array}\]

Reproduce

herbie shell --seed 2019200 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))