Average Error: 34.6 → 10.8
Time: 30.3s
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 r5142834 = b;
        double r5142835 = -r5142834;
        double r5142836 = r5142834 * r5142834;
        double r5142837 = 3.0;
        double r5142838 = a;
        double r5142839 = r5142837 * r5142838;
        double r5142840 = c;
        double r5142841 = r5142839 * r5142840;
        double r5142842 = r5142836 - r5142841;
        double r5142843 = sqrt(r5142842);
        double r5142844 = r5142835 + r5142843;
        double r5142845 = r5142844 / r5142839;
        return r5142845;
}

double f(double a, double b, double c) {
        double r5142846 = b;
        double r5142847 = -1.6964502144974645e+75;
        bool r5142848 = r5142846 <= r5142847;
        double r5142849 = 0.5;
        double r5142850 = c;
        double r5142851 = r5142850 / r5142846;
        double r5142852 = r5142849 * r5142851;
        double r5142853 = 0.6666666666666666;
        double r5142854 = a;
        double r5142855 = r5142846 / r5142854;
        double r5142856 = r5142853 * r5142855;
        double r5142857 = r5142852 - r5142856;
        double r5142858 = 7.923524897992037e-153;
        bool r5142859 = r5142846 <= r5142858;
        double r5142860 = 1.0;
        double r5142861 = 3.0;
        double r5142862 = r5142861 * r5142854;
        double r5142863 = r5142860 / r5142862;
        double r5142864 = r5142846 * r5142846;
        double r5142865 = r5142850 * r5142862;
        double r5142866 = r5142864 - r5142865;
        double r5142867 = sqrt(r5142866);
        double r5142868 = r5142867 - r5142846;
        double r5142869 = r5142863 * r5142868;
        double r5142870 = -0.5;
        double r5142871 = r5142851 * r5142870;
        double r5142872 = r5142859 ? r5142869 : r5142871;
        double r5142873 = r5142848 ? r5142857 : r5142872;
        return r5142873;
}

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)))