mixedcos

Percentage Accurate: 66.5% → 99.3%
Time: 13.2s
Alternatives: 8
Speedup: 24.1×

Specification

?
\[\begin{array}{l} \\ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))
double code(double x, double c, double s) {
	return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
public static double code(double x, double c, double s) {
	return Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x));
}
def code(x, c, s):
	return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
function code(x, c, s)
	return Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x)))
end
function tmp = code(x, c, s)
	tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x));
end
code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\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: 66.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))
double code(double x, double c, double s) {
	return cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x));
}
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))
end function
public static double code(double x, double c, double s) {
	return Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x));
}
def code(x, c, s):
	return math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))
function code(x, c, s)
	return Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x)))
end
function tmp = code(x, c, s)
	tmp = cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x));
end
code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c, 2.0], $MachinePrecision] * N[(N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}
\end{array}

Alternative 1: 99.3% accurate, 0.7× speedup?

\[\begin{array}{l} c = |c|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ t_1 := \cos \left(2 \cdot x\right)\\ \mathbf{if}\;\frac{t_1}{{c}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq \infty:\\ \;\;\;\;\frac{\frac{t_1}{t_0}}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{t_1 \cdot \frac{-1}{x}}{c \cdot s}}{x \cdot \left(c \cdot \left(-s\right)\right)}\\ \end{array} \end{array} \]
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* c (* x s))) (t_1 (cos (* 2.0 x))))
   (if (<= (/ t_1 (* (pow c 2.0) (* x (* x (pow s 2.0))))) INFINITY)
     (/ (/ t_1 t_0) t_0)
     (/ (/ (* t_1 (/ -1.0 x)) (* c s)) (* x (* c (- s)))))))
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	double t_1 = cos((2.0 * x));
	double tmp;
	if ((t_1 / (pow(c, 2.0) * (x * (x * pow(s, 2.0))))) <= ((double) INFINITY)) {
		tmp = (t_1 / t_0) / t_0;
	} else {
		tmp = ((t_1 * (-1.0 / x)) / (c * s)) / (x * (c * -s));
	}
	return tmp;
}
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	double t_1 = Math.cos((2.0 * x));
	double tmp;
	if ((t_1 / (Math.pow(c, 2.0) * (x * (x * Math.pow(s, 2.0))))) <= Double.POSITIVE_INFINITY) {
		tmp = (t_1 / t_0) / t_0;
	} else {
		tmp = ((t_1 * (-1.0 / x)) / (c * s)) / (x * (c * -s));
	}
	return tmp;
}
c = abs(c)
[c, s] = sort([c, s])
def code(x, c, s):
	t_0 = c * (x * s)
	t_1 = math.cos((2.0 * x))
	tmp = 0
	if (t_1 / (math.pow(c, 2.0) * (x * (x * math.pow(s, 2.0))))) <= math.inf:
		tmp = (t_1 / t_0) / t_0
	else:
		tmp = ((t_1 * (-1.0 / x)) / (c * s)) / (x * (c * -s))
	return tmp
c = abs(c)
c, s = sort([c, s])
function code(x, c, s)
	t_0 = Float64(c * Float64(x * s))
	t_1 = cos(Float64(2.0 * x))
	tmp = 0.0
	if (Float64(t_1 / Float64((c ^ 2.0) * Float64(x * Float64(x * (s ^ 2.0))))) <= Inf)
		tmp = Float64(Float64(t_1 / t_0) / t_0);
	else
		tmp = Float64(Float64(Float64(t_1 * Float64(-1.0 / x)) / Float64(c * s)) / Float64(x * Float64(c * Float64(-s))));
	end
	return tmp
end
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	t_0 = c * (x * s);
	t_1 = cos((2.0 * x));
	tmp = 0.0;
	if ((t_1 / ((c ^ 2.0) * (x * (x * (s ^ 2.0))))) <= Inf)
		tmp = (t_1 / t_0) / t_0;
	else
		tmp = ((t_1 * (-1.0 / x)) / (c * s)) / (x * (c * -s));
	end
	tmp_2 = tmp;
