Cubic critical, narrow range

Percentage Accurate: 55.7% → 90.8%
Time: 13.8s
Alternatives: 8
Speedup: 23.2×

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 8 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.7% 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: 90.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -1.125 \cdot \left(c \cdot \left(c \cdot \left(a \cdot a\right)\right)\right)\\ \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.16666666666666666, \frac{t_0 \cdot t_0 + 5.0625 \cdot {\left(c \cdot a\right)}^{4}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot c}{\frac{{b}^{3}}{a}}\right)\right)\right) \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (* -1.125 (* c (* c (* a a))))))
   (fma
    -0.5625
    (/ (pow c 3.0) (/ (pow b 5.0) (* a a)))
    (fma
     -0.16666666666666666
     (/ (+ (* t_0 t_0) (* 5.0625 (pow (* c a) 4.0))) (* a (pow b 7.0)))
     (fma -0.5 (/ c b) (* -0.375 (/ (* c c) (/ (pow b 3.0) a))))))))
double code(double a, double b, double c) {
	double t_0 = -1.125 * (c * (c * (a * a)));
	return fma(-0.5625, (pow(c, 3.0) / (pow(b, 5.0) / (a * a))), fma(-0.16666666666666666, (((t_0 * t_0) + (5.0625 * pow((c * a), 4.0))) / (a * pow(b, 7.0))), fma(-0.5, (c / b), (-0.375 * ((c * c) / (pow(b, 3.0) / a))))));
}
function code(a, b, c)
	t_0 = Float64(-1.125 * Float64(c * Float64(c * Float64(a * a))))
	return fma(-0.5625, Float64((c ^ 3.0) / Float64((b ^ 5.0) / Float64(a * a))), fma(-0.16666666666666666, Float64(Float64(Float64(t_0 * t_0) + Float64(5.0625 * (Float64(c * a) ^ 4.0))) / Float64(a * (b ^ 7.0))), fma(-0.5, Float64(c / b), Float64(-0.375 * Float64(Float64(c * c) / Float64((b ^ 3.0) / a))))))
end
code[a_, b_, c_] := Block[{t$95$0 = N[(-1.125 * N[(c * N[(c * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(-0.5625 * N[(N[Power[c, 3.0], $MachinePrecision] / N[(N[Power[b, 5.0], $MachinePrecision] / N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.16666666666666666 * N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] + N[(5.0625 * N[Power[N[(c * a), $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(c / b), $MachinePrecision] + N[(-0.375 * N[(N[(c * c), $MachinePrecision] / N[(N[Power[b, 3.0], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := -1.125 \cdot \left(c \cdot \left(c \cdot \left(a \cdot a\right)\right)\right)\\
\mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.16666666666666666, \frac{t_0 \cdot t_0 + 5.0625 \cdot {\left(c \cdot a\right)}^{4}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot c}{\frac{{b}^{3}}{a}}\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 54.4%

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

    \[\leadsto \color{blue}{-0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(-0.16666666666666666 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right)} \]
  3. Step-by-step derivation
    1. fma-def91.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5625, \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}, -0.16666666666666666 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right)} \]
    2. associate-/l*91.8%

      \[\leadsto \mathsf{fma}\left(-0.5625, \color{blue}{\frac{{c}^{3}}{\frac{{b}^{5}}{{a}^{2}}}}, -0.16666666666666666 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right) \]
    3. unpow291.8%

      \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{\color{blue}{a \cdot a}}}, -0.16666666666666666 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right) \]
    4. fma-def91.8%

      \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \color{blue}{\mathsf{fma}\left(-0.16666666666666666, \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}}, -0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)}\right) \]
  4. Simplified91.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.16666666666666666, \frac{{\left(-1.125 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot c}{\frac{{b}^{3}}{a}}\right)\right)\right)} \]
  5. Step-by-step derivation
    1. pow191.8%

      \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.16666666666666666, \frac{{\left(-1.125 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}^{2} + 5.0625 \cdot \color{blue}{{\left({c}^{4} \cdot {a}^{4}\right)}^{1}}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot c}{\frac{{b}^{3}}{a}}\right)\right)\right) \]
    2. pow-prod-down91.8%

      \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.16666666666666666, \frac{{\left(-1.125 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}^{2} + 5.0625 \cdot {\color{blue}{\left({\left(c \cdot a\right)}^{4}\right)}}^{1}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot c}{\frac{{b}^{3}}{a}}\right)\right)\right) \]
  6. Applied egg-rr91.8%

    \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.16666666666666666, \frac{{\left(-1.125 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}^{2} + 5.0625 \cdot \color{blue}{{\left({\left(c \cdot a\right)}^{4}\right)}^{1}}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot c}{\frac{{b}^{3}}{a}}\right)\right)\right) \]
  7. Step-by-step derivation
    1. unpow191.8%

      \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.16666666666666666, \frac{{\left(-1.125 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}^{2} + 5.0625 \cdot \color{blue}{{\left(c \cdot a\right)}^{4}}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot c}{\frac{{b}^{3}}{a}}\right)\right)\right) \]
  8. Simplified91.8%

    \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.16666666666666666, \frac{{\left(-1.125 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)}^{2} + 5.0625 \cdot \color{blue}{{\left(c \cdot a\right)}^{4}}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot c}{\frac{{b}^{3}}{a}}\right)\right)\right) \]
  9. Step-by-step derivation
    1. unpow291.8%

      \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.16666666666666666, \frac{\color{blue}{\left(-1.125 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right) \cdot \left(-1.125 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right)} + 5.0625 \cdot {\left(c \cdot a\right)}^{4}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot c}{\frac{{b}^{3}}{a}}\right)\right)\right) \]
    2. associate-*l*91.8%

      \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.16666666666666666, \frac{\left(-1.125 \cdot \color{blue}{\left(c \cdot \left(c \cdot \left(a \cdot a\right)\right)\right)}\right) \cdot \left(-1.125 \cdot \left(\left(c \cdot c\right) \cdot \left(a \cdot a\right)\right)\right) + 5.0625 \cdot {\left(c \cdot a\right)}^{4}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot c}{\frac{{b}^{3}}{a}}\right)\right)\right) \]
    3. associate-*l*91.8%

      \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.16666666666666666, \frac{\left(-1.125 \cdot \left(c \cdot \left(c \cdot \left(a \cdot a\right)\right)\right)\right) \cdot \left(-1.125 \cdot \color{blue}{\left(c \cdot \left(c \cdot \left(a \cdot a\right)\right)\right)}\right) + 5.0625 \cdot {\left(c \cdot a\right)}^{4}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot c}{\frac{{b}^{3}}{a}}\right)\right)\right) \]
  10. Applied egg-rr91.8%

    \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.16666666666666666, \frac{\color{blue}{\left(-1.125 \cdot \left(c \cdot \left(c \cdot \left(a \cdot a\right)\right)\right)\right) \cdot \left(-1.125 \cdot \left(c \cdot \left(c \cdot \left(a \cdot a\right)\right)\right)\right)} + 5.0625 \cdot {\left(c \cdot a\right)}^{4}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot c}{\frac{{b}^{3}}{a}}\right)\right)\right) \]
  11. Final simplification91.8%

    \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.16666666666666666, \frac{\left(-1.125 \cdot \left(c \cdot \left(c \cdot \left(a \cdot a\right)\right)\right)\right) \cdot \left(-1.125 \cdot \left(c \cdot \left(c \cdot \left(a \cdot a\right)\right)\right)\right) + 5.0625 \cdot {\left(c \cdot a\right)}^{4}}{a \cdot {b}^{7}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot c}{\frac{{b}^{3}}{a}}\right)\right)\right) \]

