mixedcos

Percentage Accurate: 66.3% → 98.1%
Time: 13.5s
Alternatives: 13
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 13 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.3% accurate, 1.0× speedup?

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

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

Alternative 1: 98.1% accurate, 1.0× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (pow.f64 c #s(literal 2 binary64)) < 4.00000000000000019e26

    1. Initial program 67.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. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({c}^{2} \cdot \left(\left({s}^{2} \cdot x\right) \cdot x\right)\right)\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({c}^{2} \cdot \left({s}^{2} \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \]
      4. pow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\left(c \cdot s\right)}^{2} \cdot \left(\color{blue}{x} \cdot x\right)\right)\right) \]
      5. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\left(c \cdot s\right)}^{2} \cdot {x}^{\color{blue}{2}}\right)\right) \]
      6. pow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\left(\left(c \cdot s\right) \cdot x\right)}^{\color{blue}{2}}\right)\right) \]
      7. pow-lowering-pow.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{pow.f64}\left(\left(\left(c \cdot s\right) \cdot x\right), \color{blue}{2}\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\left(c \cdot s\right), x\right), 2\right)\right) \]
      9. *-lowering-*.f6497.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(c, s\right), x\right), 2\right)\right) \]
    4. Applied egg-rr97.9%

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

    if 4.00000000000000019e26 < (pow.f64 c #s(literal 2 binary64))

    1. Initial program 62.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. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({c}^{2} \cdot \left(\left({s}^{2} \cdot x\right) \cdot x\right)\right)\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({c}^{2} \cdot \left({s}^{2} \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \]
      4. pow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\left(c \cdot s\right)}^{2} \cdot \left(\color{blue}{x} \cdot x\right)\right)\right) \]
      5. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\left(c \cdot s\right)}^{2} \cdot {x}^{\color{blue}{2}}\right)\right) \]
      6. pow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\left(\left(c \cdot s\right) \cdot x\right)}^{\color{blue}{2}}\right)\right) \]
      7. pow-lowering-pow.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{pow.f64}\left(\left(\left(c \cdot s\right) \cdot x\right), \color{blue}{2}\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\left(c \cdot s\right), x\right), 2\right)\right) \]
      9. *-lowering-*.f6494.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(c, s\right), x\right), 2\right)\right) \]
    4. Applied egg-rr94.4%

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right) \cdot 1}{{\left(c \cdot \left(s \cdot x\right)\right)}^{2}} \]
      3. unpow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right) \cdot 1}{{c}^{2} \cdot \color{blue}{{\left(s \cdot x\right)}^{2}}} \]
      4. pow2N/A

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{c \cdot c} \cdot \color{blue}{\frac{1}{{\left(s \cdot x\right)}^{2}}} \]
      6. pow2N/A

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{c \cdot c} \cdot \frac{1}{x \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}} \]
      9. times-fracN/A

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right) \cdot 1}{\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}} \]
      11. times-fracN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(c \cdot c\right) \cdot x} \cdot \color{blue}{\frac{1}{s \cdot \left(s \cdot x\right)}} \]
      12. div-invN/A

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{\left(c \cdot c\right) \cdot x}}{\color{blue}{s \cdot \left(s \cdot x\right)}} \]
      13. /-lowering-/.f64N/A

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

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

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

Alternative 2: 88.5% accurate, 2.5× speedup?

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

\mathbf{elif}\;x \leq 7 \cdot 10^{+170}:\\
\;\;\;\;\frac{t\_0}{s\_m \cdot \left(c\_m \cdot \left(x \cdot \left(x \cdot \left(c\_m \cdot s\_m\right)\right)\right)\right)}\\

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


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

    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. Taylor expanded in x around 0

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

        \[\leadsto \frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}} \]
      2. unpow2N/A

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

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

        \[\leadsto \frac{\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}}{\color{blue}{x}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}\right), \color{blue}{x}\right) \]
      6. associate-/r*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{1}{{c}^{2} \cdot {s}^{2}}}{x}\right), x\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{{c}^{2} \cdot {s}^{2}}\right), x\right), x\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({c}^{2} \cdot {s}^{2}\right)\right), x\right), x\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({s}^{2} \cdot {c}^{2}\right)\right), x\right), x\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(\left(s \cdot s\right) \cdot {c}^{2}\right)\right), x\right), x\right) \]
      11. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(s \cdot \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot \left(c \cdot c\right)\right)\right)\right), x\right), x\right) \]
      14. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(s \cdot c\right) \cdot c\right)\right)\right), x\right), x\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(c \cdot \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(c \cdot s\right)\right)\right)\right), x\right), x\right) \]
      18. *-lowering-*.f6471.5%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right), x\right), x\right) \]
    5. Simplified71.5%

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

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

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

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

        \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
      5. swap-sqrN/A

        \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}} \]
      6. unpow2N/A

        \[\leadsto \frac{1}{{\left(\left(c \cdot s\right) \cdot x\right)}^{\color{blue}{2}}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left({\left(\left(c \cdot s\right) \cdot x\right)}^{2}\right)}\right) \]
      8. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left({\left(c \cdot \left(s \cdot x\right)\right)}^{2}\right)\right) \]
      9. unpow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left({c}^{2} \cdot \color{blue}{{\left(s \cdot x\right)}^{2}}\right)\right) \]
      10. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot {\color{blue}{\left(s \cdot x\right)}}^{2}\right)\right) \]
      11. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(\left(x \cdot s\right) \cdot \left(\color{blue}{s} \cdot x\right)\right)\right)\right) \]
      13. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(s \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(\left(c \cdot c\right) \cdot x\right)}\right)\right) \]
      16. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(s \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
      17. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot s\right) \cdot \left(\color{blue}{\left(c \cdot c\right)} \cdot x\right)\right)\right)\right) \]
      19. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \color{blue}{\left(s \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right)\right) \]
      20. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      21. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \color{blue}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right)}\right)\right)\right) \]
      22. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot s\right)}\right)\right)\right)\right) \]
      23. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \left(s \cdot \color{blue}{x}\right)\right)\right)\right)\right) \]
      24. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(c \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right)\right)\right) \]
    7. Applied egg-rr78.9%

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

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \left(c \cdot \left(c \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right)\right)\right) \]
      2. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(\left(c \cdot s\right) \cdot \color{blue}{x}\right)\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right) \]
      5. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot \color{blue}{s}\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right), \color{blue}{s}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(x \cdot c\right), \left(x \cdot c\right)\right), s\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \left(x \cdot c\right)\right), s\right)\right)\right) \]
      10. *-lowering-*.f6473.5%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \mathsf{*.f64}\left(x, c\right)\right), s\right)\right)\right) \]
    9. Applied egg-rr73.5%

      \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot s\right)}} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

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

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot s\right)\right) \cdot s} \]
      3. associate-*r*N/A

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)\right) \cdot s} \]
      4. *-commutativeN/A

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot s} \]
      5. associate-*r*N/A

        \[\leadsto \frac{1}{\left(x \cdot \left(c \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)\right) \cdot s} \]
      6. *-commutativeN/A

        \[\leadsto \frac{1}{\left(x \cdot \left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right)\right) \cdot s} \]
      7. associate-*r*N/A

        \[\leadsto \frac{1}{\left(\left(x \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot c\right) \cdot s} \]
      8. associate-*l*N/A

        \[\leadsto \frac{1}{\left(x \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot \color{blue}{\left(c \cdot s\right)}} \]
      9. associate-/l/N/A

        \[\leadsto \frac{\frac{1}{c \cdot s}}{\color{blue}{x \cdot \left(\left(c \cdot s\right) \cdot x\right)}} \]
      10. associate-/l/N/A

        \[\leadsto \frac{\frac{\frac{1}{c \cdot s}}{\left(c \cdot s\right) \cdot x}}{\color{blue}{x}} \]
      11. div-invN/A

        \[\leadsto \frac{\frac{1 \cdot \frac{1}{c \cdot s}}{\left(c \cdot s\right) \cdot x}}{x} \]
      12. frac-timesN/A

        \[\leadsto \frac{\frac{1}{c \cdot s} \cdot \frac{\frac{1}{c \cdot s}}{x}}{x} \]
      13. associate-*l/N/A

        \[\leadsto \frac{\frac{1}{c \cdot s}}{x} \cdot \color{blue}{\frac{\frac{1}{c \cdot s}}{x}} \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\frac{1}{c \cdot s}}{x}\right), \color{blue}{\left(\frac{\frac{1}{c \cdot s}}{x}\right)}\right) \]
      15. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{c \cdot s}\right), x\right), \left(\frac{\color{blue}{\frac{1}{c \cdot s}}}{x}\right)\right) \]
      16. associate-/l/N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{\frac{1}{s}}{c}\right), x\right), \left(\frac{\frac{\color{blue}{1}}{c \cdot s}}{x}\right)\right) \]
      17. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{s}\right), c\right), x\right), \left(\frac{\frac{\color{blue}{1}}{c \cdot s}}{x}\right)\right) \]
      18. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, s\right), c\right), x\right), \left(\frac{\frac{1}{c \cdot s}}{x}\right)\right) \]
      19. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, s\right), c\right), x\right), \mathsf{/.f64}\left(\left(\frac{1}{c \cdot s}\right), \color{blue}{x}\right)\right) \]
    11. Applied egg-rr82.7%

      \[\leadsto \color{blue}{\frac{\frac{\frac{1}{s}}{c}}{x} \cdot \frac{\frac{\frac{1}{s}}{c}}{x}} \]

    if 5.7999999999999995e-13 < x < 7.00000000000000011e170

    1. Initial program 63.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. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\cos \left(2 \cdot x\right), \color{blue}{\left({c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)}\right) \]
      2. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\left(2 \cdot x\right)\right), \left(\color{blue}{{c}^{2}} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\color{blue}{c}}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}\right)\right) \]
      5. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot \color{blue}{x}\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right) \cdot \color{blue}{x}\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}\right)\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(x \cdot \color{blue}{\left({c}^{2} \cdot {s}^{2}\right)}\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\left({c}^{2} \cdot {s}^{2}\right)}\right)\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left({s}^{2} \cdot \color{blue}{{c}^{2}}\right)\right)\right)\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left(\left(s \cdot s\right) \cdot {\color{blue}{c}}^{2}\right)\right)\right)\right) \]
      13. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left(s \cdot \color{blue}{\left(s \cdot {c}^{2}\right)}\right)\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \color{blue}{\left(s \cdot {c}^{2}\right)}\right)\right)\right)\right) \]
      15. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(s \cdot \left(c \cdot \color{blue}{c}\right)\right)\right)\right)\right)\right) \]
      16. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(\left(s \cdot c\right) \cdot \color{blue}{c}\right)\right)\right)\right)\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(s \cdot c\right)}\right)\right)\right)\right)\right) \]
      18. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \color{blue}{\left(s \cdot c\right)}\right)\right)\right)\right)\right) \]
      19. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(c \cdot \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
      20. *-lowering-*.f6480.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
    5. Simplified80.9%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right) \cdot \color{blue}{x}\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right), \color{blue}{x}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right), x\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right), x\right)\right)\right) \]
      5. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(c \cdot \left(s \cdot \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \left(s \cdot \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
      8. *-lowering-*.f6481.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, s\right)\right)\right), x\right)\right)\right) \]
    7. Applied egg-rr81.0%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right) \cdot x\right)\right)\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(c \cdot s\right) \cdot \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}\right)\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(s \cdot c\right) \cdot \left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)\right)\right)\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(s \cdot c\right) \cdot \left(c \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right)\right) \]
      5. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)}\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(c \cdot \left(c \cdot \left(s \cdot x\right)\right)\right) \cdot \color{blue}{s}\right)\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(x \cdot \left(c \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)\right) \cdot \color{blue}{s}\right)\right) \]
      8. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(x \cdot \left(c \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)\right) \cdot s\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(\left(x \cdot \left(c \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)\right), \color{blue}{s}\right)\right) \]
    9. Applied egg-rr92.9%

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

    if 7.00000000000000011e170 < x

    1. Initial program 52.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. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({c}^{2} \cdot \left(\left({s}^{2} \cdot x\right) \cdot x\right)\right)\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({c}^{2} \cdot \left({s}^{2} \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \]
      4. pow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\left(c \cdot s\right)}^{2} \cdot \left(\color{blue}{x} \cdot x\right)\right)\right) \]
      5. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\left(c \cdot s\right)}^{2} \cdot {x}^{\color{blue}{2}}\right)\right) \]
      6. pow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\left(\left(c \cdot s\right) \cdot x\right)}^{\color{blue}{2}}\right)\right) \]
      7. pow-lowering-pow.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{pow.f64}\left(\left(\left(c \cdot s\right) \cdot x\right), \color{blue}{2}\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\left(c \cdot s\right), x\right), 2\right)\right) \]
      9. *-lowering-*.f6496.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(c, s\right), x\right), 2\right)\right) \]
    4. Applied egg-rr96.4%

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right) \cdot 1}{{\left(c \cdot \left(s \cdot x\right)\right)}^{2}} \]
      3. unpow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right) \cdot 1}{{c}^{2} \cdot \color{blue}{{\left(s \cdot x\right)}^{2}}} \]
      4. pow2N/A

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{c \cdot c} \cdot \color{blue}{\frac{1}{{\left(s \cdot x\right)}^{2}}} \]
      6. pow2N/A

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{c \cdot c} \cdot \frac{1}{x \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}} \]
      9. times-fracN/A

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right) \cdot 1}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \color{blue}{\left(s \cdot x\right)}} \]
      12. times-fracN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\left(c \cdot c\right) \cdot x\right) \cdot s} \cdot \color{blue}{\frac{1}{s \cdot x}} \]
      13. div-invN/A

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

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{s}}{\color{blue}{\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)}} \]
      16. /-lowering-/.f64N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), s\right), \left(x \cdot \left(c \cdot \left(c \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right)\right) \]
      2. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), s\right), \left(\left(x \cdot c\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), s\right), \left(\left(x \cdot c\right) \cdot \left(\left(c \cdot s\right) \cdot \color{blue}{x}\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), s\right), \left(\left(x \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right) \]
      5. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), s\right), \left(\left(x \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot \color{blue}{s}\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), s\right), \left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot \color{blue}{s}\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), s\right), \mathsf{*.f64}\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right), \color{blue}{s}\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), s\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(x \cdot c\right), \left(x \cdot c\right)\right), s\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), s\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \left(x \cdot c\right)\right), s\right)\right) \]
      10. *-lowering-*.f6477.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), s\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \mathsf{*.f64}\left(x, c\right)\right), s\right)\right) \]
    8. Applied egg-rr77.0%

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

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