end
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$1 / N[(N[Power[c, 2.0], $MachinePrecision] * N[(x * N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(t$95$1 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[(t$95$1 * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision] / N[(c * s), $MachinePrecision]), $MachinePrecision] / N[(x * N[(c * (-s)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
t_1 := \cos \left(2 \cdot x\right)\\
\mathbf{if}\;\frac{t_1}{{c}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq \infty:\\
\;\;\;\;\frac{\frac{t_1}{t_0}}{t_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{t_1 \cdot \frac{-1}{x}}{c \cdot s}}{x \cdot \left(c \cdot \left(-s\right)\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (cos.f64 (*.f64 2 x)) (*.f64 (pow.f64 c 2) (*.f64 (*.f64 x (pow.f64 s 2)) x))) < +inf.0

    1. Initial program 79.2%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Step-by-step derivation
      1. *-un-lft-identity79.2%

        \[\leadsto \frac{\color{blue}{1 \cdot \cos \left(2 \cdot x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      2. add-sqr-sqrt79.2%

        \[\leadsto \frac{1 \cdot \cos \left(2 \cdot x\right)}{\color{blue}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \cdot \sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}}} \]
      3. times-frac79.2%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}}} \]
      4. sqrt-prod79.2%

        \[\leadsto \frac{1}{\color{blue}{\sqrt{{c}^{2}} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      5. unpow279.2%

        \[\leadsto \frac{1}{\sqrt{\color{blue}{c \cdot c}} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      6. sqrt-prod38.3%

        \[\leadsto \frac{1}{\color{blue}{\left(\sqrt{c} \cdot \sqrt{c}\right)} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      7. add-sqr-sqrt58.9%

        \[\leadsto \frac{1}{\color{blue}{c} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      8. *-commutative58.9%

        \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{x \cdot \left(x \cdot {s}^{2}\right)}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      9. associate-*r*54.8%

        \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{\left(x \cdot x\right) \cdot {s}^{2}}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      10. unpow254.8%

        \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{{x}^{2}} \cdot {s}^{2}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      11. pow-prod-down59.0%

        \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{{\left(x \cdot s\right)}^{2}}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      12. sqrt-prod58.9%

        \[\leadsto \frac{1}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\sqrt{{c}^{2}} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}}} \]
    3. Applied egg-rr95.3%

      \[\leadsto \color{blue}{\frac{1}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \cdot \frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}} \]
    4. Step-by-step derivation
      1. associate-*l/95.4%

        \[\leadsto \color{blue}{\frac{1 \cdot \frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}} \]
      2. *-lft-identity95.4%

        \[\leadsto \frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
      3. unpow295.4%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{\color{blue}{\left(x \cdot s\right) \cdot \left(x \cdot s\right)}}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
      4. rem-sqrt-square95.4%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \color{blue}{\left|x \cdot s\right|}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
      5. *-commutative95.4%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|\color{blue}{s \cdot x}\right|}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
      6. unpow295.4%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \sqrt{\color{blue}{\left(x \cdot s\right) \cdot \left(x \cdot s\right)}}} \]
      7. rem-sqrt-square99.7%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \color{blue}{\left|x \cdot s\right|}} \]
      8. *-commutative99.7%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \left|\color{blue}{s \cdot x}\right|} \]
    5. Simplified99.7%

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \left|s \cdot x\right|}} \]
    6. Step-by-step derivation
      1. associate-/r*96.9%

        \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c}}{\left|s \cdot x\right|}} \]
      2. add-sqr-sqrt51.4%

        \[\leadsto \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c}}{\left|\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}\right|} \]
      3. fabs-sqr51.4%

        \[\leadsto \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c}}{\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}} \]
      4. add-sqr-sqrt68.2%

        \[\leadsto \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c}}{\color{blue}{s \cdot x}} \]
      5. associate-/l/69.5%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{\left(s \cdot x\right) \cdot c}} \]
      6. div-inv69.5%

        \[\leadsto \frac{\color{blue}{\cos \left(2 \cdot x\right) \cdot \frac{1}{c \cdot \left|s \cdot x\right|}}}{\left(s \cdot x\right) \cdot c} \]
      7. times-frac68.2%

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{s \cdot x} \cdot \frac{\frac{1}{c \cdot \left|s \cdot x\right|}}{c}} \]
      8. *-commutative68.2%

        \[\leadsto \frac{\cos \color{blue}{\left(x \cdot 2\right)}}{s \cdot x} \cdot \frac{\frac{1}{c \cdot \left|s \cdot x\right|}}{c} \]
      9. add-sqr-sqrt48.1%

        \[\leadsto \frac{\cos \left(x \cdot 2\right)}{s \cdot x} \cdot \frac{\frac{1}{c \cdot \left|\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}\right|}}{c} \]
      10. fabs-sqr48.1%

        \[\leadsto \frac{\cos \left(x \cdot 2\right)}{s \cdot x} \cdot \frac{\frac{1}{c \cdot \color{blue}{\left(\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}\right)}}}{c} \]
      11. add-sqr-sqrt96.9%

        \[\leadsto \frac{\cos \left(x \cdot 2\right)}{s \cdot x} \cdot \frac{\frac{1}{c \cdot \color{blue}{\left(s \cdot x\right)}}}{c} \]
      12. associate-*r*96.0%

        \[\leadsto \frac{\cos \left(x \cdot 2\right)}{s \cdot x} \cdot \frac{\frac{1}{\color{blue}{\left(c \cdot s\right) \cdot x}}}{c} \]
    7. Applied egg-rr96.0%

      \[\leadsto \color{blue}{\frac{\cos \left(x \cdot 2\right)}{s \cdot x} \cdot \frac{\frac{1}{\left(c \cdot s\right) \cdot x}}{c}} \]
    8. Step-by-step derivation
      1. frac-times98.0%

        \[\leadsto \color{blue}{\frac{\cos \left(x \cdot 2\right) \cdot \frac{1}{\left(c \cdot s\right) \cdot x}}{\left(s \cdot x\right) \cdot c}} \]
      2. div-inv98.0%

        \[\leadsto \frac{\color{blue}{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}}{\left(s \cdot x\right) \cdot c} \]
      3. associate-*l*99.7%

        \[\leadsto \frac{\frac{\cos \left(x \cdot 2\right)}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(s \cdot x\right) \cdot c} \]
      4. *-commutative99.7%

        \[\leadsto \frac{\frac{\cos \left(x \cdot 2\right)}{c \cdot \left(s \cdot x\right)}}{\color{blue}{\left(x \cdot s\right)} \cdot c} \]
      5. associate-*r*98.0%

        \[\leadsto \frac{\frac{\cos \left(x \cdot 2\right)}{c \cdot \left(s \cdot x\right)}}{\color{blue}{x \cdot \left(s \cdot c\right)}} \]
      6. *-commutative98.0%

        \[\leadsto \frac{\frac{\cos \left(x \cdot 2\right)}{c \cdot \left(s \cdot x\right)}}{x \cdot \color{blue}{\left(c \cdot s\right)}} \]
      7. *-commutative98.0%

        \[\leadsto \frac{\frac{\cos \left(x \cdot 2\right)}{c \cdot \left(s \cdot x\right)}}{\color{blue}{\left(c \cdot s\right) \cdot x}} \]
      8. associate-*l*99.7%

        \[\leadsto \frac{\frac{\cos \left(x \cdot 2\right)}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
    9. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(x \cdot 2\right)}{c \cdot \left(s \cdot x\right)}}{c \cdot \left(s \cdot x\right)}} \]

    if +inf.0 < (/.f64 (cos.f64 (*.f64 2 x)) (*.f64 (pow.f64 c 2) (*.f64 (*.f64 x (pow.f64 s 2)) x)))

    1. Initial program 0.0%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Step-by-step derivation
      1. *-un-lft-identity0.0%

        \[\leadsto \frac{\color{blue}{1 \cdot \cos \left(2 \cdot x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      2. add-sqr-sqrt0.0%

        \[\leadsto \frac{1 \cdot \cos \left(2 \cdot x\right)}{\color{blue}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \cdot \sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}}} \]
      3. times-frac0.0%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}}} \]
      4. sqrt-prod0.0%

        \[\leadsto \frac{1}{\color{blue}{\sqrt{{c}^{2}} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      5. unpow20.0%

        \[\leadsto \frac{1}{\sqrt{\color{blue}{c \cdot c}} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      6. sqrt-prod0.0%

        \[\leadsto \frac{1}{\color{blue}{\left(\sqrt{c} \cdot \sqrt{c}\right)} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      7. add-sqr-sqrt0.0%

        \[\leadsto \frac{1}{\color{blue}{c} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      8. *-commutative0.0%

        \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{x \cdot \left(x \cdot {s}^{2}\right)}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      9. associate-*r*0.0%

        \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{\left(x \cdot x\right) \cdot {s}^{2}}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      10. unpow20.0%

        \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{{x}^{2}} \cdot {s}^{2}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      11. pow-prod-down0.0%

        \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{{\left(x \cdot s\right)}^{2}}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      12. sqrt-prod0.0%

        \[\leadsto \frac{1}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\sqrt{{c}^{2}} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}}} \]
    3. Applied egg-rr44.3%

      \[\leadsto \color{blue}{\frac{1}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \cdot \frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}} \]
    4. Step-by-step derivation
      1. associate-*l/44.3%

        \[\leadsto \color{blue}{\frac{1 \cdot \frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}} \]
      2. *-lft-identity44.3%

        \[\leadsto \frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
      3. unpow244.3%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{\color{blue}{\left(x \cdot s\right) \cdot \left(x \cdot s\right)}}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
      4. rem-sqrt-square44.3%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \color{blue}{\left|x \cdot s\right|}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
      5. *-commutative44.3%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|\color{blue}{s \cdot x}\right|}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
      6. unpow244.3%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \sqrt{\color{blue}{\left(x \cdot s\right) \cdot \left(x \cdot s\right)}}} \]
      7. rem-sqrt-square78.3%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \color{blue}{\left|x \cdot s\right|}} \]
      8. *-commutative78.3%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \left|\color{blue}{s \cdot x}\right|} \]
    5. Simplified78.3%

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \left|s \cdot x\right|}} \]
    6. Step-by-step derivation
      1. frac-2neg78.3%

        \[\leadsto \color{blue}{\frac{-\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{-c \cdot \left|s \cdot x\right|}} \]
      2. distribute-frac-neg78.3%

        \[\leadsto \color{blue}{-\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{-c \cdot \left|s \cdot x\right|}} \]
      3. associate-/r*78.4%

        \[\leadsto -\frac{\color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{\left|s \cdot x\right|}}}{-c \cdot \left|s \cdot x\right|} \]
      4. add-sqr-sqrt39.4%

        \[\leadsto -\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{\left|\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}\right|}}{-c \cdot \left|s \cdot x\right|} \]
      5. fabs-sqr39.4%

        \[\leadsto -\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}}}{-c \cdot \left|s \cdot x\right|} \]
      6. add-sqr-sqrt40.8%

        \[\leadsto -\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{\color{blue}{s \cdot x}}}{-c \cdot \left|s \cdot x\right|} \]
      7. associate-/r*40.8%

        \[\leadsto -\frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left(s \cdot x\right)}}}{-c \cdot \left|s \cdot x\right|} \]
      8. *-commutative40.8%

        \[\leadsto -\frac{\frac{\cos \color{blue}{\left(x \cdot 2\right)}}{c \cdot \left(s \cdot x\right)}}{-c \cdot \left|s \cdot x\right|} \]
      9. associate-*r*40.8%

        \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\color{blue}{\left(c \cdot s\right) \cdot x}}}{-c \cdot \left|s \cdot x\right|} \]
      10. add-sqr-sqrt30.4%

        \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-c \cdot \left|\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}\right|} \]
      11. fabs-sqr30.4%

        \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-c \cdot \color{blue}{\left(\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}\right)}} \]
      12. add-sqr-sqrt76.4%

        \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-c \cdot \color{blue}{\left(s \cdot x\right)}} \]
      13. associate-*r*97.0%

        \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-\color{blue}{\left(c \cdot s\right) \cdot x}} \]
    7. Applied egg-rr97.0%

      \[\leadsto \color{blue}{-\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-\left(c \cdot s\right) \cdot x}} \]
    8. Step-by-step derivation
      1. associate-/r*97.0%

        \[\leadsto -\frac{\color{blue}{\frac{\frac{\cos \left(x \cdot 2\right)}{c \cdot s}}{x}}}{-\left(c \cdot s\right) \cdot x} \]
      2. div-inv97.2%

        \[\leadsto -\frac{\color{blue}{\frac{\cos \left(x \cdot 2\right)}{c \cdot s} \cdot \frac{1}{x}}}{-\left(c \cdot s\right) \cdot x} \]
    9. Applied egg-rr97.2%

      \[\leadsto -\frac{\color{blue}{\frac{\cos \left(x \cdot 2\right)}{c \cdot s} \cdot \frac{1}{x}}}{-\left(c \cdot s\right) \cdot x} \]
    10. Step-by-step derivation
      1. associate-*l/97.2%

        \[\leadsto -\frac{\color{blue}{\frac{\cos \left(x \cdot 2\right) \cdot \frac{1}{x}}{c \cdot s}}}{-\left(c \cdot s\right) \cdot x} \]
    11. Applied egg-rr97.2%

      \[\leadsto -\frac{\color{blue}{\frac{\cos \left(x \cdot 2\right) \cdot \frac{1}{x}}{c \cdot s}}}{-\left(c \cdot s\right) \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq \infty:\\ \;\;\;\;\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left(x \cdot s\right)}}{c \cdot \left(x \cdot s\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cos \left(2 \cdot x\right) \cdot \frac{-1}{x}}{c \cdot s}}{x \cdot \left(c \cdot \left(-s\right)\right)}\\ \end{array} \]

