Cubic critical, narrow range

Percentage Accurate: 55.1% → 91.4%
Time: 16.4s
Alternatives: 12
Speedup: 2.9×

Specification

?
\[\left(\left(1.0536712127723509 \cdot 10^{-8} < a \land a < 94906265.62425156\right) \land \left(1.0536712127723509 \cdot 10^{-8} < b \land b < 94906265.62425156\right)\right) \land \left(1.0536712127723509 \cdot 10^{-8} < c \land c < 94906265.62425156\right)\]
\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a))
end
function tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 12 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 55.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a))
end
function tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 91.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := b \cdot \left(b \cdot b\right)\\ t_1 := \mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)\\ t_2 := b + \sqrt{t\_1}\\ t_3 := c \cdot \left(c \cdot c\right)\\ \mathbf{if}\;b \leq 4.8:\\ \;\;\;\;\frac{\frac{t\_1}{t\_2} - \frac{b \cdot b}{t\_2}}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, -0.5, \mathsf{fma}\left(\frac{\left(t\_3 \cdot \left(c \cdot 6.328125\right)\right) \cdot \left(a \cdot \left(a \cdot \left(a \cdot a\right)\right)\right)}{a \cdot \left(t\_0 \cdot t\_0\right)}, -0.16666666666666666, \frac{\mathsf{fma}\left(-0.375, a \cdot \left(c \cdot c\right), \frac{t\_3 \cdot \left(\left(a \cdot a\right) \cdot -0.5625\right)}{b \cdot b}\right)}{b \cdot b}\right)\right)}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (* b (* b b)))
        (t_1 (fma a (* -3.0 c) (* b b)))
        (t_2 (+ b (sqrt t_1)))
        (t_3 (* c (* c c))))
   (if (<= b 4.8)
     (/ (- (/ t_1 t_2) (/ (* b b) t_2)) (* a 3.0))
     (/
      (fma
       c
       -0.5
       (fma
        (/ (* (* t_3 (* c 6.328125)) (* a (* a (* a a)))) (* a (* t_0 t_0)))
        -0.16666666666666666
        (/
         (fma -0.375 (* a (* c c)) (/ (* t_3 (* (* a a) -0.5625)) (* b b)))
         (* b b))))
      b))))
double code(double a, double b, double c) {
	double t_0 = b * (b * b);
	double t_1 = fma(a, (-3.0 * c), (b * b));
	double t_2 = b + sqrt(t_1);
	double t_3 = c * (c * c);
	double tmp;
	if (b <= 4.8) {
		tmp = ((t_1 / t_2) - ((b * b) / t_2)) / (a * 3.0);
	} else {
		tmp = fma(c, -0.5, fma((((t_3 * (c * 6.328125)) * (a * (a * (a * a)))) / (a * (t_0 * t_0))), -0.16666666666666666, (fma(-0.375, (a * (c * c)), ((t_3 * ((a * a) * -0.5625)) / (b * b))) / (b * b)))) / b;
	}
	return tmp;
}
function code(a, b, c)
	t_0 = Float64(b * Float64(b * b))
	t_1 = fma(a, Float64(-3.0 * c), Float64(b * b))
	t_2 = Float64(b + sqrt(t_1))
	t_3 = Float64(c * Float64(c * c))
	tmp = 0.0
	if (b <= 4.8)
		tmp = Float64(Float64(Float64(t_1 / t_2) - Float64(Float64(b * b) / t_2)) / Float64(a * 3.0));
	else
		tmp = Float64(fma(c, -0.5, fma(Float64(Float64(Float64(t_3 * Float64(c * 6.328125)) * Float64(a * Float64(a * Float64(a * a)))) / Float64(a * Float64(t_0 * t_0))), -0.16666666666666666, Float64(fma(-0.375, Float64(a * Float64(c * c)), Float64(Float64(t_3 * Float64(Float64(a * a) * -0.5625)) / Float64(b * b))) / Float64(b * b)))) / b);
	end
	return tmp
