Average Error: 33.2 → 9.0
Time: 24.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 -7.450359943255946 \cdot 10^{+153}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\ \mathbf{elif}\;b \le 2.3800906090147437 \cdot 10^{-254}:\\ \;\;\;\;\frac{1}{3} \cdot \frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} - b}{a}\\ \mathbf{elif}\;b \le 120698439145.82085:\\ \;\;\;\;\frac{1}{\frac{3 \cdot a}{\frac{\left(3 \cdot a\right) \cdot c + \left(b \cdot b - b \cdot b\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\ \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 -7.450359943255946 \cdot 10^{+153}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\

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

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

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

\end{array}
double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r3325117 = b;
        double r3325118 = -r3325117;
        double r3325119 = r3325117 * r3325117;
        double r3325120 = 3.0;
        double r3325121 = a;
        double r3325122 = r3325120 * r3325121;
        double r3325123 = c;
        double r3325124 = r3325122 * r3325123;
        double r3325125 = r3325119 - r3325124;
        double r3325126 = sqrt(r3325125);
        double r3325127 = r3325118 + r3325126;
        double r3325128 = r3325127 / r3325122;
        return r3325128;
}

double f(double a, double b, double c, double __attribute__((unused)) d) {
        double r3325129 = b;
        double r3325130 = -7.450359943255946e+153;
        bool r3325131 = r3325129 <= r3325130;
        double r3325132 = 0.5;
        double r3325133 = c;
        double r3325134 = r3325133 / r3325129;
        double r3325135 = r3325132 * r3325134;
        double r3325136 = a;
        double r3325137 = r3325129 / r3325136;
        double r3325138 = 0.6666666666666666;
        double r3325139 = r3325137 * r3325138;
        double r3325140 = r3325135 - r3325139;
        double r3325141 = 2.3800906090147437e-254;
        bool r3325142 = r3325129 <= r3325141;
        double r3325143 = 1.0;
        double r3325144 = 3.0;
        double r3325145 = r3325143 / r3325144;
        double r3325146 = r3325129 * r3325129;
        double r3325147 = r3325133 * r3325136;
        double r3325148 = r3325147 * r3325144;
        double r3325149 = r3325146 - r3325148;
        double r3325150 = sqrt(r3325149);
        double r3325151 = r3325150 - r3325129;
        double r3325152 = r3325151 / r3325136;
        double r3325153 = r3325145 * r3325152;
        double r3325154 = 120698439145.82085;
        bool r3325155 = r3325129 <= r3325154;
        double r3325156 = r3325144 * r3325136;
        double r3325157 = r3325156 * r3325133;
        double r3325158 = r3325146 - r3325146;
        double r3325159 = r3325157 + r3325158;
        double r3325160 = -r3325129;
        double r3325161 = r3325146 - r3325157;
        double r3325162 = sqrt(r3325161);
        double r3325163 = r3325160 - r3325162;
        double r3325164 = r3325159 / r3325163;
        double r3325165 = r3325156 / r3325164;
        double r3325166 = r3325143 / r3325165;
        double r3325167 = -0.5;
        double r3325168 = r3325134 * r3325167;
        double r3325169 = r3325155 ? r3325166 : r3325168;
        double r3325170 = r3325142 ? r3325153 : r3325169;
        double r3325171 = r3325131 ? r3325140 : r3325170;
        return r3325171;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus d

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if b < -7.450359943255946e+153

    1. Initial program 60.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 *-un-lft-identity60.9

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

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

      \[\leadsto \frac{\color{blue}{1 \cdot \left(-b\right)} + 1 \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    6. Applied distribute-lft-out60.9

      \[\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}\]
    7. Applied times-frac60.9

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

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

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

    if -7.450359943255946e+153 < b < 2.3800906090147437e-254

    1. Initial program 8.6

      \[\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-identity8.6

      \[\leadsto \frac{\left(-b\right) + \color{blue}{1 \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
    4. Applied *-un-lft-identity8.6

      \[\leadsto \frac{\left(-\color{blue}{1 \cdot b}\right) + 1 \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    5. Applied distribute-rgt-neg-in8.6

      \[\leadsto \frac{\color{blue}{1 \cdot \left(-b\right)} + 1 \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    6. Applied distribute-lft-out8.6

      \[\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}\]
    7. Applied times-frac8.8

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

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

    if 2.3800906090147437e-254 < b < 120698439145.82085

    1. Initial program 28.4

      \[\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-identity28.4

      \[\leadsto \frac{\left(-b\right) + \color{blue}{1 \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
    4. Applied *-un-lft-identity28.4

      \[\leadsto \frac{\color{blue}{1 \cdot \left(-b\right)} + 1 \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    5. Applied distribute-lft-out28.4

      \[\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}\]
    6. Applied associate-/l*28.5

      \[\leadsto \color{blue}{\frac{1}{\frac{3 \cdot a}{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}\]
    7. Using strategy rm
    8. Applied flip-+28.6

      \[\leadsto \frac{1}{\frac{3 \cdot a}{\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}}}}}\]
    9. Simplified18.6

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

    if 120698439145.82085 < b

    1. Initial program 54.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-identity54.8

      \[\leadsto \frac{\left(-b\right) + \color{blue}{1 \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
    4. Applied *-un-lft-identity54.8

      \[\leadsto \frac{\left(-\color{blue}{1 \cdot b}\right) + 1 \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    5. Applied distribute-rgt-neg-in54.8

      \[\leadsto \frac{\color{blue}{1 \cdot \left(-b\right)} + 1 \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    6. Applied distribute-lft-out54.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}\]
    7. Applied times-frac54.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -7.450359943255946 \cdot 10^{+153}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\ \mathbf{elif}\;b \le 2.3800906090147437 \cdot 10^{-254}:\\ \;\;\;\;\frac{1}{3} \cdot \frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 3} - b}{a}\\ \mathbf{elif}\;b \le 120698439145.82085:\\ \;\;\;\;\frac{1}{\frac{3 \cdot a}{\frac{\left(3 \cdot a\right) \cdot c + \left(b \cdot b - b \cdot b\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

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