mixedcos

Percentage Accurate: 66.4% → 97.1%
Time: 17.6s
Alternatives: 10
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 10 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.4% 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.1% accurate, 2.7× speedup?

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

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

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    3. distribute-lft-neg-out65.5%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
    4. distribute-lft-neg-out65.5%

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right) \cdot {c}^{2}}} \]
    7. distribute-rgt-neg-out66.0%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(\left(-x\right) \cdot {s}^{2}\right) \cdot x\right)} \cdot {c}^{2}} \]
    8. distribute-lft-neg-out66.0%

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
    10. distribute-lft-neg-in68.7%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
    11. distribute-lft-neg-out68.7%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(-\color{blue}{\left(-x \cdot {s}^{2}\right)}\right) \cdot \left(x \cdot {c}^{2}\right)} \]
    12. remove-double-neg68.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \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)} \]

Alternative 2: 85.3% accurate, 2.6× speedup?

\[\begin{array}{l} [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := \cos \left(2 \cdot x\right)\\ \mathbf{if}\;x \leq 1.08 \cdot 10^{-19}:\\ \;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \frac{\frac{1}{c}}{x \cdot s}\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{+166}:\\ \;\;\;\;\frac{t_0}{x \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(s \cdot c\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{\left(c \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot \left(x \cdot s\right)\right)}\\ \end{array} \end{array} \]
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (cos (* 2.0 x))))
   (if (<= x 1.08e-19)
     (* (/ 1.0 (* c (* x s))) (/ (/ 1.0 c) (* x s)))
     (if (<= x 1.6e+166)
       (/ t_0 (* x (* x (* c (* s (* s c))))))
       (/ t_0 (* (* c (* x c)) (* s (* x s))))))))
assert(c < s);
double code(double x, double c, double s) {
	double t_0 = cos((2.0 * x));
	double tmp;
	if (x <= 1.08e-19) {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s));
	} else if (x <= 1.6e+166) {
		tmp = t_0 / (x * (x * (c * (s * (s * c)))));
	} else {
		tmp = t_0 / ((c * (x * c)) * (s * (x * s)));
	}
	return tmp;
}
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
    real(8) :: tmp
    t_0 = cos((2.0d0 * x))
    if (x <= 1.08d-19) then
        tmp = (1.0d0 / (c * (x * s))) * ((1.0d0 / c) / (x * s))
    else if (x <= 1.6d+166) then
        tmp = t_0 / (x * (x * (c * (s * (s * c)))))
    else
        tmp = t_0 / ((c * (x * c)) * (s * (x * s)))
    end if
    code = tmp
end function
assert c < s;
public static double code(double x, double c, double s) {
	double t_0 = Math.cos((2.0 * x));
	double tmp;
	if (x <= 1.08e-19) {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s));
	} else if (x <= 1.6e+166) {
		tmp = t_0 / (x * (x * (c * (s * (s * c)))));
	} else {
		tmp = t_0 / ((c * (x * c)) * (s * (x * s)));
	}
	return tmp;
}
[c, s] = sort([c, s])
def code(x, c, s):
	t_0 = math.cos((2.0 * x))
	tmp = 0
	if x <= 1.08e-19:
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s))
	elif x <= 1.6e+166:
		tmp = t_0 / (x * (x * (c * (s * (s * c)))))
	else:
		tmp = t_0 / ((c * (x * c)) * (s * (x * s)))
	return tmp
c, s = sort([c, s])
function code(x, c, s)
	t_0 = cos(Float64(2.0 * x))
	tmp = 0.0
	if (x <= 1.08e-19)
		tmp = Float64(Float64(1.0 / Float64(c * Float64(x * s))) * Float64(Float64(1.0 / c) / Float64(x * s)));
	elseif (x <= 1.6e+166)
		tmp = Float64(t_0 / Float64(x * Float64(x * Float64(c * Float64(s * Float64(s * c))))));
	else
		tmp = Float64(t_0 / Float64(Float64(c * Float64(x * c)) * Float64(s * Float64(x * s))));
	end
	return tmp
