mixedcos

Percentage Accurate: 66.5% → 99.3%
Time: 14.8s
Alternatives: 9
Speedup: 24.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 66.5% accurate, 1.0× speedup?

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

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

Alternative 1: 99.3% accurate, 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 := s_m \cdot \left(x_m \cdot c_m\right)\\ t_1 := \cos \left(x_m \cdot 2\right)\\ \mathbf{if}\;x_m \leq 2.8 \cdot 10^{+41}:\\ \;\;\;\;{\left(c_m \cdot \left(x_m \cdot s_m\right)\right)}^{-2} \cdot t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{t_0 \cdot t_0}{t_1}}\\ \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 (* s_m (* x_m c_m))) (t_1 (cos (* x_m 2.0))))
   (if (<= x_m 2.8e+41)
     (* (pow (* c_m (* x_m s_m)) -2.0) t_1)
     (/ 1.0 (/ (* t_0 t_0) t_1)))))
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 = s_m * (x_m * c_m);
	double t_1 = cos((x_m * 2.0));
	double tmp;
	if (x_m <= 2.8e+41) {
		tmp = pow((c_m * (x_m * s_m)), -2.0) * t_1;
	} else {
		tmp = 1.0 / ((t_0 * t_0) / t_1);
	}
	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 = s_m * (x_m * c_m)
    t_1 = cos((x_m * 2.0d0))
    if (x_m <= 2.8d+41) then
        tmp = ((c_m * (x_m * s_m)) ** (-2.0d0)) * t_1
    else
        tmp = 1.0d0 / ((t_0 * t_0) / t_1)
    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 = s_m * (x_m * c_m);
	double t_1 = Math.cos((x_m * 2.0));
	double tmp;
	if (x_m <= 2.8e+41) {
		tmp = Math.pow((c_m * (x_m * s_m)), -2.0) * t_1;
	} else {
		tmp = 1.0 / ((t_0 * t_0) / t_1);
	}
	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 = s_m * (x_m * c_m)
	t_1 = math.cos((x_m * 2.0))
	tmp = 0
	if x_m <= 2.8e+41:
		tmp = math.pow((c_m * (x_m * s_m)), -2.0) * t_1
	else:
		tmp = 1.0 / ((t_0 * t_0) / t_1)
	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(s_m * Float64(x_m * c_m))
	t_1 = cos(Float64(x_m * 2.0))
	tmp = 0.0
	if (x_m <= 2.8e+41)
		tmp = Float64((Float64(c_m * Float64(x_m * s_m)) ^ -2.0) * t_1);
	else
		tmp = Float64(1.0 / Float64(Float64(t_0 * t_0) / t_1));
	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 = s_m * (x_m * c_m);
	t_1 = cos((x_m * 2.0));
	tmp = 0.0;
	if (x_m <= 2.8e+41)
		tmp = ((c_m * (x_m * s_m)) ^ -2.0) * t_1;
	else
		tmp = 1.0 / ((t_0 * t_0) / t_1);
	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[(s$95$m * N[(x$95$m * c$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x$95$m, 2.8e+41], N[(N[Power[N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision] * t$95$1), $MachinePrecision], N[(1.0 / N[(N[(t$95$0 * t$95$0), $MachinePrecision] / t$95$1), $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 := s_m \cdot \left(x_m \cdot c_m\right)\\
t_1 := \cos \left(x_m \cdot 2\right)\\
\mathbf{if}\;x_m \leq 2.8 \cdot 10^{+41}:\\
\;\;\;\;{\left(c_m \cdot \left(x_m \cdot s_m\right)\right)}^{-2} \cdot t_1\\

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


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

    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. Add Preprocessing
    3. 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. associate-*r*67.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1 \cdot \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)}} \]
      9. swap-sqr98.2%

        \[\leadsto \frac{1 \cdot \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)}} \]
      10. associate-*r*94.1%

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

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

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

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

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

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

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

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

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

    if 2.7999999999999999e41 < x

    1. Initial program 56.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. *-un-lft-identity56.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. associate-*r*56.7%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.0% 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 := c_m \cdot \left(x_m \cdot s_m\right)\\ \mathbf{if}\;x_m \leq 1.6 \cdot 10^{+33}:\\ \;\;\;\;\frac{1}{t_0} \cdot \frac{\cos \left(x_m \cdot 2\right)}{t_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x_m \cdot -2\right)}{s_m \cdot \left(\left(x_m \cdot c_m\right) \cdot \left(s_m \cdot \left(x_m \cdot c_m\right)\right)\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 (* c_m (* x_m s_m))))
   (if (<= x_m 1.6e+33)
     (* (/ 1.0 t_0) (/ (cos (* x_m 2.0)) t_0))
     (/ (cos (* x_m -2.0)) (* s_m (* (* x_m c_m) (* s_m (* x_m c_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 = c_m * (x_m * s_m);
	double tmp;
	if (x_m <= 1.6e+33) {
		tmp = (1.0 / t_0) * (cos((x_m * 2.0)) / t_0);
	} else {
		tmp = cos((x_m * -2.0)) / (s_m * ((x_m * c_m) * (s_m * (x_m * c_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 = c_m * (x_m * s_m)
    if (x_m <= 1.6d+33) then
        tmp = (1.0d0 / t_0) * (cos((x_m * 2.0d0)) / t_0)
    else
        tmp = cos((x_m * (-2.0d0))) / (s_m * ((x_m * c_m) * (s_m * (x_m * c_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 = c_m * (x_m * s_m);
	double tmp;
	if (x_m <= 1.6e+33) {
		tmp = (1.0 / t_0) * (Math.cos((x_m * 2.0)) / t_0);
	} else {
		tmp = Math.cos((x_m * -2.0)) / (s_m * ((x_m * c_m) * (s_m * (x_m * c_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 = c_m * (x_m * s_m)
	tmp = 0
	if x_m <= 1.6e+33:
		tmp = (1.0 / t_0) * (math.cos((x_m * 2.0)) / t_0)
	else:
		tmp = math.cos((x_m * -2.0)) / (s_m * ((x_m * c_m) * (s_m * (x_m * c_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 = Float64(c_m * Float64(x_m * s_m))
	tmp = 0.0
	if (x_m <= 1.6e+33)
		tmp = Float64(Float64(1.0 / t_0) * Float64(cos(Float64(x_m * 2.0)) / t_0));
	else
		tmp = Float64(cos(Float64(x_m * -2.0)) / Float64(s_m * Float64(Float64(x_m * c_m) * Float64(s_m * Float64(x_m * c_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 = c_m * (x_m * s_m);
	tmp = 0.0;
	if (x_m <= 1.6e+33)
		tmp = (1.0 / t_0) * (cos((x_m * 2.0)) / t_0);
	else
		tmp = cos((x_m * -2.0)) / (s_m * ((x_m * c_m) * (s_m * (x_m * c_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[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$95$m, 1.6e+33], N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x$95$m * -2.0), $MachinePrecision]], $MachinePrecision] / N[(s$95$m * N[(N[(x$95$m * c$95$m), $MachinePrecision] * N[(s$95$m * N[(x$95$m * c$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])\\
\\
\begin{array}{l}
t_0 := c_m \cdot \left(x_m \cdot s_m\right)\\
\mathbf{if}\;x_m \leq 1.6 \cdot 10^{+33}:\\
\;\;\;\;\frac{1}{t_0} \cdot \frac{\cos \left(x_m \cdot 2\right)}{t_0}\\

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


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

    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. Add Preprocessing
    3. 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.2%

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

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

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

    if 1.60000000000000009e33 < x

    1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(x \cdot -2\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 50.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\cos \left(x \cdot -2\right)}{\left(\left(\color{blue}{\left(s \cdot c\right)} \cdot x\right) \cdot \left(c \cdot x\right)\right) \cdot s} \]
      9. associate-*r*91.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} \]
    9. Applied egg-rr91.6%

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

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

Alternative 3: 94.2% 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 := c_m \cdot \left(x_m \cdot s_m\right)\\ \mathbf{if}\;x_m \leq 4 \cdot 10^{-25}:\\ \;\;\;\;{t_0}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x_m \cdot -2\right)}{x_m \cdot \left(t_0 \cdot \left(c_m \cdot s_m\right)\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 (* c_m (* x_m s_m))))
   (if (<= x_m 4e-25)
     (pow t_0 -2.0)
     (/ (cos (* x_m -2.0)) (* x_m (* t_0 (* 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 = c_m * (x_m * s_m);
	double tmp;
	if (x_m <= 4e-25) {
		tmp = pow(t_0, -2.0);
	} else {
		tmp = cos((x_m * -2.0)) / (x_m * (t_0 * (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 = c_m * (x_m * s_m)
    if (x_m <= 4d-25) then
        tmp = t_0 ** (-2.0d0)
    else
        tmp = cos((x_m * (-2.0d0))) / (x_m * (t_0 * (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 = c_m * (x_m * s_m);
	double tmp;
	if (x_m <= 4e-25) {
		tmp = Math.pow(t_0, -2.0);
	} else {
		tmp = Math.cos((x_m * -2.0)) / (x_m * (t_0 * (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 = c_m * (x_m * s_m)
	tmp = 0
	if x_m <= 4e-25:
		tmp = math.pow(t_0, -2.0)
	else:
		tmp = math.cos((x_m * -2.0)) / (x_m * (t_0 * (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 = Float64(c_m * Float64(x_m * s_m))
	tmp = 0.0
	if (x_m <= 4e-25)
		tmp = t_0 ^ -2.0;
	else
		tmp = Float64(cos(Float64(x_m * -2.0)) / Float64(x_m * Float64(t_0 * 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 = c_m * (x_m * s_m);
	tmp = 0.0;
	if (x_m <= 4e-25)
		tmp = t_0 ^ -2.0;
	else
		tmp = cos((x_m * -2.0)) / (x_m * (t_0 * (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[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$95$m, 4e-25], N[Power[t$95$0, -2.0], $MachinePrecision], N[(N[Cos[N[(x$95$m * -2.0), $MachinePrecision]], $MachinePrecision] / N[(x$95$m * N[(t$95$0 * N[(c$95$m * s$95$m), $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])\\
\\
\begin{array}{l}
t_0 := c_m \cdot \left(x_m \cdot s_m\right)\\
\mathbf{if}\;x_m \leq 4 \cdot 10^{-25}:\\
\;\;\;\;{t_0}^{-2}\\

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


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

    1. Initial program 67.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(x \cdot -2\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 60.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
      15. /-rgt-identity82.0%

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

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

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

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

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

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

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

    if 4.00000000000000015e-25 < x

    1. Initial program 55.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(x \cdot -2\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 49.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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)}} \]
      5. associate-*r*95.1%

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

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

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

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

        \[\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} \]
      10. *-commutative91.1%

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

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

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

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

Alternative 4: 94.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} \mathbf{if}\;x_m \leq 3.3 \cdot 10^{-22}:\\ \;\;\;\;{\left(c_m \cdot \left(x_m \cdot s_m\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x_m \cdot -2\right)}{\left(x_m \cdot s_m\right) \cdot \left(c_m \cdot \left(s_m \cdot \left(x_m \cdot c_m\right)\right)\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
 (if (<= x_m 3.3e-22)
   (pow (* c_m (* x_m s_m)) -2.0)
   (/ (cos (* x_m -2.0)) (* (* x_m s_m) (* c_m (* s_m (* x_m c_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 tmp;
	if (x_m <= 3.3e-22) {
		tmp = pow((c_m * (x_m * s_m)), -2.0);
	} else {
		tmp = cos((x_m * -2.0)) / ((x_m * s_m) * (c_m * (s_m * (x_m * c_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) :: tmp
    if (x_m <= 3.3d-22) then
        tmp = (c_m * (x_m * s_m)) ** (-2.0d0)
    else
        tmp = cos((x_m * (-2.0d0))) / ((x_m * s_m) * (c_m * (s_m * (x_m * c_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 tmp;
	if (x_m <= 3.3e-22) {
		tmp = Math.pow((c_m * (x_m * s_m)), -2.0);
	} else {
		tmp = Math.cos((x_m * -2.0)) / ((x_m * s_m) * (c_m * (s_m * (x_m * c_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):
	tmp = 0
	if x_m <= 3.3e-22:
		tmp = math.pow((c_m * (x_m * s_m)), -2.0)
	else:
		tmp = math.cos((x_m * -2.0)) / ((x_m * s_m) * (c_m * (s_m * (x_m * c_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)
	tmp = 0.0
	if (x_m <= 3.3e-22)
		tmp = Float64(c_m * Float64(x_m * s_m)) ^ -2.0;
	else
		tmp = Float64(cos(Float64(x_m * -2.0)) / Float64(Float64(x_m * s_m) * Float64(c_m * Float64(s_m * Float64(x_m * c_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)
	tmp = 0.0;
	if (x_m <= 3.3e-22)
		tmp = (c_m * (x_m * s_m)) ^ -2.0;
	else
		tmp = cos((x_m * -2.0)) / ((x_m * s_m) * (c_m * (s_m * (x_m * c_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_] := If[LessEqual[x$95$m, 3.3e-22], N[Power[N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(x$95$m * -2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(x$95$m * s$95$m), $MachinePrecision] * N[(c$95$m * N[(s$95$m * N[(x$95$m * c$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])\\
\\
\begin{array}{l}
\mathbf{if}\;x_m \leq 3.3 \cdot 10^{-22}:\\
\;\;\;\;{\left(c_m \cdot \left(x_m \cdot s_m\right)\right)}^{-2}\\

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


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

    1. Initial program 67.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(x \cdot -2\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 60.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
      15. /-rgt-identity82.0%

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

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

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

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

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

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

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

    if 3.3000000000000001e-22 < x

    1. Initial program 55.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(x \cdot -2\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 49.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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)}} \]
      5. associate-*r*93.9%

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

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

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

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

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

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

Alternative 5: 97.7% 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} \mathbf{if}\;x_m \leq 2.25 \cdot 10^{-23}:\\ \;\;\;\;{\left(c_m \cdot \left(x_m \cdot s_m\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x_m \cdot -2\right)}{\left(x_m \cdot c_m\right) \cdot \left(s_m \cdot \left(s_m \cdot \left(x_m \cdot c_m\right)\right)\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
 (if (<= x_m 2.25e-23)
   (pow (* c_m (* x_m s_m)) -2.0)
   (/ (cos (* x_m -2.0)) (* (* x_m c_m) (* s_m (* s_m (* x_m c_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 tmp;
	if (x_m <= 2.25e-23) {
		tmp = pow((c_m * (x_m * s_m)), -2.0);
	} else {
		tmp = cos((x_m * -2.0)) / ((x_m * c_m) * (s_m * (s_m * (x_m * c_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) :: tmp
    if (x_m <= 2.25d-23) then
        tmp = (c_m * (x_m * s_m)) ** (-2.0d0)
    else
        tmp = cos((x_m * (-2.0d0))) / ((x_m * c_m) * (s_m * (s_m * (x_m * c_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 tmp;
	if (x_m <= 2.25e-23) {
		tmp = Math.pow((c_m * (x_m * s_m)), -2.0);
	} else {
		tmp = Math.cos((x_m * -2.0)) / ((x_m * c_m) * (s_m * (s_m * (x_m * c_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):
	tmp = 0
	if x_m <= 2.25e-23:
		tmp = math.pow((c_m * (x_m * s_m)), -2.0)
	else:
		tmp = math.cos((x_m * -2.0)) / ((x_m * c_m) * (s_m * (s_m * (x_m * c_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)
	tmp = 0.0
	if (x_m <= 2.25e-23)
		tmp = Float64(c_m * Float64(x_m * s_m)) ^ -2.0;
	else
		tmp = Float64(cos(Float64(x_m * -2.0)) / Float64(Float64(x_m * c_m) * Float64(s_m * Float64(s_m * Float64(x_m * c_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)
	tmp = 0.0;
	if (x_m <= 2.25e-23)
		tmp = (c_m * (x_m * s_m)) ^ -2.0;
	else
		tmp = cos((x_m * -2.0)) / ((x_m * c_m) * (s_m * (s_m * (x_m * c_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_] := If[LessEqual[x$95$m, 2.25e-23], N[Power[N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(x$95$m * -2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(x$95$m * c$95$m), $MachinePrecision] * N[(s$95$m * N[(s$95$m * N[(x$95$m * c$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])\\
\\
\begin{array}{l}
\mathbf{if}\;x_m \leq 2.25 \cdot 10^{-23}:\\
\;\;\;\;{\left(c_m \cdot \left(x_m \cdot s_m\right)\right)}^{-2}\\

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


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

    1. Initial program 67.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(x \cdot -2\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 60.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
      15. /-rgt-identity82.0%

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

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

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

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

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

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

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

    if 2.24999999999999987e-23 < x

    1. Initial program 55.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(x \cdot -2\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 49.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(x \cdot -2\right)}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
    8. Step-by-step derivation
      1. unpow293.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. associate-*r*92.5%

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

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

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

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

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

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

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

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

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

Alternative 6: 98.7% 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} \mathbf{if}\;x_m \leq 4.8 \cdot 10^{-21}:\\ \;\;\;\;{\left(c_m \cdot \left(x_m \cdot s_m\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x_m \cdot -2\right)}{s_m \cdot \left(\left(x_m \cdot c_m\right) \cdot \left(s_m \cdot \left(x_m \cdot c_m\right)\right)\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
 (if (<= x_m 4.8e-21)
   (pow (* c_m (* x_m s_m)) -2.0)
   (/ (cos (* x_m -2.0)) (* s_m (* (* x_m c_m) (* s_m (* x_m c_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 tmp;
	if (x_m <= 4.8e-21) {
		tmp = pow((c_m * (x_m * s_m)), -2.0);
	} else {
		tmp = cos((x_m * -2.0)) / (s_m * ((x_m * c_m) * (s_m * (x_m * c_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) :: tmp
    if (x_m <= 4.8d-21) then
        tmp = (c_m * (x_m * s_m)) ** (-2.0d0)
    else
        tmp = cos((x_m * (-2.0d0))) / (s_m * ((x_m * c_m) * (s_m * (x_m * c_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 tmp;
	if (x_m <= 4.8e-21) {
		tmp = Math.pow((c_m * (x_m * s_m)), -2.0);
	} else {
		tmp = Math.cos((x_m * -2.0)) / (s_m * ((x_m * c_m) * (s_m * (x_m * c_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):
	tmp = 0
	if x_m <= 4.8e-21:
		tmp = math.pow((c_m * (x_m * s_m)), -2.0)
	else:
		tmp = math.cos((x_m * -2.0)) / (s_m * ((x_m * c_m) * (s_m * (x_m * c_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)
	tmp = 0.0
	if (x_m <= 4.8e-21)
		tmp = Float64(c_m * Float64(x_m * s_m)) ^ -2.0;
	else
		tmp = Float64(cos(Float64(x_m * -2.0)) / Float64(s_m * Float64(Float64(x_m * c_m) * Float64(s_m * Float64(x_m * c_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)
	tmp = 0.0;
	if (x_m <= 4.8e-21)
		tmp = (c_m * (x_m * s_m)) ^ -2.0;
	else
		tmp = cos((x_m * -2.0)) / (s_m * ((x_m * c_m) * (s_m * (x_m * c_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_] := If[LessEqual[x$95$m, 4.8e-21], N[Power[N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(x$95$m * -2.0), $MachinePrecision]], $MachinePrecision] / N[(s$95$m * N[(N[(x$95$m * c$95$m), $MachinePrecision] * N[(s$95$m * N[(x$95$m * c$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])\\
\\
\begin{array}{l}
\mathbf{if}\;x_m \leq 4.8 \cdot 10^{-21}:\\
\;\;\;\;{\left(c_m \cdot \left(x_m \cdot s_m\right)\right)}^{-2}\\

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


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

    1. Initial program 66.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(x \cdot -2\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 60.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.7999999999999999e-21 < x

    1. Initial program 56.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(x \cdot -2\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 50.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(x \cdot -2\right)}{{\left(s \cdot \left(c \cdot x\right)\right)}^{2}}} \]
    8. Step-by-step derivation
      1. unpow293.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. associate-*r*92.4%

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

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

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

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

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

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

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

        \[\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} \]
    9. Applied egg-rr92.3%

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

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

Alternative 7: 79.6% accurate, 3.0× 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])\\ \\ {\left(c_m \cdot \left(x_m \cdot s_m\right)\right)}^{-2} \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 (pow (* c_m (* x_m s_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) {
	return pow((c_m * (x_m * s_m)), -2.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
    code = (c_m * (x_m * s_m)) ** (-2.0d0)
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 Math.pow((c_m * (x_m * s_m)), -2.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):
	return math.pow((c_m * (x_m * s_m)), -2.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)
	return Float64(c_m * Float64(x_m * s_m)) ^ -2.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)
	tmp = (c_m * (x_m * s_m)) ^ -2.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_] := N[Power[N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision], -2.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])\\
\\
{\left(c_m \cdot \left(x_m \cdot s_m\right)\right)}^{-2}
\end{array}
Derivation
  1. Initial program 64.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\cos \left(x \cdot -2\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in x around inf 58.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{\left(c \cdot \left(s \cdot x\right)\right)}^{-2}} \]
  11. Final simplification76.8%

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

Alternative 8: 74.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])\\ \\ \frac{\frac{1}{s_m}}{\left(c_m \cdot \left(x_m \cdot s_m\right)\right) \cdot \left(x_m \cdot c_m\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 s_m) (* (* c_m (* x_m s_m)) (* x_m c_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 / s_m) / ((c_m * (x_m * s_m)) * (x_m * c_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 / s_m) / ((c_m * (x_m * s_m)) * (x_m * c_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 / s_m) / ((c_m * (x_m * s_m)) * (x_m * c_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 / s_m) / ((c_m * (x_m * s_m)) * (x_m * c_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(Float64(1.0 / s_m) / Float64(Float64(c_m * Float64(x_m * s_m)) * Float64(x_m * c_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 / s_m) / ((c_m * (x_m * s_m)) * (x_m * c_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[(N[(1.0 / s$95$m), $MachinePrecision] / N[(N[(c$95$m * N[(x$95$m * s$95$m), $MachinePrecision]), $MachinePrecision] * N[(x$95$m * c$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])\\
\\
\frac{\frac{1}{s_m}}{\left(c_m \cdot \left(x_m \cdot s_m\right)\right) \cdot \left(x_m \cdot c_m\right)}
\end{array}
Derivation
  1. Initial program 64.2%

    \[\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 51.8%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot {\left(x \cdot s\right)}^{2}} \]
    9. unpow262.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.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 79.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 64.2%

    \[\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 51.8%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot {\left(x \cdot s\right)}^{2}} \]
    9. unpow262.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.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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