Alternative 3: 87.9% accurate, 2.5× speedup?

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

\mathbf{elif}\;x \leq 5 \cdot 10^{+167}:\\
\;\;\;\;\frac{t\_0}{s\_m \cdot \left(c\_m \cdot \left(x \cdot t\_2\right)\right)}\\

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


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

    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. Taylor expanded in x around 0

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

        \[\leadsto \frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}} \]
      2. unpow2N/A

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

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

        \[\leadsto \frac{\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}}{\color{blue}{x}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}\right), \color{blue}{x}\right) \]
      6. associate-/r*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{1}{{c}^{2} \cdot {s}^{2}}}{x}\right), x\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{{c}^{2} \cdot {s}^{2}}\right), x\right), x\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({c}^{2} \cdot {s}^{2}\right)\right), x\right), x\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({s}^{2} \cdot {c}^{2}\right)\right), x\right), x\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(\left(s \cdot s\right) \cdot {c}^{2}\right)\right), x\right), x\right) \]
      11. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(s \cdot \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot \left(c \cdot c\right)\right)\right)\right), x\right), x\right) \]
      14. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(s \cdot c\right) \cdot c\right)\right)\right), x\right), x\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(c \cdot \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(c \cdot s\right)\right)\right)\right), x\right), x\right) \]
      18. *-lowering-*.f6471.5%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right), x\right), x\right) \]
    5. Simplified71.5%

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

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

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

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

        \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
      5. swap-sqrN/A

        \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}} \]
      6. unpow2N/A

        \[\leadsto \frac{1}{{\left(\left(c \cdot s\right) \cdot x\right)}^{\color{blue}{2}}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left({\left(\left(c \cdot s\right) \cdot x\right)}^{2}\right)}\right) \]
      8. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left({\left(c \cdot \left(s \cdot x\right)\right)}^{2}\right)\right) \]
      9. unpow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left({c}^{2} \cdot \color{blue}{{\left(s \cdot x\right)}^{2}}\right)\right) \]
      10. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot {\color{blue}{\left(s \cdot x\right)}}^{2}\right)\right) \]
      11. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(\left(x \cdot s\right) \cdot \left(\color{blue}{s} \cdot x\right)\right)\right)\right) \]
      13. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(s \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(\left(c \cdot c\right) \cdot x\right)}\right)\right) \]
      16. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(s \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
      17. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot s\right) \cdot \left(\color{blue}{\left(c \cdot c\right)} \cdot x\right)\right)\right)\right) \]
      19. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \color{blue}{\left(s \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right)\right) \]
      20. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      21. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \color{blue}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right)}\right)\right)\right) \]
      22. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot s\right)}\right)\right)\right)\right) \]
      23. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \left(s \cdot \color{blue}{x}\right)\right)\right)\right)\right) \]
      24. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(c \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right)\right)\right) \]
    7. Applied egg-rr78.9%

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

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \left(c \cdot \left(c \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right)\right)\right) \]
      2. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(\left(c \cdot s\right) \cdot \color{blue}{x}\right)\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right) \]
      5. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot \color{blue}{s}\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right), \color{blue}{s}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(x \cdot c\right), \left(x \cdot c\right)\right), s\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \left(x \cdot c\right)\right), s\right)\right)\right) \]
      10. *-lowering-*.f6473.5%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \mathsf{*.f64}\left(x, c\right)\right), s\right)\right)\right) \]
    9. Applied egg-rr73.5%

      \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot s\right)}} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

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

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot s\right)\right) \cdot s} \]
      3. associate-*r*N/A

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)\right) \cdot s} \]
      4. *-commutativeN/A

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot s} \]
      5. associate-*r*N/A

        \[\leadsto \frac{1}{\left(x \cdot \left(c \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)\right) \cdot s} \]
      6. *-commutativeN/A

        \[\leadsto \frac{1}{\left(x \cdot \left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right)\right) \cdot s} \]
      7. associate-*r*N/A

        \[\leadsto \frac{1}{\left(\left(x \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot c\right) \cdot s} \]
      8. associate-*l*N/A

        \[\leadsto \frac{1}{\left(x \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot \color{blue}{\left(c \cdot s\right)}} \]
      9. associate-/l/N/A

        \[\leadsto \frac{\frac{1}{c \cdot s}}{\color{blue}{x \cdot \left(\left(c \cdot s\right) \cdot x\right)}} \]
      10. associate-/l/N/A

        \[\leadsto \frac{\frac{\frac{1}{c \cdot s}}{\left(c \cdot s\right) \cdot x}}{\color{blue}{x}} \]
      11. div-invN/A

        \[\leadsto \frac{\frac{1 \cdot \frac{1}{c \cdot s}}{\left(c \cdot s\right) \cdot x}}{x} \]
      12. frac-timesN/A

        \[\leadsto \frac{\frac{1}{c \cdot s} \cdot \frac{\frac{1}{c \cdot s}}{x}}{x} \]
      13. associate-*l/N/A

        \[\leadsto \frac{\frac{1}{c \cdot s}}{x} \cdot \color{blue}{\frac{\frac{1}{c \cdot s}}{x}} \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\frac{1}{c \cdot s}}{x}\right), \color{blue}{\left(\frac{\frac{1}{c \cdot s}}{x}\right)}\right) \]
      15. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{c \cdot s}\right), x\right), \left(\frac{\color{blue}{\frac{1}{c \cdot s}}}{x}\right)\right) \]
      16. associate-/l/N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{\frac{1}{s}}{c}\right), x\right), \left(\frac{\frac{\color{blue}{1}}{c \cdot s}}{x}\right)\right) \]
      17. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{s}\right), c\right), x\right), \left(\frac{\frac{\color{blue}{1}}{c \cdot s}}{x}\right)\right) \]
      18. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, s\right), c\right), x\right), \left(\frac{\frac{1}{c \cdot s}}{x}\right)\right) \]
      19. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, s\right), c\right), x\right), \mathsf{/.f64}\left(\left(\frac{1}{c \cdot s}\right), \color{blue}{x}\right)\right) \]
    11. Applied egg-rr82.7%

      \[\leadsto \color{blue}{\frac{\frac{\frac{1}{s}}{c}}{x} \cdot \frac{\frac{\frac{1}{s}}{c}}{x}} \]

    if 5.7999999999999995e-13 < x < 4.9999999999999997e167

    1. Initial program 66.0%

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

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\cos \left(2 \cdot x\right), \color{blue}{\left({c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)}\right) \]
      2. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\left(2 \cdot x\right)\right), \left(\color{blue}{{c}^{2}} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\color{blue}{c}}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}\right)\right) \]
      5. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot \color{blue}{x}\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right) \cdot \color{blue}{x}\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}\right)\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(x \cdot \color{blue}{\left({c}^{2} \cdot {s}^{2}\right)}\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\left({c}^{2} \cdot {s}^{2}\right)}\right)\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left({s}^{2} \cdot \color{blue}{{c}^{2}}\right)\right)\right)\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left(\left(s \cdot s\right) \cdot {\color{blue}{c}}^{2}\right)\right)\right)\right) \]
      13. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left(s \cdot \color{blue}{\left(s \cdot {c}^{2}\right)}\right)\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \color{blue}{\left(s \cdot {c}^{2}\right)}\right)\right)\right)\right) \]
      15. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(s \cdot \left(c \cdot \color{blue}{c}\right)\right)\right)\right)\right)\right) \]
      16. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(\left(s \cdot c\right) \cdot \color{blue}{c}\right)\right)\right)\right)\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(s \cdot c\right)}\right)\right)\right)\right)\right) \]
      18. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \color{blue}{\left(s \cdot c\right)}\right)\right)\right)\right)\right) \]
      19. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(c \cdot \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
      20. *-lowering-*.f6482.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
    5. Simplified82.4%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right) \cdot \color{blue}{x}\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right), \color{blue}{x}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right), x\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right), x\right)\right)\right) \]
      5. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(c \cdot \left(s \cdot \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \left(s \cdot \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
      8. *-lowering-*.f6484.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, s\right)\right)\right), x\right)\right)\right) \]
    7. Applied egg-rr84.9%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right) \cdot x\right)\right)\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(c \cdot s\right) \cdot \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}\right)\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(s \cdot c\right) \cdot \left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)\right)\right)\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(s \cdot c\right) \cdot \left(c \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right)\right) \]
      5. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)}\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(c \cdot \left(c \cdot \left(s \cdot x\right)\right)\right) \cdot \color{blue}{s}\right)\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(x \cdot \left(c \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)\right) \cdot \color{blue}{s}\right)\right) \]
      8. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(x \cdot \left(c \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)\right) \cdot s\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(\left(x \cdot \left(c \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)\right), \color{blue}{s}\right)\right) \]
    9. Applied egg-rr95.0%

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

    if 4.9999999999999997e167 < x

    1. Initial program 49.3%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({c}^{2} \cdot \left(\left({s}^{2} \cdot x\right) \cdot x\right)\right)\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({c}^{2} \cdot \left({s}^{2} \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \]
      4. pow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\left(c \cdot s\right)}^{2} \cdot \left(\color{blue}{x} \cdot x\right)\right)\right) \]
      5. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\left(c \cdot s\right)}^{2} \cdot {x}^{\color{blue}{2}}\right)\right) \]
      6. pow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\left(\left(c \cdot s\right) \cdot x\right)}^{\color{blue}{2}}\right)\right) \]
      7. pow-lowering-pow.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{pow.f64}\left(\left(\left(c \cdot s\right) \cdot x\right), \color{blue}{2}\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\left(c \cdot s\right), x\right), 2\right)\right) \]
      9. *-lowering-*.f6496.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(c, s\right), x\right), 2\right)\right) \]
    4. Applied egg-rr96.6%

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right) \cdot 1}{{\left(c \cdot \left(s \cdot x\right)\right)}^{2}} \]
      3. unpow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right) \cdot 1}{{c}^{2} \cdot \color{blue}{{\left(s \cdot x\right)}^{2}}} \]
      4. pow2N/A

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{c \cdot c} \cdot \color{blue}{\frac{1}{{\left(s \cdot x\right)}^{2}}} \]
      6. pow2N/A

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{c \cdot c} \cdot \frac{1}{x \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}} \]
      9. times-fracN/A

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right) \cdot 1}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \color{blue}{\left(s \cdot x\right)}} \]
      12. times-fracN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\left(c \cdot c\right) \cdot x\right) \cdot s} \cdot \color{blue}{\frac{1}{s \cdot x}} \]
      13. div-invN/A

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

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

        \[\leadsto \frac{\frac{\cos \left(2 \cdot x\right)}{s}}{\color{blue}{\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)}} \]
      16. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\cos \left(2 \cdot x\right)}{s}\right), \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right) \]
    6. Applied egg-rr81.8%

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

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