end
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	t_0 = cos((2.0 * x));
	tmp = 0.0;
	if (x <= 1.08e-19)
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s));
	elseif (x <= 1.6e+166)
		tmp = t_0 / (x * (x * (c * (s * (s * c)))));
	else
		tmp = t_0 / ((c * (x * c)) * (s * (x * s)));
	end
	tmp_2 = tmp;
end
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1.08e-19], N[(N[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.6e+166], N[(t$95$0 / N[(x * N[(x * N[(c * N[(s * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(N[(c * N[(x * c), $MachinePrecision]), $MachinePrecision] * N[(s * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(2 \cdot x\right)\\
\mathbf{if}\;x \leq 1.08 \cdot 10^{-19}:\\
\;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \frac{\frac{1}{c}}{x \cdot s}\\

\mathbf{elif}\;x \leq 1.6 \cdot 10^{+166}:\\
\;\;\;\;\frac{t_0}{x \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(s \cdot c\right)\right)\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 1.08e-19

    1. Initial program 61.5%

      \[\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*61.9%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
      2. remove-double-neg61.9%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      3. distribute-lft-neg-out61.9%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
      4. distribute-lft-neg-out61.9%

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

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

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right) \cdot {c}^{2}}} \]
      7. distribute-rgt-neg-out61.5%

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
      10. distribute-lft-neg-in64.7%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
      11. distribute-lft-neg-out64.7%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(-\color{blue}{\left(-x \cdot {s}^{2}\right)}\right) \cdot \left(x \cdot {c}^{2}\right)} \]
      12. remove-double-neg64.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.08e-19 < x < 1.59999999999999984e166

    1. Initial program 85.3%

      \[\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*85.4%

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

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
      4. distribute-lft-neg-out85.4%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right)} \cdot x} \]
      5. distribute-rgt-neg-out85.4%

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

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right) \cdot {c}^{2}}} \]
      7. distribute-rgt-neg-out85.3%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(\left(-x\right) \cdot {s}^{2}\right) \cdot x\right)} \cdot {c}^{2}} \]
      8. distribute-lft-neg-out85.3%

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
      10. distribute-lft-neg-in85.4%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
      11. distribute-lft-neg-out85.4%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(-\color{blue}{\left(-x \cdot {s}^{2}\right)}\right) \cdot \left(x \cdot {c}^{2}\right)} \]
      12. remove-double-neg85.4%

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

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

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

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

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

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

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

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

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

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

    if 1.59999999999999984e166 < x

    1. Initial program 68.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. associate-/r*59.7%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
      2. remove-double-neg59.7%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      3. distribute-lft-neg-out59.7%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
      4. distribute-lft-neg-out59.7%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right)} \cdot x} \]
      5. distribute-rgt-neg-out59.7%

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

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right) \cdot {c}^{2}}} \]
      7. distribute-rgt-neg-out68.0%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(\left(-x\right) \cdot {s}^{2}\right) \cdot x\right)} \cdot {c}^{2}} \]
      8. distribute-lft-neg-out68.0%

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
      10. distribute-lft-neg-in72.0%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
      11. distribute-lft-neg-out72.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.08 \cdot 10^{-19}:\\ \;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \frac{\frac{1}{c}}{x \cdot s}\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{+166}:\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(s \cdot c\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{\left(c \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot \left(x \cdot s\right)\right)}\\ \end{array} \]

Alternative 3: 82.1% accurate, 2.7× speedup?

\[\begin{array}{l} [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 0.0125:\\ \;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \frac{\frac{1}{c}}{x \cdot s}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \left(c \cdot \left(c \cdot \left(s \cdot s\right)\right)\right)\right)}\\ \end{array} \end{array} \]
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (if (<= x 0.0125)
   (* (/ 1.0 (* c (* x s))) (/ (/ 1.0 c) (* x s)))
   (/ (cos (* 2.0 x)) (* x (* x (* c (* c (* s s))))))))
assert(c < s);
double code(double x, double c, double s) {
	double tmp;
	if (x <= 0.0125) {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s));
	} else {
		tmp = cos((2.0 * x)) / (x * (x * (c * (c * (s * s)))));
	}
	return tmp;
}
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 <= 0.0125d0) then
        tmp = (1.0d0 / (c * (x * s))) * ((1.0d0 / c) / (x * s))
    else
        tmp = cos((2.0d0 * x)) / (x * (x * (c * (c * (s * s)))))
    end if
    code = tmp