Alternative 2: 96.9% accurate, 2.7× speedup?

\[\begin{array}{l} c = |c|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot s} \cdot \frac{-1}{x}}{x \cdot \left(c \cdot \left(-s\right)\right)} \end{array} \]
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (/ (* (/ (cos (* 2.0 x)) (* c s)) (/ -1.0 x)) (* x (* c (- s)))))
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
	return ((cos((2.0 * x)) / (c * s)) * (-1.0 / x)) / (x * (c * -s));
}
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = ((cos((2.0d0 * x)) / (c * s)) * ((-1.0d0) / x)) / (x * (c * -s))
end function
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
	return ((Math.cos((2.0 * x)) / (c * s)) * (-1.0 / x)) / (x * (c * -s));
}
c = abs(c)
[c, s] = sort([c, s])
def code(x, c, s):
	return ((math.cos((2.0 * x)) / (c * s)) * (-1.0 / x)) / (x * (c * -s))
c = abs(c)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(Float64(Float64(cos(Float64(2.0 * x)) / Float64(c * s)) * Float64(-1.0 / x)) / Float64(x * Float64(c * Float64(-s))))
end
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = ((cos((2.0 * x)) / (c * s)) * (-1.0 / x)) / (x * (c * -s));
end
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(N[(N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(c * s), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision] / N[(x * N[(c * (-s)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot s} \cdot \frac{-1}{x}}{x \cdot \left(c \cdot \left(-s\right)\right)}
\end{array}
Derivation
  1. Initial program 64.9%

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Step-by-step derivation
    1. *-un-lft-identity64.9%

      \[\leadsto \frac{\color{blue}{1 \cdot \cos \left(2 \cdot x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. add-sqr-sqrt64.9%

      \[\leadsto \frac{1 \cdot \cos \left(2 \cdot x\right)}{\color{blue}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \cdot \sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}}} \]
    3. times-frac65.0%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}}} \]
    4. sqrt-prod65.0%

      \[\leadsto \frac{1}{\color{blue}{\sqrt{{c}^{2}} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    5. unpow265.0%

      \[\leadsto \frac{1}{\sqrt{\color{blue}{c \cdot c}} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    6. sqrt-prod31.4%

      \[\leadsto \frac{1}{\color{blue}{\left(\sqrt{c} \cdot \sqrt{c}\right)} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    7. add-sqr-sqrt48.4%

      \[\leadsto \frac{1}{\color{blue}{c} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    8. *-commutative48.4%

      \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{x \cdot \left(x \cdot {s}^{2}\right)}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    9. associate-*r*45.0%

      \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{\left(x \cdot x\right) \cdot {s}^{2}}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    10. unpow245.0%

      \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{{x}^{2}} \cdot {s}^{2}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    11. pow-prod-down48.4%

      \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{{\left(x \cdot s\right)}^{2}}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    12. sqrt-prod48.3%

      \[\leadsto \frac{1}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\sqrt{{c}^{2}} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}}} \]
  3. Applied egg-rr86.1%

    \[\leadsto \color{blue}{\frac{1}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \cdot \frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}} \]
  4. Step-by-step derivation
    1. associate-*l/86.2%

      \[\leadsto \color{blue}{\frac{1 \cdot \frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}} \]
    2. *-lft-identity86.2%

      \[\leadsto \frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
    3. unpow286.2%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{\color{blue}{\left(x \cdot s\right) \cdot \left(x \cdot s\right)}}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
    4. rem-sqrt-square86.2%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \color{blue}{\left|x \cdot s\right|}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
    5. *-commutative86.2%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|\color{blue}{s \cdot x}\right|}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
    6. unpow286.2%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \sqrt{\color{blue}{\left(x \cdot s\right) \cdot \left(x \cdot s\right)}}} \]
    7. rem-sqrt-square95.9%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \color{blue}{\left|x \cdot s\right|}} \]
    8. *-commutative95.9%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \left|\color{blue}{s \cdot x}\right|} \]
  5. Simplified95.9%

    \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \left|s \cdot x\right|}} \]
  6. Step-by-step derivation
    1. frac-2neg95.9%

      \[\leadsto \color{blue}{\frac{-\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{-c \cdot \left|s \cdot x\right|}} \]
    2. distribute-frac-neg95.9%

      \[\leadsto \color{blue}{-\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{-c \cdot \left|s \cdot x\right|}} \]
    3. associate-/r*95.9%

      \[\leadsto -\frac{\color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{\left|s \cdot x\right|}}}{-c \cdot \left|s \cdot x\right|} \]
    4. add-sqr-sqrt50.3%

      \[\leadsto -\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{\left|\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}\right|}}{-c \cdot \left|s \cdot x\right|} \]
    5. fabs-sqr50.3%

      \[\leadsto -\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}}}{-c \cdot \left|s \cdot x\right|} \]
    6. add-sqr-sqrt64.3%

      \[\leadsto -\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{\color{blue}{s \cdot x}}}{-c \cdot \left|s \cdot x\right|} \]
    7. associate-/r*64.3%

      \[\leadsto -\frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left(s \cdot x\right)}}}{-c \cdot \left|s \cdot x\right|} \]
    8. *-commutative64.3%

      \[\leadsto -\frac{\frac{\cos \color{blue}{\left(x \cdot 2\right)}}{c \cdot \left(s \cdot x\right)}}{-c \cdot \left|s \cdot x\right|} \]
    9. associate-*r*63.3%

      \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\color{blue}{\left(c \cdot s\right) \cdot x}}}{-c \cdot \left|s \cdot x\right|} \]
    10. add-sqr-sqrt44.9%

      \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-c \cdot \left|\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}\right|} \]
    11. fabs-sqr44.9%

      \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-c \cdot \color{blue}{\left(\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}\right)}} \]
    12. add-sqr-sqrt94.1%

      \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-c \cdot \color{blue}{\left(s \cdot x\right)}} \]
    13. associate-*r*97.8%

      \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-\color{blue}{\left(c \cdot s\right) \cdot x}} \]
  7. Applied egg-rr97.8%

    \[\leadsto \color{blue}{-\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-\left(c \cdot s\right) \cdot x}} \]
  8. Step-by-step derivation
    1. associate-/r*97.9%

      \[\leadsto -\frac{\color{blue}{\frac{\frac{\cos \left(x \cdot 2\right)}{c \cdot s}}{x}}}{-\left(c \cdot s\right) \cdot x} \]
    2. div-inv97.9%

      \[\leadsto -\frac{\color{blue}{\frac{\cos \left(x \cdot 2\right)}{c \cdot s} \cdot \frac{1}{x}}}{-\left(c \cdot s\right) \cdot x} \]
  9. Applied egg-rr97.9%

    \[\leadsto -\frac{\color{blue}{\frac{\cos \left(x \cdot 2\right)}{c \cdot s} \cdot \frac{1}{x}}}{-\left(c \cdot s\right) \cdot x} \]
  10. Final simplification97.9%

    \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot s} \cdot \frac{-1}{x}}{x \cdot \left(c \cdot \left(-s\right)\right)} \]

