Average Error: 34.0 → 7.4
Time: 16.5s
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 -4.137767488706158662875767200280605724187 \cdot 10^{113}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -2.09566795091098069769904337484991989359 \cdot 10^{-241}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\ \mathbf{elif}\;b \le 0.01064842317658122247681085070780682144687:\\ \;\;\;\;\frac{c}{\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 -4.137767488706158662875767200280605724187 \cdot 10^{113}:\\
\;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\

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

\mathbf{elif}\;b \le 0.01064842317658122247681085070780682144687:\\
\;\;\;\;\frac{c}{\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 r94673 = b;
        double r94674 = -r94673;
        double r94675 = r94673 * r94673;
        double r94676 = 3.0;
        double r94677 = a;
        double r94678 = r94676 * r94677;
        double r94679 = c;
        double r94680 = r94678 * r94679;
        double r94681 = r94675 - r94680;
        double r94682 = sqrt(r94681);
        double r94683 = r94674 + r94682;
        double r94684 = r94683 / r94678;
        return r94684;
}

double f(double a, double b, double c) {
        double r94685 = b;
        double r94686 = -4.137767488706159e+113;
        bool r94687 = r94685 <= r94686;
        double r94688 = 0.5;
        double r94689 = c;
        double r94690 = r94689 / r94685;
        double r94691 = r94688 * r94690;
        double r94692 = 0.6666666666666666;
        double r94693 = a;
        double r94694 = r94685 / r94693;
        double r94695 = r94692 * r94694;
        double r94696 = r94691 - r94695;
        double r94697 = -2.0956679509109807e-241;
        bool r94698 = r94685 <= r94697;
        double r94699 = -r94685;
        double r94700 = r94685 * r94685;
        double r94701 = 3.0;
        double r94702 = r94701 * r94693;
        double r94703 = r94702 * r94689;
        double r94704 = r94700 - r94703;
        double r94705 = sqrt(r94704);
        double r94706 = r94699 + r94705;
        double r94707 = r94706 / r94702;
        double r94708 = 0.010648423176581222;
        bool r94709 = r94685 <= r94708;
        double r94710 = r94699 - r94705;
        double r94711 = r94689 / r94710;
        double r94712 = -0.5;
        double r94713 = r94712 * r94690;
        double r94714 = r94709 ? r94711 : r94713;
        double r94715 = r94698 ? r94707 : r94714;
        double r94716 = r94687 ? r94696 : r94715;
        return r94716;
}

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 < -4.137767488706159e+113

    1. Initial program 50.4

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

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

    if -4.137767488706159e+113 < b < -2.0956679509109807e-241

    1. Initial program 7.6

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

    if -2.0956679509109807e-241 < b < 0.010648423176581222

    1. Initial program 23.8

      \[\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-+23.9

      \[\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. Simplified17.8

      \[\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-inv17.9

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

      \[\leadsto \frac{\color{blue}{\frac{\left(0 + \left(3 \cdot a\right) \cdot c\right) \cdot 1}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    9. Simplified17.8

      \[\leadsto \frac{\frac{\color{blue}{c \cdot \left(3 \cdot a\right)}}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
    10. Using strategy rm
    11. Applied *-un-lft-identity17.8

      \[\leadsto \frac{\frac{c \cdot \left(3 \cdot a\right)}{\color{blue}{1 \cdot \left(\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}}}{3 \cdot a}\]
    12. Applied times-frac14.9

      \[\leadsto \frac{\color{blue}{\frac{c}{1} \cdot \frac{3 \cdot a}{\left(-b\right) - \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
    13. Applied associate-/l*11.3

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

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

    if 0.010648423176581222 < b

    1. Initial program 55.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.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -4.137767488706158662875767200280605724187 \cdot 10^{113}:\\ \;\;\;\;0.5 \cdot \frac{c}{b} - 0.6666666666666666296592325124947819858789 \cdot \frac{b}{a}\\ \mathbf{elif}\;b \le -2.09566795091098069769904337484991989359 \cdot 10^{-241}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\ \mathbf{elif}\;b \le 0.01064842317658122247681085070780682144687:\\ \;\;\;\;\frac{c}{\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 2019305 
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))