mixedcos

Percentage Accurate: 66.4% → 99.5%
Time: 13.2s
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.4% accurate, 1.0× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(t\_0 \cdot t\_0\right)\\


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

    1. Initial program 67.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{c \cdot \color{blue}{\left(s \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)}} \]
      15. *-commutative44.5%

        \[\leadsto \frac{1}{c \cdot \color{blue}{\left(x \cdot s\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-rr97.4%

      \[\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)}} \]
    5. Step-by-step derivation
      1. associate-*l/97.5%

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

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

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

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

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

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

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

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

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

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

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

    if 8.99999999999999994e36 < x

    1. Initial program 61.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{c \cdot \color{blue}{\left(s \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)}} \]
      15. *-commutative49.1%

        \[\leadsto \frac{1}{c \cdot \color{blue}{\left(x \cdot s\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-rr96.3%

      \[\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)}} \]
    5. Step-by-step derivation
      1. *-commutative96.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 67.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{c \cdot \color{blue}{\left(s \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)}} \]
      15. *-commutative44.7%

        \[\leadsto \frac{1}{c \cdot \color{blue}{\left(x \cdot s\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-rr97.4%

      \[\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)}} \]
    5. Step-by-step derivation
      1. associate-*l/97.5%

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

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

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

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

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

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

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

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

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

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

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

    if 3.3000000000000002e35 < x

    1. Initial program 62.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-identity62.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{c \cdot \color{blue}{\left(s \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)}} \]
      15. *-commutative48.3%

        \[\leadsto \frac{1}{c \cdot \color{blue}{\left(x \cdot s\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-rr96.4%

      \[\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)}} \]
    5. Step-by-step derivation
      1. *-commutative96.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 68.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{c \cdot \color{blue}{\left(s \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)}} \]
      15. *-commutative44.9%

        \[\leadsto \frac{1}{c \cdot \color{blue}{\left(x \cdot s\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-rr97.4%

      \[\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)}} \]
    5. Step-by-step derivation
      1. associate-*l/97.5%

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999914e28 < x

    1. Initial program 61.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{c \cdot \color{blue}{\left(s \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)}} \]
      15. *-commutative47.5%

        \[\leadsto \frac{1}{c \cdot \color{blue}{\left(x \cdot s\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-rr96.5%

      \[\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)}} \]
    5. Step-by-step derivation
      1. *-commutative96.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 68.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-identity68.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{c \cdot \color{blue}{\left(s \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)}} \]
      15. *-commutative45.5%

        \[\leadsto \frac{1}{c \cdot \color{blue}{\left(x \cdot s\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-rr97.3%

      \[\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)}} \]
    5. Taylor expanded in x around 0 86.1%

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

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

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

    if 2.4e-9 < x

    1. Initial program 61.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. Step-by-step derivation
      1. *-un-lft-identity61.2%

        \[\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-sqrt61.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-frac61.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. sqrt-prod61.2%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{c \cdot \color{blue}{\left(s \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)}} \]
      15. *-commutative45.7%

        \[\leadsto \frac{1}{c \cdot \color{blue}{\left(x \cdot s\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-rr96.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 96.8% accurate, 2.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{c \cdot \color{blue}{\left(s \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)}} \]
    15. *-commutative45.5%

      \[\leadsto \frac{1}{c \cdot \color{blue}{\left(x \cdot s\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-rr97.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)}} \]
  5. Step-by-step derivation
    1. associate-*l/97.2%

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

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

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

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

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

Alternative 6: 93.1% accurate, 2.7× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x_m, c_m, s_m] = \mathsf{sort}([x_m, c_m, s_m])\\ \\ \frac{\frac{\cos \left(x\_m \cdot 2\right)}{c\_m}}{\left(x\_m \cdot s\_m\right) \cdot \left(\left(x\_m \cdot s\_m\right) \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
 (/ (/ (cos (* x_m 2.0)) c_m) (* (* x_m s_m) (* (* x_m s_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 (cos((x_m * 2.0)) / c_m) / ((x_m * s_m) * ((x_m * s_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 = (cos((x_m * 2.0d0)) / c_m) / ((x_m * s_m) * ((x_m * s_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 (Math.cos((x_m * 2.0)) / c_m) / ((x_m * s_m) * ((x_m * s_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 (math.cos((x_m * 2.0)) / c_m) / ((x_m * s_m) * ((x_m * s_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(cos(Float64(x_m * 2.0)) / c_m) / Float64(Float64(x_m * s_m) * Float64(Float64(x_m * s_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 = (cos((x_m * 2.0)) / c_m) / ((x_m * s_m) * ((x_m * s_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[(N[Cos[N[(x$95$m * 2.0), $MachinePrecision]], $MachinePrecision] / c$95$m), $MachinePrecision] / N[(N[(x$95$m * s$95$m), $MachinePrecision] * N[(N[(x$95$m * s$95$m), $MachinePrecision] * 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{\cos \left(x\_m \cdot 2\right)}{c\_m}}{\left(x\_m \cdot s\_m\right) \cdot \left(\left(x\_m \cdot s\_m\right) \cdot c\_m\right)}
\end{array}
Derivation
  1. Initial program 66.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{c \cdot \color{blue}{\left(s \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)}} \]
    15. *-commutative45.5%

      \[\leadsto \frac{1}{c \cdot \color{blue}{\left(x \cdot s\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-rr97.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)}} \]
  5. Step-by-step derivation
    1. associate-/r*97.2%

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

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

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

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

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

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

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

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

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

Alternative 7: 79.5% accurate, 20.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{c \cdot \color{blue}{\left(s \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)}} \]
    15. *-commutative45.5%

      \[\leadsto \frac{1}{c \cdot \color{blue}{\left(x \cdot s\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-rr97.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)}} \]
  5. Taylor expanded in x around 0 76.0%

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

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

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

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

Alternative 8: 79.5% accurate, 20.9× 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 := \frac{1}{\left(x\_m \cdot s\_m\right) \cdot c\_m}\\ t\_0 \cdot t\_0 \end{array} \end{array} \]
x_m = (fabs.f64 x)
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x_m, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x_m c_m s_m)
 :precision binary64
 (let* ((t_0 (/ 1.0 (* (* x_m s_m) c_m)))) (* 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 = 1.0 / ((x_m * s_m) * c_m);
	return 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 = 1.0d0 / ((x_m * s_m) * c_m)
    code = 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 = 1.0 / ((x_m * s_m) * c_m);
	return 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 = 1.0 / ((x_m * s_m) * c_m)
	return 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(1.0 / Float64(Float64(x_m * s_m) * c_m))
	return Float64(t_0 * t_0)
end
x_m = abs(x);
c_m = abs(c);
s_m = abs(s);
x_m, c_m, s_m = num2cell(sort([x_m, c_m, s_m])){:}
function tmp = code(x_m, c_m, s_m)
	t_0 = 1.0 / ((x_m * s_m) * c_m);
	tmp = 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[(1.0 / N[(N[(x$95$m * s$95$m), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * 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 := \frac{1}{\left(x\_m \cdot s\_m\right) \cdot c\_m}\\
t\_0 \cdot t\_0
\end{array}
\end{array}
Derivation
  1. Initial program 66.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{c \cdot \color{blue}{\left(s \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)}} \]
    15. *-commutative45.5%

      \[\leadsto \frac{1}{c \cdot \color{blue}{\left(x \cdot s\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-rr97.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)}} \]
  5. Taylor expanded in x around 0 76.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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