Alternative 2: 89.7% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{c \cdot \left(3 \cdot a\right)}\\
t_1 := \left(b + t_0\right) \cdot \left(b - t_0\right)\\
\mathbf{if}\;b \leq 3.4:\\
\;\;\;\;\frac{\frac{b \cdot b - t_1}{\left(-b\right) - \sqrt{t_1}}}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot c}{\frac{{b}^{3}}{a}}\right)\right)\\


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

    1. Initial program 82.6%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Step-by-step derivation
      1. add-sqr-sqrt82.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\sqrt{\left(3 \cdot a\right) \cdot c} \cdot \sqrt{\left(3 \cdot a\right) \cdot c}}}}{3 \cdot a} \]
      2. difference-of-squares82.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(b + \sqrt{\left(3 \cdot a\right) \cdot c}\right) \cdot \left(b - \sqrt{\left(3 \cdot a\right) \cdot c}\right)}}}{3 \cdot a} \]
      3. associate-*l*82.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{\color{blue}{3 \cdot \left(a \cdot c\right)}}\right) \cdot \left(b - \sqrt{\left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a} \]
      4. associate-*l*82.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{3 \cdot \left(a \cdot c\right)}\right) \cdot \left(b - \sqrt{\color{blue}{3 \cdot \left(a \cdot c\right)}}\right)}}{3 \cdot a} \]
    3. Applied egg-rr82.5%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(b + \sqrt{3 \cdot \left(a \cdot c\right)}\right) \cdot \left(b - \sqrt{3 \cdot \left(a \cdot c\right)}\right)}}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. *-commutative82.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{\color{blue}{\left(a \cdot c\right) \cdot 3}}\right) \cdot \left(b - \sqrt{3 \cdot \left(a \cdot c\right)}\right)}}{3 \cdot a} \]
      2. *-commutative82.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{\color{blue}{\left(c \cdot a\right)} \cdot 3}\right) \cdot \left(b - \sqrt{3 \cdot \left(a \cdot c\right)}\right)}}{3 \cdot a} \]
      3. associate-*l*82.4%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{\color{blue}{c \cdot \left(a \cdot 3\right)}}\right) \cdot \left(b - \sqrt{3 \cdot \left(a \cdot c\right)}\right)}}{3 \cdot a} \]
      4. *-commutative82.4%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{\color{blue}{\left(a \cdot c\right) \cdot 3}}\right)}}{3 \cdot a} \]
      5. *-commutative82.4%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{\color{blue}{\left(c \cdot a\right)} \cdot 3}\right)}}{3 \cdot a} \]
      6. associate-*l*82.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{\color{blue}{c \cdot \left(a \cdot 3\right)}}\right)}}{3 \cdot a} \]
    5. Simplified82.6%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}}{3 \cdot a} \]
    6. Step-by-step derivation
      1. flip-+82.4%

        \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)} \cdot \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}{\left(-b\right) - \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}}}{3 \cdot a} \]
      2. add-sqr-sqrt83.7%

        \[\leadsto \frac{\frac{\left(-b\right) \cdot \left(-b\right) - \color{blue}{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}{\left(-b\right) - \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}}{3 \cdot a} \]
    7. Applied egg-rr83.7%

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) \cdot \left(-b\right) - \left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}{\left(-b\right) - \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}}}{3 \cdot a} \]
    8. Step-by-step derivation
      1. sqr-neg83.7%

        \[\leadsto \frac{\frac{\color{blue}{b \cdot b} - \left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}{\left(-b\right) - \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}}{3 \cdot a} \]
    9. Simplified83.7%

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

    if 3.39999999999999991 < b

    1. Initial program 47.8%

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

      \[\leadsto \color{blue}{-0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)} \]
    3. Step-by-step derivation
      1. fma-def93.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5625, \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}, -0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)} \]
      2. associate-/l*93.3%

        \[\leadsto \mathsf{fma}\left(-0.5625, \color{blue}{\frac{{c}^{3}}{\frac{{b}^{5}}{{a}^{2}}}}, -0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right) \]
      3. unpow293.3%

        \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{\color{blue}{a \cdot a}}}, -0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right) \]
      4. fma-def93.3%

        \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \color{blue}{\mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)}\right) \]
      5. associate-/l*93.3%

        \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \color{blue}{\frac{{c}^{2}}{\frac{{b}^{3}}{a}}}\right)\right) \]
      6. unpow293.3%

        \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{\color{blue}{c \cdot c}}{\frac{{b}^{3}}{a}}\right)\right) \]
    4. Simplified93.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot c}{\frac{{b}^{3}}{a}}\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification91.5%

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