end function
assert c < s;
public static double code(double x, double c, double s) {
	double tmp;
	if (x <= 0.0125) {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s));
	} else {
		tmp = Math.cos((2.0 * x)) / (x * (x * (c * (c * (s * s)))));
	}
	return tmp;
}
[c, s] = sort([c, s])
def code(x, c, s):
	tmp = 0
	if x <= 0.0125:
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s))
	else:
		tmp = math.cos((2.0 * x)) / (x * (x * (c * (c * (s * s)))))
	return tmp
c, s = sort([c, s])
function code(x, c, s)
	tmp = 0.0
	if (x <= 0.0125)
		tmp = Float64(Float64(1.0 / Float64(c * Float64(x * s))) * Float64(Float64(1.0 / c) / Float64(x * s)));
	else
		tmp = Float64(cos(Float64(2.0 * x)) / Float64(x * Float64(x * Float64(c * Float64(c * Float64(s * s))))));
	end
	return tmp
end
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (x <= 0.0125)
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s));
	else
		tmp = cos((2.0 * x)) / (x * (x * (c * (c * (s * s)))));
	end
	tmp_2 = tmp;
end
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := If[LessEqual[x, 0.0125], N[(N[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(x * N[(x * N[(c * N[(c * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.0125:\\
\;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \frac{\frac{1}{c}}{x \cdot s}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 0.012500000000000001

    1. Initial program 62.4%

      \[\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*62.8%

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      3. distribute-lft-neg-out62.8%

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

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

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

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right) \cdot {c}^{2}}} \]
      7. distribute-rgt-neg-out62.4%

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
      10. distribute-lft-neg-in65.4%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
      11. distribute-lft-neg-out65.4%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(-\color{blue}{\left(-x \cdot {s}^{2}\right)}\right) \cdot \left(x \cdot {c}^{2}\right)} \]
      12. remove-double-neg65.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.012500000000000001 < x

    1. Initial program 78.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*74.7%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
      2. remove-double-neg74.7%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      3. distribute-lft-neg-out74.7%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
      4. distribute-lft-neg-out74.7%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right)} \cdot x} \]
      5. distribute-rgt-neg-out74.7%

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

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right) \cdot {c}^{2}}} \]
      7. distribute-rgt-neg-out78.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(\left(-x\right) \cdot {s}^{2}\right) \cdot x\right)} \cdot {c}^{2}} \]
      8. distribute-lft-neg-out78.1%

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
      10. distribute-lft-neg-in79.8%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
      11. distribute-lft-neg-out79.8%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(-\color{blue}{\left(-x \cdot {s}^{2}\right)}\right) \cdot \left(x \cdot {c}^{2}\right)} \]
      12. remove-double-neg79.8%

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

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

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

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

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

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

Alternative 4: 84.4% accurate, 2.7× speedup?

\[\begin{array}{l} [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 10^{-19}:\\ \;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \frac{\frac{1}{c}}{x \cdot s}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(s \cdot c\right)\right)\right)\right)}\\ \end{array} \end{array} \]
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (if (<= x 1e-19)
   (* (/ 1.0 (* c (* x s))) (/ (/ 1.0 c) (* x s)))
   (/ (cos (* 2.0 x)) (* x (* x (* c (* s (* s c))))))))
assert(c < s);
double code(double x, double c, double s) {
	double tmp;
	if (x <= 1e-19) {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s));
	} else {
		tmp = cos((2.0 * x)) / (x * (x * (c * (s * (s * c)))));
	}
	return tmp;
}
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 <= 1d-19) then
        tmp = (1.0d0 / (c * (x * s))) * ((1.0d0 / c) / (x * s))
    else
        tmp = cos((2.0d0 * x)) / (x * (x * (c * (s * (s * c)))))
    end if
    code = tmp
