Average Error: 34.0 → 8.5
Time: 16.5s
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.063770735185840945354498847982543421727 \cdot 10^{112}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -3.960211999483477631208781586663998392671 \cdot 10^{-305}:\\ \;\;\;\;\frac{1}{\frac{3 \cdot a}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}}\\ \mathbf{elif}\;b \le 3.424603050151593475509461695672638978245 \cdot 10^{-29}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 3}{\frac{-c}{\frac{\sqrt{\mathsf{fma}\left(3 \cdot a, -c, {b}^{2}\right)} + b}{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.063770735185840945354498847982543421727 \cdot 10^{112}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\

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

\mathbf{elif}\;b \le 3.424603050151593475509461695672638978245 \cdot 10^{-29}:\\
\;\;\;\;\frac{1}{\frac{a \cdot 3}{\frac{-c}{\frac{\sqrt{\mathsf{fma}\left(3 \cdot a, -c, {b}^{2}\right)} + b}{3 \cdot a}}}}\\

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

\end{array}
double f(double a, double b, double c) {
        double r83015 = b;
        double r83016 = -r83015;
        double r83017 = r83015 * r83015;
        double r83018 = 3.0;
        double r83019 = a;
        double r83020 = r83018 * r83019;
        double r83021 = c;
        double r83022 = r83020 * r83021;
        double r83023 = r83017 - r83022;
        double r83024 = sqrt(r83023);
        double r83025 = r83016 + r83024;
        double r83026 = r83025 / r83020;
        return r83026;
}

double f(double a, double b, double c) {
        double r83027 = b;
        double r83028 = -2.063770735185841e+112;
        bool r83029 = r83027 <= r83028;
        double r83030 = 0.5;
        double r83031 = c;
        double r83032 = r83031 / r83027;
        double r83033 = r83030 * r83032;
        double r83034 = 0.6666666666666666;
        double r83035 = a;
        double r83036 = r83027 / r83035;
        double r83037 = r83034 * r83036;
        double r83038 = r83033 - r83037;
        double r83039 = -3.9602119994834776e-305;
        bool r83040 = r83027 <= r83039;
        double r83041 = 1.0;
        double r83042 = 3.0;
        double r83043 = r83042 * r83035;
        double r83044 = r83027 * r83027;
        double r83045 = r83043 * r83031;
        double r83046 = r83044 - r83045;
        double r83047 = sqrt(r83046);
        double r83048 = r83047 - r83027;
        double r83049 = r83043 / r83048;
        double r83050 = r83041 / r83049;
        double r83051 = 3.4246030501515935e-29;
        bool r83052 = r83027 <= r83051;
        double r83053 = r83035 * r83042;
        double r83054 = -r83031;
        double r83055 = 2.0;
        double r83056 = pow(r83027, r83055);
        double r83057 = fma(r83043, r83054, r83056);
        double r83058 = sqrt(r83057);
        double r83059 = r83058 + r83027;
        double r83060 = r83059 / r83043;
        double r83061 = r83054 / r83060;
        double r83062 = r83053 / r83061;
        double r83063 = r83041 / r83062;
        double r83064 = -0.5;
        double r83065 = r83064 * r83032;
        double r83066 = r83052 ? r83063 : r83065;
        double r83067 = r83040 ? r83050 : r83066;
        double r83068 = r83029 ? r83038 : r83067;
        return r83068;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 4 regimes
  2. if b < -2.063770735185841e+112

    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 3.7

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

    if -2.063770735185841e+112 < b < -3.9602119994834776e-305

    1. Initial program 8.4

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

      \[\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-num8.5

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

    if -3.9602119994834776e-305 < b < 3.4246030501515935e-29

    1. Initial program 23.8

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{{b}^{2} - 3 \cdot \left(a \cdot c\right)}} - b}{3 \cdot a}\]
    4. Simplified23.8

      \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{fma}\left(3 \cdot a, -c, b \cdot b\right)}} - b}{3 \cdot a}\]
    5. Using strategy rm
    6. Applied flip--23.8

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{\mathsf{fma}\left(3 \cdot a, -c, b \cdot b\right)} \cdot \sqrt{\mathsf{fma}\left(3 \cdot a, -c, b \cdot b\right)} - b \cdot b}{\sqrt{\mathsf{fma}\left(3 \cdot a, -c, b \cdot b\right)} + b}}}{3 \cdot a}\]
    7. Simplified18.4

      \[\leadsto \frac{\frac{\color{blue}{\mathsf{fma}\left(-c, 3 \cdot a, 0\right)}}{\sqrt{\mathsf{fma}\left(3 \cdot a, -c, b \cdot b\right)} + b}}{3 \cdot a}\]
    8. Simplified18.4

      \[\leadsto \frac{\frac{\mathsf{fma}\left(-c, 3 \cdot a, 0\right)}{\color{blue}{\sqrt{\mathsf{fma}\left(3 \cdot a, -c, {b}^{2}\right)} + b}}}{3 \cdot a}\]
    9. Using strategy rm
    10. Applied *-un-lft-identity18.4

      \[\leadsto \frac{\frac{\mathsf{fma}\left(-c, 3 \cdot a, 0\right)}{\color{blue}{1 \cdot \left(\sqrt{\mathsf{fma}\left(3 \cdot a, -c, {b}^{2}\right)} + b\right)}}}{3 \cdot a}\]
    11. Applied *-un-lft-identity18.4

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot \mathsf{fma}\left(-c, 3 \cdot a, 0\right)}}{1 \cdot \left(\sqrt{\mathsf{fma}\left(3 \cdot a, -c, {b}^{2}\right)} + b\right)}}{3 \cdot a}\]
    12. Applied times-frac18.4

      \[\leadsto \frac{\color{blue}{\frac{1}{1} \cdot \frac{\mathsf{fma}\left(-c, 3 \cdot a, 0\right)}{\sqrt{\mathsf{fma}\left(3 \cdot a, -c, {b}^{2}\right)} + b}}}{3 \cdot a}\]
    13. Applied associate-/l*18.4

      \[\leadsto \color{blue}{\frac{\frac{1}{1}}{\frac{3 \cdot a}{\frac{\mathsf{fma}\left(-c, 3 \cdot a, 0\right)}{\sqrt{\mathsf{fma}\left(3 \cdot a, -c, {b}^{2}\right)} + b}}}}\]
    14. Simplified18.4

      \[\leadsto \frac{\frac{1}{1}}{\color{blue}{\frac{a \cdot 3}{\frac{\left(-c\right) \cdot \left(3 \cdot a\right)}{\sqrt{\mathsf{fma}\left(3 \cdot a, -c, {b}^{2}\right)} + b}}}}\]
    15. Using strategy rm
    16. Applied associate-/l*14.6

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

    if 3.4246030501515935e-29 < 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. Simplified54.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 7.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.063770735185840945354498847982543421727 \cdot 10^{112}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -3.960211999483477631208781586663998392671 \cdot 10^{-305}:\\ \;\;\;\;\frac{1}{\frac{3 \cdot a}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}}\\ \mathbf{elif}\;b \le 3.424603050151593475509461695672638978245 \cdot 10^{-29}:\\ \;\;\;\;\frac{1}{\frac{a \cdot 3}{\frac{-c}{\frac{\sqrt{\mathsf{fma}\left(3 \cdot a, -c, {b}^{2}\right)} + b}{3 \cdot a}}}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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