Alternative 3: 89.5% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{c \cdot \left(3 \cdot a\right)}\\ \mathbf{if}\;b \leq 3.4:\\ \;\;\;\;\sqrt[3]{{\left(\frac{\sqrt{\left(b + t_0\right) \cdot \left(b - t_0\right)} - b}{3 \cdot a}\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot c}{\frac{{b}^{3}}{a}}\right)\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (* c (* 3.0 a)))))
   (if (<= b 3.4)
     (cbrt (pow (/ (- (sqrt (* (+ b t_0) (- b t_0))) b) (* 3.0 a)) 3.0))
     (fma
      -0.5625
      (/ (pow c 3.0) (/ (pow b 5.0) (* a a)))
      (fma -0.5 (/ c b) (* -0.375 (/ (* c c) (/ (pow b 3.0) a))))))))
double code(double a, double b, double c) {
	double t_0 = sqrt((c * (3.0 * a)));
	double tmp;
	if (b <= 3.4) {
		tmp = cbrt(pow(((sqrt(((b + t_0) * (b - t_0))) - b) / (3.0 * a)), 3.0));
	} else {
		tmp = fma(-0.5625, (pow(c, 3.0) / (pow(b, 5.0) / (a * a))), fma(-0.5, (c / b), (-0.375 * ((c * c) / (pow(b, 3.0) / a)))));
	}
	return tmp;
}
function code(a, b, c)
	t_0 = sqrt(Float64(c * Float64(3.0 * a)))
	tmp = 0.0
	if (b <= 3.4)
		tmp = cbrt((Float64(Float64(sqrt(Float64(Float64(b + t_0) * Float64(b - t_0))) - b) / Float64(3.0 * a)) ^ 3.0));
	else
		tmp = fma(-0.5625, Float64((c ^ 3.0) / Float64((b ^ 5.0) / Float64(a * a))), fma(-0.5, Float64(c / b), Float64(-0.375 * Float64(Float64(c * c) / Float64((b ^ 3.0) / a)))));
	end
	return tmp