Alternative 4: 87.8% accurate, 2.5× speedup?

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

\mathbf{elif}\;x \leq 1.05 \cdot 10^{+169}:\\
\;\;\;\;\frac{t\_0}{s\_m \cdot \left(c\_m \cdot \left(x \cdot t\_2\right)\right)}\\

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


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

    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. Taylor expanded in x around 0

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

        \[\leadsto \frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}} \]
      2. unpow2N/A

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

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

        \[\leadsto \frac{\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}}{\color{blue}{x}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}\right), \color{blue}{x}\right) \]
      6. associate-/r*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{1}{{c}^{2} \cdot {s}^{2}}}{x}\right), x\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{{c}^{2} \cdot {s}^{2}}\right), x\right), x\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({c}^{2} \cdot {s}^{2}\right)\right), x\right), x\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({s}^{2} \cdot {c}^{2}\right)\right), x\right), x\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(\left(s \cdot s\right) \cdot {c}^{2}\right)\right), x\right), x\right) \]
      11. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(s \cdot \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot \left(c \cdot c\right)\right)\right)\right), x\right), x\right) \]
      14. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(s \cdot c\right) \cdot c\right)\right)\right), x\right), x\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(c \cdot \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(c \cdot s\right)\right)\right)\right), x\right), x\right) \]
      18. *-lowering-*.f6471.5%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right), x\right), x\right) \]
    5. Simplified71.5%

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

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

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

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

        \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
      5. swap-sqrN/A

        \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}} \]
      6. unpow2N/A

        \[\leadsto \frac{1}{{\left(\left(c \cdot s\right) \cdot x\right)}^{\color{blue}{2}}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left({\left(\left(c \cdot s\right) \cdot x\right)}^{2}\right)}\right) \]
      8. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left({\left(c \cdot \left(s \cdot x\right)\right)}^{2}\right)\right) \]
      9. unpow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left({c}^{2} \cdot \color{blue}{{\left(s \cdot x\right)}^{2}}\right)\right) \]
      10. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot {\color{blue}{\left(s \cdot x\right)}}^{2}\right)\right) \]
      11. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(\left(x \cdot s\right) \cdot \left(\color{blue}{s} \cdot x\right)\right)\right)\right) \]
      13. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(s \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(\left(c \cdot c\right) \cdot x\right)}\right)\right) \]
      16. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(s \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
      17. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot s\right) \cdot \left(\color{blue}{\left(c \cdot c\right)} \cdot x\right)\right)\right)\right) \]
      19. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \color{blue}{\left(s \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right)\right) \]
      20. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      21. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \color{blue}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right)}\right)\right)\right) \]
      22. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot s\right)}\right)\right)\right)\right) \]
      23. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \left(s \cdot \color{blue}{x}\right)\right)\right)\right)\right) \]
      24. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(c \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right)\right)\right) \]
    7. Applied egg-rr78.9%

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

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \left(c \cdot \left(c \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right)\right)\right) \]
      2. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(\left(c \cdot s\right) \cdot \color{blue}{x}\right)\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right) \]
      5. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot \color{blue}{s}\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right), \color{blue}{s}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(x \cdot c\right), \left(x \cdot c\right)\right), s\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \left(x \cdot c\right)\right), s\right)\right)\right) \]
      10. *-lowering-*.f6473.5%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \mathsf{*.f64}\left(x, c\right)\right), s\right)\right)\right) \]
    9. Applied egg-rr73.5%

      \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot s\right)}} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

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

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot s\right)\right) \cdot s} \]
      3. associate-*r*N/A

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)\right) \cdot s} \]
      4. *-commutativeN/A

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot s} \]
      5. associate-*r*N/A

        \[\leadsto \frac{1}{\left(x \cdot \left(c \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)\right) \cdot s} \]
      6. *-commutativeN/A

        \[\leadsto \frac{1}{\left(x \cdot \left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right)\right) \cdot s} \]
      7. associate-*r*N/A

        \[\leadsto \frac{1}{\left(\left(x \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot c\right) \cdot s} \]
      8. associate-*l*N/A

        \[\leadsto \frac{1}{\left(x \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot \color{blue}{\left(c \cdot s\right)}} \]
      9. associate-/l/N/A

        \[\leadsto \frac{\frac{1}{c \cdot s}}{\color{blue}{x \cdot \left(\left(c \cdot s\right) \cdot x\right)}} \]
      10. associate-/l/N/A

        \[\leadsto \frac{\frac{\frac{1}{c \cdot s}}{\left(c \cdot s\right) \cdot x}}{\color{blue}{x}} \]
      11. div-invN/A

        \[\leadsto \frac{\frac{1 \cdot \frac{1}{c \cdot s}}{\left(c \cdot s\right) \cdot x}}{x} \]
      12. frac-timesN/A

        \[\leadsto \frac{\frac{1}{c \cdot s} \cdot \frac{\frac{1}{c \cdot s}}{x}}{x} \]
      13. associate-*l/N/A

        \[\leadsto \frac{\frac{1}{c \cdot s}}{x} \cdot \color{blue}{\frac{\frac{1}{c \cdot s}}{x}} \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\frac{1}{c \cdot s}}{x}\right), \color{blue}{\left(\frac{\frac{1}{c \cdot s}}{x}\right)}\right) \]
      15. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{c \cdot s}\right), x\right), \left(\frac{\color{blue}{\frac{1}{c \cdot s}}}{x}\right)\right) \]
      16. associate-/l/N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{\frac{1}{s}}{c}\right), x\right), \left(\frac{\frac{\color{blue}{1}}{c \cdot s}}{x}\right)\right) \]
      17. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{s}\right), c\right), x\right), \left(\frac{\frac{\color{blue}{1}}{c \cdot s}}{x}\right)\right) \]
      18. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, s\right), c\right), x\right), \left(\frac{\frac{1}{c \cdot s}}{x}\right)\right) \]
      19. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, s\right), c\right), x\right), \mathsf{/.f64}\left(\left(\frac{1}{c \cdot s}\right), \color{blue}{x}\right)\right) \]
    11. Applied egg-rr82.7%

      \[\leadsto \color{blue}{\frac{\frac{\frac{1}{s}}{c}}{x} \cdot \frac{\frac{\frac{1}{s}}{c}}{x}} \]

    if 5.7999999999999995e-13 < x < 1.0500000000000001e169

    1. Initial program 66.0%

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

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\cos \left(2 \cdot x\right), \color{blue}{\left({c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)}\right) \]
      2. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\left(2 \cdot x\right)\right), \left(\color{blue}{{c}^{2}} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\color{blue}{c}}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}\right)\right) \]
      5. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot \color{blue}{x}\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right) \cdot \color{blue}{x}\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}\right)\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(x \cdot \color{blue}{\left({c}^{2} \cdot {s}^{2}\right)}\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\left({c}^{2} \cdot {s}^{2}\right)}\right)\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left({s}^{2} \cdot \color{blue}{{c}^{2}}\right)\right)\right)\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left(\left(s \cdot s\right) \cdot {\color{blue}{c}}^{2}\right)\right)\right)\right) \]
      13. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left(s \cdot \color{blue}{\left(s \cdot {c}^{2}\right)}\right)\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \color{blue}{\left(s \cdot {c}^{2}\right)}\right)\right)\right)\right) \]
      15. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(s \cdot \left(c \cdot \color{blue}{c}\right)\right)\right)\right)\right)\right) \]
      16. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(\left(s \cdot c\right) \cdot \color{blue}{c}\right)\right)\right)\right)\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(s \cdot c\right)}\right)\right)\right)\right)\right) \]
      18. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \color{blue}{\left(s \cdot c\right)}\right)\right)\right)\right)\right) \]
      19. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(c \cdot \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
      20. *-lowering-*.f6482.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
    5. Simplified82.4%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right) \cdot \color{blue}{x}\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right), \color{blue}{x}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right), x\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right), x\right)\right)\right) \]
      5. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(c \cdot \left(s \cdot \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \left(s \cdot \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
      8. *-lowering-*.f6484.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, s\right)\right)\right), x\right)\right)\right) \]
    7. Applied egg-rr84.9%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right) \cdot x\right)\right)\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(c \cdot s\right) \cdot \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}\right)\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(s \cdot c\right) \cdot \left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)\right)\right)\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(s \cdot c\right) \cdot \left(c \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right)\right) \]
      5. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)}\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(c \cdot \left(c \cdot \left(s \cdot x\right)\right)\right) \cdot \color{blue}{s}\right)\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(x \cdot \left(c \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)\right) \cdot \color{blue}{s}\right)\right) \]
      8. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(x \cdot \left(c \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)\right) \cdot s\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(\left(x \cdot \left(c \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)\right), \color{blue}{s}\right)\right) \]
    9. Applied egg-rr95.0%

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

    if 1.0500000000000001e169 < x

    1. Initial program 49.3%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({c}^{2} \cdot \left(\left({s}^{2} \cdot x\right) \cdot x\right)\right)\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({c}^{2} \cdot \left({s}^{2} \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \]
      4. pow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\left(c \cdot s\right)}^{2} \cdot \left(\color{blue}{x} \cdot x\right)\right)\right) \]
      5. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\left(c \cdot s\right)}^{2} \cdot {x}^{\color{blue}{2}}\right)\right) \]
      6. pow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\left(\left(c \cdot s\right) \cdot x\right)}^{\color{blue}{2}}\right)\right) \]
      7. pow-lowering-pow.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{pow.f64}\left(\left(\left(c \cdot s\right) \cdot x\right), \color{blue}{2}\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\left(c \cdot s\right), x\right), 2\right)\right) \]
      9. *-lowering-*.f6496.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(c, s\right), x\right), 2\right)\right) \]
    4. Applied egg-rr96.6%

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

        \[\leadsto \mathsf{/.f64}\left(\cos \left(2 \cdot x\right), \color{blue}{\left({\left(\left(c \cdot s\right) \cdot x\right)}^{2}\right)}\right) \]
      2. count-2N/A

        \[\leadsto \mathsf{/.f64}\left(\cos \left(x + x\right), \left({\left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)}^{2}\right)\right) \]
      3. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\left(x + x\right)\right), \left({\color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}}^{2}\right)\right) \]
      4. count-2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\left(2 \cdot x\right)\right), \left({\left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)}^{2}\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\left(x \cdot 2\right)\right), \left({\left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)}^{2}\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \left({\left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)}^{2}\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \left({\left(c \cdot \left(s \cdot x\right)\right)}^{2}\right)\right) \]
      8. unpow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \left({c}^{2} \cdot \color{blue}{{\left(s \cdot x\right)}^{2}}\right)\right) \]
      9. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \left(\left(c \cdot c\right) \cdot {\color{blue}{\left(s \cdot x\right)}}^{2}\right)\right) \]
      10. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \left(\left(c \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \left(\left(c \cdot c\right) \cdot \left(\left(x \cdot s\right) \cdot \left(\color{blue}{s} \cdot x\right)\right)\right)\right) \]
      12. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \left(\left(c \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
      13. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \left(\left(s \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(\left(c \cdot c\right) \cdot x\right)}\right)\right) \]
      15. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \left(s \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \mathsf{*.f64}\left(s, \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \mathsf{*.f64}\left(s, \left(\left(x \cdot s\right) \cdot \left(\color{blue}{\left(c \cdot c\right)} \cdot x\right)\right)\right)\right) \]
      18. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \mathsf{*.f64}\left(s, \left(x \cdot \color{blue}{\left(s \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right)\right) \]
      19. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \mathsf{*.f64}\left(s, \left(x \cdot \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      20. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \color{blue}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right)}\right)\right)\right) \]
      21. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot s\right)}\right)\right)\right)\right) \]
      22. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \left(s \cdot \color{blue}{x}\right)\right)\right)\right)\right) \]
      23. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(c \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right)\right)\right) \]
      24. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(c \cdot \left(\left(c \cdot s\right) \cdot \color{blue}{x}\right)\right)\right)\right)\right) \]
      25. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(c, \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}\right)\right)\right)\right) \]
      26. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(\left(c \cdot s\right), \color{blue}{x}\right)\right)\right)\right)\right) \]
      27. *-lowering-*.f6481.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(x, 2\right)\right), \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, s\right), x\right)\right)\right)\right)\right) \]
    6. Applied egg-rr81.9%

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

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

