mixedcos

Percentage Accurate: 66.6% → 97.3%
Time: 10.6s
Alternatives: 9
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 9 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.6% 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: 97.3% accurate, 1.5× speedup?

\[\begin{array}{l} c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \cos \left(x \cdot 2\right) \cdot {\left(s \cdot \left(x \cdot c\right)\right)}^{-2} \end{array} \]
NOTE: c should be positive before calling this function
NOTE: s 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 (* x 2.0)) (pow (* s (* x c)) -2.0)))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return cos((x * 2.0)) * pow((s * (x * c)), -2.0);
}
NOTE: c should be positive before calling this function
NOTE: s 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((x * 2.0d0)) * ((s * (x * c)) ** (-2.0d0))
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return Math.cos((x * 2.0)) * Math.pow((s * (x * c)), -2.0);
}
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return math.cos((x * 2.0)) * math.pow((s * (x * c)), -2.0)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(cos(Float64(x * 2.0)) * (Float64(s * Float64(x * c)) ^ -2.0))
end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = cos((x * 2.0)) * ((s * (x * c)) ^ -2.0);
end
NOTE: c should be positive before calling this function
NOTE: s 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[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\cos \left(x \cdot 2\right) \cdot {\left(s \cdot \left(x \cdot c\right)\right)}^{-2}
\end{array}
Derivation
  1. Initial program 65.1%

    \[\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. *-commutative65.1%

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

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

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\color{blue}{\left(c \cdot c\right)} \cdot \left(x \cdot x\right)\right) \cdot {s}^{2}} \]
    5. unswap-sqr76.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 87.1% accurate, 2.7× speedup?

\[\begin{array}{l} c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 6 \cdot 10^{-5}:\\ \;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{s \cdot \left(s \cdot \left(x \cdot \left(c \cdot \left(x \cdot c\right)\right)\right)\right)}\\ \end{array} \end{array} \]
NOTE: c should be positive before calling this function
NOTE: s 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
 (if (<= x 6e-5)
   (pow (* c (* x s)) -2.0)
   (/ (cos (* x 2.0)) (* s (* s (* x (* c (* x c))))))))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double tmp;
	if (x <= 6e-5) {
		tmp = pow((c * (x * s)), -2.0);
	} else {
		tmp = cos((x * 2.0)) / (s * (s * (x * (c * (x * c)))));
	}
	return tmp;
}
NOTE: c should be positive before calling this function
NOTE: s 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) :: tmp
    if (x <= 6d-5) then
        tmp = (c * (x * s)) ** (-2.0d0)
    else
        tmp = cos((x * 2.0d0)) / (s * (s * (x * (c * (x * c)))))
    end if
    code = tmp
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double tmp;
	if (x <= 6e-5) {
		tmp = Math.pow((c * (x * s)), -2.0);
	} else {
		tmp = Math.cos((x * 2.0)) / (s * (s * (x * (c * (x * c)))));
	}
	return tmp;
}
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	tmp = 0
	if x <= 6e-5:
		tmp = math.pow((c * (x * s)), -2.0)
	else:
		tmp = math.cos((x * 2.0)) / (s * (s * (x * (c * (x * c)))))
	return tmp
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	tmp = 0.0
	if (x <= 6e-5)
		tmp = Float64(c * Float64(x * s)) ^ -2.0;
	else
		tmp = Float64(cos(Float64(x * 2.0)) / Float64(s * Float64(s * Float64(x * Float64(c * Float64(x * c))))));
	end
	return tmp
end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (x <= 6e-5)
		tmp = (c * (x * s)) ^ -2.0;
	else
		tmp = cos((x * 2.0)) / (s * (s * (x * (c * (x * c)))));
	end
	tmp_2 = tmp;
