Average Error: 33.5 → 12.0
Time: 24.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.5936256221995724 \cdot 10^{+117}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\ \mathbf{elif}\;b \le 3.207624111695675 \cdot 10^{-187}:\\ \;\;\;\;\frac{1}{\frac{a}{\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)} - b} \cdot 3}\\ \mathbf{elif}\;b \le 4.186415469310955 \cdot 10^{-111}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\ \mathbf{elif}\;b \le 1.922674299151799 \cdot 10^{-16}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)}}{3 \cdot a} - \frac{b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \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 -1.5936256221995724 \cdot 10^{+117}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\

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

\mathbf{elif}\;b \le 4.186415469310955 \cdot 10^{-111}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\

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

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

\end{array}
double f(double a, double b, double c) {
        double r4232980 = b;
        double r4232981 = -r4232980;
        double r4232982 = r4232980 * r4232980;
        double r4232983 = 3.0;
        double r4232984 = a;
        double r4232985 = r4232983 * r4232984;
        double r4232986 = c;
        double r4232987 = r4232985 * r4232986;
        double r4232988 = r4232982 - r4232987;
        double r4232989 = sqrt(r4232988);
        double r4232990 = r4232981 + r4232989;
        double r4232991 = r4232990 / r4232985;
        return r4232991;
}

double f(double a, double b, double c) {
        double r4232992 = b;
        double r4232993 = -1.5936256221995724e+117;
        bool r4232994 = r4232992 <= r4232993;
        double r4232995 = 0.5;
        double r4232996 = c;
        double r4232997 = r4232996 / r4232992;
        double r4232998 = r4232995 * r4232997;
        double r4232999 = a;
        double r4233000 = r4232992 / r4232999;
        double r4233001 = 0.6666666666666666;
        double r4233002 = r4233000 * r4233001;
        double r4233003 = r4232998 - r4233002;
        double r4233004 = 3.207624111695675e-187;
        bool r4233005 = r4232992 <= r4233004;
        double r4233006 = 1.0;
        double r4233007 = r4232992 * r4232992;
        double r4233008 = 3.0;
        double r4233009 = r4233008 * r4232999;
        double r4233010 = r4232996 * r4233009;
        double r4233011 = r4233007 - r4233010;
        double r4233012 = sqrt(r4233011);
        double r4233013 = r4233012 - r4232992;
        double r4233014 = r4232999 / r4233013;
        double r4233015 = r4233014 * r4233008;
        double r4233016 = r4233006 / r4233015;
        double r4233017 = 4.186415469310955e-111;
        bool r4233018 = r4232992 <= r4233017;
        double r4233019 = -0.5;
        double r4233020 = r4233019 * r4232997;
        double r4233021 = 1.922674299151799e-16;
        bool r4233022 = r4232992 <= r4233021;
        double r4233023 = r4233012 / r4233009;
        double r4233024 = r4232992 / r4233009;
        double r4233025 = r4233023 - r4233024;
        double r4233026 = r4233022 ? r4233025 : r4233020;
        double r4233027 = r4233018 ? r4233020 : r4233026;
        double r4233028 = r4233005 ? r4233016 : r4233027;
        double r4233029 = r4232994 ? r4233003 : r4233028;
        return r4233029;
}

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 < -1.5936256221995724e+117

    1. Initial program 48.8

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

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

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

    if -1.5936256221995724e+117 < b < 3.207624111695675e-187

    1. Initial program 10.6

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{3 \cdot a}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity10.7

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

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

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

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

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

    if 3.207624111695675e-187 < b < 4.186415469310955e-111 or 1.922674299151799e-16 < b

    1. Initial program 50.1

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

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

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

    if 4.186415469310955e-111 < b < 1.922674299151799e-16

    1. Initial program 36.3

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} - \frac{b}{3 \cdot a}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification12.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.5936256221995724 \cdot 10^{+117}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b} - \frac{b}{a} \cdot \frac{2}{3}\\ \mathbf{elif}\;b \le 3.207624111695675 \cdot 10^{-187}:\\ \;\;\;\;\frac{1}{\frac{a}{\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)} - b} \cdot 3}\\ \mathbf{elif}\;b \le 4.186415469310955 \cdot 10^{-111}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\ \mathbf{elif}\;b \le 1.922674299151799 \cdot 10^{-16}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)}}{3 \cdot a} - \frac{b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019139 
(FPCore (a b c)
  :name "Cubic critical"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))