Average Error: 44.1 → 11.1
Time: 14.1s
Precision: 64
\[1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt a \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt b \lt 9007199254740992 \land 1.1102230246251565404236316680908203125 \cdot 10^{-16} \lt c \lt 9007199254740992\]
\[\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.724747266396373623605423053284368961613 \cdot 10^{-6}:\\ \;\;\;\;\frac{\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) - b \cdot b}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}{3}}{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.724747266396373623605423053284368961613 \cdot 10^{-6}:\\
\;\;\;\;\frac{\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) - b \cdot b}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}{3}}{a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r107330 = b;
        double r107331 = -r107330;
        double r107332 = r107330 * r107330;
        double r107333 = 3.0;
        double r107334 = a;
        double r107335 = r107333 * r107334;
        double r107336 = c;
        double r107337 = r107335 * r107336;
        double r107338 = r107332 - r107337;
        double r107339 = sqrt(r107338);
        double r107340 = r107331 + r107339;
        double r107341 = r107340 / r107335;
        return r107341;
}

double f(double a, double b, double c) {
        double r107342 = b;
        double r107343 = 6.724747266396374e-06;
        bool r107344 = r107342 <= r107343;
        double r107345 = r107342 * r107342;
        double r107346 = 3.0;
        double r107347 = a;
        double r107348 = r107346 * r107347;
        double r107349 = c;
        double r107350 = r107348 * r107349;
        double r107351 = r107345 - r107350;
        double r107352 = r107351 - r107345;
        double r107353 = sqrt(r107351);
        double r107354 = r107353 + r107342;
        double r107355 = r107352 / r107354;
        double r107356 = r107355 / r107346;
        double r107357 = r107356 / r107347;
        double r107358 = -0.5;
        double r107359 = r107349 / r107342;
        double r107360 = r107358 * r107359;
        double r107361 = r107344 ? r107357 : r107360;
        return r107361;
}

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 2 regimes
  2. if b < 6.724747266396374e-06

    1. Initial program 17.4

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

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

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

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

    if 6.724747266396374e-06 < b

    1. Initial program 45.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 6.724747266396373623605423053284368961613 \cdot 10^{-6}:\\ \;\;\;\;\frac{\frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) - b \cdot b}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + b}}{3}}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019326 
(FPCore (a b c)
  :name "Cubic critical, medium range"
  :precision binary64
  :pre (and (< 1.11022e-16 a 9.0072e+15) (< 1.11022e-16 b 9.0072e+15) (< 1.11022e-16 c 9.0072e+15))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))