Alternative 5: 86.1% accurate, 2.5× speedup?

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

\mathbf{elif}\;x \leq 3.2 \cdot 10^{+197}:\\
\;\;\;\;\frac{t\_0}{x \cdot \left(x \cdot \left(c\_m \cdot \left(s\_m \cdot \left(c\_m \cdot s\_m\right)\right)\right)\right)}\\

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


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

    1. Initial program 67.5%

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

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

        \[\leadsto \frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}} \]
      2. unpow2N/A

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

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

        \[\leadsto \frac{\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}}{\color{blue}{x}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}\right), \color{blue}{x}\right) \]
      6. associate-/r*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{1}{{c}^{2} \cdot {s}^{2}}}{x}\right), x\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{{c}^{2} \cdot {s}^{2}}\right), x\right), x\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({c}^{2} \cdot {s}^{2}\right)\right), x\right), x\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({s}^{2} \cdot {c}^{2}\right)\right), x\right), x\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(\left(s \cdot s\right) \cdot {c}^{2}\right)\right), x\right), x\right) \]
      11. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(s \cdot \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot \left(c \cdot c\right)\right)\right)\right), x\right), x\right) \]
      14. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(s \cdot c\right) \cdot c\right)\right)\right), x\right), x\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(c \cdot \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(c \cdot s\right)\right)\right)\right), x\right), x\right) \]
      18. *-lowering-*.f6471.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right), x\right), x\right) \]
    5. Simplified71.1%

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

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

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

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

        \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
      5. swap-sqrN/A

        \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}} \]
      6. unpow2N/A

        \[\leadsto \frac{1}{{\left(\left(c \cdot s\right) \cdot x\right)}^{\color{blue}{2}}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left({\left(\left(c \cdot s\right) \cdot x\right)}^{2}\right)}\right) \]
      8. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left({\left(c \cdot \left(s \cdot x\right)\right)}^{2}\right)\right) \]
      9. unpow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left({c}^{2} \cdot \color{blue}{{\left(s \cdot x\right)}^{2}}\right)\right) \]
      10. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot {\color{blue}{\left(s \cdot x\right)}}^{2}\right)\right) \]
      11. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(\left(x \cdot s\right) \cdot \left(\color{blue}{s} \cdot x\right)\right)\right)\right) \]
      13. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(s \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(\left(c \cdot c\right) \cdot x\right)}\right)\right) \]
      16. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(s \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
      17. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot s\right) \cdot \left(\color{blue}{\left(c \cdot c\right)} \cdot x\right)\right)\right)\right) \]
      19. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \color{blue}{\left(s \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right)\right) \]
      20. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      21. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \color{blue}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right)}\right)\right)\right) \]
      22. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot s\right)}\right)\right)\right)\right) \]
      23. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \left(s \cdot \color{blue}{x}\right)\right)\right)\right)\right) \]
      24. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(c \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right)\right)\right) \]
    7. Applied egg-rr78.6%

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

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \left(c \cdot \left(c \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right)\right)\right) \]
      2. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(\left(c \cdot s\right) \cdot \color{blue}{x}\right)\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right) \]
      5. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot \color{blue}{s}\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right), \color{blue}{s}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(x \cdot c\right), \left(x \cdot c\right)\right), s\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \left(x \cdot c\right)\right), s\right)\right)\right) \]
      10. *-lowering-*.f6473.5%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \mathsf{*.f64}\left(x, c\right)\right), s\right)\right)\right) \]
    9. Applied egg-rr73.5%

      \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot s\right)}} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

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

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot s\right)\right) \cdot s} \]
      3. associate-*r*N/A

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)\right) \cdot s} \]
      4. *-commutativeN/A

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot s} \]
      5. associate-*r*N/A

        \[\leadsto \frac{1}{\left(x \cdot \left(c \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)\right) \cdot s} \]
      6. *-commutativeN/A

        \[\leadsto \frac{1}{\left(x \cdot \left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right)\right) \cdot s} \]
      7. associate-*r*N/A

        \[\leadsto \frac{1}{\left(\left(x \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot c\right) \cdot s} \]
      8. associate-*l*N/A

        \[\leadsto \frac{1}{\left(x \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot \color{blue}{\left(c \cdot s\right)}} \]
      9. associate-/l/N/A

        \[\leadsto \frac{\frac{1}{c \cdot s}}{\color{blue}{x \cdot \left(\left(c \cdot s\right) \cdot x\right)}} \]
      10. associate-/l/N/A

        \[\leadsto \frac{\frac{\frac{1}{c \cdot s}}{\left(c \cdot s\right) \cdot x}}{\color{blue}{x}} \]
      11. div-invN/A

        \[\leadsto \frac{\frac{1 \cdot \frac{1}{c \cdot s}}{\left(c \cdot s\right) \cdot x}}{x} \]
      12. frac-timesN/A

        \[\leadsto \frac{\frac{1}{c \cdot s} \cdot \frac{\frac{1}{c \cdot s}}{x}}{x} \]
      13. associate-*l/N/A

        \[\leadsto \frac{\frac{1}{c \cdot s}}{x} \cdot \color{blue}{\frac{\frac{1}{c \cdot s}}{x}} \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\frac{1}{c \cdot s}}{x}\right), \color{blue}{\left(\frac{\frac{1}{c \cdot s}}{x}\right)}\right) \]
      15. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{c \cdot s}\right), x\right), \left(\frac{\color{blue}{\frac{1}{c \cdot s}}}{x}\right)\right) \]
      16. associate-/l/N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{\frac{1}{s}}{c}\right), x\right), \left(\frac{\frac{\color{blue}{1}}{c \cdot s}}{x}\right)\right) \]
      17. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{s}\right), c\right), x\right), \left(\frac{\frac{\color{blue}{1}}{c \cdot s}}{x}\right)\right) \]
      18. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, s\right), c\right), x\right), \left(\frac{\frac{1}{c \cdot s}}{x}\right)\right) \]
      19. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, s\right), c\right), x\right), \mathsf{/.f64}\left(\left(\frac{1}{c \cdot s}\right), \color{blue}{x}\right)\right) \]
    11. Applied egg-rr82.4%

      \[\leadsto \color{blue}{\frac{\frac{\frac{1}{s}}{c}}{x} \cdot \frac{\frac{\frac{1}{s}}{c}}{x}} \]

    if 2.84999999999999987e-34 < x < 3.1999999999999998e197

    1. Initial program 64.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. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\cos \left(2 \cdot x\right), \color{blue}{\left({c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)}\right) \]
      2. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\left(2 \cdot x\right)\right), \left(\color{blue}{{c}^{2}} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\color{blue}{c}}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}\right)\right) \]
      5. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot \color{blue}{x}\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right) \cdot \color{blue}{x}\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}\right)\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(x \cdot \color{blue}{\left({c}^{2} \cdot {s}^{2}\right)}\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\left({c}^{2} \cdot {s}^{2}\right)}\right)\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left({s}^{2} \cdot \color{blue}{{c}^{2}}\right)\right)\right)\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left(\left(s \cdot s\right) \cdot {\color{blue}{c}}^{2}\right)\right)\right)\right) \]
      13. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left(s \cdot \color{blue}{\left(s \cdot {c}^{2}\right)}\right)\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \color{blue}{\left(s \cdot {c}^{2}\right)}\right)\right)\right)\right) \]
      15. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(s \cdot \left(c \cdot \color{blue}{c}\right)\right)\right)\right)\right)\right) \]
      16. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(\left(s \cdot c\right) \cdot \color{blue}{c}\right)\right)\right)\right)\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(s \cdot c\right)}\right)\right)\right)\right)\right) \]
      18. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \color{blue}{\left(s \cdot c\right)}\right)\right)\right)\right)\right) \]
      19. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(c \cdot \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
      20. *-lowering-*.f6484.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
    5. Simplified84.0%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right) \cdot \color{blue}{x}\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right), \color{blue}{x}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right), x\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right), x\right)\right)\right) \]
      5. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(c \cdot \left(s \cdot \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \left(s \cdot \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
      8. *-lowering-*.f6484.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, s\right)\right)\right), x\right)\right)\right) \]
    7. Applied egg-rr84.1%

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

    if 3.1999999999999998e197 < x

    1. Initial program 50.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. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({c}^{2} \cdot \left(\left({s}^{2} \cdot x\right) \cdot x\right)\right)\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({c}^{2} \cdot \left({s}^{2} \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \]
      4. pow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\left(c \cdot s\right)}^{2} \cdot \left(\color{blue}{x} \cdot x\right)\right)\right) \]
      5. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\left(c \cdot s\right)}^{2} \cdot {x}^{\color{blue}{2}}\right)\right) \]
      6. pow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\left(\left(c \cdot s\right) \cdot x\right)}^{\color{blue}{2}}\right)\right) \]
      7. pow-lowering-pow.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{pow.f64}\left(\left(\left(c \cdot s\right) \cdot x\right), \color{blue}{2}\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\left(c \cdot s\right), x\right), 2\right)\right) \]
      9. *-lowering-*.f6495.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{pow.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(c, s\right), x\right), 2\right)\right) \]
    4. Applied egg-rr95.9%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\left(c \cdot \left(s \cdot x\right)\right)}^{2}\right)\right) \]
      2. unpow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({c}^{2} \cdot \color{blue}{{\left(s \cdot x\right)}^{2}}\right)\right) \]
      3. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(c \cdot c\right) \cdot {\color{blue}{\left(s \cdot x\right)}}^{2}\right)\right) \]
      4. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(c \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(c \cdot c\right) \cdot \left(\left(x \cdot s\right) \cdot \left(\color{blue}{s} \cdot x\right)\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(c \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right) \]
      8. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(c \cdot \left(c \cdot x\right)\right) \cdot \left(\color{blue}{s} \cdot \left(s \cdot x\right)\right)\right)\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(\left(c \cdot x\right) \cdot c\right) \cdot \left(\color{blue}{s} \cdot \left(s \cdot x\right)\right)\right)\right) \]
      10. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(c \cdot x\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot \left(s \cdot x\right)\right)\right)}\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(\left(c \cdot x\right), \color{blue}{\left(c \cdot \left(s \cdot \left(s \cdot x\right)\right)\right)}\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, x\right), \left(\color{blue}{c} \cdot \left(s \cdot \left(s \cdot x\right)\right)\right)\right)\right) \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, x\right), \mathsf{*.f64}\left(c, \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, x\right), \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \color{blue}{\left(s \cdot x\right)}\right)\right)\right)\right) \]
      15. *-lowering-*.f6488.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, x\right), \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(s, \color{blue}{x}\right)\right)\right)\right)\right) \]
    6. Applied egg-rr88.1%

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

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