end function
assert c < s;
public static double code(double x, double c, double s) {
	double tmp;
	if (x <= 1e-19) {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s));
	} else {
		tmp = Math.cos((2.0 * x)) / (x * (x * (c * (s * (s * c)))));
	}
	return tmp;
}
[c, s] = sort([c, s])
def code(x, c, s):
	tmp = 0
	if x <= 1e-19:
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s))
	else:
		tmp = math.cos((2.0 * x)) / (x * (x * (c * (s * (s * c)))))
	return tmp
c, s = sort([c, s])
function code(x, c, s)
	tmp = 0.0
	if (x <= 1e-19)
		tmp = Float64(Float64(1.0 / Float64(c * Float64(x * s))) * Float64(Float64(1.0 / c) / Float64(x * s)));
	else
		tmp = Float64(cos(Float64(2.0 * x)) / Float64(x * Float64(x * Float64(c * Float64(s * Float64(s * c))))));
	end
	return tmp
end
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (x <= 1e-19)
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s));
	else
		tmp = cos((2.0 * x)) / (x * (x * (c * (s * (s * c)))));
	end
	tmp_2 = tmp;
end
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := If[LessEqual[x, 1e-19], N[(N[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(x * N[(x * N[(c * N[(s * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{-19}:\\
\;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \frac{\frac{1}{c}}{x \cdot s}\\

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


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

    1. Initial program 61.5%

      \[\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*61.9%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
      2. remove-double-neg61.9%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      3. distribute-lft-neg-out61.9%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
      4. distribute-lft-neg-out61.9%

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

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

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right) \cdot {c}^{2}}} \]
      7. distribute-rgt-neg-out61.5%

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
      10. distribute-lft-neg-in64.7%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
      11. distribute-lft-neg-out64.7%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(-\color{blue}{\left(-x \cdot {s}^{2}\right)}\right) \cdot \left(x \cdot {c}^{2}\right)} \]
      12. remove-double-neg64.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999998e-20 < x

    1. Initial program 78.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. associate-/r*75.9%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
      2. remove-double-neg75.9%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      3. distribute-lft-neg-out75.9%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
      4. distribute-lft-neg-out75.9%

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

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

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right) \cdot {c}^{2}}} \]
      7. distribute-rgt-neg-out78.9%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(\left(-x\right) \cdot {s}^{2}\right) \cdot x\right)} \cdot {c}^{2}} \]
      8. distribute-lft-neg-out78.9%

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
      10. distribute-lft-neg-in80.5%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
      11. distribute-lft-neg-out80.5%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 94.7% accurate, 2.7× speedup?

\[\begin{array}{l} [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{\cos \left(2 \cdot x\right)}{\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)} \end{array} \]
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (/ (cos (* 2.0 x)) (* (* s (* x c)) (* c (* x s)))))
assert(c < s);
double code(double x, double c, double s) {
	return cos((2.0 * x)) / ((s * (x * c)) * (c * (x * s)));
}
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)) / ((s * (x * c)) * (c * (x * s)))
end function
assert c < s;
public static double code(double x, double c, double s) {
	return Math.cos((2.0 * x)) / ((s * (x * c)) * (c * (x * s)));
}
[c, s] = sort([c, s])
def code(x, c, s):
	return math.cos((2.0 * x)) / ((s * (x * c)) * (c * (x * s)))
c, s = sort([c, s])
function code(x, c, s)
	return Float64(cos(Float64(2.0 * x)) / Float64(Float64(s * Float64(x * c)) * Float64(c * Float64(x * s))))
end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = cos((2.0 * x)) / ((s * (x * c)) * (c * (x * s)));
end
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\cos \left(2 \cdot x\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 66.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. associate-/r*65.5%

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

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    3. distribute-lft-neg-out65.5%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
    4. distribute-lft-neg-out65.5%

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right) \cdot {c}^{2}}} \]
    7. distribute-rgt-neg-out66.0%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(\left(-x\right) \cdot {s}^{2}\right) \cdot x\right)} \cdot {c}^{2}} \]
    8. distribute-lft-neg-out66.0%

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
    10. distribute-lft-neg-in68.7%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
    11. distribute-lft-neg-out68.7%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(-\color{blue}{\left(-x \cdot {s}^{2}\right)}\right) \cdot \left(x \cdot {c}^{2}\right)} \]
    12. remove-double-neg68.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 70.8% accurate, 16.4× speedup?

