mixedcos

Percentage Accurate: 67.3% → 99.3%
Time: 11.9s
Alternatives: 9
Speedup: 24.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 67.3% accurate, 1.0× speedup?

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

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

Alternative 1: 99.3% accurate, 1.5× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{{\left(s\_m \cdot \left(x\_m \cdot c\_m\right)\right)}^{2}}\\


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

    1. Initial program 67.4%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt67.4%

        \[\leadsto \frac{\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)}}} \]
      2. associate-/r*67.3%

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

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

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

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

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

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

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

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

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

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

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

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

    if 220 < x

    1. Initial program 64.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.4% accurate, 1.4× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (pow.f64 s #s(literal 2 binary64)) < 5.0000000000000002e-62

    1. Initial program 60.9%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt60.9%

        \[\leadsto \frac{\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)}}} \]
      2. associate-/r*60.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000002e-62 < (pow.f64 s #s(literal 2 binary64))

    1. Initial program 71.5%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt71.4%

        \[\leadsto \frac{\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)}}} \]
      2. associate-/r*71.4%

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

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

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

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

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

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

Alternative 3: 98.4% accurate, 2.6× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_1}{t\_0}}{t\_0}\\


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

    1. Initial program 66.9%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt66.8%

        \[\leadsto \frac{\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)}}} \]
      2. associate-/r*66.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.9000000000000003e-14 < s

    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. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt65.9%

        \[\leadsto \frac{\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)}}} \]
      2. associate-/r*65.9%

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

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

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

Alternative 4: 98.4% accurate, 2.6× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_1}{t\_0}}{t\_0}\\


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

    1. Initial program 66.9%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt66.8%

        \[\leadsto \frac{\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)}}} \]
      2. associate-/r*66.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999999e-15 < s

    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. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt65.9%

        \[\leadsto \frac{\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)}}} \]
      2. associate-/r*65.9%

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

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

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

Alternative 5: 97.3% accurate, 2.7× speedup?

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

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-sqr-sqrt66.6%

      \[\leadsto \frac{\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)}}} \]
    2. associate-/r*66.6%

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

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

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

Alternative 6: 97.0% accurate, 2.7× speedup?

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

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. *-commutative66.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(\color{blue}{x} \cdot \sqrt{{c}^{2} \cdot {s}^{2}}\right)} \]
    19. pow-prod-down57.7%

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

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

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

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

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

    \[\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)} \]
  6. Add Preprocessing

Alternative 7: 80.6% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 79.9% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 79.5% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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