Alternative 6: 87.0% accurate, 2.6× speedup?

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

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


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

    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. Taylor expanded in x around 0

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

        \[\leadsto \frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}} \]
      2. unpow2N/A

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

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

        \[\leadsto \frac{\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}}{\color{blue}{x}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}\right), \color{blue}{x}\right) \]
      6. associate-/r*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{1}{{c}^{2} \cdot {s}^{2}}}{x}\right), x\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{{c}^{2} \cdot {s}^{2}}\right), x\right), x\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({c}^{2} \cdot {s}^{2}\right)\right), x\right), x\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({s}^{2} \cdot {c}^{2}\right)\right), x\right), x\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(\left(s \cdot s\right) \cdot {c}^{2}\right)\right), x\right), x\right) \]
      11. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(s \cdot \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot \left(c \cdot c\right)\right)\right)\right), x\right), x\right) \]
      14. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(s \cdot c\right) \cdot c\right)\right)\right), x\right), x\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(c \cdot \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(c \cdot s\right)\right)\right)\right), x\right), x\right) \]
      18. *-lowering-*.f6471.5%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right), x\right), x\right) \]
    5. Simplified71.5%

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

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

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

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

        \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
      5. swap-sqrN/A

        \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}} \]
      6. unpow2N/A

        \[\leadsto \frac{1}{{\left(\left(c \cdot s\right) \cdot x\right)}^{\color{blue}{2}}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left({\left(\left(c \cdot s\right) \cdot x\right)}^{2}\right)}\right) \]
      8. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left({\left(c \cdot \left(s \cdot x\right)\right)}^{2}\right)\right) \]
      9. unpow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left({c}^{2} \cdot \color{blue}{{\left(s \cdot x\right)}^{2}}\right)\right) \]
      10. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot {\color{blue}{\left(s \cdot x\right)}}^{2}\right)\right) \]
      11. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(\left(x \cdot s\right) \cdot \left(\color{blue}{s} \cdot x\right)\right)\right)\right) \]
      13. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(s \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(\left(c \cdot c\right) \cdot x\right)}\right)\right) \]
      16. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(s \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
      17. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot s\right) \cdot \left(\color{blue}{\left(c \cdot c\right)} \cdot x\right)\right)\right)\right) \]
      19. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \color{blue}{\left(s \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right)\right) \]
      20. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      21. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \color{blue}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right)}\right)\right)\right) \]
      22. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot s\right)}\right)\right)\right)\right) \]
      23. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \left(s \cdot \color{blue}{x}\right)\right)\right)\right)\right) \]
      24. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(c \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right)\right)\right) \]
    7. Applied egg-rr78.9%

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

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \left(c \cdot \left(c \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right)\right)\right) \]
      2. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(\left(c \cdot s\right) \cdot \color{blue}{x}\right)\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right) \]
      5. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot \color{blue}{s}\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right), \color{blue}{s}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(x \cdot c\right), \left(x \cdot c\right)\right), s\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \left(x \cdot c\right)\right), s\right)\right)\right) \]
      10. *-lowering-*.f6473.5%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \mathsf{*.f64}\left(x, c\right)\right), s\right)\right)\right) \]
    9. Applied egg-rr73.5%

      \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot s\right)}} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

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

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot s\right)\right) \cdot s} \]
      3. associate-*r*N/A

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)\right) \cdot s} \]
      4. *-commutativeN/A

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot s} \]
      5. associate-*r*N/A

        \[\leadsto \frac{1}{\left(x \cdot \left(c \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)\right) \cdot s} \]
      6. *-commutativeN/A

        \[\leadsto \frac{1}{\left(x \cdot \left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right)\right) \cdot s} \]
      7. associate-*r*N/A

        \[\leadsto \frac{1}{\left(\left(x \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot c\right) \cdot s} \]
      8. associate-*l*N/A

        \[\leadsto \frac{1}{\left(x \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot \color{blue}{\left(c \cdot s\right)}} \]
      9. associate-/l/N/A

        \[\leadsto \frac{\frac{1}{c \cdot s}}{\color{blue}{x \cdot \left(\left(c \cdot s\right) \cdot x\right)}} \]
      10. associate-/l/N/A

        \[\leadsto \frac{\frac{\frac{1}{c \cdot s}}{\left(c \cdot s\right) \cdot x}}{\color{blue}{x}} \]
      11. div-invN/A

        \[\leadsto \frac{\frac{1 \cdot \frac{1}{c \cdot s}}{\left(c \cdot s\right) \cdot x}}{x} \]
      12. frac-timesN/A

        \[\leadsto \frac{\frac{1}{c \cdot s} \cdot \frac{\frac{1}{c \cdot s}}{x}}{x} \]
      13. associate-*l/N/A

        \[\leadsto \frac{\frac{1}{c \cdot s}}{x} \cdot \color{blue}{\frac{\frac{1}{c \cdot s}}{x}} \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\frac{1}{c \cdot s}}{x}\right), \color{blue}{\left(\frac{\frac{1}{c \cdot s}}{x}\right)}\right) \]
      15. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{c \cdot s}\right), x\right), \left(\frac{\color{blue}{\frac{1}{c \cdot s}}}{x}\right)\right) \]
      16. associate-/l/N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{\frac{1}{s}}{c}\right), x\right), \left(\frac{\frac{\color{blue}{1}}{c \cdot s}}{x}\right)\right) \]
      17. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{s}\right), c\right), x\right), \left(\frac{\frac{\color{blue}{1}}{c \cdot s}}{x}\right)\right) \]
      18. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, s\right), c\right), x\right), \left(\frac{\frac{1}{c \cdot s}}{x}\right)\right) \]
      19. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, s\right), c\right), x\right), \mathsf{/.f64}\left(\left(\frac{1}{c \cdot s}\right), \color{blue}{x}\right)\right) \]
    11. Applied egg-rr82.7%

      \[\leadsto \color{blue}{\frac{\frac{\frac{1}{s}}{c}}{x} \cdot \frac{\frac{\frac{1}{s}}{c}}{x}} \]

    if 4.19999999999999977e-13 < x

    1. Initial program 58.7%

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

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\cos \left(2 \cdot x\right), \color{blue}{\left({c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)}\right) \]
      2. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\left(2 \cdot x\right)\right), \left(\color{blue}{{c}^{2}} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\color{blue}{c}}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}\right)\right) \]
      5. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot \color{blue}{x}\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right) \cdot \color{blue}{x}\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}\right)\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(x \cdot \color{blue}{\left({c}^{2} \cdot {s}^{2}\right)}\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\left({c}^{2} \cdot {s}^{2}\right)}\right)\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left({s}^{2} \cdot \color{blue}{{c}^{2}}\right)\right)\right)\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left(\left(s \cdot s\right) \cdot {\color{blue}{c}}^{2}\right)\right)\right)\right) \]
      13. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left(s \cdot \color{blue}{\left(s \cdot {c}^{2}\right)}\right)\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \color{blue}{\left(s \cdot {c}^{2}\right)}\right)\right)\right)\right) \]
      15. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(s \cdot \left(c \cdot \color{blue}{c}\right)\right)\right)\right)\right)\right) \]
      16. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(\left(s \cdot c\right) \cdot \color{blue}{c}\right)\right)\right)\right)\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(s \cdot c\right)}\right)\right)\right)\right)\right) \]
      18. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \color{blue}{\left(s \cdot c\right)}\right)\right)\right)\right)\right) \]
      19. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(c \cdot \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
      20. *-lowering-*.f6478.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
    5. Simplified78.8%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right) \cdot \color{blue}{x}\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right), \color{blue}{x}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right), x\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right), x\right)\right)\right) \]
      5. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(c \cdot \left(s \cdot \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \left(s \cdot \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
      8. *-lowering-*.f6478.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, s\right)\right)\right), x\right)\right)\right) \]
    7. Applied egg-rr78.8%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right) \cdot x\right)\right)\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(c \cdot s\right) \cdot \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}\right)\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(s \cdot c\right) \cdot \left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)\right)\right)\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(s \cdot c\right) \cdot \left(c \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right)\right) \]
      5. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)}\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \left(\left(c \cdot \left(c \cdot \left(s \cdot x\right)\right)\right) \cdot \color{blue}{s}\right)\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(x \cdot \left(c \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)\right) \cdot \color{blue}{s}\right)\right) \]
      8. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(x \cdot \left(c \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)\right) \cdot s\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(\left(x \cdot \left(c \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)\right), \color{blue}{s}\right)\right) \]
    9. Applied egg-rr87.9%

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

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