end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(c * N[(3.0 * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, 3.4], N[Power[N[Power[N[(N[(N[Sqrt[N[(N[(b + t$95$0), $MachinePrecision] * N[(b - t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision], N[(-0.5625 * N[(N[Power[c, 3.0], $MachinePrecision] / N[(N[Power[b, 5.0], $MachinePrecision] / N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(c / b), $MachinePrecision] + N[(-0.375 * N[(N[(c * c), $MachinePrecision] / N[(N[Power[b, 3.0], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{c \cdot \left(3 \cdot a\right)}\\
\mathbf{if}\;b \leq 3.4:\\
\;\;\;\;\sqrt[3]{{\left(\frac{\sqrt{\left(b + t_0\right) \cdot \left(b - t_0\right)} - b}{3 \cdot a}\right)}^{3}}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot c}{\frac{{b}^{3}}{a}}\right)\right)\\


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

    1. Initial program 82.6%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Step-by-step derivation
      1. add-sqr-sqrt82.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\sqrt{\left(3 \cdot a\right) \cdot c} \cdot \sqrt{\left(3 \cdot a\right) \cdot c}}}}{3 \cdot a} \]
      2. difference-of-squares82.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(b + \sqrt{\left(3 \cdot a\right) \cdot c}\right) \cdot \left(b - \sqrt{\left(3 \cdot a\right) \cdot c}\right)}}}{3 \cdot a} \]
      3. associate-*l*82.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{\color{blue}{3 \cdot \left(a \cdot c\right)}}\right) \cdot \left(b - \sqrt{\left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a} \]
      4. associate-*l*82.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{3 \cdot \left(a \cdot c\right)}\right) \cdot \left(b - \sqrt{\color{blue}{3 \cdot \left(a \cdot c\right)}}\right)}}{3 \cdot a} \]
    3. Applied egg-rr82.5%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(b + \sqrt{3 \cdot \left(a \cdot c\right)}\right) \cdot \left(b - \sqrt{3 \cdot \left(a \cdot c\right)}\right)}}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. *-commutative82.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{\color{blue}{\left(a \cdot c\right) \cdot 3}}\right) \cdot \left(b - \sqrt{3 \cdot \left(a \cdot c\right)}\right)}}{3 \cdot a} \]
      2. *-commutative82.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{\color{blue}{\left(c \cdot a\right)} \cdot 3}\right) \cdot \left(b - \sqrt{3 \cdot \left(a \cdot c\right)}\right)}}{3 \cdot a} \]
      3. associate-*l*82.4%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{\color{blue}{c \cdot \left(a \cdot 3\right)}}\right) \cdot \left(b - \sqrt{3 \cdot \left(a \cdot c\right)}\right)}}{3 \cdot a} \]
      4. *-commutative82.4%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{\color{blue}{\left(a \cdot c\right) \cdot 3}}\right)}}{3 \cdot a} \]
      5. *-commutative82.4%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{\color{blue}{\left(c \cdot a\right)} \cdot 3}\right)}}{3 \cdot a} \]
      6. associate-*l*82.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{\color{blue}{c \cdot \left(a \cdot 3\right)}}\right)}}{3 \cdot a} \]
    5. Simplified82.6%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}}{3 \cdot a} \]
    6. Step-by-step derivation
      1. add-log-exp75.0%

        \[\leadsto \frac{\color{blue}{\log \left(e^{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}\right)}}{3 \cdot a} \]
    7. Applied egg-rr75.0%

      \[\leadsto \frac{\color{blue}{\log \left(e^{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}\right)}}{3 \cdot a} \]
    8. Step-by-step derivation
      1. add-cbrt-cube75.1%

        \[\leadsto \color{blue}{\sqrt[3]{\left(\frac{\log \left(e^{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}\right)}{3 \cdot a} \cdot \frac{\log \left(e^{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}\right)}{3 \cdot a}\right) \cdot \frac{\log \left(e^{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}\right)}{3 \cdot a}}} \]
    9. Applied egg-rr82.7%

      \[\leadsto \color{blue}{\sqrt[3]{\left(\frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}{a \cdot 3} \cdot \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}{a \cdot 3}\right) \cdot \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}{a \cdot 3}}} \]
    10. Step-by-step derivation
      1. associate-*l*82.7%

        \[\leadsto \sqrt[3]{\color{blue}{\frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}{a \cdot 3} \cdot \left(\frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}{a \cdot 3} \cdot \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}{a \cdot 3}\right)}} \]
      2. cube-unmult82.6%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(\frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}{a \cdot 3}\right)}^{3}}} \]
    11. Simplified82.6%

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

    if 3.39999999999999991 < b

    1. Initial program 47.8%

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

      \[\leadsto \color{blue}{-0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)} \]
    3. Step-by-step derivation
      1. fma-def93.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5625, \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}, -0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)} \]
      2. associate-/l*93.3%

        \[\leadsto \mathsf{fma}\left(-0.5625, \color{blue}{\frac{{c}^{3}}{\frac{{b}^{5}}{{a}^{2}}}}, -0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right) \]
      3. unpow293.3%

        \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{\color{blue}{a \cdot a}}}, -0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right) \]
      4. fma-def93.3%

        \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \color{blue}{\mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)}\right) \]
      5. associate-/l*93.3%

        \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \color{blue}{\frac{{c}^{2}}{\frac{{b}^{3}}{a}}}\right)\right) \]
      6. unpow293.3%

        \[\leadsto \mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{\color{blue}{c \cdot c}}{\frac{{b}^{3}}{a}}\right)\right) \]
    4. Simplified93.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5625, \frac{{c}^{3}}{\frac{{b}^{5}}{a \cdot a}}, \mathsf{fma}\left(-0.5, \frac{c}{b}, -0.375 \cdot \frac{c \cdot c}{\frac{{b}^{3}}{a}}\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification91.3%

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

Alternative 4: 85.4% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{c \cdot \left(3 \cdot a\right)}\\ \mathbf{if}\;b \leq 3.4:\\ \;\;\;\;\sqrt[3]{{\left(\frac{\sqrt{\left(b + t_0\right) \cdot \left(b - t_0\right)} - b}{3 \cdot a}\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.375, a \cdot \frac{c \cdot c}{{b}^{3}}, -0.5 \cdot \frac{c}{b}\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (sqrt (* c (* 3.0 a)))))
   (if (<= b 3.4)
     (cbrt (pow (/ (- (sqrt (* (+ b t_0) (- b t_0))) b) (* 3.0 a)) 3.0))
     (fma -0.375 (* a (/ (* c c) (pow b 3.0))) (* -0.5 (/ c b))))))