end
NOTE: c should be positive before calling this function
NOTE: s 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_] := If[LessEqual[x, 6e-5], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(s * N[(s * N[(x * N[(c * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6 \cdot 10^{-5}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\

\mathbf{else}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{s \cdot \left(s \cdot \left(x \cdot \left(c \cdot \left(x \cdot c\right)\right)\right)\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 6.00000000000000015e-5

    1. Initial program 63.8%

      \[\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. *-commutative63.8%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}} \]
    4. Taylor expanded in x around 0 53.5%

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\left(c \cdot c\right) \cdot \color{blue}{{\left(x \cdot s\right)}^{2}}\right)}^{-1} \]
      4. *-commutative70.3%

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

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

        \[\leadsto {\color{blue}{\left({\left(\left(x \cdot s\right) \cdot c\right)}^{2}\right)}}^{-1} \]
      7. *-commutative84.3%

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

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

        \[\leadsto {\color{blue}{\left(\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)\right)}}^{-1} \]
      10. pow-prod-down83.8%

        \[\leadsto \color{blue}{{\left(s \cdot \left(x \cdot c\right)\right)}^{-1} \cdot {\left(s \cdot \left(x \cdot c\right)\right)}^{-1}} \]
      11. pow-prod-up83.8%

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

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

      \[\leadsto \color{blue}{{\left(s \cdot \left(x \cdot c\right)\right)}^{-2}} \]
    9. Taylor expanded in s around 0 84.4%

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

    if 6.00000000000000015e-5 < x

    1. Initial program 69.1%

      \[\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. *-commutative69.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{s \cdot \left(\left(x \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot s\right)\right)}} \]
    4. Taylor expanded in x around 0 66.9%

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

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

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

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

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

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

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

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

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

Alternative 3: 94.8% accurate, 2.7× speedup?

\[\begin{array}{l} c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{\cos \left(x \cdot 2\right)}{\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)} \end{array} \]
NOTE: c should be positive before calling this function
NOTE: s 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 (* x 2.0)) (* (* s (* x c)) (* c (* x s)))))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return cos((x * 2.0)) / ((s * (x * c)) * (c * (x * s)));
}
NOTE: c should be positive before calling this function
NOTE: s 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((x * 2.0d0)) / ((s * (x * c)) * (c * (x * s)))
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return Math.cos((x * 2.0)) / ((s * (x * c)) * (c * (x * s)));
}
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return math.cos((x * 2.0)) / ((s * (x * c)) * (c * (x * s)))
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(cos(Float64(x * 2.0)) / Float64(Float64(s * Float64(x * c)) * Float64(c * Float64(x * s))))
end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = cos((x * 2.0)) / ((s * (x * c)) * (c * (x * s)));
end
NOTE: c should be positive before calling this function
NOTE: s 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[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\cos \left(x \cdot 2\right)}{\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}
\end{array}
Derivation
  1. Initial program 65.1%

    \[\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. *-commutative65.1%

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

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

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\color{blue}{\left(c \cdot c\right)} \cdot \left(x \cdot x\right)\right) \cdot {s}^{2}} \]
    5. unswap-sqr76.8%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}} \]
  4. Taylor expanded in s around 0 94.1%

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

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

Alternative 4: 97.0% accurate, 2.7× speedup?

\[\begin{array}{l} c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := s \cdot \left(x \cdot c\right)\\ \frac{\cos \left(x \cdot 2\right)}{t_0 \cdot t_0} \end{array} \end{array} \]
NOTE: c should be positive before calling this function
NOTE: s 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 (* s (* x c)))) (/ (cos (* x 2.0)) (* t_0 t_0))))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double t_0 = s * (x * c);
	return cos((x * 2.0)) / (t_0 * t_0);
}
NOTE: c should be positive before calling this function
NOTE: s 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 = s * (x * c)
    code = cos((x * 2.0d0)) / (t_0 * t_0)
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double t_0 = s * (x * c);
	return Math.cos((x * 2.0)) / (t_0 * t_0);
}
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	t_0 = s * (x * c)
	return math.cos((x * 2.0)) / (t_0 * t_0)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	t_0 = Float64(s * Float64(x * c))
	return Float64(cos(Float64(x * 2.0)) / Float64(t_0 * t_0))
end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	t_0 = s * (x * c);
	tmp = cos((x * 2.0)) / (t_0 * t_0);
end
NOTE: c should be positive before calling this function
NOTE: s 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[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]}, N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot c\right)\\
\frac{\cos \left(x \cdot 2\right)}{t_0 \cdot t_0}
\end{array}
\end{array}
Derivation
  1. Initial program 65.1%

    \[\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. *-commutative65.1%

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

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

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\color{blue}{\left(c \cdot c\right)} \cdot \left(x \cdot x\right)\right) \cdot {s}^{2}} \]
    5. unswap-sqr76.8%

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

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

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

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

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

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

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

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

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

Alternative 5: 97.3% accurate, 2.7× speedup?

