Average Error: 34.3 → 9.1
Time: 13.9s
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 -6.037732156581497447354386556821909484269 \cdot 10^{149}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 2.252938494289993994868747689126193333884 \cdot 10^{-138}:\\ \;\;\;\;\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3}}{a}\\ \mathbf{elif}\;b \le 566139209116996478133070611773128704:\\ \;\;\;\;\frac{0 + 3 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \frac{1}{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 -6.037732156581497447354386556821909484269 \cdot 10^{149}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\

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

\mathbf{elif}\;b \le 566139209116996478133070611773128704:\\
\;\;\;\;\frac{0 + 3 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \frac{1}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r73242 = b;
        double r73243 = -r73242;
        double r73244 = r73242 * r73242;
        double r73245 = 3.0;
        double r73246 = a;
        double r73247 = r73245 * r73246;
        double r73248 = c;
        double r73249 = r73247 * r73248;
        double r73250 = r73244 - r73249;
        double r73251 = sqrt(r73250);
        double r73252 = r73243 + r73251;
        double r73253 = r73252 / r73247;
        return r73253;
}

double f(double a, double b, double c) {
        double r73254 = b;
        double r73255 = -6.037732156581497e+149;
        bool r73256 = r73254 <= r73255;
        double r73257 = 0.5;
        double r73258 = c;
        double r73259 = r73258 / r73254;
        double r73260 = r73257 * r73259;
        double r73261 = 0.6666666666666666;
        double r73262 = a;
        double r73263 = r73254 / r73262;
        double r73264 = r73261 * r73263;
        double r73265 = r73260 - r73264;
        double r73266 = 2.252938494289994e-138;
        bool r73267 = r73254 <= r73266;
        double r73268 = -r73254;
        double r73269 = r73254 * r73254;
        double r73270 = 3.0;
        double r73271 = r73270 * r73262;
        double r73272 = r73271 * r73258;
        double r73273 = r73269 - r73272;
        double r73274 = sqrt(r73273);
        double r73275 = r73268 + r73274;
        double r73276 = r73275 / r73270;
        double r73277 = r73276 / r73262;
        double r73278 = 5.661392091169965e+35;
        bool r73279 = r73254 <= r73278;
        double r73280 = 0.0;
        double r73281 = r73262 * r73258;
        double r73282 = r73270 * r73281;
        double r73283 = r73280 + r73282;
        double r73284 = r73268 - r73274;
        double r73285 = r73283 / r73284;
        double r73286 = 1.0;
        double r73287 = r73286 / r73271;
        double r73288 = r73285 * r73287;
        double r73289 = -0.5;
        double r73290 = r73289 * r73259;
        double r73291 = r73279 ? r73288 : r73290;
        double r73292 = r73267 ? r73277 : r73291;
        double r73293 = r73256 ? r73265 : r73292;
        return r73293;
}

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 < -6.037732156581497e+149

    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 3.1

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

    if -6.037732156581497e+149 < b < 2.252938494289994e-138

    1. Initial program 11.4

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity11.4

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a}\]
    4. Applied times-frac11.5

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

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

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

    if 2.252938494289994e-138 < b < 5.661392091169965e+35

    1. Initial program 36.4

      \[\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-inv36.4

      \[\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}}\]
    4. Using strategy rm
    5. Applied flip-+36.5

      \[\leadsto \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}}} \cdot \frac{1}{3 \cdot a}\]
    6. Simplified16.9

      \[\leadsto \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}} \cdot \frac{1}{3 \cdot a}\]

    if 5.661392091169965e+35 < b

    1. Initial program 56.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -6.037732156581497447354386556821909484269 \cdot 10^{149}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le 2.252938494289993994868747689126193333884 \cdot 10^{-138}:\\ \;\;\;\;\frac{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3}}{a}\\ \mathbf{elif}\;b \le 566139209116996478133070611773128704:\\ \;\;\;\;\frac{0 + 3 \cdot \left(a \cdot c\right)}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}} \cdot \frac{1}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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