\[\begin{array}{l} [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} \mathbf{if}\;s \leq 7.8 \cdot 10^{-64}:\\ \;\;\;\;\frac{\frac{x \cdot -2 + \frac{1}{x}}{s \cdot s}}{c \cdot \left(x \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \frac{\frac{1}{c}}{x \cdot s}\\ \end{array} \end{array} \]
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (if (<= s 7.8e-64)
   (/ (/ (+ (* x -2.0) (/ 1.0 x)) (* s s)) (* c (* x c)))
   (* (/ 1.0 (* c (* x s))) (/ (/ 1.0 c) (* x s)))))
assert(c < s);
double code(double x, double c, double s) {
	double tmp;
	if (s <= 7.8e-64) {
		tmp = (((x * -2.0) + (1.0 / x)) / (s * s)) / (c * (x * c));
	} else {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s));
	}
	return tmp;
}
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 (s <= 7.8d-64) then
        tmp = (((x * (-2.0d0)) + (1.0d0 / x)) / (s * s)) / (c * (x * c))
    else
        tmp = (1.0d0 / (c * (x * s))) * ((1.0d0 / c) / (x * s))
    end if
    code = tmp
end function
assert c < s;
public static double code(double x, double c, double s) {
	double tmp;
	if (s <= 7.8e-64) {
		tmp = (((x * -2.0) + (1.0 / x)) / (s * s)) / (c * (x * c));
	} else {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s));
	}
	return tmp;
}
[c, s] = sort([c, s])
def code(x, c, s):
	tmp = 0
	if s <= 7.8e-64:
		tmp = (((x * -2.0) + (1.0 / x)) / (s * s)) / (c * (x * c))
	else:
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s))
	return tmp
c, s = sort([c, s])
function code(x, c, s)
	tmp = 0.0
	if (s <= 7.8e-64)
		tmp = Float64(Float64(Float64(Float64(x * -2.0) + Float64(1.0 / x)) / Float64(s * s)) / Float64(c * Float64(x * c)));
	else
		tmp = Float64(Float64(1.0 / Float64(c * Float64(x * s))) * Float64(Float64(1.0 / c) / Float64(x * s)));
	end
	return tmp
end
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (s <= 7.8e-64)
		tmp = (((x * -2.0) + (1.0 / x)) / (s * s)) / (c * (x * c));
	else
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s));
	end
	tmp_2 = tmp;
end
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := If[LessEqual[s, 7.8e-64], N[(N[(N[(N[(x * -2.0), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision] / N[(s * s), $MachinePrecision]), $MachinePrecision] / N[(c * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;s \leq 7.8 \cdot 10^{-64}:\\
\;\;\;\;\frac{\frac{x \cdot -2 + \frac{1}{x}}{s \cdot s}}{c \cdot \left(x \cdot c\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if s < 7.7999999999999994e-64

    1. Initial program 65.3%

      \[\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*65.7%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
      2. remove-double-neg65.7%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      3. distribute-lft-neg-out65.7%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
      4. distribute-lft-neg-out65.7%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right)} \cdot x} \]
      5. distribute-rgt-neg-out65.7%

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

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right) \cdot {c}^{2}}} \]
      7. distribute-rgt-neg-out65.3%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(\left(-x\right) \cdot {s}^{2}\right) \cdot x\right)} \cdot {c}^{2}} \]
      8. distribute-lft-neg-out65.3%

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
      10. distribute-lft-neg-in68.1%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
      11. distribute-lft-neg-out68.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.7999999999999994e-64 < s

    1. Initial program 67.5%

      \[\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.9%

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\left(x \cdot {s}^{2}\right) \cdot x}} \]
      2. remove-double-neg64.9%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      3. distribute-lft-neg-out64.9%

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
      4. distribute-lft-neg-out64.9%

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

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

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right) \cdot {c}^{2}}} \]
      7. distribute-rgt-neg-out67.5%

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
      10. distribute-lft-neg-in70.0%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
      11. distribute-lft-neg-out70.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 78.9% accurate, 20.9× speedup?

