Average Error: 44.1 → 10.2
Time: 15.3s
Precision: 64
\[1.1102230246251565 \cdot 10^{-16} \lt a \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt b \lt 9007199254740992.0 \land 1.1102230246251565 \cdot 10^{-16} \lt c \lt 9007199254740992.0\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -2.9605365894731364 \cdot 10^{-07}:\\ \;\;\;\;\left(\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)\right) \cdot \frac{1}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b} \cdot \frac{-1}{2}\\ \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}\;\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \le -2.9605365894731364 \cdot 10^{-07}:\\
\;\;\;\;\left(\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)\right) \cdot \frac{1}{3 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r4446779 = b;
        double r4446780 = -r4446779;
        double r4446781 = r4446779 * r4446779;
        double r4446782 = 3.0;
        double r4446783 = a;
        double r4446784 = r4446782 * r4446783;
        double r4446785 = c;
        double r4446786 = r4446784 * r4446785;
        double r4446787 = r4446781 - r4446786;
        double r4446788 = sqrt(r4446787);
        double r4446789 = r4446780 + r4446788;
        double r4446790 = r4446789 / r4446784;
        return r4446790;
}

double f(double a, double b, double c) {
        double r4446791 = b;
        double r4446792 = r4446791 * r4446791;
        double r4446793 = 3.0;
        double r4446794 = a;
        double r4446795 = r4446793 * r4446794;
        double r4446796 = c;
        double r4446797 = r4446795 * r4446796;
        double r4446798 = r4446792 - r4446797;
        double r4446799 = sqrt(r4446798);
        double r4446800 = -r4446791;
        double r4446801 = r4446799 + r4446800;
        double r4446802 = r4446801 / r4446795;
        double r4446803 = -2.9605365894731364e-07;
        bool r4446804 = r4446802 <= r4446803;
        double r4446805 = 1.0;
        double r4446806 = r4446805 / r4446795;
        double r4446807 = r4446801 * r4446806;
        double r4446808 = r4446796 / r4446791;
        double r4446809 = -0.5;
        double r4446810 = r4446808 * r4446809;
        double r4446811 = r4446804 ? r4446807 : r4446810;
        return r4446811;
}

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) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)) < -2.9605365894731364e-07

    1. Initial program 21.9

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
    2. Using strategy rm
    3. Applied div-inv21.9

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

    if -2.9605365894731364e-07 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))

    1. Initial program 53.7

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

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

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

Reproduce

herbie shell --seed 2019158 +o rules:numerics
(FPCore (a b c)
  :name "Cubic critical, medium range"
  :pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))