Alternative 7: 85.0% accurate, 2.6× speedup?

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

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


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

    1. Initial program 67.5%

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

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

        \[\leadsto \frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}} \]
      2. unpow2N/A

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

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

        \[\leadsto \frac{\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}}{\color{blue}{x}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}\right), \color{blue}{x}\right) \]
      6. associate-/r*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{1}{{c}^{2} \cdot {s}^{2}}}{x}\right), x\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{{c}^{2} \cdot {s}^{2}}\right), x\right), x\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({c}^{2} \cdot {s}^{2}\right)\right), x\right), x\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({s}^{2} \cdot {c}^{2}\right)\right), x\right), x\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(\left(s \cdot s\right) \cdot {c}^{2}\right)\right), x\right), x\right) \]
      11. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(s \cdot \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot \left(c \cdot c\right)\right)\right)\right), x\right), x\right) \]
      14. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(s \cdot c\right) \cdot c\right)\right)\right), x\right), x\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(c \cdot \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(c \cdot s\right)\right)\right)\right), x\right), x\right) \]
      18. *-lowering-*.f6471.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right), x\right), x\right) \]
    5. Simplified71.1%

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

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

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

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

        \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
      5. swap-sqrN/A

        \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}} \]
      6. unpow2N/A

        \[\leadsto \frac{1}{{\left(\left(c \cdot s\right) \cdot x\right)}^{\color{blue}{2}}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left({\left(\left(c \cdot s\right) \cdot x\right)}^{2}\right)}\right) \]
      8. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left({\left(c \cdot \left(s \cdot x\right)\right)}^{2}\right)\right) \]
      9. unpow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left({c}^{2} \cdot \color{blue}{{\left(s \cdot x\right)}^{2}}\right)\right) \]
      10. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot {\color{blue}{\left(s \cdot x\right)}}^{2}\right)\right) \]
      11. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(\left(x \cdot s\right) \cdot \left(\color{blue}{s} \cdot x\right)\right)\right)\right) \]
      13. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(s \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(\left(c \cdot c\right) \cdot x\right)}\right)\right) \]
      16. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(s \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
      17. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot s\right) \cdot \left(\color{blue}{\left(c \cdot c\right)} \cdot x\right)\right)\right)\right) \]
      19. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \color{blue}{\left(s \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right)\right) \]
      20. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      21. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \color{blue}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right)}\right)\right)\right) \]
      22. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot s\right)}\right)\right)\right)\right) \]
      23. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \left(s \cdot \color{blue}{x}\right)\right)\right)\right)\right) \]
      24. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(c \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right)\right)\right) \]
    7. Applied egg-rr78.6%

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

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \left(c \cdot \left(c \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right)\right)\right) \]
      2. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(\left(c \cdot s\right) \cdot \color{blue}{x}\right)\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right) \]
      5. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot \color{blue}{s}\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right), \color{blue}{s}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(x \cdot c\right), \left(x \cdot c\right)\right), s\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \left(x \cdot c\right)\right), s\right)\right)\right) \]
      10. *-lowering-*.f6473.5%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \mathsf{*.f64}\left(x, c\right)\right), s\right)\right)\right) \]
    9. Applied egg-rr73.5%

      \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot s\right)}} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

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

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot s\right)\right) \cdot s} \]
      3. associate-*r*N/A

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)\right) \cdot s} \]
      4. *-commutativeN/A

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot s} \]
      5. associate-*r*N/A

        \[\leadsto \frac{1}{\left(x \cdot \left(c \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)\right) \cdot s} \]
      6. *-commutativeN/A

        \[\leadsto \frac{1}{\left(x \cdot \left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right)\right) \cdot s} \]
      7. associate-*r*N/A

        \[\leadsto \frac{1}{\left(\left(x \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot c\right) \cdot s} \]
      8. associate-*l*N/A

        \[\leadsto \frac{1}{\left(x \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot \color{blue}{\left(c \cdot s\right)}} \]
      9. associate-/l/N/A

        \[\leadsto \frac{\frac{1}{c \cdot s}}{\color{blue}{x \cdot \left(\left(c \cdot s\right) \cdot x\right)}} \]
      10. associate-/l/N/A

        \[\leadsto \frac{\frac{\frac{1}{c \cdot s}}{\left(c \cdot s\right) \cdot x}}{\color{blue}{x}} \]
      11. div-invN/A

        \[\leadsto \frac{\frac{1 \cdot \frac{1}{c \cdot s}}{\left(c \cdot s\right) \cdot x}}{x} \]
      12. frac-timesN/A

        \[\leadsto \frac{\frac{1}{c \cdot s} \cdot \frac{\frac{1}{c \cdot s}}{x}}{x} \]
      13. associate-*l/N/A

        \[\leadsto \frac{\frac{1}{c \cdot s}}{x} \cdot \color{blue}{\frac{\frac{1}{c \cdot s}}{x}} \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\frac{1}{c \cdot s}}{x}\right), \color{blue}{\left(\frac{\frac{1}{c \cdot s}}{x}\right)}\right) \]
      15. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{c \cdot s}\right), x\right), \left(\frac{\color{blue}{\frac{1}{c \cdot s}}}{x}\right)\right) \]
      16. associate-/l/N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{\frac{1}{s}}{c}\right), x\right), \left(\frac{\frac{\color{blue}{1}}{c \cdot s}}{x}\right)\right) \]
      17. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{s}\right), c\right), x\right), \left(\frac{\frac{\color{blue}{1}}{c \cdot s}}{x}\right)\right) \]
      18. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, s\right), c\right), x\right), \left(\frac{\frac{1}{c \cdot s}}{x}\right)\right) \]
      19. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, s\right), c\right), x\right), \mathsf{/.f64}\left(\left(\frac{1}{c \cdot s}\right), \color{blue}{x}\right)\right) \]
    11. Applied egg-rr82.4%

      \[\leadsto \color{blue}{\frac{\frac{\frac{1}{s}}{c}}{x} \cdot \frac{\frac{\frac{1}{s}}{c}}{x}} \]

    if 5.1999999999999999e-34 < x

    1. Initial program 60.3%

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

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\cos \left(2 \cdot x\right), \color{blue}{\left({c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)}\right) \]
      2. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\left(2 \cdot x\right)\right), \left(\color{blue}{{c}^{2}} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\color{blue}{c}}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}\right)\right) \]
      5. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot \color{blue}{x}\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right) \cdot \color{blue}{x}\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}\right)\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(x \cdot \color{blue}{\left({c}^{2} \cdot {s}^{2}\right)}\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\left({c}^{2} \cdot {s}^{2}\right)}\right)\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left({s}^{2} \cdot \color{blue}{{c}^{2}}\right)\right)\right)\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left(\left(s \cdot s\right) \cdot {\color{blue}{c}}^{2}\right)\right)\right)\right) \]
      13. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left(s \cdot \color{blue}{\left(s \cdot {c}^{2}\right)}\right)\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \color{blue}{\left(s \cdot {c}^{2}\right)}\right)\right)\right)\right) \]
      15. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(s \cdot \left(c \cdot \color{blue}{c}\right)\right)\right)\right)\right)\right) \]
      16. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(\left(s \cdot c\right) \cdot \color{blue}{c}\right)\right)\right)\right)\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(s \cdot c\right)}\right)\right)\right)\right)\right) \]
      18. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \color{blue}{\left(s \cdot c\right)}\right)\right)\right)\right)\right) \]
      19. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(c \cdot \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
      20. *-lowering-*.f6479.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
    5. Simplified79.6%

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right) \cdot \color{blue}{x}\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right), \color{blue}{x}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right), x\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right), x\right)\right)\right) \]
      5. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(c \cdot \left(s \cdot \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \left(s \cdot \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
      8. *-lowering-*.f6479.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, s\right)\right)\right), x\right)\right)\right) \]
    7. Applied egg-rr79.6%

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

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

Alternative 8: 84.1% accurate, 2.6× speedup?

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

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


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

    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. Taylor expanded in x around 0

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

        \[\leadsto \frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}} \]
      2. unpow2N/A

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

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

        \[\leadsto \frac{\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}}{\color{blue}{x}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}\right), \color{blue}{x}\right) \]
      6. associate-/r*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{1}{{c}^{2} \cdot {s}^{2}}}{x}\right), x\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{{c}^{2} \cdot {s}^{2}}\right), x\right), x\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({c}^{2} \cdot {s}^{2}\right)\right), x\right), x\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({s}^{2} \cdot {c}^{2}\right)\right), x\right), x\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(\left(s \cdot s\right) \cdot {c}^{2}\right)\right), x\right), x\right) \]
      11. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(s \cdot \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot \left(c \cdot c\right)\right)\right)\right), x\right), x\right) \]
      14. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(s \cdot c\right) \cdot c\right)\right)\right), x\right), x\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(c \cdot \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(c \cdot s\right)\right)\right)\right), x\right), x\right) \]
      18. *-lowering-*.f6471.5%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right), x\right), x\right) \]
    5. Simplified71.5%

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

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

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

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

        \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
      5. swap-sqrN/A

        \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}} \]
      6. unpow2N/A

        \[\leadsto \frac{1}{{\left(\left(c \cdot s\right) \cdot x\right)}^{\color{blue}{2}}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left({\left(\left(c \cdot s\right) \cdot x\right)}^{2}\right)}\right) \]
      8. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left({\left(c \cdot \left(s \cdot x\right)\right)}^{2}\right)\right) \]
      9. unpow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left({c}^{2} \cdot \color{blue}{{\left(s \cdot x\right)}^{2}}\right)\right) \]
      10. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot {\color{blue}{\left(s \cdot x\right)}}^{2}\right)\right) \]
      11. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(\left(x \cdot s\right) \cdot \left(\color{blue}{s} \cdot x\right)\right)\right)\right) \]
      13. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(s \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(\left(c \cdot c\right) \cdot x\right)}\right)\right) \]
      16. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(s \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
      17. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot s\right) \cdot \left(\color{blue}{\left(c \cdot c\right)} \cdot x\right)\right)\right)\right) \]
      19. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \color{blue}{\left(s \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right)\right) \]
      20. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      21. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \color{blue}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right)}\right)\right)\right) \]
      22. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot s\right)}\right)\right)\right)\right) \]
      23. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \left(s \cdot \color{blue}{x}\right)\right)\right)\right)\right) \]
      24. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(c \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right)\right)\right) \]
    7. Applied egg-rr78.9%

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

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \left(c \cdot \left(c \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right)\right)\right) \]
      2. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(\left(c \cdot s\right) \cdot \color{blue}{x}\right)\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right) \]
      5. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot \color{blue}{s}\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right), \color{blue}{s}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(x \cdot c\right), \left(x \cdot c\right)\right), s\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \left(x \cdot c\right)\right), s\right)\right)\right) \]
      10. *-lowering-*.f6473.5%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \mathsf{*.f64}\left(x, c\right)\right), s\right)\right)\right) \]
    9. Applied egg-rr73.5%

      \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot s\right)}} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

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

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot s\right)\right) \cdot s} \]
      3. associate-*r*N/A

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)\right) \cdot s} \]
      4. *-commutativeN/A

        \[\leadsto \frac{1}{\left(\left(x \cdot c\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot s} \]
      5. associate-*r*N/A

        \[\leadsto \frac{1}{\left(x \cdot \left(c \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)\right) \cdot s} \]
      6. *-commutativeN/A

        \[\leadsto \frac{1}{\left(x \cdot \left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right)\right) \cdot s} \]
      7. associate-*r*N/A

        \[\leadsto \frac{1}{\left(\left(x \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot c\right) \cdot s} \]
      8. associate-*l*N/A

        \[\leadsto \frac{1}{\left(x \cdot \left(\left(c \cdot s\right) \cdot x\right)\right) \cdot \color{blue}{\left(c \cdot s\right)}} \]
      9. associate-/l/N/A

        \[\leadsto \frac{\frac{1}{c \cdot s}}{\color{blue}{x \cdot \left(\left(c \cdot s\right) \cdot x\right)}} \]
      10. associate-/l/N/A

        \[\leadsto \frac{\frac{\frac{1}{c \cdot s}}{\left(c \cdot s\right) \cdot x}}{\color{blue}{x}} \]
      11. div-invN/A

        \[\leadsto \frac{\frac{1 \cdot \frac{1}{c \cdot s}}{\left(c \cdot s\right) \cdot x}}{x} \]
      12. frac-timesN/A

        \[\leadsto \frac{\frac{1}{c \cdot s} \cdot \frac{\frac{1}{c \cdot s}}{x}}{x} \]
      13. associate-*l/N/A

        \[\leadsto \frac{\frac{1}{c \cdot s}}{x} \cdot \color{blue}{\frac{\frac{1}{c \cdot s}}{x}} \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\frac{\frac{1}{c \cdot s}}{x}\right), \color{blue}{\left(\frac{\frac{1}{c \cdot s}}{x}\right)}\right) \]
      15. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{c \cdot s}\right), x\right), \left(\frac{\color{blue}{\frac{1}{c \cdot s}}}{x}\right)\right) \]
      16. associate-/l/N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\left(\frac{\frac{1}{s}}{c}\right), x\right), \left(\frac{\frac{\color{blue}{1}}{c \cdot s}}{x}\right)\right) \]
      17. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{s}\right), c\right), x\right), \left(\frac{\frac{\color{blue}{1}}{c \cdot s}}{x}\right)\right) \]
      18. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, s\right), c\right), x\right), \left(\frac{\frac{1}{c \cdot s}}{x}\right)\right) \]
      19. /-lowering-/.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, s\right), c\right), x\right), \mathsf{/.f64}\left(\left(\frac{1}{c \cdot s}\right), \color{blue}{x}\right)\right) \]
    11. Applied egg-rr82.7%

      \[\leadsto \color{blue}{\frac{\frac{\frac{1}{s}}{c}}{x} \cdot \frac{\frac{\frac{1}{s}}{c}}{x}} \]

    if 2.09999999999999989e-13 < x

    1. Initial program 58.7%

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

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\cos \left(2 \cdot x\right), \color{blue}{\left({c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)}\right) \]
      2. cos-lowering-cos.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\left(2 \cdot x\right)\right), \left(\color{blue}{{c}^{2}} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\color{blue}{c}}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}\right)\right) \]
      5. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot \color{blue}{x}\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right) \cdot \color{blue}{x}\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}\right)\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(x \cdot \color{blue}{\left({c}^{2} \cdot {s}^{2}\right)}\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\left({c}^{2} \cdot {s}^{2}\right)}\right)\right)\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left({s}^{2} \cdot \color{blue}{{c}^{2}}\right)\right)\right)\right) \]
      12. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left(\left(s \cdot s\right) \cdot {\color{blue}{c}}^{2}\right)\right)\right)\right) \]
      13. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left(s \cdot \color{blue}{\left(s \cdot {c}^{2}\right)}\right)\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \color{blue}{\left(s \cdot {c}^{2}\right)}\right)\right)\right)\right) \]
      15. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(s \cdot \left(c \cdot \color{blue}{c}\right)\right)\right)\right)\right)\right) \]
      16. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(\left(s \cdot c\right) \cdot \color{blue}{c}\right)\right)\right)\right)\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(s \cdot c\right)}\right)\right)\right)\right)\right) \]
      18. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \color{blue}{\left(s \cdot c\right)}\right)\right)\right)\right)\right) \]
      19. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(c \cdot \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
      20. *-lowering-*.f6478.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
    5. Simplified78.8%

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

Alternative 9: 79.9% accurate, 17.4× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < 5e21

    1. Initial program 66.4%

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

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

        \[\leadsto \frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}} \]
      2. unpow2N/A

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

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

        \[\leadsto \frac{\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}}{\color{blue}{x}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}\right), \color{blue}{x}\right) \]
      6. associate-/r*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{1}{{c}^{2} \cdot {s}^{2}}}{x}\right), x\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{{c}^{2} \cdot {s}^{2}}\right), x\right), x\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({c}^{2} \cdot {s}^{2}\right)\right), x\right), x\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({s}^{2} \cdot {c}^{2}\right)\right), x\right), x\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(\left(s \cdot s\right) \cdot {c}^{2}\right)\right), x\right), x\right) \]
      11. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(s \cdot \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot \left(c \cdot c\right)\right)\right)\right), x\right), x\right) \]
      14. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(s \cdot c\right) \cdot c\right)\right)\right), x\right), x\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(c \cdot \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(c \cdot s\right)\right)\right)\right), x\right), x\right) \]
      18. *-lowering-*.f6464.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right), x\right), x\right) \]
    5. Simplified64.0%

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

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

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right) \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}} \]
      3. *-commutativeN/A

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

        \[\leadsto \frac{1}{\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right) \cdot \left(\color{blue}{x} \cdot x\right)} \]
      5. *-commutativeN/A

        \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
      6. swap-sqrN/A

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

        \[\leadsto \frac{\frac{1}{\left(c \cdot s\right) \cdot x}}{\color{blue}{\left(c \cdot s\right) \cdot x}} \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{\left(c \cdot s\right) \cdot x}\right), \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}\right) \]
      9. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(\left(c \cdot s\right) \cdot x\right)\right), \left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\left(c \cdot s\right), x\right)\right), \left(\left(c \cdot \color{blue}{s}\right) \cdot x\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, s\right), x\right)\right), \left(\left(c \cdot s\right) \cdot x\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, s\right), x\right)\right), \mathsf{*.f64}\left(\left(c \cdot s\right), \color{blue}{x}\right)\right) \]
      13. *-lowering-*.f6472.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, s\right), x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, s\right), x\right)\right) \]
    7. Applied egg-rr72.3%

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

    if 5e21 < c

    1. Initial program 61.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. associate-/r*N/A

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

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

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

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

        \[\leadsto \frac{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{x}}{x \cdot s}}{\color{blue}{s}} \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{x}}{x \cdot s}\right), \color{blue}{s}\right) \]
    4. Applied egg-rr73.4%

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\color{blue}{\left(\frac{1}{{c}^{2} \cdot x}\right)}, \mathsf{*.f64}\left(s, x\right)\right), s\right) \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({c}^{2} \cdot x\right)\right), \mathsf{*.f64}\left(s, x\right)\right), s\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot x\right)\right), \mathsf{*.f64}\left(s, x\right)\right), s\right) \]
      3. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(c \cdot \left(c \cdot x\right)\right)\right), \mathsf{*.f64}\left(s, x\right)\right), s\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(c \cdot \left(x \cdot c\right)\right)\right), \mathsf{*.f64}\left(s, x\right)\right), s\right) \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(c, \left(x \cdot c\right)\right)\right), \mathsf{*.f64}\left(s, x\right)\right), s\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(c, \left(c \cdot x\right)\right)\right), \mathsf{*.f64}\left(s, x\right)\right), s\right) \]
      7. *-lowering-*.f6478.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, x\right)\right)\right), \mathsf{*.f64}\left(s, x\right)\right), s\right) \]
    7. Simplified78.0%

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

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