\[\begin{array}{l} [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{1}{c \cdot \left(x \cdot s\right)} \cdot \frac{\frac{1}{c}}{x \cdot s} \end{array} \]
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (* (/ 1.0 (* c (* x s))) (/ (/ 1.0 c) (* x s))))
assert(c < s);
double code(double x, double c, double s) {
	return (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s));
}
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 / (c * (x * s))) * ((1.0d0 / c) / (x * s))
end function
assert c < s;
public static double code(double x, double c, double s) {
	return (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s));
}
[c, s] = sort([c, s])
def code(x, c, s):
	return (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s))
c, s = sort([c, s])
function code(x, c, s)
	return Float64(Float64(1.0 / Float64(c * Float64(x * s))) * Float64(Float64(1.0 / c) / Float64(x * s)))
end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s));
end
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(N[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \frac{\frac{1}{c}}{x \cdot s}
\end{array}
Derivation
  1. Initial program 66.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. associate-/r*65.5%

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

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    3. distribute-lft-neg-out65.5%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
    4. distribute-lft-neg-out65.5%

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right) \cdot {c}^{2}}} \]
    7. distribute-rgt-neg-out66.0%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(\left(-x\right) \cdot {s}^{2}\right) \cdot x\right)} \cdot {c}^{2}} \]
    8. distribute-lft-neg-out66.0%

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
    10. distribute-lft-neg-in68.7%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
    11. distribute-lft-neg-out68.7%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(-\color{blue}{\left(-x \cdot {s}^{2}\right)}\right) \cdot \left(x \cdot {c}^{2}\right)} \]
    12. remove-double-neg68.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 75.4% accurate, 24.1× speedup?

\[\begin{array}{l} [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{1}{\left(s \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot \left(x \cdot s\right)\right)} \end{array} \]
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s) :precision binary64 (/ 1.0 (* (* s c) (* (* x c) (* x s)))))
assert(c < s);
double code(double x, double c, double s) {
	return 1.0 / ((s * c) * ((x * c) * (x * s)));
}
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 * c) * ((x * c) * (x * s)))
end function
assert c < s;
public static double code(double x, double c, double s) {
	return 1.0 / ((s * c) * ((x * c) * (x * s)));
}
[c, s] = sort([c, s])
def code(x, c, s):
	return 1.0 / ((s * c) * ((x * c) * (x * s)))
c, s = sort([c, s])
function code(x, c, s)
	return Float64(1.0 / Float64(Float64(s * c) * Float64(Float64(x * c) * Float64(x * s))))
end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = 1.0 / ((s * c) * ((x * c) * (x * s)));
end
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(1.0 / N[(N[(s * c), $MachinePrecision] * N[(N[(x * c), $MachinePrecision] * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{\left(s \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot \left(x \cdot s\right)\right)}
\end{array}
Derivation
  1. Initial program 66.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. associate-/r*65.5%

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

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    3. distribute-lft-neg-out65.5%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
    4. distribute-lft-neg-out65.5%

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right) \cdot {c}^{2}}} \]
    7. distribute-rgt-neg-out66.0%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(\left(-x\right) \cdot {s}^{2}\right) \cdot x\right)} \cdot {c}^{2}} \]
    8. distribute-lft-neg-out66.0%

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
    10. distribute-lft-neg-in68.7%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
    11. distribute-lft-neg-out68.7%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(-\color{blue}{\left(-x \cdot {s}^{2}\right)}\right) \cdot \left(x \cdot {c}^{2}\right)} \]
    12. remove-double-neg68.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 75.4% accurate, 24.1× speedup?

\[\begin{array}{l} [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{\frac{1}{s \cdot c}}{\left(x \cdot c\right) \cdot \left(x \cdot s\right)} \end{array} \]
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s) :precision binary64 (/ (/ 1.0 (* s c)) (* (* x c) (* x s))))
assert(c < s);
double code(double x, double c, double s) {
	return (1.0 / (s * c)) / ((x * c) * (x * s));
}
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 * c)) / ((x * c) * (x * s))
end function
assert c < s;
public static double code(double x, double c, double s) {
	return (1.0 / (s * c)) / ((x * c) * (x * s));
}
[c, s] = sort([c, s])
def code(x, c, s):
	return (1.0 / (s * c)) / ((x * c) * (x * s))