double code(double a, double b, double c) {
	double t_0 = sqrt((c * (3.0 * a)));
	double tmp;
	if (b <= 3.4) {
		tmp = cbrt(pow(((sqrt(((b + t_0) * (b - t_0))) - b) / (3.0 * a)), 3.0));
	} else {
		tmp = fma(-0.375, (a * ((c * c) / pow(b, 3.0))), (-0.5 * (c / b)));
	}
	return tmp;
}
function code(a, b, c)
	t_0 = sqrt(Float64(c * Float64(3.0 * a)))
	tmp = 0.0
	if (b <= 3.4)
		tmp = cbrt((Float64(Float64(sqrt(Float64(Float64(b + t_0) * Float64(b - t_0))) - b) / Float64(3.0 * a)) ^ 3.0));
	else
		tmp = fma(-0.375, Float64(a * Float64(Float64(c * c) / (b ^ 3.0))), Float64(-0.5 * Float64(c / b)));
	end
	return tmp
end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(c * N[(3.0 * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, 3.4], N[Power[N[Power[N[(N[(N[Sqrt[N[(N[(b + t$95$0), $MachinePrecision] * N[(b - t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision], N[(-0.375 * N[(a * N[(N[(c * c), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{c \cdot \left(3 \cdot a\right)}\\
\mathbf{if}\;b \leq 3.4:\\
\;\;\;\;\sqrt[3]{{\left(\frac{\sqrt{\left(b + t_0\right) \cdot \left(b - t_0\right)} - b}{3 \cdot a}\right)}^{3}}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.375, a \cdot \frac{c \cdot c}{{b}^{3}}, -0.5 \cdot \frac{c}{b}\right)\\


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

    1. Initial program 82.6%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Step-by-step derivation
      1. add-sqr-sqrt82.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\sqrt{\left(3 \cdot a\right) \cdot c} \cdot \sqrt{\left(3 \cdot a\right) \cdot c}}}}{3 \cdot a} \]
      2. difference-of-squares82.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(b + \sqrt{\left(3 \cdot a\right) \cdot c}\right) \cdot \left(b - \sqrt{\left(3 \cdot a\right) \cdot c}\right)}}}{3 \cdot a} \]
      3. associate-*l*82.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{\color{blue}{3 \cdot \left(a \cdot c\right)}}\right) \cdot \left(b - \sqrt{\left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a} \]
      4. associate-*l*82.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{3 \cdot \left(a \cdot c\right)}\right) \cdot \left(b - \sqrt{\color{blue}{3 \cdot \left(a \cdot c\right)}}\right)}}{3 \cdot a} \]
    3. Applied egg-rr82.5%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(b + \sqrt{3 \cdot \left(a \cdot c\right)}\right) \cdot \left(b - \sqrt{3 \cdot \left(a \cdot c\right)}\right)}}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. *-commutative82.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{\color{blue}{\left(a \cdot c\right) \cdot 3}}\right) \cdot \left(b - \sqrt{3 \cdot \left(a \cdot c\right)}\right)}}{3 \cdot a} \]
      2. *-commutative82.5%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{\color{blue}{\left(c \cdot a\right)} \cdot 3}\right) \cdot \left(b - \sqrt{3 \cdot \left(a \cdot c\right)}\right)}}{3 \cdot a} \]
      3. associate-*l*82.4%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{\color{blue}{c \cdot \left(a \cdot 3\right)}}\right) \cdot \left(b - \sqrt{3 \cdot \left(a \cdot c\right)}\right)}}{3 \cdot a} \]
      4. *-commutative82.4%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{\color{blue}{\left(a \cdot c\right) \cdot 3}}\right)}}{3 \cdot a} \]
      5. *-commutative82.4%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{\color{blue}{\left(c \cdot a\right)} \cdot 3}\right)}}{3 \cdot a} \]
      6. associate-*l*82.6%

        \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{\color{blue}{c \cdot \left(a \cdot 3\right)}}\right)}}{3 \cdot a} \]
    5. Simplified82.6%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}}{3 \cdot a} \]
    6. Step-by-step derivation
      1. add-log-exp75.0%

        \[\leadsto \frac{\color{blue}{\log \left(e^{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}\right)}}{3 \cdot a} \]
    7. Applied egg-rr75.0%

      \[\leadsto \frac{\color{blue}{\log \left(e^{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}\right)}}{3 \cdot a} \]
    8. Step-by-step derivation
      1. add-cbrt-cube75.1%

        \[\leadsto \color{blue}{\sqrt[3]{\left(\frac{\log \left(e^{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}\right)}{3 \cdot a} \cdot \frac{\log \left(e^{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}\right)}{3 \cdot a}\right) \cdot \frac{\log \left(e^{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}\right)}{3 \cdot a}}} \]
    9. Applied egg-rr82.7%

      \[\leadsto \color{blue}{\sqrt[3]{\left(\frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}{a \cdot 3} \cdot \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}{a \cdot 3}\right) \cdot \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}{a \cdot 3}}} \]
    10. Step-by-step derivation
      1. associate-*l*82.7%

        \[\leadsto \sqrt[3]{\color{blue}{\frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}{a \cdot 3} \cdot \left(\frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}{a \cdot 3} \cdot \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}{a \cdot 3}\right)}} \]
      2. cube-unmult82.6%

        \[\leadsto \sqrt[3]{\color{blue}{{\left(\frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}{a \cdot 3}\right)}^{3}}} \]
    11. Simplified82.6%

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

    if 3.39999999999999991 < b

    1. Initial program 47.8%

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}} \]
    3. Step-by-step derivation
      1. +-commutative88.2%

        \[\leadsto \color{blue}{-0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + -0.5 \cdot \frac{c}{b}} \]
      2. fma-def88.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.375, \frac{{c}^{2} \cdot a}{{b}^{3}}, -0.5 \cdot \frac{c}{b}\right)} \]
      3. associate-/l*88.2%

        \[\leadsto \mathsf{fma}\left(-0.375, \color{blue}{\frac{{c}^{2}}{\frac{{b}^{3}}{a}}}, -0.5 \cdot \frac{c}{b}\right) \]
      4. associate-/r/88.2%

        \[\leadsto \mathsf{fma}\left(-0.375, \color{blue}{\frac{{c}^{2}}{{b}^{3}} \cdot a}, -0.5 \cdot \frac{c}{b}\right) \]
      5. unpow288.2%

        \[\leadsto \mathsf{fma}\left(-0.375, \frac{\color{blue}{c \cdot c}}{{b}^{3}} \cdot a, -0.5 \cdot \frac{c}{b}\right) \]
    4. Simplified88.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.375, \frac{c \cdot c}{{b}^{3}} \cdot a, -0.5 \cdot \frac{c}{b}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification87.1%

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

