Average Error: 33.7 → 13.0
Time: 12.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 -2.2724541866372811 \cdot 10^{165}:\\ \;\;\;\;\frac{\frac{\frac{1}{2} \cdot \left(a \cdot \left(3 \cdot c\right)\right)}{b} - 2 \cdot b}{3 \cdot a}\\ \mathbf{elif}\;b \le 1.72707344940377835 \cdot 10^{-162}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b + \left(3 \cdot a\right) \cdot \left(-c\right)}}{3 \cdot a}\\ \mathbf{elif}\;b \le 2.0964838406867355 \cdot 10^{136}:\\ \;\;\;\;\frac{\frac{b \cdot \left(b - b\right) + 3 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \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.2724541866372811 \cdot 10^{165}:\\
\;\;\;\;\frac{\frac{\frac{1}{2} \cdot \left(a \cdot \left(3 \cdot c\right)\right)}{b} - 2 \cdot b}{3 \cdot a}\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\

\end{array}
double f(double a, double b, double c) {
        double r125028 = b;
        double r125029 = -r125028;
        double r125030 = r125028 * r125028;
        double r125031 = 3.0;
        double r125032 = a;
        double r125033 = r125031 * r125032;
        double r125034 = c;
        double r125035 = r125033 * r125034;
        double r125036 = r125030 - r125035;
        double r125037 = sqrt(r125036);
        double r125038 = r125029 + r125037;
        double r125039 = r125038 / r125033;
        return r125039;
}

double f(double a, double b, double c) {
        double r125040 = b;
        double r125041 = -2.272454186637281e+165;
        bool r125042 = r125040 <= r125041;
        double r125043 = 0.5;
        double r125044 = a;
        double r125045 = 3.0;
        double r125046 = c;
        double r125047 = r125045 * r125046;
        double r125048 = r125044 * r125047;
        double r125049 = r125043 * r125048;
        double r125050 = r125049 / r125040;
        double r125051 = 2.0;
        double r125052 = r125051 * r125040;
        double r125053 = r125050 - r125052;
        double r125054 = r125045 * r125044;
        double r125055 = r125053 / r125054;
        double r125056 = 1.7270734494037783e-162;
        bool r125057 = r125040 <= r125056;
        double r125058 = -r125040;
        double r125059 = r125040 * r125040;
        double r125060 = -r125046;
        double r125061 = r125054 * r125060;
        double r125062 = r125059 + r125061;
        double r125063 = sqrt(r125062);
        double r125064 = r125058 + r125063;
        double r125065 = r125064 / r125054;
        double r125066 = 2.0964838406867355e+136;
        bool r125067 = r125040 <= r125066;
        double r125068 = r125040 - r125040;
        double r125069 = r125040 * r125068;
        double r125070 = r125044 * r125046;
        double r125071 = r125045 * r125070;
        double r125072 = r125069 + r125071;
        double r125073 = r125059 - r125071;
        double r125074 = sqrt(r125073);
        double r125075 = r125058 - r125074;
        double r125076 = r125072 / r125075;
        double r125077 = r125076 / r125054;
        double r125078 = -1.5;
        double r125079 = r125070 / r125040;
        double r125080 = r125078 * r125079;
        double r125081 = r125080 / r125054;
        double r125082 = r125067 ? r125077 : r125081;
        double r125083 = r125057 ? r125065 : r125082;
        double r125084 = r125042 ? r125055 : r125083;
        return r125084;
}

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.272454186637281e+165

    1. Initial program 64.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 associate-*l*64.0

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt64.0

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\left(\sqrt{3} \cdot \sqrt{3}\right)} \cdot \left(a \cdot c\right)}}{3 \cdot a}\]
    6. Applied associate-*l*64.0

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

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

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

    if -2.272454186637281e+165 < b < 1.7270734494037783e-162

    1. Initial program 11.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 add-cube-cbrt11.4

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot \color{blue}{\left(\left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right) \cdot \sqrt[3]{c}\right)}}}{3 \cdot a}\]
    4. Applied associate-*r*11.4

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\left(\left(3 \cdot a\right) \cdot \left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right)\right) \cdot \sqrt[3]{c}}}}{3 \cdot a}\]
    5. Using strategy rm
    6. Applied sub-neg11.4

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

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

    if 1.7270734494037783e-162 < b < 2.0964838406867355e+136

    1. Initial program 39.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 associate-*l*39.9

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt40.0

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\left(\sqrt{3} \cdot \sqrt{3}\right)} \cdot \left(a \cdot c\right)}}{3 \cdot a}\]
    6. Applied associate-*l*40.0

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

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

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

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

    if 2.0964838406867355e+136 < b

    1. Initial program 62.0

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

      \[\leadsto \frac{\color{blue}{-1.5 \cdot \frac{a \cdot c}{b}}}{3 \cdot a}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification13.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.2724541866372811 \cdot 10^{165}:\\ \;\;\;\;\frac{\frac{\frac{1}{2} \cdot \left(a \cdot \left(3 \cdot c\right)\right)}{b} - 2 \cdot b}{3 \cdot a}\\ \mathbf{elif}\;b \le 1.72707344940377835 \cdot 10^{-162}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b + \left(3 \cdot a\right) \cdot \left(-c\right)}}{3 \cdot a}\\ \mathbf{elif}\;b \le 2.0964838406867355 \cdot 10^{136}:\\ \;\;\;\;\frac{\frac{b \cdot \left(b - b\right) + 3 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1.5 \cdot \frac{a \cdot c}{b}}{3 \cdot a}\\ \end{array}\]

Reproduce

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