c, s = sort([c, s])
function code(x, c, s)
	return Float64(Float64(1.0 / Float64(s * c)) / Float64(Float64(x * c) * Float64(x * s)))
end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = (1.0 / (s * c)) / ((x * c) * (x * s));
end
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(N[(1.0 / N[(s * c), $MachinePrecision]), $MachinePrecision] / N[(N[(x * c), $MachinePrecision] * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{1}{s \cdot c}}{\left(x \cdot c\right) \cdot \left(x \cdot s\right)}
\end{array}
Derivation
  1. Initial program 66.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. associate-/r*65.5%

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

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    3. distribute-lft-neg-out65.5%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
    4. distribute-lft-neg-out65.5%

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right) \cdot {c}^{2}}} \]
    7. distribute-rgt-neg-out66.0%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(\left(-x\right) \cdot {s}^{2}\right) \cdot x\right)} \cdot {c}^{2}} \]
    8. distribute-lft-neg-out66.0%

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
    10. distribute-lft-neg-in68.7%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
    11. distribute-lft-neg-out68.7%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(-\color{blue}{\left(-x \cdot {s}^{2}\right)}\right) \cdot \left(x \cdot {c}^{2}\right)} \]
    12. remove-double-neg68.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 28.2% accurate, 34.8× speedup?

\[\begin{array}{l} [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{-2}{c \cdot \left(c \cdot \left(s \cdot s\right)\right)} \end{array} \]
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s) :precision binary64 (/ -2.0 (* c (* c (* s s)))))
assert(c < s);
double code(double x, double c, double s) {
	return -2.0 / (c * (c * (s * s)));
}
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 = (-2.0d0) / (c * (c * (s * s)))
end function
assert c < s;
public static double code(double x, double c, double s) {
	return -2.0 / (c * (c * (s * s)));
}
[c, s] = sort([c, s])
def code(x, c, s):
	return -2.0 / (c * (c * (s * s)))
c, s = sort([c, s])
function code(x, c, s)
	return Float64(-2.0 / Float64(c * Float64(c * Float64(s * s))))
end
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = -2.0 / (c * (c * (s * s)));
end
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(-2.0 / N[(c * N[(c * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{-2}{c \cdot \left(c \cdot \left(s \cdot s\right)\right)}
\end{array}
Derivation
  1. Initial program 66.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. associate-/r*65.5%

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

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{\color{blue}{-\left(-\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    3. distribute-lft-neg-out65.5%

      \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{-\color{blue}{\left(-x \cdot {s}^{2}\right) \cdot x}} \]
    4. distribute-lft-neg-out65.5%

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(-x\right)\right) \cdot {c}^{2}}} \]
    7. distribute-rgt-neg-out66.0%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(\left(-x\right) \cdot {s}^{2}\right) \cdot x\right)} \cdot {c}^{2}} \]
    8. distribute-lft-neg-out66.0%

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{-\color{blue}{\left(\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
    10. distribute-lft-neg-in68.7%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(-\left(-x\right) \cdot {s}^{2}\right) \cdot \left(x \cdot {c}^{2}\right)}} \]
    11. distribute-lft-neg-out68.7%

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(-\color{blue}{\left(-x \cdot {s}^{2}\right)}\right) \cdot \left(x \cdot {c}^{2}\right)} \]
    12. remove-double-neg68.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{c \cdot c}}{\left(s \cdot s\right) \cdot \left(x \cdot x\right)} - \color{blue}{\frac{2 \cdot 1}{{c}^{2} \cdot {s}^{2}}} \]
    10. metadata-eval31.7%

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{1}{c \cdot c}}{\left(s \cdot s\right) \cdot \left(x \cdot x\right)} - \frac{2}{\left(s \cdot s\right) \cdot \left(c \cdot c\right)}} \]
  7. Taylor expanded in x around inf 30.9%

    \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
  8. Step-by-step derivation
    1. unpow230.9%

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

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

      \[\leadsto \frac{-2}{c \cdot \left(c \cdot \color{blue}{\left(s \cdot s\right)}\right)} \]
  9. Simplified31.1%

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

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

Reproduce

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