\[\begin{array}{l} c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := s \cdot \left(x \cdot c\right)\\ \frac{\frac{\cos \left(x \cdot 2\right)}{t_0}}{t_0} \end{array} \end{array} \]
NOTE: c should be positive before calling this function
NOTE: s 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 (* s (* x c)))) (/ (/ (cos (* x 2.0)) t_0) t_0)))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double t_0 = s * (x * c);
	return (cos((x * 2.0)) / t_0) / t_0;
}
NOTE: c should be positive before calling this function
NOTE: s 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 = s * (x * c)
    code = (cos((x * 2.0d0)) / t_0) / t_0
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double t_0 = s * (x * c);
	return (Math.cos((x * 2.0)) / t_0) / t_0;
}
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	t_0 = s * (x * c)
	return (math.cos((x * 2.0)) / t_0) / t_0
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	t_0 = Float64(s * Float64(x * c))
	return Float64(Float64(cos(Float64(x * 2.0)) / t_0) / t_0)
end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	t_0 = s * (x * c);
	tmp = (cos((x * 2.0)) / t_0) / t_0;
end
NOTE: c should be positive before calling this function
NOTE: s 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[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot c\right)\\
\frac{\frac{\cos \left(x \cdot 2\right)}{t_0}}{t_0}
\end{array}
\end{array}
Derivation
  1. Initial program 65.1%

    \[\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. *-commutative65.1%

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

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

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\color{blue}{\left(c \cdot c\right)} \cdot \left(x \cdot x\right)\right) \cdot {s}^{2}} \]
    5. unswap-sqr76.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(x \cdot 2\right) \cdot {\left(s \cdot \left(x \cdot c\right)\right)}^{\color{blue}{\left(-1 + -1\right)}} \]
    2. pow-prod-up96.9%

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

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

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

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

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

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

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

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

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

Alternative 6: 80.0% accurate, 3.0× speedup?

\[\begin{array}{l} c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ {\left(c \cdot \left(x \cdot s\right)\right)}^{-2} \end{array} \]
NOTE: c should be positive before calling this function
NOTE: s 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 (pow (* c (* x s)) -2.0))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return pow((c * (x * s)), -2.0);
}
NOTE: c should be positive before calling this function
NOTE: s 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 = (c * (x * s)) ** (-2.0d0)
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return Math.pow((c * (x * s)), -2.0);
}
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return math.pow((c * (x * s)), -2.0)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(c * Float64(x * s)) ^ -2.0
end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = (c * (x * s)) ^ -2.0;
end
NOTE: c should be positive before calling this function
NOTE: s 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[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}
\end{array}
Derivation
  1. Initial program 65.1%

    \[\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. *-commutative65.1%

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

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

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\color{blue}{\left(c \cdot c\right)} \cdot \left(x \cdot x\right)\right) \cdot {s}^{2}} \]
    5. unswap-sqr76.8%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}} \]
  4. Taylor expanded in x around 0 52.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\color{blue}{\left({\left(\left(x \cdot s\right) \cdot c\right)}^{2}\right)}}^{-1} \]
    7. *-commutative77.3%

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

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

      \[\leadsto {\color{blue}{\left(\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)\right)}}^{-1} \]
    10. pow-prod-down76.9%

      \[\leadsto \color{blue}{{\left(s \cdot \left(x \cdot c\right)\right)}^{-1} \cdot {\left(s \cdot \left(x \cdot c\right)\right)}^{-1}} \]
    11. pow-prod-up76.9%

      \[\leadsto \color{blue}{{\left(s \cdot \left(x \cdot c\right)\right)}^{\left(-1 + -1\right)}} \]
    12. metadata-eval76.9%

      \[\leadsto {\left(s \cdot \left(x \cdot c\right)\right)}^{\color{blue}{-2}} \]
  8. Applied egg-rr76.9%

    \[\leadsto \color{blue}{{\left(s \cdot \left(x \cdot c\right)\right)}^{-2}} \]
  9. Taylor expanded in s around 0 77.4%

    \[\leadsto {\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}}^{-2} \]
  10. Final simplification77.4%

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

Alternative 7: 79.9% accurate, 20.9× speedup?

\[\begin{array}{l} c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := \frac{\frac{1}{c}}{x \cdot s}\\ t_0 \cdot t_0 \end{array} \end{array} \]
NOTE: c should be positive before calling this function
NOTE: s 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 (/ (/ 1.0 c) (* x s)))) (* t_0 t_0)))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double t_0 = (1.0 / c) / (x * s);
	return t_0 * t_0;
}
NOTE: c should be positive before calling this function
NOTE: s 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 = (1.0d0 / c) / (x * s)
    code = t_0 * t_0
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double t_0 = (1.0 / c) / (x * s);
	return t_0 * t_0;
}
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	t_0 = (1.0 / c) / (x * s)
	return t_0 * t_0
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	t_0 = Float64(Float64(1.0 / c) / Float64(x * s))
	return Float64(t_0 * t_0)