Alternative 3: 97.1% accurate, 2.7× speedup?

\[\begin{array}{l} c = |c|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{\frac{-\cos \left(2 \cdot x\right)}{x \cdot \left(c \cdot s\right)}}{x \cdot \left(c \cdot \left(-s\right)\right)} \end{array} \]
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (/ (/ (- (cos (* 2.0 x))) (* x (* c s))) (* x (* c (- s)))))
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
	return (-cos((2.0 * x)) / (x * (c * s))) / (x * (c * -s));
}
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = (-cos((2.0d0 * x)) / (x * (c * s))) / (x * (c * -s))
end function
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
	return (-Math.cos((2.0 * x)) / (x * (c * s))) / (x * (c * -s));
}
c = abs(c)
[c, s] = sort([c, s])
def code(x, c, s):
	return (-math.cos((2.0 * x)) / (x * (c * s))) / (x * (c * -s))
c = abs(c)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(Float64(Float64(-cos(Float64(2.0 * x))) / Float64(x * Float64(c * s))) / Float64(x * Float64(c * Float64(-s))))
end
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = (-cos((2.0 * x)) / (x * (c * s))) / (x * (c * -s));
end
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(N[((-N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]) / N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * N[(c * (-s)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{-\cos \left(2 \cdot x\right)}{x \cdot \left(c \cdot s\right)}}{x \cdot \left(c \cdot \left(-s\right)\right)}
\end{array}
Derivation
  1. Initial program 64.9%

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Step-by-step derivation
    1. *-un-lft-identity64.9%

      \[\leadsto \frac{\color{blue}{1 \cdot \cos \left(2 \cdot x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. add-sqr-sqrt64.9%

      \[\leadsto \frac{1 \cdot \cos \left(2 \cdot x\right)}{\color{blue}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \cdot \sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}}} \]
    3. times-frac65.0%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}}} \]
    4. sqrt-prod65.0%

      \[\leadsto \frac{1}{\color{blue}{\sqrt{{c}^{2}} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    5. unpow265.0%

      \[\leadsto \frac{1}{\sqrt{\color{blue}{c \cdot c}} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    6. sqrt-prod31.4%

      \[\leadsto \frac{1}{\color{blue}{\left(\sqrt{c} \cdot \sqrt{c}\right)} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    7. add-sqr-sqrt48.4%

      \[\leadsto \frac{1}{\color{blue}{c} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    8. *-commutative48.4%

      \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{x \cdot \left(x \cdot {s}^{2}\right)}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    9. associate-*r*45.0%

      \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{\left(x \cdot x\right) \cdot {s}^{2}}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    10. unpow245.0%

      \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{{x}^{2}} \cdot {s}^{2}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    11. pow-prod-down48.4%

      \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{{\left(x \cdot s\right)}^{2}}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    12. sqrt-prod48.3%

      \[\leadsto \frac{1}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\sqrt{{c}^{2}} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}}} \]
  3. Applied egg-rr86.1%

    \[\leadsto \color{blue}{\frac{1}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \cdot \frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}} \]
  4. Step-by-step derivation
    1. associate-*l/86.2%

      \[\leadsto \color{blue}{\frac{1 \cdot \frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}} \]
    2. *-lft-identity86.2%

      \[\leadsto \frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
    3. unpow286.2%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{\color{blue}{\left(x \cdot s\right) \cdot \left(x \cdot s\right)}}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
    4. rem-sqrt-square86.2%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \color{blue}{\left|x \cdot s\right|}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
    5. *-commutative86.2%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|\color{blue}{s \cdot x}\right|}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
    6. unpow286.2%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \sqrt{\color{blue}{\left(x \cdot s\right) \cdot \left(x \cdot s\right)}}} \]
    7. rem-sqrt-square95.9%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \color{blue}{\left|x \cdot s\right|}} \]
    8. *-commutative95.9%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \left|\color{blue}{s \cdot x}\right|} \]
  5. Simplified95.9%

    \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \left|s \cdot x\right|}} \]
  6. Step-by-step derivation
    1. frac-2neg95.9%

      \[\leadsto \color{blue}{\frac{-\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{-c \cdot \left|s \cdot x\right|}} \]
    2. distribute-frac-neg95.9%

      \[\leadsto \color{blue}{-\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{-c \cdot \left|s \cdot x\right|}} \]
    3. associate-/r*95.9%

      \[\leadsto -\frac{\color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{\left|s \cdot x\right|}}}{-c \cdot \left|s \cdot x\right|} \]
    4. add-sqr-sqrt50.3%

      \[\leadsto -\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{\left|\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}\right|}}{-c \cdot \left|s \cdot x\right|} \]
    5. fabs-sqr50.3%

      \[\leadsto -\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}}}{-c \cdot \left|s \cdot x\right|} \]
    6. add-sqr-sqrt64.3%

      \[\leadsto -\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{\color{blue}{s \cdot x}}}{-c \cdot \left|s \cdot x\right|} \]
    7. associate-/r*64.3%

      \[\leadsto -\frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left(s \cdot x\right)}}}{-c \cdot \left|s \cdot x\right|} \]
    8. *-commutative64.3%

      \[\leadsto -\frac{\frac{\cos \color{blue}{\left(x \cdot 2\right)}}{c \cdot \left(s \cdot x\right)}}{-c \cdot \left|s \cdot x\right|} \]
    9. associate-*r*63.3%

      \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\color{blue}{\left(c \cdot s\right) \cdot x}}}{-c \cdot \left|s \cdot x\right|} \]
    10. add-sqr-sqrt44.9%

      \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-c \cdot \left|\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}\right|} \]
    11. fabs-sqr44.9%

      \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-c \cdot \color{blue}{\left(\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}\right)}} \]
    12. add-sqr-sqrt94.1%

      \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-c \cdot \color{blue}{\left(s \cdot x\right)}} \]
    13. associate-*r*97.8%

      \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-\color{blue}{\left(c \cdot s\right) \cdot x}} \]
  7. Applied egg-rr97.8%

    \[\leadsto \color{blue}{-\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-\left(c \cdot s\right) \cdot x}} \]
  8. Final simplification97.8%

    \[\leadsto \frac{\frac{-\cos \left(2 \cdot x\right)}{x \cdot \left(c \cdot s\right)}}{x \cdot \left(c \cdot \left(-s\right)\right)} \]

Alternative 4: 96.9% accurate, 2.7× speedup?

\[\begin{array}{l} c = |c|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{\frac{\frac{-\cos \left(2 \cdot x\right)}{c \cdot s}}{x}}{x \cdot \left(c \cdot \left(-s\right)\right)} \end{array} \]
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (/ (/ (/ (- (cos (* 2.0 x))) (* c s)) x) (* x (* c (- s)))))
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
	return ((-cos((2.0 * x)) / (c * s)) / x) / (x * (c * -s));
}
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = ((-cos((2.0d0 * x)) / (c * s)) / x) / (x * (c * -s))
end function
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
	return ((-Math.cos((2.0 * x)) / (c * s)) / x) / (x * (c * -s));
}
c = abs(c)
[c, s] = sort([c, s])
def code(x, c, s):
	return ((-math.cos((2.0 * x)) / (c * s)) / x) / (x * (c * -s))