Alternative 5: 76.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)} - b}{3 \cdot a}\\ \mathbf{if}\;t_0 \leq -3.8 \cdot 10^{-6}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (/ (- (sqrt (- (* b b) (* c (* 3.0 a)))) b) (* 3.0 a))))
   (if (<= t_0 -3.8e-6) t_0 (* -0.5 (/ c b)))))
double code(double a, double b, double c) {
	double t_0 = (sqrt(((b * b) - (c * (3.0 * a)))) - b) / (3.0 * a);
	double tmp;
	if (t_0 <= -3.8e-6) {
		tmp = t_0;
	} else {
		tmp = -0.5 * (c / b);
	}
	return tmp;
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (sqrt(((b * b) - (c * (3.0d0 * a)))) - b) / (3.0d0 * a)
    if (t_0 <= (-3.8d-6)) then
        tmp = t_0
    else
        tmp = (-0.5d0) * (c / b)
    end if
    code = tmp
end function
public static double code(double a, double b, double c) {
	double t_0 = (Math.sqrt(((b * b) - (c * (3.0 * a)))) - b) / (3.0 * a);
	double tmp;
	if (t_0 <= -3.8e-6) {
		tmp = t_0;
	} else {
		tmp = -0.5 * (c / b);
	}
	return tmp;
}
def code(a, b, c):
	t_0 = (math.sqrt(((b * b) - (c * (3.0 * a)))) - b) / (3.0 * a)
	tmp = 0
	if t_0 <= -3.8e-6:
		tmp = t_0
	else:
		tmp = -0.5 * (c / b)
	return tmp
function code(a, b, c)
	t_0 = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(3.0 * a)))) - b) / Float64(3.0 * a))
	tmp = 0.0
	if (t_0 <= -3.8e-6)
		tmp = t_0;
	else
		tmp = Float64(-0.5 * Float64(c / b));
	end
	return tmp
end
function tmp_2 = code(a, b, c)
	t_0 = (sqrt(((b * b) - (c * (3.0 * a)))) - b) / (3.0 * a);
	tmp = 0.0;
	if (t_0 <= -3.8e-6)
		tmp = t_0;
	else
		tmp = -0.5 * (c / b);
	end
	tmp_2 = tmp;