end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	t_0 = (1.0 / c) / (x * s);
	tmp = t_0 * t_0;
end
NOTE: c should be positive before calling this function
NOTE: s 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[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{c}}{x \cdot s}\\
t_0 \cdot t_0
\end{array}
\end{array}
Derivation
  1. Initial program 65.1%

    \[\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. associate-/r*64.2%

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{c \cdot c}}{x \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
  4. Taylor expanded in x around 0 57.0%

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

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

    \[\leadsto \frac{\color{blue}{\frac{1}{c \cdot c}}}{x \cdot \left(x \cdot \left(s \cdot s\right)\right)} \]
  7. Step-by-step derivation
    1. add-sqr-sqrt57.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{c}}{\color{blue}{x} \cdot \sqrt{s \cdot s}} \cdot \sqrt{\frac{\frac{1}{c \cdot c}}{x \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
    11. sqrt-prod21.7%

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

      \[\leadsto \frac{\frac{1}{c}}{x \cdot \color{blue}{s}} \cdot \sqrt{\frac{\frac{1}{c \cdot c}}{x \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
    13. *-commutative43.3%

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

      \[\leadsto \frac{\frac{1}{c}}{s \cdot x} \cdot \color{blue}{\frac{\sqrt{\frac{1}{c \cdot c}}}{\sqrt{x \cdot \left(x \cdot \left(s \cdot s\right)\right)}}} \]
    15. sqrt-div44.1%

      \[\leadsto \frac{\frac{1}{c}}{s \cdot x} \cdot \frac{\color{blue}{\frac{\sqrt{1}}{\sqrt{c \cdot c}}}}{\sqrt{x \cdot \left(x \cdot \left(s \cdot s\right)\right)}} \]
    16. metadata-eval44.1%

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

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

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

      \[\leadsto \frac{\frac{1}{c}}{s \cdot x} \cdot \frac{\frac{1}{c}}{\sqrt{\color{blue}{\left(x \cdot x\right) \cdot \left(s \cdot s\right)}}} \]
    20. sqrt-prod43.2%

      \[\leadsto \frac{\frac{1}{c}}{s \cdot x} \cdot \frac{\frac{1}{c}}{\color{blue}{\sqrt{x \cdot x} \cdot \sqrt{s \cdot s}}} \]
  8. Applied egg-rr77.4%

    \[\leadsto \color{blue}{\frac{\frac{1}{c}}{s \cdot x} \cdot \frac{\frac{1}{c}}{s \cdot x}} \]
  9. Final simplification77.4%

    \[\leadsto \frac{\frac{1}{c}}{x \cdot s} \cdot \frac{\frac{1}{c}}{x \cdot s} \]

Alternative 8: 74.9% accurate, 24.1× speedup?

\[\begin{array}{l} c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{1}{s \cdot \left(\left(x \cdot c\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)} \end{array} \]
NOTE: c should be positive before calling this function
NOTE: s 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 (* s (* (* x c) (* c (* x s))))))
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return 1.0 / (s * ((x * c) * (c * (x * s))));
}
NOTE: c should be positive before calling this function
NOTE: s 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 / (s * ((x * c) * (c * (x * s))))
end function
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return 1.0 / (s * ((x * c) * (c * (x * s))));
}
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return 1.0 / (s * ((x * c) * (c * (x * s))))
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(1.0 / Float64(s * Float64(Float64(x * c) * Float64(c * Float64(x * s)))))
end
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = 1.0 / (s * ((x * c) * (c * (x * s))));
end
NOTE: c should be positive before calling this function
NOTE: s 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[(s * N[(N[(x * c), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{s \cdot \left(\left(x \cdot c\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 65.1%

    \[\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. *-commutative65.1%

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

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

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\color{blue}{\left(c \cdot c\right)} \cdot \left(x \cdot x\right)\right) \cdot {s}^{2}} \]
    5. unswap-sqr76.8%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}} \]
  4. Taylor expanded in x around 0 52.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\color{blue}{\left({\left(\left(x \cdot s\right) \cdot c\right)}^{2}\right)}}^{-1} \]
    7. *-commutative77.3%

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

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

      \[\leadsto {\color{blue}{\left(\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)\right)}}^{-1} \]
    10. pow-prod-down76.9%

      \[\leadsto \color{blue}{{\left(s \cdot \left(x \cdot c\right)\right)}^{-1} \cdot {\left(s \cdot \left(x \cdot c\right)\right)}^{-1}} \]
    11. pow-prod-up76.9%

      \[\leadsto \color{blue}{{\left(s \cdot \left(x \cdot c\right)\right)}^{\left(-1 + -1\right)}} \]
    12. metadata-eval76.9%

      \[\leadsto {\left(s \cdot \left(x \cdot c\right)\right)}^{\color{blue}{-2}} \]
  8. Applied egg-rr76.9%

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

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

      \[\leadsto \color{blue}{{\left(s \cdot \left(x \cdot c\right)\right)}^{-1} \cdot {\left(s \cdot \left(x \cdot c\right)\right)}^{-1}} \]
    3. pow-prod-down76.8%

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

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

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

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

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

      \[\leadsto {\left({\left(x \cdot s\right)}^{2} \cdot \color{blue}{\left(c \cdot c\right)}\right)}^{-1} \]
    9. *-commutative65.4%

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

      \[\leadsto {\left(\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}\right)}^{-1} \]
    11. unswap-sqr52.0%

      \[\leadsto {\left(\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)}\right)}^{-1} \]
    12. inv-pow52.0%

      \[\leadsto \color{blue}{\frac{1}{\left(c \cdot c\right) \cdot \left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)}} \]
    13. unswap-sqr65.4%

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

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

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

      \[\leadsto \frac{1}{{\left(x \cdot s\right)}^{2} \cdot \color{blue}{{c}^{2}}} \]
    17. pow-prod-down77.3%

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{1}{\color{blue}{s \cdot \left(\left(x \cdot c\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)\right)}} \]
  13. Final simplification75.2%

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