Alternative 10: 79.8% accurate, 17.4× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < 2e22

    1. Initial program 66.4%

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

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

        \[\leadsto \frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}} \]
      2. unpow2N/A

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

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

        \[\leadsto \frac{\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}}{\color{blue}{x}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}\right), \color{blue}{x}\right) \]
      6. associate-/r*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{1}{{c}^{2} \cdot {s}^{2}}}{x}\right), x\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{{c}^{2} \cdot {s}^{2}}\right), x\right), x\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({c}^{2} \cdot {s}^{2}\right)\right), x\right), x\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({s}^{2} \cdot {c}^{2}\right)\right), x\right), x\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(\left(s \cdot s\right) \cdot {c}^{2}\right)\right), x\right), x\right) \]
      11. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(s \cdot \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot \left(c \cdot c\right)\right)\right)\right), x\right), x\right) \]
      14. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(s \cdot c\right) \cdot c\right)\right)\right), x\right), x\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(c \cdot \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(c \cdot s\right)\right)\right)\right), x\right), x\right) \]
      18. *-lowering-*.f6464.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right), x\right), x\right) \]
    5. Simplified64.0%

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

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

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right) \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}} \]
      3. *-commutativeN/A

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

        \[\leadsto \frac{1}{\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right) \cdot \left(\color{blue}{x} \cdot x\right)} \]
      5. *-commutativeN/A

        \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
      6. swap-sqrN/A

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

        \[\leadsto \frac{\frac{1}{\left(c \cdot s\right) \cdot x}}{\color{blue}{\left(c \cdot s\right) \cdot x}} \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{\left(c \cdot s\right) \cdot x}\right), \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}\right) \]
      9. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(\left(c \cdot s\right) \cdot x\right)\right), \left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\left(c \cdot s\right), x\right)\right), \left(\left(c \cdot \color{blue}{s}\right) \cdot x\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, s\right), x\right)\right), \left(\left(c \cdot s\right) \cdot x\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, s\right), x\right)\right), \mathsf{*.f64}\left(\left(c \cdot s\right), \color{blue}{x}\right)\right) \]
      13. *-lowering-*.f6472.3%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, s\right), x\right)\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, s\right), x\right)\right) \]
    7. Applied egg-rr72.3%

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

    if 2e22 < c

    1. Initial program 61.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. associate-/r*N/A

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

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

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

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

        \[\leadsto \frac{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{x}}{x \cdot s}}{\color{blue}{s}} \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{x}}{x \cdot s}\right), \color{blue}{s}\right) \]
    4. Applied egg-rr73.4%

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

      \[\leadsto \mathsf{/.f64}\left(\color{blue}{\left(\frac{1}{{c}^{2} \cdot \left(s \cdot {x}^{2}\right)}\right)}, s\right) \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({c}^{2} \cdot \left(s \cdot {x}^{2}\right)\right)\right), s\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({c}^{2} \cdot \left(s \cdot \left(x \cdot x\right)\right)\right)\right), s\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({c}^{2} \cdot \left(\left(s \cdot x\right) \cdot x\right)\right)\right), s\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(\left({c}^{2} \cdot \left(s \cdot x\right)\right) \cdot x\right)\right), s\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(x \cdot \left({c}^{2} \cdot \left(s \cdot x\right)\right)\right)\right), s\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(x, \left({c}^{2} \cdot \left(s \cdot x\right)\right)\right)\right), s\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \left(s \cdot x\right)\right)\right)\right), s\right) \]
      8. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(x, \left(c \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)\right)\right), s\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(c, \left(c \cdot \left(s \cdot x\right)\right)\right)\right)\right), s\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \left(s \cdot x\right)\right)\right)\right)\right), s\right) \]
      11. *-lowering-*.f6477.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, x\right)\right)\right)\right)\right), s\right) \]
    7. Simplified77.8%

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

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

Alternative 11: 78.8% accurate, 17.4× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < 0.0550000000000000003

    1. Initial program 66.1%

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

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

        \[\leadsto \frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}} \]
      2. unpow2N/A

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

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

        \[\leadsto \frac{\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}}{\color{blue}{x}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}\right), \color{blue}{x}\right) \]
      6. associate-/r*N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{1}{{c}^{2} \cdot {s}^{2}}}{x}\right), x\right) \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{{c}^{2} \cdot {s}^{2}}\right), x\right), x\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({c}^{2} \cdot {s}^{2}\right)\right), x\right), x\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({s}^{2} \cdot {c}^{2}\right)\right), x\right), x\right) \]
      10. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(\left(s \cdot s\right) \cdot {c}^{2}\right)\right), x\right), x\right) \]
      11. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(s \cdot \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot \left(c \cdot c\right)\right)\right)\right), x\right), x\right) \]
      14. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(s \cdot c\right) \cdot c\right)\right)\right), x\right), x\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(c \cdot \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(c \cdot s\right)\right)\right)\right), x\right), x\right) \]
      18. *-lowering-*.f6464.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right), x\right), x\right) \]
    5. Simplified64.0%

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

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

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

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

        \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
      5. swap-sqrN/A

        \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}} \]
      6. unpow2N/A

        \[\leadsto \frac{1}{{\left(\left(c \cdot s\right) \cdot x\right)}^{\color{blue}{2}}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left({\left(\left(c \cdot s\right) \cdot x\right)}^{2}\right)}\right) \]
      8. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left({\left(c \cdot \left(s \cdot x\right)\right)}^{2}\right)\right) \]
      9. unpow-prod-downN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left({c}^{2} \cdot \color{blue}{{\left(s \cdot x\right)}^{2}}\right)\right) \]
      10. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot {\color{blue}{\left(s \cdot x\right)}}^{2}\right)\right) \]
      11. pow2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(\left(x \cdot s\right) \cdot \left(\color{blue}{s} \cdot x\right)\right)\right)\right) \]
      13. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(s \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(\left(c \cdot c\right) \cdot x\right)}\right)\right) \]
      16. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(s \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
      17. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
      18. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot s\right) \cdot \left(\color{blue}{\left(c \cdot c\right)} \cdot x\right)\right)\right)\right) \]
      19. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \color{blue}{\left(s \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right)\right) \]
      20. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      21. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \color{blue}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right)}\right)\right)\right) \]
      22. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot s\right)}\right)\right)\right)\right) \]
      23. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \left(s \cdot \color{blue}{x}\right)\right)\right)\right)\right) \]
      24. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(c \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right)\right)\right) \]
    7. Applied egg-rr69.8%

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

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \left(c \cdot \left(c \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right)\right)\right) \]
      2. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(\left(c \cdot s\right) \cdot \color{blue}{x}\right)\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right) \]
      5. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      6. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot \color{blue}{s}\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right), \color{blue}{s}\right)\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(x \cdot c\right), \left(x \cdot c\right)\right), s\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \left(x \cdot c\right)\right), s\right)\right)\right) \]
      10. *-lowering-*.f6464.5%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \mathsf{*.f64}\left(x, c\right)\right), s\right)\right)\right) \]
    9. Applied egg-rr64.5%

      \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot s\right)}} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot s\right) \cdot \color{blue}{s}\right)\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot \color{blue}{\left(s \cdot s\right)}\right)\right) \]
      3. swap-sqrN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\left(x \cdot c\right) \cdot s\right) \cdot \color{blue}{\left(\left(x \cdot c\right) \cdot s\right)}\right)\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(\color{blue}{\left(x \cdot c\right)} \cdot s\right)\right)\right) \]
      5. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\left(c \cdot s\right) \cdot x\right) \cdot \left(\color{blue}{x} \cdot \left(c \cdot s\right)\right)\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(\color{blue}{x} \cdot \left(c \cdot s\right)\right)\right)\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(\left(c \cdot s\right) \cdot \color{blue}{x}\right)\right)\right) \]
      9. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(c \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)}\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(c, \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)}\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(\left(s \cdot x\right), \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}\right)\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(\left(x \cdot s\right), \left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)\right)\right)\right) \]
      13. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, s\right), \left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)\right)\right)\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, s\right), \left(x \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, s\right), \mathsf{*.f64}\left(x, \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right) \]
      16. *-lowering-*.f6470.7%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, s\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(c, \color{blue}{s}\right)\right)\right)\right)\right) \]
    11. Applied egg-rr70.7%

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

    if 0.0550000000000000003 < c

    1. Initial program 63.1%

      \[\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. associate-/r*N/A

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

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

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

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

        \[\leadsto \frac{\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{x}}{x \cdot s}}{\color{blue}{s}} \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{\frac{\cos \left(2 \cdot x\right)}{{c}^{2}}}{x}}{x \cdot s}\right), \color{blue}{s}\right) \]
    4. Applied egg-rr74.4%

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

      \[\leadsto \mathsf{/.f64}\left(\color{blue}{\left(\frac{1}{{c}^{2} \cdot \left(s \cdot {x}^{2}\right)}\right)}, s\right) \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({c}^{2} \cdot \left(s \cdot {x}^{2}\right)\right)\right), s\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({c}^{2} \cdot \left(s \cdot \left(x \cdot x\right)\right)\right)\right), s\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({c}^{2} \cdot \left(\left(s \cdot x\right) \cdot x\right)\right)\right), s\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(\left({c}^{2} \cdot \left(s \cdot x\right)\right) \cdot x\right)\right), s\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(x \cdot \left({c}^{2} \cdot \left(s \cdot x\right)\right)\right)\right), s\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(x, \left({c}^{2} \cdot \left(s \cdot x\right)\right)\right)\right), s\right) \]
      7. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \left(s \cdot x\right)\right)\right)\right), s\right) \]
      8. associate-*l*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(x, \left(c \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)\right)\right), s\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(c, \left(c \cdot \left(s \cdot x\right)\right)\right)\right)\right), s\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \left(s \cdot x\right)\right)\right)\right)\right), s\right) \]
      11. *-lowering-*.f6477.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, x\right)\right)\right)\right)\right), s\right) \]
    7. Simplified77.1%

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

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