end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -3.8e-6], t$95$0, N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)} - b}{3 \cdot a}\\
\mathbf{if}\;t_0 \leq -3.8 \cdot 10^{-6}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a)) < -3.8e-6

    1. Initial program 71.1%

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

    if -3.8e-6 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 3 a) c)))) (*.f64 3 a))

    1. Initial program 34.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)} - b}{3 \cdot a} \leq -3.8 \cdot 10^{-6}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(3 \cdot a\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]

Alternative 6: 85.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 3.4:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.375, a \cdot \frac{c \cdot c}{{b}^{3}}, -0.5 \cdot \frac{c}{b}\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<= b 3.4)
   (/ (- (sqrt (fma b b (* c (* a -3.0)))) b) (* 3.0 a))
   (fma -0.375 (* a (/ (* c c) (pow b 3.0))) (* -0.5 (/ c b)))))
double code(double a, double b, double c) {
	double tmp;
	if (b <= 3.4) {
		tmp = (sqrt(fma(b, b, (c * (a * -3.0)))) - b) / (3.0 * a);
	} else {
		tmp = fma(-0.375, (a * ((c * c) / pow(b, 3.0))), (-0.5 * (c / b)));
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (b <= 3.4)
		tmp = Float64(Float64(sqrt(fma(b, b, Float64(c * Float64(a * -3.0)))) - b) / Float64(3.0 * a));
	else
		tmp = fma(-0.375, Float64(a * Float64(Float64(c * c) / (b ^ 3.0))), Float64(-0.5 * Float64(c / b)));
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[b, 3.4], N[(N[(N[Sqrt[N[(b * b + N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(-0.375 * N[(a * N[(N[(c * c), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.4:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)} - b}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.375, a \cdot \frac{c \cdot c}{{b}^{3}}, -0.5 \cdot \frac{c}{b}\right)\\


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

    1. Initial program 82.6%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Step-by-step derivation
      1. +-commutative82.6%

        \[\leadsto \frac{\color{blue}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}}{3 \cdot a} \]
      2. sqr-neg82.6%

        \[\leadsto \frac{\sqrt{\color{blue}{\left(-b\right) \cdot \left(-b\right)} - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}{3 \cdot a} \]
      3. unsub-neg82.6%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right) - \left(3 \cdot a\right) \cdot c} - b}}{3 \cdot a} \]
      4. +-rgt-identity82.6%

        \[\leadsto \frac{\color{blue}{\left(\sqrt{\left(-b\right) \cdot \left(-b\right) - \left(3 \cdot a\right) \cdot c} + 0\right)} - b}{3 \cdot a} \]
      5. metadata-eval82.6%

        \[\leadsto \frac{\left(\sqrt{\left(-b\right) \cdot \left(-b\right) - \left(3 \cdot a\right) \cdot c} + \color{blue}{\left(-0\right)}\right) - b}{3 \cdot a} \]
      6. sub-neg82.6%

        \[\leadsto \frac{\color{blue}{\left(\sqrt{\left(-b\right) \cdot \left(-b\right) - \left(3 \cdot a\right) \cdot c} - 0\right)} - b}{3 \cdot a} \]
    3. Simplified82.6%

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

    if 3.39999999999999991 < b

    1. Initial program 47.8%

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

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}} \]
    3. Step-by-step derivation
      1. +-commutative88.2%

        \[\leadsto \color{blue}{-0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}} + -0.5 \cdot \frac{c}{b}} \]
      2. fma-def88.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.375, \frac{{c}^{2} \cdot a}{{b}^{3}}, -0.5 \cdot \frac{c}{b}\right)} \]
      3. associate-/l*88.2%

        \[\leadsto \mathsf{fma}\left(-0.375, \color{blue}{\frac{{c}^{2}}{\frac{{b}^{3}}{a}}}, -0.5 \cdot \frac{c}{b}\right) \]
      4. associate-/r/88.2%

        \[\leadsto \mathsf{fma}\left(-0.375, \color{blue}{\frac{{c}^{2}}{{b}^{3}} \cdot a}, -0.5 \cdot \frac{c}{b}\right) \]
      5. unpow288.2%

        \[\leadsto \mathsf{fma}\left(-0.375, \frac{\color{blue}{c \cdot c}}{{b}^{3}} \cdot a, -0.5 \cdot \frac{c}{b}\right) \]
    4. Simplified88.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.375, \frac{c \cdot c}{{b}^{3}} \cdot a, -0.5 \cdot \frac{c}{b}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification87.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq 3.4:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)} - b}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-0.375, a \cdot \frac{c \cdot c}{{b}^{3}}, -0.5 \cdot \frac{c}{b}\right)\\ \end{array} \]

Alternative 7: 64.2% accurate, 23.2× speedup?

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

\\
-0.5 \cdot \frac{c}{b}
\end{array}
Derivation
  1. Initial program 54.4%

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

    \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
  3. Final simplification65.1%

    \[\leadsto -0.5 \cdot \frac{c}{b} \]

Alternative 8: 3.2% accurate, 38.7× speedup?