end
code[a_, b_, c_] := Block[{t$95$0 = N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(a * N[(-3.0 * c), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(b + N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(c * N[(c * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 4.8], N[(N[(N[(t$95$1 / t$95$2), $MachinePrecision] - N[(N[(b * b), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5 + N[(N[(N[(N[(t$95$3 * N[(c * 6.328125), $MachinePrecision]), $MachinePrecision] * N[(a * N[(a * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.16666666666666666 + N[(N[(-0.375 * N[(a * N[(c * c), $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$3 * N[(N[(a * a), $MachinePrecision] * -0.5625), $MachinePrecision]), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := b \cdot \left(b \cdot b\right)\\
t_1 := \mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)\\
t_2 := b + \sqrt{t\_1}\\
t_3 := c \cdot \left(c \cdot c\right)\\
\mathbf{if}\;b \leq 4.8:\\
\;\;\;\;\frac{\frac{t\_1}{t\_2} - \frac{b \cdot b}{t\_2}}{a \cdot 3}\\

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(c, -0.5, \mathsf{fma}\left(\frac{\left(t\_3 \cdot \left(c \cdot 6.328125\right)\right) \cdot \left(a \cdot \left(a \cdot \left(a \cdot a\right)\right)\right)}{a \cdot \left(t\_0 \cdot t\_0\right)}, -0.16666666666666666, \frac{\mathsf{fma}\left(-0.375, a \cdot \left(c \cdot c\right), \frac{t\_3 \cdot \left(\left(a \cdot a\right) \cdot -0.5625\right)}{b \cdot b}\right)}{b \cdot b}\right)\right)}{b}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 4.79999999999999982

    1. Initial program 84.2%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Applied rewrites84.6%

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

    if 4.79999999999999982 < b

    1. Initial program 49.4%

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

      \[\leadsto \color{blue}{\frac{\frac{-9}{16} \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{4}} + \left(\frac{-1}{2} \cdot c + \left(\frac{-3}{8} \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} + \frac{-1}{6} \cdot \frac{\frac{81}{64} \cdot \left({a}^{4} \cdot {c}^{4}\right) + \frac{81}{16} \cdot \left({a}^{4} \cdot {c}^{4}\right)}{a \cdot {b}^{6}}\right)\right)}{b}} \]
    4. Applied rewrites93.6%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a \cdot a, \frac{c \cdot \left(c \cdot c\right)}{{b}^{4}} \cdot -0.5625, \mathsf{fma}\left(c, -0.5, \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{4} \cdot \left({c}^{4} \cdot 6.328125\right)}{a \cdot {b}^{6}}, \frac{\left(a \cdot \left(c \cdot c\right)\right) \cdot -0.375}{b \cdot b}\right)\right)\right)}{b}} \]
    5. Applied rewrites93.7%

      \[\leadsto \frac{\mathsf{fma}\left(c, -0.5, \mathsf{fma}\left(a, \frac{\left(c \cdot c\right) \cdot -0.375}{b \cdot b}, \frac{\left(-0.16666666666666666 \cdot \left(a \cdot \left(a \cdot \left(a \cdot a\right)\right)\right)\right) \cdot \left(\left(c \cdot c\right) \cdot \left(\left(c \cdot c\right) \cdot 6.328125\right)\right)}{a \cdot \left(\left(b \cdot \left(b \cdot b\right)\right) \cdot \left(b \cdot \left(b \cdot b\right)\right)\right)}\right) + \frac{c \cdot \left(c \cdot c\right)}{b \cdot \left(b \cdot \left(b \cdot b\right)\right)} \cdot \left(-0.5625 \cdot \left(a \cdot a\right)\right)\right)}{b} \]
    6. Applied rewrites93.7%

      \[\leadsto \frac{\mathsf{fma}\left(c, -0.5, \mathsf{fma}\left(\frac{\left(\left(c \cdot \left(c \cdot c\right)\right) \cdot \left(c \cdot 6.328125\right)\right) \cdot \left(a \cdot \left(a \cdot \left(a \cdot a\right)\right)\right)}{a \cdot \left(\left(b \cdot \left(b \cdot b\right)\right) \cdot \left(b \cdot \left(b \cdot b\right)\right)\right)}, -0.16666666666666666, \mathsf{fma}\left(a, \frac{c \cdot \left(c \cdot -0.375\right)}{b \cdot b}, \frac{\left(c \cdot c\right) \cdot \left(c \cdot \left(\left(a \cdot a\right) \cdot -0.5625\right)\right)}{b \cdot \left(b \cdot \left(b \cdot b\right)\right)}\right)\right)\right)}{b} \]
    7. Taylor expanded in b around inf

      \[\leadsto \frac{\mathsf{fma}\left(c, \frac{-1}{2}, \mathsf{fma}\left(\frac{\left(\left(c \cdot \left(c \cdot c\right)\right) \cdot \left(c \cdot \frac{405}{64}\right)\right) \cdot \left(a \cdot \left(a \cdot \left(a \cdot a\right)\right)\right)}{a \cdot \left(\left(b \cdot \left(b \cdot b\right)\right) \cdot \left(b \cdot \left(b \cdot b\right)\right)\right)}, \frac{-1}{6}, \frac{\frac{-9}{16} \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{2}} + \frac{-3}{8} \cdot \left(a \cdot {c}^{2}\right)}{{b}^{2}}\right)\right)}{b} \]
    8. Step-by-step derivation
      1. Applied rewrites93.7%

        \[\leadsto \frac{\mathsf{fma}\left(c, -0.5, \mathsf{fma}\left(\frac{\left(\left(c \cdot \left(c \cdot c\right)\right) \cdot \left(c \cdot 6.328125\right)\right) \cdot \left(a \cdot \left(a \cdot \left(a \cdot a\right)\right)\right)}{a \cdot \left(\left(b \cdot \left(b \cdot b\right)\right) \cdot \left(b \cdot \left(b \cdot b\right)\right)\right)}, -0.16666666666666666, \frac{\mathsf{fma}\left(-0.375, a \cdot \left(c \cdot c\right), \frac{\left(c \cdot \left(c \cdot c\right)\right) \cdot \left(\left(a \cdot a\right) \cdot -0.5625\right)}{b \cdot b}\right)}{b \cdot b}\right)\right)}{b} \]
    9. Recombined 2 regimes into one program.
    10. Final simplification92.2%

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 4.8:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}} - \frac{b \cdot b}{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, -0.5, \mathsf{fma}\left(\frac{\left(\left(c \cdot \left(c \cdot c\right)\right) \cdot \left(c \cdot 6.328125\right)\right) \cdot \left(a \cdot \left(a \cdot \left(a \cdot a\right)\right)\right)}{a \cdot \left(\left(b \cdot \left(b \cdot b\right)\right) \cdot \left(b \cdot \left(b \cdot b\right)\right)\right)}, -0.16666666666666666, \frac{\mathsf{fma}\left(-0.375, a \cdot \left(c \cdot c\right), \frac{\left(c \cdot \left(c \cdot c\right)\right) \cdot \left(\left(a \cdot a\right) \cdot -0.5625\right)}{b \cdot b}\right)}{b \cdot b}\right)\right)}{b}\\ \end{array} \]
    11. Add Preprocessing

    Alternative 2: 89.6% accurate, 0.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)\\ t_1 := b + \sqrt{t\_0}\\ \mathbf{if}\;b \leq 5.6:\\ \;\;\;\;\frac{\frac{t\_0}{t\_1} - \frac{b \cdot b}{t\_1}}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, -0.5, \frac{\mathsf{fma}\left(\left(c \cdot c\right) \cdot \left(a \cdot \left(a \cdot c\right)\right), \frac{-0.5625}{b \cdot b}, a \cdot \left(\left(c \cdot c\right) \cdot -0.375\right)\right)}{b \cdot b}\right)}{b}\\ \end{array} \end{array} \]
    (FPCore (a b c)
     :precision binary64
     (let* ((t_0 (fma a (* -3.0 c) (* b b))) (t_1 (+ b (sqrt t_0))))
       (if (<= b 5.6)
         (/ (- (/ t_0 t_1) (/ (* b b) t_1)) (* a 3.0))
         (/
          (fma
           c
           -0.5
           (/
            (fma
             (* (* c c) (* a (* a c)))
             (/ -0.5625 (* b b))
             (* a (* (* c c) -0.375)))
            (* b b)))
          b))))
    double code(double a, double b, double c) {
    	double t_0 = fma(a, (-3.0 * c), (b * b));
    	double t_1 = b + sqrt(t_0);
    	double tmp;
    	if (b <= 5.6) {
    		tmp = ((t_0 / t_1) - ((b * b) / t_1)) / (a * 3.0);
    	} else {
    		tmp = fma(c, -0.5, (fma(((c * c) * (a * (a * c))), (-0.5625 / (b * b)), (a * ((c * c) * -0.375))) / (b * b))) / b;
    	}
    	return tmp;
    }
    
    function code(a, b, c)
    	t_0 = fma(a, Float64(-3.0 * c), Float64(b * b))
    	t_1 = Float64(b + sqrt(t_0))
    	tmp = 0.0
    	if (b <= 5.6)
    		tmp = Float64(Float64(Float64(t_0 / t_1) - Float64(Float64(b * b) / t_1)) / Float64(a * 3.0));
    	else
    		tmp = Float64(fma(c, -0.5, Float64(fma(Float64(Float64(c * c) * Float64(a * Float64(a * c))), Float64(-0.5625 / Float64(b * b)), Float64(a * Float64(Float64(c * c) * -0.375))) / Float64(b * b))) / b);
    	end
    	return tmp
    end
    
    code[a_, b_, c_] := Block[{t$95$0 = N[(a * N[(-3.0 * c), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b + N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 5.6], N[(N[(N[(t$95$0 / t$95$1), $MachinePrecision] - N[(N[(b * b), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5 + N[(N[(N[(N[(c * c), $MachinePrecision] * N[(a * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-0.5625 / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[(c * c), $MachinePrecision] * -0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)\\
    t_1 := b + \sqrt{t\_0}\\
    \mathbf{if}\;b \leq 5.6:\\
    \;\;\;\;\frac{\frac{t\_0}{t\_1} - \frac{b \cdot b}{t\_1}}{a \cdot 3}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\mathsf{fma}\left(c, -0.5, \frac{\mathsf{fma}\left(\left(c \cdot c\right) \cdot \left(a \cdot \left(a \cdot c\right)\right), \frac{-0.5625}{b \cdot b}, a \cdot \left(\left(c \cdot c\right) \cdot -0.375\right)\right)}{b \cdot b}\right)}{b}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if b < 5.5999999999999996

      1. Initial program 80.0%

        \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
      2. Add Preprocessing
      3. Applied rewrites80.7%

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

      if 5.5999999999999996 < b

      1. Initial program 48.6%

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

        \[\leadsto \color{blue}{\frac{\frac{-9}{16} \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{4}} + \left(\frac{-1}{2} \cdot c + \left(\frac{-3}{8} \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} + \frac{-1}{6} \cdot \frac{\frac{81}{64} \cdot \left({a}^{4} \cdot {c}^{4}\right) + \frac{81}{16} \cdot \left({a}^{4} \cdot {c}^{4}\right)}{a \cdot {b}^{6}}\right)\right)}{b}} \]
      4. Applied rewrites94.1%

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a \cdot a, \frac{c \cdot \left(c \cdot c\right)}{{b}^{4}} \cdot -0.5625, \mathsf{fma}\left(c, -0.5, \mathsf{fma}\left(-0.16666666666666666, \frac{{a}^{4} \cdot \left({c}^{4} \cdot 6.328125\right)}{a \cdot {b}^{6}}, \frac{\left(a \cdot \left(c \cdot c\right)\right) \cdot -0.375}{b \cdot b}\right)\right)\right)}{b}} \]
      5. Applied rewrites94.1%

        \[\leadsto \frac{\mathsf{fma}\left(c, -0.5, \mathsf{fma}\left(a, \frac{\left(c \cdot c\right) \cdot -0.375}{b \cdot b}, \frac{\left(-0.16666666666666666 \cdot \left(a \cdot \left(a \cdot \left(a \cdot a\right)\right)\right)\right) \cdot \left(\left(c \cdot c\right) \cdot \left(\left(c \cdot c\right) \cdot 6.328125\right)\right)}{a \cdot \left(\left(b \cdot \left(b \cdot b\right)\right) \cdot \left(b \cdot \left(b \cdot b\right)\right)\right)}\right) + \frac{c \cdot \left(c \cdot c\right)}{b \cdot \left(b \cdot \left(b \cdot b\right)\right)} \cdot \left(-0.5625 \cdot \left(a \cdot a\right)\right)\right)}{b} \]
      6. Taylor expanded in b around inf

        \[\leadsto \frac{\mathsf{fma}\left(c, \frac{-1}{2}, \frac{\frac{-9}{16} \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{2}} + \frac{-3}{8} \cdot \left(a \cdot {c}^{2}\right)}{{b}^{2}}\right)}{b} \]
      7. Step-by-step derivation
        1. Applied rewrites91.9%

          \[\leadsto \frac{\mathsf{fma}\left(c, -0.5, \frac{\mathsf{fma}\left(\left(c \cdot c\right) \cdot \left(a \cdot \left(a \cdot c\right)\right), \frac{-0.5625}{b \cdot b}, a \cdot \left(-0.375 \cdot \left(c \cdot c\right)\right)\right)}{b \cdot b}\right)}{b} \]
      8. Recombined 2 regimes into one program.
      9. Final simplification89.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 5.6:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}} - \frac{b \cdot b}{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(c, -0.5, \frac{\mathsf{fma}\left(\left(c \cdot c\right) \cdot \left(a \cdot \left(a \cdot c\right)\right), \frac{-0.5625}{b \cdot b}, a \cdot \left(\left(c \cdot c\right) \cdot -0.375\right)\right)}{b \cdot b}\right)}{b}\\ \end{array} \]
      10. Add Preprocessing

      Reproduce

      ?
      herbie shell --seed 2024222 
      (FPCore (a b c)
        :name "Cubic critical, narrow range"
        :precision binary64
        :pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
        (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))