Average Error: 43.8 → 11.0
Time: 9.2s
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 0.004205915758382604285881001260349876247346:\\ \;\;\;\;\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 0.004205915758382604285881001260349876247346:\\
\;\;\;\;\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 r118714 = b;
        double r118715 = -r118714;
        double r118716 = r118714 * r118714;
        double r118717 = 3.0;
        double r118718 = a;
        double r118719 = r118717 * r118718;
        double r118720 = c;
        double r118721 = r118719 * r118720;
        double r118722 = r118716 - r118721;
        double r118723 = sqrt(r118722);
        double r118724 = r118715 + r118723;
        double r118725 = r118724 / r118719;
        return r118725;
}

double f(double a, double b, double c) {
        double r118726 = b;
        double r118727 = 0.004205915758382604;
        bool r118728 = r118726 <= r118727;
        double r118729 = r118726 * r118726;
        double r118730 = 3.0;
        double r118731 = a;
        double r118732 = r118730 * r118731;
        double r118733 = c;
        double r118734 = r118732 * r118733;
        double r118735 = r118729 - r118734;
        double r118736 = r118735 - r118729;
        double r118737 = sqrt(r118735);
        double r118738 = r118737 + r118726;
        double r118739 = r118736 / r118738;
        double r118740 = r118739 / r118730;
        double r118741 = r118740 / r118731;
        double r118742 = -0.5;
        double r118743 = r118733 / r118726;
        double r118744 = r118742 * r118743;
        double r118745 = r118728 ? r118741 : r118744;
        return r118745;
}

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 < 0.004205915758382604

    1. Initial program 20.5

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

      \[\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--20.5

      \[\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. Simplified19.5

      \[\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 0.004205915758382604 < b

    1. Initial program 46.3

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

      \[\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.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 0.004205915758382604285881001260349876247346:\\ \;\;\;\;\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 2019351 
(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)))