Alternative 9: 79.9% accurate, 24.1× speedup?

\[\begin{array}{l} c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ \frac{1}{t_0 \cdot t_0} \end{array} \end{array} \]
NOTE: c should be positive before calling this function
NOTE: s 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);
s = abs(s);
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: s 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);
s = Math.abs(s);
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)
s = abs(s)
[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)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	t_0 = Float64(c * Float64(x * s))
	return Float64(1.0 / Float64(t_0 * t_0))
end
c = abs(c)
s = abs(s)
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: s 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[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{1}{t_0 \cdot t_0}
\end{array}
\end{array}
Derivation
  1. Initial program 65.1%

    \[\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. *-commutative65.1%

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

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

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\color{blue}{\left(c \cdot c\right)} \cdot \left(x \cdot x\right)\right) \cdot {s}^{2}} \]
    5. unswap-sqr76.8%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}} \]
  4. Taylor expanded in x around 0 52.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\color{blue}{\left({\left(\left(x \cdot s\right) \cdot c\right)}^{2}\right)}}^{-1} \]
    7. *-commutative77.3%

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

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

      \[\leadsto {\color{blue}{\left(\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)\right)}}^{-1} \]
    10. pow-prod-down76.9%

      \[\leadsto \color{blue}{{\left(s \cdot \left(x \cdot c\right)\right)}^{-1} \cdot {\left(s \cdot \left(x \cdot c\right)\right)}^{-1}} \]
    11. pow-prod-up76.9%

      \[\leadsto \color{blue}{{\left(s \cdot \left(x \cdot c\right)\right)}^{\left(-1 + -1\right)}} \]
    12. metadata-eval76.9%

      \[\leadsto {\left(s \cdot \left(x \cdot c\right)\right)}^{\color{blue}{-2}} \]
  8. Applied egg-rr76.9%

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

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

      \[\leadsto \color{blue}{{\left(s \cdot \left(x \cdot c\right)\right)}^{-1} \cdot {\left(s \cdot \left(x \cdot c\right)\right)}^{-1}} \]
    3. pow-prod-down76.8%

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

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

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

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

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

      \[\leadsto {\left({\left(x \cdot s\right)}^{2} \cdot \color{blue}{\left(c \cdot c\right)}\right)}^{-1} \]
    9. *-commutative65.4%

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

      \[\leadsto {\left(\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}\right)}^{-1} \]
    11. unswap-sqr52.0%

      \[\leadsto {\left(\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)}\right)}^{-1} \]
    12. inv-pow52.0%

      \[\leadsto \color{blue}{\frac{1}{\left(c \cdot c\right) \cdot \left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)}} \]
    13. unswap-sqr65.4%

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

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

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

      \[\leadsto \frac{1}{{\left(x \cdot s\right)}^{2} \cdot \color{blue}{{c}^{2}}} \]
    17. pow-prod-down77.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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