\[\begin{array}{l} \\ \frac{0}{a} \end{array} \]
(FPCore (a b c) :precision binary64 (/ 0.0 a))
double code(double a, double b, double c) {
	return 0.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 = 0.0d0 / a
end function
public static double code(double a, double b, double c) {
	return 0.0 / a;
}
def code(a, b, c):
	return 0.0 / a
function code(a, b, c)
	return Float64(0.0 / a)
end
function tmp = code(a, b, c)
	tmp = 0.0 / a;
end
code[a_, b_, c_] := N[(0.0 / a), $MachinePrecision]
\begin{array}{l}

\\
\frac{0}{a}
\end{array}
Derivation
  1. Initial program 54.4%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  2. Step-by-step derivation
    1. add-sqr-sqrt54.4%

      \[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\sqrt{\left(3 \cdot a\right) \cdot c} \cdot \sqrt{\left(3 \cdot a\right) \cdot c}}}}{3 \cdot a} \]
    2. difference-of-squares54.5%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(b + \sqrt{\left(3 \cdot a\right) \cdot c}\right) \cdot \left(b - \sqrt{\left(3 \cdot a\right) \cdot c}\right)}}}{3 \cdot a} \]
    3. associate-*l*54.4%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{\color{blue}{3 \cdot \left(a \cdot c\right)}}\right) \cdot \left(b - \sqrt{\left(3 \cdot a\right) \cdot c}\right)}}{3 \cdot a} \]
    4. associate-*l*54.4%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{3 \cdot \left(a \cdot c\right)}\right) \cdot \left(b - \sqrt{\color{blue}{3 \cdot \left(a \cdot c\right)}}\right)}}{3 \cdot a} \]
  3. Applied egg-rr54.4%

    \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(b + \sqrt{3 \cdot \left(a \cdot c\right)}\right) \cdot \left(b - \sqrt{3 \cdot \left(a \cdot c\right)}\right)}}}{3 \cdot a} \]
  4. Step-by-step derivation
    1. *-commutative54.4%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{\color{blue}{\left(a \cdot c\right) \cdot 3}}\right) \cdot \left(b - \sqrt{3 \cdot \left(a \cdot c\right)}\right)}}{3 \cdot a} \]
    2. *-commutative54.4%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{\color{blue}{\left(c \cdot a\right)} \cdot 3}\right) \cdot \left(b - \sqrt{3 \cdot \left(a \cdot c\right)}\right)}}{3 \cdot a} \]
    3. associate-*l*54.4%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{\color{blue}{c \cdot \left(a \cdot 3\right)}}\right) \cdot \left(b - \sqrt{3 \cdot \left(a \cdot c\right)}\right)}}{3 \cdot a} \]
    4. *-commutative54.4%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{\color{blue}{\left(a \cdot c\right) \cdot 3}}\right)}}{3 \cdot a} \]
    5. *-commutative54.4%

      \[\leadsto \frac{\left(-b\right) + \sqrt{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{\color{blue}{\left(c \cdot a\right)} \cdot 3}\right)}}{3 \cdot a} \]
    6. associate-*l*54.5%

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

    \[\leadsto \frac{\left(-b\right) + \sqrt{\color{blue}{\left(b + \sqrt{c \cdot \left(a \cdot 3\right)}\right) \cdot \left(b - \sqrt{c \cdot \left(a \cdot 3\right)}\right)}}}{3 \cdot a} \]
  6. Taylor expanded in b around inf 3.2%

    \[\leadsto \color{blue}{0.16666666666666666 \cdot \frac{\sqrt{c \cdot a} \cdot \sqrt{3} + -1 \cdot \left(\sqrt{c \cdot a} \cdot \sqrt{3}\right)}{a}} \]
  7. Step-by-step derivation
    1. associate-*r/3.2%

      \[\leadsto \color{blue}{\frac{0.16666666666666666 \cdot \left(\sqrt{c \cdot a} \cdot \sqrt{3} + -1 \cdot \left(\sqrt{c \cdot a} \cdot \sqrt{3}\right)\right)}{a}} \]
    2. distribute-rgt1-in3.2%

      \[\leadsto \frac{0.16666666666666666 \cdot \color{blue}{\left(\left(-1 + 1\right) \cdot \left(\sqrt{c \cdot a} \cdot \sqrt{3}\right)\right)}}{a} \]
    3. metadata-eval3.2%

      \[\leadsto \frac{0.16666666666666666 \cdot \left(\color{blue}{0} \cdot \left(\sqrt{c \cdot a} \cdot \sqrt{3}\right)\right)}{a} \]
    4. mul0-lft3.2%

      \[\leadsto \frac{0.16666666666666666 \cdot \color{blue}{0}}{a} \]
    5. metadata-eval3.2%

      \[\leadsto \frac{\color{blue}{0}}{a} \]
  8. Simplified3.2%

    \[\leadsto \color{blue}{\frac{0}{a}} \]
  9. Final simplification3.2%

    \[\leadsto \frac{0}{a} \]

Reproduce

?
herbie shell --seed 2023266 
(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)))