Average Error: 34.0 → 7.1
Time: 6.7s
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.32906277428687545 \cdot 10^{134}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -1.4498491900648225 \cdot 10^{-249}:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \frac{1}{3 \cdot a}\\ \mathbf{elif}\;b \le 2.69584594832460355 \cdot 10^{37}:\\ \;\;\;\;\frac{\frac{-c}{-1}}{\frac{\frac{a}{1}}{\frac{a}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}\\ \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.32906277428687545 \cdot 10^{134}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\

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

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

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

\end{array}
double f(double a, double b, double c) {
        double r110998 = b;
        double r110999 = -r110998;
        double r111000 = r110998 * r110998;
        double r111001 = 3.0;
        double r111002 = a;
        double r111003 = r111001 * r111002;
        double r111004 = c;
        double r111005 = r111003 * r111004;
        double r111006 = r111000 - r111005;
        double r111007 = sqrt(r111006);
        double r111008 = r110999 + r111007;
        double r111009 = r111008 / r111003;
        return r111009;
}

double f(double a, double b, double c) {
        double r111010 = b;
        double r111011 = -2.3290627742868755e+134;
        bool r111012 = r111010 <= r111011;
        double r111013 = 0.5;
        double r111014 = c;
        double r111015 = r111014 / r111010;
        double r111016 = r111013 * r111015;
        double r111017 = 0.6666666666666666;
        double r111018 = a;
        double r111019 = r111010 / r111018;
        double r111020 = r111017 * r111019;
        double r111021 = r111016 - r111020;
        double r111022 = -1.4498491900648225e-249;
        bool r111023 = r111010 <= r111022;
        double r111024 = -r111010;
        double r111025 = r111010 * r111010;
        double r111026 = 3.0;
        double r111027 = r111026 * r111018;
        double r111028 = r111027 * r111014;
        double r111029 = r111025 - r111028;
        double r111030 = sqrt(r111029);
        double r111031 = r111024 + r111030;
        double r111032 = 1.0;
        double r111033 = r111032 / r111027;
        double r111034 = r111031 * r111033;
        double r111035 = 2.6958459483246036e+37;
        bool r111036 = r111010 <= r111035;
        double r111037 = -r111014;
        double r111038 = -1.0;
        double r111039 = r111037 / r111038;
        double r111040 = r111018 / r111032;
        double r111041 = r111024 - r111030;
        double r111042 = r111018 / r111041;
        double r111043 = r111040 / r111042;
        double r111044 = r111039 / r111043;
        double r111045 = -0.5;
        double r111046 = r111045 * r111015;
        double r111047 = r111036 ? r111044 : r111046;
        double r111048 = r111023 ? r111034 : r111047;
        double r111049 = r111012 ? r111021 : r111048;
        return r111049;
}

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.3290627742868755e+134

    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 2.8

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

    if -2.3290627742868755e+134 < b < -1.4498491900648225e-249

    1. Initial program 8.1

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied div-inv8.2

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

    if -1.4498491900648225e-249 < b < 2.6958459483246036e+37

    1. Initial program 27.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-+27.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. Simplified17.7

      \[\leadsto \frac{\frac{\color{blue}{0 + 3 \cdot \left(a \cdot c\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
    5. Using strategy rm
    6. Applied associate-/r*17.6

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

      \[\leadsto \frac{\color{blue}{\frac{3 \cdot \left(a \cdot c\right)}{3 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{a}\]
    8. Using strategy rm
    9. Applied frac-2neg17.6

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

      \[\leadsto \frac{\frac{\color{blue}{-c \cdot \left(3 \cdot a\right)}}{-3 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{a}\]
    11. Using strategy rm
    12. Applied neg-mul-117.5

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

      \[\leadsto \frac{\frac{\color{blue}{\left(-c\right) \cdot \left(3 \cdot a\right)}}{-1 \cdot \left(3 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)\right)}}{a}\]
    14. Applied times-frac14.9

      \[\leadsto \frac{\color{blue}{\frac{-c}{-1} \cdot \frac{3 \cdot a}{3 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{a}\]
    15. Applied associate-/l*11.1

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

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

    if 2.6958459483246036e+37 < b

    1. Initial program 56.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.32906277428687545 \cdot 10^{134}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.66666666666666663 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -1.4498491900648225 \cdot 10^{-249}:\\ \;\;\;\;\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \frac{1}{3 \cdot a}\\ \mathbf{elif}\;b \le 2.69584594832460355 \cdot 10^{37}:\\ \;\;\;\;\frac{\frac{-c}{-1}}{\frac{\frac{a}{1}}{\frac{a}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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