Average Error: 33.8 → 8.9
Time: 18.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 -25481725115075804321919054901585903616:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -6.502225290114381437308913602915977771945 \cdot 10^{-251}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}\\ \mathbf{elif}\;b \le 1.670520676242107312150598739005390962163 \cdot 10^{112}:\\ \;\;\;\;\frac{\frac{c \cdot \left(3 \cdot a\right)}{3 \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}\\ \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 -25481725115075804321919054901585903616:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\

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

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

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

\end{array}
double f(double a, double b, double c) {
        double r88574 = b;
        double r88575 = -r88574;
        double r88576 = r88574 * r88574;
        double r88577 = 3.0;
        double r88578 = a;
        double r88579 = r88577 * r88578;
        double r88580 = c;
        double r88581 = r88579 * r88580;
        double r88582 = r88576 - r88581;
        double r88583 = sqrt(r88582);
        double r88584 = r88575 + r88583;
        double r88585 = r88584 / r88579;
        return r88585;
}

double f(double a, double b, double c) {
        double r88586 = b;
        double r88587 = -2.5481725115075804e+37;
        bool r88588 = r88586 <= r88587;
        double r88589 = 0.5;
        double r88590 = c;
        double r88591 = r88590 / r88586;
        double r88592 = r88589 * r88591;
        double r88593 = 0.6666666666666666;
        double r88594 = a;
        double r88595 = r88586 / r88594;
        double r88596 = r88593 * r88595;
        double r88597 = r88592 - r88596;
        double r88598 = -6.5022252901143814e-251;
        bool r88599 = r88586 <= r88598;
        double r88600 = r88586 * r88586;
        double r88601 = 3.0;
        double r88602 = r88601 * r88594;
        double r88603 = r88602 * r88590;
        double r88604 = r88600 - r88603;
        double r88605 = sqrt(r88604);
        double r88606 = r88605 - r88586;
        double r88607 = r88606 / r88601;
        double r88608 = r88607 / r88594;
        double r88609 = 1.6705206762421073e+112;
        bool r88610 = r88586 <= r88609;
        double r88611 = r88590 * r88602;
        double r88612 = r88611 / r88602;
        double r88613 = -r88586;
        double r88614 = r88613 - r88605;
        double r88615 = r88612 / r88614;
        double r88616 = -0.5;
        double r88617 = r88616 * r88591;
        double r88618 = r88610 ? r88615 : r88617;
        double r88619 = r88599 ? r88608 : r88618;
        double r88620 = r88588 ? r88597 : r88619;
        return r88620;
}

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.5481725115075804e+37

    1. Initial program 36.6

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

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

    if -2.5481725115075804e+37 < b < -6.5022252901143814e-251

    1. Initial program 9.3

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

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

    if -6.5022252901143814e-251 < b < 1.6705206762421073e+112

    1. Initial program 30.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 flip-+30.5

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

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

      \[\leadsto \color{blue}{\frac{0 + \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}}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity15.7

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

      \[\leadsto \color{blue}{1 \cdot \left(\frac{0 + \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}\right)}\]
    10. Simplified14.8

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

    if 1.6705206762421073e+112 < b

    1. Initial program 59.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -25481725115075804321919054901585903616:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -6.502225290114381437308913602915977771945 \cdot 10^{-251}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}{3}}{a}\\ \mathbf{elif}\;b \le 1.670520676242107312150598739005390962163 \cdot 10^{112}:\\ \;\;\;\;\frac{\frac{c \cdot \left(3 \cdot a\right)}{3 \cdot a}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array}\]

Reproduce

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