c = abs(c)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(Float64(Float64(Float64(-cos(Float64(2.0 * x))) / Float64(c * s)) / x) / Float64(x * Float64(c * Float64(-s))))
end
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = ((-cos((2.0 * x)) / (c * s)) / x) / (x * (c * -s));
end
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(N[(N[((-N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]) / N[(c * s), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / N[(x * N[(c * (-s)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{\frac{-\cos \left(2 \cdot x\right)}{c \cdot s}}{x}}{x \cdot \left(c \cdot \left(-s\right)\right)}
\end{array}
Derivation
  1. Initial program 64.9%

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Step-by-step derivation
    1. *-un-lft-identity64.9%

      \[\leadsto \frac{\color{blue}{1 \cdot \cos \left(2 \cdot x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. add-sqr-sqrt64.9%

      \[\leadsto \frac{1 \cdot \cos \left(2 \cdot x\right)}{\color{blue}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \cdot \sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}}} \]
    3. times-frac65.0%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}}} \]
    4. sqrt-prod65.0%

      \[\leadsto \frac{1}{\color{blue}{\sqrt{{c}^{2}} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    5. unpow265.0%

      \[\leadsto \frac{1}{\sqrt{\color{blue}{c \cdot c}} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    6. sqrt-prod31.4%

      \[\leadsto \frac{1}{\color{blue}{\left(\sqrt{c} \cdot \sqrt{c}\right)} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    7. add-sqr-sqrt48.4%

      \[\leadsto \frac{1}{\color{blue}{c} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    8. *-commutative48.4%

      \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{x \cdot \left(x \cdot {s}^{2}\right)}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    9. associate-*r*45.0%

      \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{\left(x \cdot x\right) \cdot {s}^{2}}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    10. unpow245.0%

      \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{{x}^{2}} \cdot {s}^{2}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    11. pow-prod-down48.4%

      \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{{\left(x \cdot s\right)}^{2}}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    12. sqrt-prod48.3%

      \[\leadsto \frac{1}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\sqrt{{c}^{2}} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}}} \]
  3. Applied egg-rr86.1%

    \[\leadsto \color{blue}{\frac{1}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \cdot \frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}} \]
  4. Step-by-step derivation
    1. associate-*l/86.2%

      \[\leadsto \color{blue}{\frac{1 \cdot \frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}} \]
    2. *-lft-identity86.2%

      \[\leadsto \frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
    3. unpow286.2%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{\color{blue}{\left(x \cdot s\right) \cdot \left(x \cdot s\right)}}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
    4. rem-sqrt-square86.2%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \color{blue}{\left|x \cdot s\right|}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
    5. *-commutative86.2%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|\color{blue}{s \cdot x}\right|}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
    6. unpow286.2%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \sqrt{\color{blue}{\left(x \cdot s\right) \cdot \left(x \cdot s\right)}}} \]
    7. rem-sqrt-square95.9%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \color{blue}{\left|x \cdot s\right|}} \]
    8. *-commutative95.9%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \left|\color{blue}{s \cdot x}\right|} \]
  5. Simplified95.9%

    \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \left|s \cdot x\right|}} \]
  6. Step-by-step derivation
    1. frac-2neg95.9%

      \[\leadsto \color{blue}{\frac{-\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{-c \cdot \left|s \cdot x\right|}} \]
    2. distribute-frac-neg95.9%

      \[\leadsto \color{blue}{-\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{-c \cdot \left|s \cdot x\right|}} \]
    3. associate-/r*95.9%

      \[\leadsto -\frac{\color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{\left|s \cdot x\right|}}}{-c \cdot \left|s \cdot x\right|} \]
    4. add-sqr-sqrt50.3%

      \[\leadsto -\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{\left|\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}\right|}}{-c \cdot \left|s \cdot x\right|} \]
    5. fabs-sqr50.3%

      \[\leadsto -\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}}}{-c \cdot \left|s \cdot x\right|} \]
    6. add-sqr-sqrt64.3%

      \[\leadsto -\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{\color{blue}{s \cdot x}}}{-c \cdot \left|s \cdot x\right|} \]
    7. associate-/r*64.3%

      \[\leadsto -\frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left(s \cdot x\right)}}}{-c \cdot \left|s \cdot x\right|} \]
    8. *-commutative64.3%

      \[\leadsto -\frac{\frac{\cos \color{blue}{\left(x \cdot 2\right)}}{c \cdot \left(s \cdot x\right)}}{-c \cdot \left|s \cdot x\right|} \]
    9. associate-*r*63.3%

      \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\color{blue}{\left(c \cdot s\right) \cdot x}}}{-c \cdot \left|s \cdot x\right|} \]
    10. add-sqr-sqrt44.9%

      \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-c \cdot \left|\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}\right|} \]
    11. fabs-sqr44.9%

      \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-c \cdot \color{blue}{\left(\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}\right)}} \]
    12. add-sqr-sqrt94.1%

      \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-c \cdot \color{blue}{\left(s \cdot x\right)}} \]
    13. associate-*r*97.8%

      \[\leadsto -\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-\color{blue}{\left(c \cdot s\right) \cdot x}} \]
  7. Applied egg-rr97.8%

    \[\leadsto \color{blue}{-\frac{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}{-\left(c \cdot s\right) \cdot x}} \]
  8. Step-by-step derivation
    1. associate-/r*97.9%

      \[\leadsto -\frac{\color{blue}{\frac{\frac{\cos \left(x \cdot 2\right)}{c \cdot s}}{x}}}{-\left(c \cdot s\right) \cdot x} \]
    2. div-inv97.9%

      \[\leadsto -\frac{\color{blue}{\frac{\cos \left(x \cdot 2\right)}{c \cdot s} \cdot \frac{1}{x}}}{-\left(c \cdot s\right) \cdot x} \]
  9. Applied egg-rr97.9%

    \[\leadsto -\frac{\color{blue}{\frac{\cos \left(x \cdot 2\right)}{c \cdot s} \cdot \frac{1}{x}}}{-\left(c \cdot s\right) \cdot x} \]
  10. Step-by-step derivation
    1. un-div-inv97.9%

      \[\leadsto -\frac{\color{blue}{\frac{\frac{\cos \left(x \cdot 2\right)}{c \cdot s}}{x}}}{-\left(c \cdot s\right) \cdot x} \]
  11. Applied egg-rr97.9%

    \[\leadsto -\frac{\color{blue}{\frac{\frac{\cos \left(x \cdot 2\right)}{c \cdot s}}{x}}}{-\left(c \cdot s\right) \cdot x} \]
  12. Final simplification97.9%

    \[\leadsto \frac{\frac{\frac{-\cos \left(2 \cdot x\right)}{c \cdot s}}{x}}{x \cdot \left(c \cdot \left(-s\right)\right)} \]

Alternative 5: 97.2% accurate, 2.7× speedup?

\[\begin{array}{l} c = |c|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ \frac{\frac{\cos \left(2 \cdot x\right)}{t_0}}{t_0} \end{array} \end{array} \]
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* c (* x s)))) (/ (/ (cos (* 2.0 x)) t_0) t_0)))
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	return (cos((2.0 * x)) / t_0) / t_0;
}
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: t_0
    t_0 = c * (x * s)
    code = (cos((2.0d0 * x)) / t_0) / t_0
end function
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	return (Math.cos((2.0 * x)) / t_0) / t_0;
}
c = abs(c)
[c, s] = sort([c, s])
def code(x, c, s):
	t_0 = c * (x * s)
	return (math.cos((2.0 * x)) / t_0) / t_0
c = abs(c)
c, s = sort([c, s])
function code(x, c, s)
	t_0 = Float64(c * Float64(x * s))
	return Float64(Float64(cos(Float64(2.0 * x)) / t_0) / t_0)
end
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	t_0 = c * (x * s);
	tmp = (cos((2.0 * x)) / t_0) / t_0;
