mixedcos

Percentage Accurate: 65.6% → 97.3%
Time: 13.3s
Alternatives: 7
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 7 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: 65.6% accurate, 1.0× speedup?

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

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

Alternative 1: 97.3% accurate, 2.6× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\ \\ \begin{array}{l} t_0 := \cos \left(x \cdot 2\right)\\ \mathbf{if}\;c_m \leq 1.7 \cdot 10^{-267}:\\ \;\;\;\;\frac{t_0}{x \cdot \left(\left(c_m \cdot s_m\right) \cdot \left(x \cdot \left(c_m \cdot s_m\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x \cdot s_m}}{c_m} \cdot \frac{t_0}{c_m \cdot \left(x \cdot s_m\right)}\\ \end{array} \end{array} \]
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
 :precision binary64
 (let* ((t_0 (cos (* x 2.0))))
   (if (<= c_m 1.7e-267)
     (/ t_0 (* x (* (* c_m s_m) (* x (* c_m s_m)))))
     (* (/ (/ 1.0 (* x s_m)) c_m) (/ t_0 (* c_m (* x s_m)))))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
	double t_0 = cos((x * 2.0));
	double tmp;
	if (c_m <= 1.7e-267) {
		tmp = t_0 / (x * ((c_m * s_m) * (x * (c_m * s_m))));
	} else {
		tmp = ((1.0 / (x * s_m)) / c_m) * (t_0 / (c_m * (x * s_m)));
	}
	return tmp;
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = cos((x * 2.0d0))
    if (c_m <= 1.7d-267) then
        tmp = t_0 / (x * ((c_m * s_m) * (x * (c_m * s_m))))
    else
        tmp = ((1.0d0 / (x * s_m)) / c_m) * (t_0 / (c_m * (x * s_m)))
    end if
    code = tmp
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
	double t_0 = Math.cos((x * 2.0));
	double tmp;
	if (c_m <= 1.7e-267) {
		tmp = t_0 / (x * ((c_m * s_m) * (x * (c_m * s_m))));
	} else {
		tmp = ((1.0 / (x * s_m)) / c_m) * (t_0 / (c_m * (x * s_m)));
	}
	return tmp;
}
c_m = math.fabs(c)
s_m = math.fabs(s)
[x, c_m, s_m] = sort([x, c_m, s_m])
def code(x, c_m, s_m):
	t_0 = math.cos((x * 2.0))
	tmp = 0
	if c_m <= 1.7e-267:
		tmp = t_0 / (x * ((c_m * s_m) * (x * (c_m * s_m))))
	else:
		tmp = ((1.0 / (x * s_m)) / c_m) * (t_0 / (c_m * (x * s_m)))
	return tmp
c_m = abs(c)
s_m = abs(s)
x, c_m, s_m = sort([x, c_m, s_m])
function code(x, c_m, s_m)
	t_0 = cos(Float64(x * 2.0))
	tmp = 0.0
	if (c_m <= 1.7e-267)
		tmp = Float64(t_0 / Float64(x * Float64(Float64(c_m * s_m) * Float64(x * Float64(c_m * s_m)))));
	else
		tmp = Float64(Float64(Float64(1.0 / Float64(x * s_m)) / c_m) * Float64(t_0 / Float64(c_m * Float64(x * s_m))));
	end
	return tmp
end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
	t_0 = cos((x * 2.0));
	tmp = 0.0;
	if (c_m <= 1.7e-267)
		tmp = t_0 / (x * ((c_m * s_m) * (x * (c_m * s_m))));
	else
		tmp = ((1.0 / (x * s_m)) / c_m) * (t_0 / (c_m * (x * s_m)));
	end
	tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[c$95$m, 1.7e-267], N[(t$95$0 / N[(x * N[(N[(c$95$m * s$95$m), $MachinePrecision] * N[(x * N[(c$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / N[(x * s$95$m), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision] * N[(t$95$0 / N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;c_m \leq 1.7 \cdot 10^{-267}:\\
\;\;\;\;\frac{t_0}{x \cdot \left(\left(c_m \cdot s_m\right) \cdot \left(x \cdot \left(c_m \cdot s_m\right)\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x \cdot s_m}}{c_m} \cdot \frac{t_0}{c_m \cdot \left(x \cdot s_m\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < 1.7000000000000001e-267

    1. Initial program 68.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.7000000000000001e-267 < c

    1. Initial program 66.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. *-un-lft-identity66.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.2% accurate, 2.6× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\ \\ \begin{array}{l} t_0 := c_m \cdot \left(x \cdot s_m\right)\\ t_1 := \cos \left(x \cdot 2\right)\\ \mathbf{if}\;c_m \leq 1.5 \cdot 10^{-267}:\\ \;\;\;\;\frac{t_1}{x \cdot \left(\left(c_m \cdot s_m\right) \cdot \left(x \cdot \left(c_m \cdot s_m\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1}{t_0} \cdot \frac{1}{t_0}\\ \end{array} \end{array} \]
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
 :precision binary64
 (let* ((t_0 (* c_m (* x s_m))) (t_1 (cos (* x 2.0))))
   (if (<= c_m 1.5e-267)
     (/ t_1 (* x (* (* c_m s_m) (* x (* c_m s_m)))))
     (* (/ t_1 t_0) (/ 1.0 t_0)))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
	double t_0 = c_m * (x * s_m);
	double t_1 = cos((x * 2.0));
	double tmp;
	if (c_m <= 1.5e-267) {
		tmp = t_1 / (x * ((c_m * s_m) * (x * (c_m * s_m))));
	} else {
		tmp = (t_1 / t_0) * (1.0 / t_0);
	}
	return tmp;
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s_m
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = c_m * (x * s_m)
    t_1 = cos((x * 2.0d0))
    if (c_m <= 1.5d-267) then
        tmp = t_1 / (x * ((c_m * s_m) * (x * (c_m * s_m))))
    else
        tmp = (t_1 / t_0) * (1.0d0 / t_0)
    end if
    code = tmp
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
	double t_0 = c_m * (x * s_m);
	double t_1 = Math.cos((x * 2.0));
	double tmp;
	if (c_m <= 1.5e-267) {
		tmp = t_1 / (x * ((c_m * s_m) * (x * (c_m * s_m))));
	} else {
		tmp = (t_1 / t_0) * (1.0 / t_0);
	}
	return tmp;
}
c_m = math.fabs(c)
s_m = math.fabs(s)
[x, c_m, s_m] = sort([x, c_m, s_m])
def code(x, c_m, s_m):
	t_0 = c_m * (x * s_m)
	t_1 = math.cos((x * 2.0))
	tmp = 0
	if c_m <= 1.5e-267:
		tmp = t_1 / (x * ((c_m * s_m) * (x * (c_m * s_m))))
	else:
		tmp = (t_1 / t_0) * (1.0 / t_0)
	return tmp
c_m = abs(c)
s_m = abs(s)
x, c_m, s_m = sort([x, c_m, s_m])
function code(x, c_m, s_m)
	t_0 = Float64(c_m * Float64(x * s_m))
	t_1 = cos(Float64(x * 2.0))
	tmp = 0.0
	if (c_m <= 1.5e-267)
		tmp = Float64(t_1 / Float64(x * Float64(Float64(c_m * s_m) * Float64(x * Float64(c_m * s_m)))));
	else
		tmp = Float64(Float64(t_1 / t_0) * Float64(1.0 / t_0));
	end
	return tmp
end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
	t_0 = c_m * (x * s_m);
	t_1 = cos((x * 2.0));
	tmp = 0.0;
	if (c_m <= 1.5e-267)
		tmp = t_1 / (x * ((c_m * s_m) * (x * (c_m * s_m))));
	else
		tmp = (t_1 / t_0) * (1.0 / t_0);
	end
	tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[c$95$m, 1.5e-267], N[(t$95$1 / N[(x * N[(N[(c$95$m * s$95$m), $MachinePrecision] * N[(x * N[(c$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 / t$95$0), $MachinePrecision] * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := c_m \cdot \left(x \cdot s_m\right)\\
t_1 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;c_m \leq 1.5 \cdot 10^{-267}:\\
\;\;\;\;\frac{t_1}{x \cdot \left(\left(c_m \cdot s_m\right) \cdot \left(x \cdot \left(c_m \cdot s_m\right)\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{t_1}{t_0} \cdot \frac{1}{t_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < 1.5e-267

    1. Initial program 68.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.5e-267 < c

    1. Initial program 66.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. *-un-lft-identity66.4%

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

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

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

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

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

Alternative 3: 87.7% accurate, 2.7× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 1.25 \cdot 10^{-103}:\\ \;\;\;\;\frac{\frac{1}{x \cdot s_m}}{c_m} \cdot \frac{1}{c_m \cdot \left(x \cdot s_m\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{s_m \cdot \left(\left(x \cdot \left(c_m \cdot s_m\right)\right) \cdot \left(x \cdot c_m\right)\right)}\\ \end{array} \end{array} \]
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
 :precision binary64
 (if (<= x 1.25e-103)
   (* (/ (/ 1.0 (* x s_m)) c_m) (/ 1.0 (* c_m (* x s_m))))
   (/ (cos (* x 2.0)) (* s_m (* (* x (* c_m s_m)) (* x c_m))))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
	double tmp;
	if (x <= 1.25e-103) {
		tmp = ((1.0 / (x * s_m)) / c_m) * (1.0 / (c_m * (x * s_m)));
	} else {
		tmp = cos((x * 2.0)) / (s_m * ((x * (c_m * s_m)) * (x * c_m)));
	}
	return tmp;
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s_m
    real(8) :: tmp
    if (x <= 1.25d-103) then
        tmp = ((1.0d0 / (x * s_m)) / c_m) * (1.0d0 / (c_m * (x * s_m)))
    else
        tmp = cos((x * 2.0d0)) / (s_m * ((x * (c_m * s_m)) * (x * c_m)))
    end if
    code = tmp
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
	double tmp;
	if (x <= 1.25e-103) {
		tmp = ((1.0 / (x * s_m)) / c_m) * (1.0 / (c_m * (x * s_m)));
	} else {
		tmp = Math.cos((x * 2.0)) / (s_m * ((x * (c_m * s_m)) * (x * c_m)));
	}
	return tmp;
}
c_m = math.fabs(c)
s_m = math.fabs(s)
[x, c_m, s_m] = sort([x, c_m, s_m])
def code(x, c_m, s_m):
	tmp = 0
	if x <= 1.25e-103:
		tmp = ((1.0 / (x * s_m)) / c_m) * (1.0 / (c_m * (x * s_m)))
	else:
		tmp = math.cos((x * 2.0)) / (s_m * ((x * (c_m * s_m)) * (x * c_m)))
	return tmp
c_m = abs(c)
s_m = abs(s)
x, c_m, s_m = sort([x, c_m, s_m])
function code(x, c_m, s_m)
	tmp = 0.0
	if (x <= 1.25e-103)
		tmp = Float64(Float64(Float64(1.0 / Float64(x * s_m)) / c_m) * Float64(1.0 / Float64(c_m * Float64(x * s_m))));
	else
		tmp = Float64(cos(Float64(x * 2.0)) / Float64(s_m * Float64(Float64(x * Float64(c_m * s_m)) * Float64(x * c_m))));
	end
	return tmp
end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
	tmp = 0.0;
	if (x <= 1.25e-103)
		tmp = ((1.0 / (x * s_m)) / c_m) * (1.0 / (c_m * (x * s_m)));
	else
		tmp = cos((x * 2.0)) / (s_m * ((x * (c_m * s_m)) * (x * c_m)));
	end
	tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := If[LessEqual[x, 1.25e-103], N[(N[(N[(1.0 / N[(x * s$95$m), $MachinePrecision]), $MachinePrecision] / c$95$m), $MachinePrecision] * N[(1.0 / N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(s$95$m * N[(N[(x * N[(c$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] * N[(x * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.25 \cdot 10^{-103}:\\
\;\;\;\;\frac{\frac{1}{x \cdot s_m}}{c_m} \cdot \frac{1}{c_m \cdot \left(x \cdot s_m\right)}\\

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


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

    1. Initial program 68.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{c \cdot \left(x \cdot s\right)}}{c \cdot \left(x \cdot s\right)}} \]
      6. un-div-inv81.6%

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

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

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

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

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

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

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

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

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

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

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

    if 1.24999999999999992e-103 < x

    1. Initial program 66.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. *-un-lft-identity66.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 96.7% accurate, 2.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 75.2% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 78.7% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 77.6% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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