Average Error: 44.1 → 11.1
Time: 14.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 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 r44794 = b;
        double r44795 = -r44794;
        double r44796 = r44794 * r44794;
        double r44797 = 3.0;
        double r44798 = a;
        double r44799 = r44797 * r44798;
        double r44800 = c;
        double r44801 = r44799 * r44800;
        double r44802 = r44796 - r44801;
        double r44803 = sqrt(r44802);
        double r44804 = r44795 + r44803;
        double r44805 = r44804 / r44799;
        return r44805;
}

double f(double a, double b, double c) {
        double r44806 = b;
        double r44807 = 6.724747266396374e-06;
        bool r44808 = r44806 <= r44807;
        double r44809 = r44806 * r44806;
        double r44810 = 3.0;
        double r44811 = a;
        double r44812 = r44810 * r44811;
        double r44813 = c;
        double r44814 = r44812 * r44813;
        double r44815 = r44809 - r44814;
        double r44816 = r44815 - r44809;
        double r44817 = sqrt(r44815);
        double r44818 = r44817 + r44806;
        double r44819 = r44816 / r44818;
        double r44820 = r44819 / r44810;
        double r44821 = r44820 / r44811;
        double r44822 = -0.5;
        double r44823 = r44813 / r44806;
        double r44824 = r44822 * r44823;
        double r44825 = r44808 ? r44821 : r44824;
        return r44825;
}

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