end
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{\frac{\cos \left(2 \cdot x\right)}{t_0}}{t_0}
\end{array}
\end{array}
Derivation
  1. Initial program 64.9%

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Step-by-step derivation
    1. *-un-lft-identity64.9%

      \[\leadsto \frac{\color{blue}{1 \cdot \cos \left(2 \cdot x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. add-sqr-sqrt64.9%

      \[\leadsto \frac{1 \cdot \cos \left(2 \cdot x\right)}{\color{blue}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \cdot \sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}}} \]
    3. times-frac65.0%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}}} \]
    4. sqrt-prod65.0%

      \[\leadsto \frac{1}{\color{blue}{\sqrt{{c}^{2}} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    5. unpow265.0%

      \[\leadsto \frac{1}{\sqrt{\color{blue}{c \cdot c}} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    6. sqrt-prod31.4%

      \[\leadsto \frac{1}{\color{blue}{\left(\sqrt{c} \cdot \sqrt{c}\right)} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    7. add-sqr-sqrt48.4%

      \[\leadsto \frac{1}{\color{blue}{c} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    8. *-commutative48.4%

      \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{x \cdot \left(x \cdot {s}^{2}\right)}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    9. associate-*r*45.0%

      \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{\left(x \cdot x\right) \cdot {s}^{2}}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    10. unpow245.0%

      \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{{x}^{2}} \cdot {s}^{2}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    11. pow-prod-down48.4%

      \[\leadsto \frac{1}{c \cdot \sqrt{\color{blue}{{\left(x \cdot s\right)}^{2}}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    12. sqrt-prod48.3%

      \[\leadsto \frac{1}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\sqrt{{c}^{2}} \cdot \sqrt{\left(x \cdot {s}^{2}\right) \cdot x}}} \]
  3. Applied egg-rr86.1%

    \[\leadsto \color{blue}{\frac{1}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \cdot \frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}} \]
  4. Step-by-step derivation
    1. associate-*l/86.2%

      \[\leadsto \color{blue}{\frac{1 \cdot \frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}} \]
    2. *-lft-identity86.2%

      \[\leadsto \frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
    3. unpow286.2%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{\color{blue}{\left(x \cdot s\right) \cdot \left(x \cdot s\right)}}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
    4. rem-sqrt-square86.2%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \color{blue}{\left|x \cdot s\right|}}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
    5. *-commutative86.2%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|\color{blue}{s \cdot x}\right|}}{c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}} \]
    6. unpow286.2%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \sqrt{\color{blue}{\left(x \cdot s\right) \cdot \left(x \cdot s\right)}}} \]
    7. rem-sqrt-square95.9%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \color{blue}{\left|x \cdot s\right|}} \]
    8. *-commutative95.9%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \left|\color{blue}{s \cdot x}\right|} \]
  5. Simplified95.9%

    \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c \cdot \left|s \cdot x\right|}} \]
  6. Step-by-step derivation
    1. associate-/r*90.7%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c}}{\left|s \cdot x\right|}} \]
    2. add-sqr-sqrt48.9%

      \[\leadsto \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c}}{\left|\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}\right|} \]
    3. fabs-sqr48.9%

      \[\leadsto \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c}}{\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}} \]
    4. add-sqr-sqrt62.9%

      \[\leadsto \frac{\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{c}}{\color{blue}{s \cdot x}} \]
    5. associate-/l/64.3%

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left|s \cdot x\right|}}{\left(s \cdot x\right) \cdot c}} \]
    6. div-inv64.3%

      \[\leadsto \frac{\color{blue}{\cos \left(2 \cdot x\right) \cdot \frac{1}{c \cdot \left|s \cdot x\right|}}}{\left(s \cdot x\right) \cdot c} \]
    7. times-frac62.9%

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{s \cdot x} \cdot \frac{\frac{1}{c \cdot \left|s \cdot x\right|}}{c}} \]
    8. *-commutative62.9%

      \[\leadsto \frac{\cos \color{blue}{\left(x \cdot 2\right)}}{s \cdot x} \cdot \frac{\frac{1}{c \cdot \left|s \cdot x\right|}}{c} \]
    9. add-sqr-sqrt44.5%

      \[\leadsto \frac{\cos \left(x \cdot 2\right)}{s \cdot x} \cdot \frac{\frac{1}{c \cdot \left|\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}\right|}}{c} \]
    10. fabs-sqr44.5%

      \[\leadsto \frac{\cos \left(x \cdot 2\right)}{s \cdot x} \cdot \frac{\frac{1}{c \cdot \color{blue}{\left(\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}\right)}}}{c} \]
    11. add-sqr-sqrt90.4%

      \[\leadsto \frac{\cos \left(x \cdot 2\right)}{s \cdot x} \cdot \frac{\frac{1}{c \cdot \color{blue}{\left(s \cdot x\right)}}}{c} \]
    12. associate-*r*89.7%

      \[\leadsto \frac{\cos \left(x \cdot 2\right)}{s \cdot x} \cdot \frac{\frac{1}{\color{blue}{\left(c \cdot s\right) \cdot x}}}{c} \]
  7. Applied egg-rr89.7%

    \[\leadsto \color{blue}{\frac{\cos \left(x \cdot 2\right)}{s \cdot x} \cdot \frac{\frac{1}{\left(c \cdot s\right) \cdot x}}{c}} \]
  8. Step-by-step derivation
    1. frac-times94.1%

      \[\leadsto \color{blue}{\frac{\cos \left(x \cdot 2\right) \cdot \frac{1}{\left(c \cdot s\right) \cdot x}}{\left(s \cdot x\right) \cdot c}} \]
    2. div-inv94.1%

      \[\leadsto \frac{\color{blue}{\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot s\right) \cdot x}}}{\left(s \cdot x\right) \cdot c} \]
    3. associate-*l*95.9%

      \[\leadsto \frac{\frac{\cos \left(x \cdot 2\right)}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(s \cdot x\right) \cdot c} \]
    4. *-commutative95.9%

      \[\leadsto \frac{\frac{\cos \left(x \cdot 2\right)}{c \cdot \left(s \cdot x\right)}}{\color{blue}{\left(x \cdot s\right)} \cdot c} \]
    5. associate-*r*94.1%

      \[\leadsto \frac{\frac{\cos \left(x \cdot 2\right)}{c \cdot \left(s \cdot x\right)}}{\color{blue}{x \cdot \left(s \cdot c\right)}} \]
    6. *-commutative94.1%

      \[\leadsto \frac{\frac{\cos \left(x \cdot 2\right)}{c \cdot \left(s \cdot x\right)}}{x \cdot \color{blue}{\left(c \cdot s\right)}} \]
    7. *-commutative94.1%

      \[\leadsto \frac{\frac{\cos \left(x \cdot 2\right)}{c \cdot \left(s \cdot x\right)}}{\color{blue}{\left(c \cdot s\right) \cdot x}} \]
    8. associate-*l*95.9%

      \[\leadsto \frac{\frac{\cos \left(x \cdot 2\right)}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
  9. Applied egg-rr95.9%

    \[\leadsto \color{blue}{\frac{\frac{\cos \left(x \cdot 2\right)}{c \cdot \left(s \cdot x\right)}}{c \cdot \left(s \cdot x\right)}} \]
  10. Final simplification95.9%

    \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left(x \cdot s\right)}}{c \cdot \left(x \cdot s\right)} \]

Alternative 6: 76.5% accurate, 24.1× speedup?

\[\begin{array}{l} c = |c|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{1}{\left(x \cdot s\right) \cdot \left(c \cdot \left(s \cdot \left(x \cdot c\right)\right)\right)} \end{array} \]
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s) :precision binary64 (/ 1.0 (* (* x s) (* c (* s (* x c))))))
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
	return 1.0 / ((x * s) * (c * (s * (x * c))));
}
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = 1.0d0 / ((x * s) * (c * (s * (x * c))))
end function
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
	return 1.0 / ((x * s) * (c * (s * (x * c))));
}
c = abs(c)
[c, s] = sort([c, s])
def code(x, c, s):
	return 1.0 / ((x * s) * (c * (s * (x * c))))