Alternative 12: 77.8% accurate, 24.1× speedup?

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

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

      \[\leadsto \frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}} \]
    2. unpow2N/A

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

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

      \[\leadsto \frac{\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}}{\color{blue}{x}} \]
    5. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{\left({c}^{2} \cdot {s}^{2}\right) \cdot x}\right), \color{blue}{x}\right) \]
    6. associate-/r*N/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{\frac{1}{{c}^{2} \cdot {s}^{2}}}{x}\right), x\right) \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\frac{1}{{c}^{2} \cdot {s}^{2}}\right), x\right), x\right) \]
    8. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({c}^{2} \cdot {s}^{2}\right)\right), x\right), x\right) \]
    9. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left({s}^{2} \cdot {c}^{2}\right)\right), x\right), x\right) \]
    10. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(\left(s \cdot s\right) \cdot {c}^{2}\right)\right), x\right), x\right) \]
    11. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \left(s \cdot \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot {c}^{2}\right)\right)\right), x\right), x\right) \]
    13. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(s \cdot \left(c \cdot c\right)\right)\right)\right), x\right), x\right) \]
    14. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(s \cdot c\right) \cdot c\right)\right)\right), x\right), x\right) \]
    15. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(c \cdot \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
    16. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(s \cdot c\right)\right)\right)\right), x\right), x\right) \]
    17. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(c \cdot s\right)\right)\right)\right), x\right), x\right) \]
    18. *-lowering-*.f6465.8%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right), x\right), x\right) \]
  5. Simplified65.8%

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

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

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

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

      \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
    5. swap-sqrN/A

      \[\leadsto \frac{1}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}} \]
    6. unpow2N/A

      \[\leadsto \frac{1}{{\left(\left(c \cdot s\right) \cdot x\right)}^{\color{blue}{2}}} \]
    7. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left({\left(\left(c \cdot s\right) \cdot x\right)}^{2}\right)}\right) \]
    8. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(1, \left({\left(c \cdot \left(s \cdot x\right)\right)}^{2}\right)\right) \]
    9. unpow-prod-downN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left({c}^{2} \cdot \color{blue}{{\left(s \cdot x\right)}^{2}}\right)\right) \]
    10. pow2N/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot {\color{blue}{\left(s \cdot x\right)}}^{2}\right)\right) \]
    11. pow2N/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right) \]
    12. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(\left(x \cdot s\right) \cdot \left(\color{blue}{s} \cdot x\right)\right)\right)\right) \]
    13. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
    14. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{\left(s \cdot \left(s \cdot x\right)\right)}\right)\right) \]
    15. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(s \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(\left(c \cdot c\right) \cdot x\right)}\right)\right) \]
    16. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(s \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
    17. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right) \]
    18. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot s\right) \cdot \left(\color{blue}{\left(c \cdot c\right)} \cdot x\right)\right)\right)\right) \]
    19. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \color{blue}{\left(s \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)}\right)\right)\right) \]
    20. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \left(\left(\left(c \cdot c\right) \cdot x\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
    21. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \color{blue}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right)}\right)\right)\right) \]
    22. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot s\right)}\right)\right)\right)\right) \]
    23. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(\left(c \cdot c\right) \cdot \left(s \cdot \color{blue}{x}\right)\right)\right)\right)\right) \]
    24. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \left(c \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right)\right)\right) \]
  7. Applied egg-rr71.4%

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

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(x \cdot \left(c \cdot \left(c \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)\right)\right)\right) \]
    2. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)\right)\right) \]
    3. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(\left(c \cdot s\right) \cdot \color{blue}{x}\right)\right)\right)\right) \]
    4. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right) \]
    5. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(x \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
    6. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot \color{blue}{s}\right)\right)\right) \]
    7. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right), \color{blue}{s}\right)\right)\right) \]
    8. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(x \cdot c\right), \left(x \cdot c\right)\right), s\right)\right)\right) \]
    9. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \left(x \cdot c\right)\right), s\right)\right)\right) \]
    10. *-lowering-*.f6467.0%

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, c\right), \mathsf{*.f64}\left(x, c\right)\right), s\right)\right)\right) \]
  9. Applied egg-rr67.0%

    \[\leadsto \frac{1}{s \cdot \color{blue}{\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot s\right)}} \]
  10. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot s\right) \cdot \color{blue}{s}\right)\right) \]
    2. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot \color{blue}{\left(s \cdot s\right)}\right)\right) \]
    3. swap-sqrN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\left(x \cdot c\right) \cdot s\right) \cdot \color{blue}{\left(\left(x \cdot c\right) \cdot s\right)}\right)\right) \]
    4. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(\color{blue}{\left(x \cdot c\right)} \cdot s\right)\right)\right) \]
    5. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right) \]
    6. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(\left(c \cdot s\right) \cdot x\right) \cdot \left(\color{blue}{x} \cdot \left(c \cdot s\right)\right)\right)\right) \]
    7. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(\color{blue}{x} \cdot \left(c \cdot s\right)\right)\right)\right) \]
    8. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(\left(c \cdot s\right) \cdot \color{blue}{x}\right)\right)\right) \]
    9. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(1, \left(c \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)}\right)\right) \]
    10. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(c, \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)}\right)\right) \]
    11. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(\left(s \cdot x\right), \color{blue}{\left(\left(c \cdot s\right) \cdot x\right)}\right)\right)\right) \]
    12. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(\left(x \cdot s\right), \left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)\right)\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, s\right), \left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)\right)\right)\right) \]
    14. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, s\right), \left(x \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right) \]
    15. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, s\right), \mathsf{*.f64}\left(x, \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right) \]
    16. *-lowering-*.f6471.9%

      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, s\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(c, \color{blue}{s}\right)\right)\right)\right)\right) \]
  11. Applied egg-rr71.9%

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

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

Alternative 13: 25.4% accurate, 34.8× speedup?

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

    \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
  4. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\cos \left(2 \cdot x\right), \color{blue}{\left({c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)}\right) \]
    2. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\left(2 \cdot x\right)\right), \left(\color{blue}{{c}^{2}} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left({\color{blue}{c}}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)\right) \]
    4. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{{x}^{2}}\right)\right) \]
    5. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot \color{blue}{x}\right)\right)\right) \]
    6. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right) \cdot \color{blue}{x}\right)\right) \]
    7. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \left(x \cdot \color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}\right)\right) \]
    8. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \color{blue}{\left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}\right)\right) \]
    9. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(x \cdot \color{blue}{\left({c}^{2} \cdot {s}^{2}\right)}\right)\right)\right) \]
    10. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\left({c}^{2} \cdot {s}^{2}\right)}\right)\right)\right) \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left({s}^{2} \cdot \color{blue}{{c}^{2}}\right)\right)\right)\right) \]
    12. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left(\left(s \cdot s\right) \cdot {\color{blue}{c}}^{2}\right)\right)\right)\right) \]
    13. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \left(s \cdot \color{blue}{\left(s \cdot {c}^{2}\right)}\right)\right)\right)\right) \]
    14. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \color{blue}{\left(s \cdot {c}^{2}\right)}\right)\right)\right)\right) \]
    15. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(s \cdot \left(c \cdot \color{blue}{c}\right)\right)\right)\right)\right)\right) \]
    16. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(\left(s \cdot c\right) \cdot \color{blue}{c}\right)\right)\right)\right)\right) \]
    17. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(s \cdot c\right)}\right)\right)\right)\right)\right) \]
    18. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \color{blue}{\left(s \cdot c\right)}\right)\right)\right)\right)\right) \]
    19. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \left(c \cdot \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
    20. *-lowering-*.f6481.4%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \color{blue}{s}\right)\right)\right)\right)\right)\right) \]
  5. Simplified81.4%

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right) \cdot \color{blue}{x}\right)\right)\right) \]
    2. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right), \color{blue}{x}\right)\right)\right) \]
    3. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right), x\right)\right)\right) \]
    4. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right), x\right)\right)\right) \]
    5. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\left(c \cdot \left(s \cdot \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
    6. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \left(s \cdot \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
    7. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \left(c \cdot s\right)\right)\right), x\right)\right)\right) \]
    8. *-lowering-*.f6480.6%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, s\right)\right)\right), x\right)\right)\right) \]
  7. Applied egg-rr80.6%

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

    \[\leadsto \mathsf{/.f64}\left(\color{blue}{\left(1 + -2 \cdot {x}^{2}\right)}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, s\right)\right)\right), x\right)\right)\right) \]
  9. Step-by-step derivation
    1. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(-2 \cdot {x}^{2}\right)\right), \mathsf{*.f64}\left(\color{blue}{x}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, s\right)\right)\right), x\right)\right)\right) \]
    2. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(-2 \cdot \left(x \cdot x\right)\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, s\right)\right)\right), x\right)\right)\right) \]
    3. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(\left(-2 \cdot x\right) \cdot x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, s\right)\right)\right), x\right)\right)\right) \]
    4. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(x \cdot \left(-2 \cdot x\right)\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, s\right)\right)\right), x\right)\right)\right) \]
    5. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(x, \left(-2 \cdot x\right)\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, s\right)\right)\right), x\right)\right)\right) \]
    6. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(x, \left(x \cdot -2\right)\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, s\right)\right)\right), x\right)\right)\right) \]
    7. *-lowering-*.f6450.6%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, -2\right)\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(\mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, s\right)\right)\right), x\right)\right)\right) \]
  10. Simplified50.6%

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

    \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
  12. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(-2, \color{blue}{\left({c}^{2} \cdot {s}^{2}\right)}\right) \]
    2. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(-2, \left({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right) \]
    3. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(-2, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right) \]
    4. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(-2, \left(s \cdot \color{blue}{\left({c}^{2} \cdot s\right)}\right)\right) \]
    5. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(s, \color{blue}{\left({c}^{2} \cdot s\right)}\right)\right) \]
    6. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(s, \left(\left(c \cdot c\right) \cdot s\right)\right)\right) \]
    7. associate-*l*N/A

      \[\leadsto \mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right) \]
    8. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \color{blue}{\left(c \cdot s\right)}\right)\right)\right) \]
    9. *-lowering-*.f6423.0%

      \[\leadsto \mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \color{blue}{s}\right)\right)\right)\right) \]
  13. Simplified23.0%

    \[\leadsto \color{blue}{\frac{-2}{s \cdot \left(c \cdot \left(c \cdot s\right)\right)}} \]
  14. Add Preprocessing

Reproduce

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