c = abs(c)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(1.0 / Float64(Float64(x * s) * Float64(c * Float64(s * Float64(x * c)))))
end
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = 1.0 / ((x * s) * (c * (s * (x * c))));
end
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(1.0 / N[(N[(x * s), $MachinePrecision] * N[(c * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{\left(x \cdot s\right) \cdot \left(c \cdot \left(s \cdot \left(x \cdot c\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 64.9%

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Taylor expanded in x around 0 56.9%

    \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
  3. Step-by-step derivation
    1. associate-/r*56.4%

      \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
    2. *-commutative56.4%

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
    3. unpow256.4%

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{{x}^{2} \cdot \color{blue}{\left(s \cdot s\right)}} \]
    4. unpow256.4%

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{\left(x \cdot x\right)} \cdot \left(s \cdot s\right)} \]
    5. swap-sqr67.2%

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{\left(x \cdot s\right) \cdot \left(x \cdot s\right)}} \]
    6. unpow267.2%

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{\left(x \cdot s\right)}^{2}}} \]
    7. associate-/r*67.7%

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot {\left(x \cdot s\right)}^{2}}} \]
    8. rem-square-sqrt67.7%

      \[\leadsto \frac{1}{{c}^{2} \cdot \color{blue}{\left(\sqrt{{\left(x \cdot s\right)}^{2}} \cdot \sqrt{{\left(x \cdot s\right)}^{2}}\right)}} \]
    9. unpow267.7%

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot \left(\sqrt{{\left(x \cdot s\right)}^{2}} \cdot \sqrt{{\left(x \cdot s\right)}^{2}}\right)} \]
    10. swap-sqr74.6%

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}\right) \cdot \left(c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}\right)}} \]
    11. unpow274.6%

      \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}\right)}^{2}}} \]
    12. unpow274.6%

      \[\leadsto \frac{1}{{\left(c \cdot \sqrt{\color{blue}{\left(x \cdot s\right) \cdot \left(x \cdot s\right)}}\right)}^{2}} \]
    13. rem-sqrt-square79.8%

      \[\leadsto \frac{1}{{\left(c \cdot \color{blue}{\left|x \cdot s\right|}\right)}^{2}} \]
    14. *-commutative79.8%

      \[\leadsto \frac{1}{{\left(c \cdot \left|\color{blue}{s \cdot x}\right|\right)}^{2}} \]
  4. Simplified79.8%

    \[\leadsto \color{blue}{\frac{1}{{\left(c \cdot \left|s \cdot x\right|\right)}^{2}}} \]
  5. Step-by-step derivation
    1. unpow279.8%

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot \left|s \cdot x\right|\right) \cdot \left(c \cdot \left|s \cdot x\right|\right)}} \]
    2. add-sqr-sqrt42.3%

      \[\leadsto \frac{1}{\left(c \cdot \left|s \cdot x\right|\right) \cdot \left(c \cdot \left|\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}\right|\right)} \]
    3. fabs-sqr42.3%

      \[\leadsto \frac{1}{\left(c \cdot \left|s \cdot x\right|\right) \cdot \left(c \cdot \color{blue}{\left(\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}\right)}\right)} \]
    4. add-sqr-sqrt57.6%

      \[\leadsto \frac{1}{\left(c \cdot \left|s \cdot x\right|\right) \cdot \left(c \cdot \color{blue}{\left(s \cdot x\right)}\right)} \]
    5. associate-*r*56.8%

      \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot \left|s \cdot x\right|\right) \cdot c\right) \cdot \left(s \cdot x\right)}} \]
    6. add-sqr-sqrt37.3%

      \[\leadsto \frac{1}{\left(\left(c \cdot \left|\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}\right|\right) \cdot c\right) \cdot \left(s \cdot x\right)} \]
    7. fabs-sqr37.3%

      \[\leadsto \frac{1}{\left(\left(c \cdot \color{blue}{\left(\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}\right)}\right) \cdot c\right) \cdot \left(s \cdot x\right)} \]
    8. add-sqr-sqrt77.6%

      \[\leadsto \frac{1}{\left(\left(c \cdot \color{blue}{\left(s \cdot x\right)}\right) \cdot c\right) \cdot \left(s \cdot x\right)} \]
    9. associate-*r*77.2%

      \[\leadsto \frac{1}{\left(\color{blue}{\left(\left(c \cdot s\right) \cdot x\right)} \cdot c\right) \cdot \left(s \cdot x\right)} \]
  6. Applied egg-rr77.2%

    \[\leadsto \frac{1}{\color{blue}{\left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right) \cdot \left(s \cdot x\right)}} \]
  7. Step-by-step derivation
    1. expm1-log1p-u53.1%

      \[\leadsto \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right)\right)} \cdot \left(s \cdot x\right)} \]
    2. expm1-udef33.5%

      \[\leadsto \frac{1}{\color{blue}{\left(e^{\mathsf{log1p}\left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right)} - 1\right)} \cdot \left(s \cdot x\right)} \]
    3. associate-*l*33.4%

      \[\leadsto \frac{1}{\left(e^{\mathsf{log1p}\left(\color{blue}{\left(c \cdot s\right) \cdot \left(x \cdot c\right)}\right)} - 1\right) \cdot \left(s \cdot x\right)} \]
  8. Applied egg-rr33.4%

    \[\leadsto \frac{1}{\color{blue}{\left(e^{\mathsf{log1p}\left(\left(c \cdot s\right) \cdot \left(x \cdot c\right)\right)} - 1\right)} \cdot \left(s \cdot x\right)} \]
  9. Step-by-step derivation
    1. expm1-def52.5%

      \[\leadsto \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(c \cdot s\right) \cdot \left(x \cdot c\right)\right)\right)} \cdot \left(s \cdot x\right)} \]
    2. expm1-log1p76.6%

      \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot s\right) \cdot \left(x \cdot c\right)\right)} \cdot \left(s \cdot x\right)} \]
    3. associate-*l*77.0%

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot \left(s \cdot \left(x \cdot c\right)\right)\right)} \cdot \left(s \cdot x\right)} \]
    4. *-commutative77.0%

      \[\leadsto \frac{1}{\left(c \cdot \left(s \cdot \color{blue}{\left(c \cdot x\right)}\right)\right) \cdot \left(s \cdot x\right)} \]
  10. Simplified77.0%

    \[\leadsto \frac{1}{\color{blue}{\left(c \cdot \left(s \cdot \left(c \cdot x\right)\right)\right)} \cdot \left(s \cdot x\right)} \]
  11. Final simplification77.0%

    \[\leadsto \frac{1}{\left(x \cdot s\right) \cdot \left(c \cdot \left(s \cdot \left(x \cdot c\right)\right)\right)} \]

Alternative 7: 78.5% accurate, 24.1× speedup?

\[\begin{array}{l} c = |c|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := x \cdot \left(c \cdot s\right)\\ \frac{1}{t_0 \cdot t_0} \end{array} \end{array} \]
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* x (* c s)))) (/ 1.0 (* t_0 t_0))))
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
	double t_0 = x * (c * s);
	return 1.0 / (t_0 * t_0);
}
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: t_0
    t_0 = x * (c * s)
    code = 1.0d0 / (t_0 * t_0)
end function
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
	double t_0 = x * (c * s);
	return 1.0 / (t_0 * t_0);
}
c = abs(c)
[c, s] = sort([c, s])
def code(x, c, s):
	t_0 = x * (c * s)
	return 1.0 / (t_0 * t_0)
c = abs(c)
c, s = sort([c, s])
function code(x, c, s)
	t_0 = Float64(x * Float64(c * s))
	return Float64(1.0 / Float64(t_0 * t_0))
end
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	t_0 = x * (c * s);
	tmp = 1.0 / (t_0 * t_0);
end
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := x \cdot \left(c \cdot s\right)\\
\frac{1}{t_0 \cdot t_0}
\end{array}
\end{array}
Derivation
  1. Initial program 64.9%

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Taylor expanded in x around 0 56.9%

    \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
  3. Step-by-step derivation
    1. associate-/r*56.4%

      \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
    2. *-commutative56.4%

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
    3. unpow256.4%

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{{x}^{2} \cdot \color{blue}{\left(s \cdot s\right)}} \]
    4. unpow256.4%

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{\left(x \cdot x\right)} \cdot \left(s \cdot s\right)} \]
    5. swap-sqr67.2%

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{\left(x \cdot s\right) \cdot \left(x \cdot s\right)}} \]
    6. unpow267.2%

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{\left(x \cdot s\right)}^{2}}} \]
    7. associate-/r*67.7%

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot {\left(x \cdot s\right)}^{2}}} \]
    8. rem-square-sqrt67.7%

      \[\leadsto \frac{1}{{c}^{2} \cdot \color{blue}{\left(\sqrt{{\left(x \cdot s\right)}^{2}} \cdot \sqrt{{\left(x \cdot s\right)}^{2}}\right)}} \]
    9. unpow267.7%

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot \left(\sqrt{{\left(x \cdot s\right)}^{2}} \cdot \sqrt{{\left(x \cdot s\right)}^{2}}\right)} \]
    10. swap-sqr74.6%

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}\right) \cdot \left(c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}\right)}} \]
    11. unpow274.6%

      \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}\right)}^{2}}} \]
    12. unpow274.6%

      \[\leadsto \frac{1}{{\left(c \cdot \sqrt{\color{blue}{\left(x \cdot s\right) \cdot \left(x \cdot s\right)}}\right)}^{2}} \]
    13. rem-sqrt-square79.8%

      \[\leadsto \frac{1}{{\left(c \cdot \color{blue}{\left|x \cdot s\right|}\right)}^{2}} \]
    14. *-commutative79.8%

      \[\leadsto \frac{1}{{\left(c \cdot \left|\color{blue}{s \cdot x}\right|\right)}^{2}} \]
  4. Simplified79.8%

    \[\leadsto \color{blue}{\frac{1}{{\left(c \cdot \left|s \cdot x\right|\right)}^{2}}} \]
  5. Step-by-step derivation
    1. unpow-prod-down67.7%

      \[\leadsto \frac{1}{\color{blue}{{c}^{2} \cdot {\left(\left|s \cdot x\right|\right)}^{2}}} \]
    2. unpow267.7%

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot {\left(\left|s \cdot x\right|\right)}^{2}} \]
    3. pow267.7%

      \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left|s \cdot x\right| \cdot \left|s \cdot x\right|\right)}} \]
    4. sqr-abs67.7%

      \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(s \cdot x\right)\right)}} \]
    5. swap-sqr79.8%

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(c \cdot \left(s \cdot x\right)\right)}} \]
    6. associate-*r*78.4%

      \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot s\right) \cdot x\right)} \cdot \left(c \cdot \left(s \cdot x\right)\right)} \]
    7. associate-*r*80.9%

      \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}} \]
  6. Applied egg-rr80.9%

    \[\leadsto \frac{1}{\color{blue}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)}} \]
  7. Final simplification80.9%

    \[\leadsto \frac{1}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)} \]

Alternative 8: 79.4% accurate, 24.1× speedup?

\[\begin{array}{l} c = |c|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ \frac{\frac{1}{t_0}}{t_0} \end{array} \end{array} \]
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* c (* x s)))) (/ (/ 1.0 t_0) t_0)))
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	return (1.0 / t_0) / t_0;
}
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: t_0
    t_0 = c * (x * s)
    code = (1.0d0 / t_0) / t_0
end function
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	return (1.0 / t_0) / t_0;
}
c = abs(c)
[c, s] = sort([c, s])
def code(x, c, s):
	t_0 = c * (x * s)
	return (1.0 / t_0) / t_0
c = abs(c)
c, s = sort([c, s])
function code(x, c, s)
	t_0 = Float64(c * Float64(x * s))
	return Float64(Float64(1.0 / t_0) / t_0)
end
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	t_0 = c * (x * s);
	tmp = (1.0 / t_0) / t_0;
end
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{\frac{1}{t_0}}{t_0}
\end{array}
\end{array}
Derivation
  1. Initial program 64.9%

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Taylor expanded in x around 0 56.9%

    \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
  3. Step-by-step derivation
    1. associate-/r*56.4%

      \[\leadsto \color{blue}{\frac{\frac{1}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
    2. *-commutative56.4%

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{x}^{2} \cdot {s}^{2}}} \]
    3. unpow256.4%

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{{x}^{2} \cdot \color{blue}{\left(s \cdot s\right)}} \]
    4. unpow256.4%

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{\left(x \cdot x\right)} \cdot \left(s \cdot s\right)} \]
    5. swap-sqr67.2%

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{\left(x \cdot s\right) \cdot \left(x \cdot s\right)}} \]
    6. unpow267.2%

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{{\left(x \cdot s\right)}^{2}}} \]
    7. associate-/r*67.7%

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot {\left(x \cdot s\right)}^{2}}} \]
    8. rem-square-sqrt67.7%

      \[\leadsto \frac{1}{{c}^{2} \cdot \color{blue}{\left(\sqrt{{\left(x \cdot s\right)}^{2}} \cdot \sqrt{{\left(x \cdot s\right)}^{2}}\right)}} \]
    9. unpow267.7%

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot \left(\sqrt{{\left(x \cdot s\right)}^{2}} \cdot \sqrt{{\left(x \cdot s\right)}^{2}}\right)} \]
    10. swap-sqr74.6%

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}\right) \cdot \left(c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}\right)}} \]
    11. unpow274.6%

      \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \sqrt{{\left(x \cdot s\right)}^{2}}\right)}^{2}}} \]
    12. unpow274.6%

      \[\leadsto \frac{1}{{\left(c \cdot \sqrt{\color{blue}{\left(x \cdot s\right) \cdot \left(x \cdot s\right)}}\right)}^{2}} \]
    13. rem-sqrt-square79.8%

      \[\leadsto \frac{1}{{\left(c \cdot \color{blue}{\left|x \cdot s\right|}\right)}^{2}} \]
    14. *-commutative79.8%

      \[\leadsto \frac{1}{{\left(c \cdot \left|\color{blue}{s \cdot x}\right|\right)}^{2}} \]
  4. Simplified79.8%

    \[\leadsto \color{blue}{\frac{1}{{\left(c \cdot \left|s \cdot x\right|\right)}^{2}}} \]
  5. Step-by-step derivation
    1. pow-flip80.0%

      \[\leadsto \color{blue}{{\left(c \cdot \left|s \cdot x\right|\right)}^{\left(-2\right)}} \]
    2. add-sqr-sqrt42.3%

      \[\leadsto {\left(c \cdot \left|\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}\right|\right)}^{\left(-2\right)} \]
    3. fabs-sqr42.3%

      \[\leadsto {\left(c \cdot \color{blue}{\left(\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}\right)}\right)}^{\left(-2\right)} \]
    4. add-sqr-sqrt80.0%

      \[\leadsto {\left(c \cdot \color{blue}{\left(s \cdot x\right)}\right)}^{\left(-2\right)} \]
    5. *-commutative80.0%

      \[\leadsto {\left(c \cdot \color{blue}{\left(x \cdot s\right)}\right)}^{\left(-2\right)} \]
    6. *-commutative80.0%

      \[\leadsto {\left(c \cdot \color{blue}{\left(s \cdot x\right)}\right)}^{\left(-2\right)} \]
    7. associate-*r*81.1%

      \[\leadsto {\color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}}^{\left(-2\right)} \]
    8. metadata-eval81.1%

      \[\leadsto {\left(\left(c \cdot s\right) \cdot x\right)}^{\color{blue}{-2}} \]
  6. Applied egg-rr81.1%

    \[\leadsto \color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{-2}} \]
  7. Step-by-step derivation
    1. metadata-eval81.1%

      \[\leadsto {\left(\left(c \cdot s\right) \cdot x\right)}^{\color{blue}{\left(-1 - 1\right)}} \]
    2. pow-div81.1%

      \[\leadsto \color{blue}{\frac{{\left(\left(c \cdot s\right) \cdot x\right)}^{-1}}{{\left(\left(c \cdot s\right) \cdot x\right)}^{1}}} \]
    3. inv-pow81.1%

      \[\leadsto \frac{\color{blue}{\frac{1}{\left(c \cdot s\right) \cdot x}}}{{\left(\left(c \cdot s\right) \cdot x\right)}^{1}} \]
    4. associate-*l*78.6%

      \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{{\left(\left(c \cdot s\right) \cdot x\right)}^{1}} \]
    5. pow178.6%

      \[\leadsto \frac{\frac{1}{c \cdot \left(s \cdot x\right)}}{\color{blue}{\left(c \cdot s\right) \cdot x}} \]
    6. associate-*l*80.0%

      \[\leadsto \frac{\frac{1}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
  8. Applied egg-rr80.0%

    \[\leadsto \color{blue}{\frac{\frac{1}{c \cdot \left(s \cdot x\right)}}{c \cdot \left(s \cdot x\right)}} \]
  9. Final simplification80.0%

    \[\leadsto \frac{\frac{1}{c \cdot \left(x \cdot s\right)}}{c \cdot \left(x \cdot s\right)} \]

Reproduce

?
herbie shell --seed 2023305 
(FPCore (x c s)
  :name "mixedcos"
  :precision binary64
  (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))