mixedcos

Percentage Accurate: 66.2% → 97.5%
Time: 12.4s
Alternatives: 16
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 16 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.2% accurate, 1.0× speedup?

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

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

Alternative 1: 97.5% accurate, 2.6× speedup?

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

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


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

    1. Initial program 68.9%

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
      12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
      16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
      17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
      18. *-lowering-*.f6486.1%

        \[\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) \]
    3. Simplified86.1%

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

      \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}\right), \color{blue}{\left({x}^{2}\right)}\right) \]
    7. Simplified49.8%

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

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

        \[\leadsto \left(1 + x \cdot \left(x \cdot -2\right)\right) \cdot \frac{\frac{1}{c \cdot c} \cdot \frac{1}{s \cdot s}}{\color{blue}{x} \cdot x} \]
      3. frac-timesN/A

        \[\leadsto \left(1 + x \cdot \left(x \cdot -2\right)\right) \cdot \frac{\frac{1 \cdot 1}{\left(c \cdot c\right) \cdot \left(s \cdot s\right)}}{\color{blue}{x} \cdot x} \]
      4. metadata-evalN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.50000000000000012e-5 < x

    1. Initial program 55.6%

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
      12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
      16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
      17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
      18. *-lowering-*.f6481.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) \]
    3. Simplified81.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)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. associate-/r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 96.5% accurate, 2.6× speedup?

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

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


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

    1. Initial program 68.9%

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
      12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
      16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
      17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
      18. *-lowering-*.f6486.1%

        \[\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) \]
    3. Simplified86.1%

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

      \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}\right), \color{blue}{\left({x}^{2}\right)}\right) \]
    7. Simplified49.8%

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

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

        \[\leadsto \left(1 + x \cdot \left(x \cdot -2\right)\right) \cdot \frac{\frac{1}{c \cdot c} \cdot \frac{1}{s \cdot s}}{\color{blue}{x} \cdot x} \]
      3. frac-timesN/A

        \[\leadsto \left(1 + x \cdot \left(x \cdot -2\right)\right) \cdot \frac{\frac{1 \cdot 1}{\left(c \cdot c\right) \cdot \left(s \cdot s\right)}}{\color{blue}{x} \cdot x} \]
      4. metadata-evalN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.50000000000000012e-5 < x

    1. Initial program 55.6%

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
      12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
      16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
      17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
      18. *-lowering-*.f6481.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) \]
    3. Simplified81.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)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. associate-/r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 95.2% accurate, 2.6× speedup?

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

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


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

    1. Initial program 65.1%

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
      12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
      16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
      17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
      18. *-lowering-*.f6485.2%

        \[\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) \]
    3. Simplified85.2%

      \[\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)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. associate-/r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999996e-95 < c

    1. Initial program 66.6%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. 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(\left(x \cdot {s}^{2}\right) \cdot x\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(\left(x \cdot {s}^{2}\right) \cdot x\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(\left(x \cdot {s}^{2}\right) \cdot x\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 \left(x \cdot {s}^{2}\right)\right) \cdot \color{blue}{x}\right)\right) \]
      5. *-commutativeN/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
      12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
      16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
      17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
      18. *-lowering-*.f6484.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) \]
    3. Simplified84.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)}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. associate-/r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 95.5% accurate, 2.6× speedup?

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

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


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

    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. 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(\left(x \cdot {s}^{2}\right) \cdot x\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(\left(x \cdot {s}^{2}\right) \cdot x\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(\left(x \cdot {s}^{2}\right) \cdot x\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 \left(x \cdot {s}^{2}\right)\right) \cdot \color{blue}{x}\right)\right) \]
      5. *-commutativeN/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
      12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
      13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
      16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
      17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
      18. *-lowering-*.f6485.5%

        \[\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) \]
    3. Simplified85.5%

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

      \[\leadsto \mathsf{/.f64}\left(\color{blue}{1}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right)\right)\right) \]
    6. Step-by-step derivation
      1. Simplified76.9%

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, c\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \color{blue}{c}\right)\right)\right)\right) \]
      3. Applied egg-rr86.8%

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

      if 5.2e-22 < x

      1. Initial program 60.7%

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

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

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

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
        12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
        13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
        16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
        17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
        18. *-lowering-*.f6483.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) \]
      3. Simplified83.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)}} \]
      4. Add Preprocessing
      5. Step-by-step derivation
        1. associate-/r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 5: 94.3% accurate, 2.6× speedup?

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

      1. Initial program 68.9%

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

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

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

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
        12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
        13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
        16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
        17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
        18. *-lowering-*.f6486.1%

          \[\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) \]
      3. Simplified86.1%

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

        \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
      6. Step-by-step derivation
        1. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\left(-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}\right), \color{blue}{\left({x}^{2}\right)}\right) \]
      7. Simplified49.8%

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

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

          \[\leadsto \left(1 + x \cdot \left(x \cdot -2\right)\right) \cdot \frac{\frac{1}{c \cdot c} \cdot \frac{1}{s \cdot s}}{\color{blue}{x} \cdot x} \]
        3. frac-timesN/A

          \[\leadsto \left(1 + x \cdot \left(x \cdot -2\right)\right) \cdot \frac{\frac{1 \cdot 1}{\left(c \cdot c\right) \cdot \left(s \cdot s\right)}}{\color{blue}{x} \cdot x} \]
        4. metadata-evalN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 2.50000000000000012e-5 < x

      1. Initial program 55.6%

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

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

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

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
        12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
        13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
        16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
        17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
        18. *-lowering-*.f6481.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) \]
      3. Simplified81.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)}} \]
      4. Add Preprocessing
      5. Step-by-step derivation
        1. associate-*r*N/A

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

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

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left(x \cdot c\right) \cdot \color{blue}{\left(s \cdot \left(c \cdot s\right)\right)}\right)\right)\right) \]
        5. *-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(x \cdot c\right), \color{blue}{\left(s \cdot \left(c \cdot s\right)\right)}\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(x, c\right), \left(\color{blue}{s} \cdot \left(c \cdot s\right)\right)\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(x, c\right), \mathsf{*.f64}\left(s, \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right) \]
        8. *-commutativeN/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(x, c\right), \mathsf{*.f64}\left(s, \left(s \cdot \color{blue}{c}\right)\right)\right)\right)\right) \]
        9. *-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(x, c\right), \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(s, \color{blue}{c}\right)\right)\right)\right)\right) \]
      6. Applied egg-rr84.9%

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

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

    Alternative 6: 95.0% accurate, 2.6× speedup?

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

      1. Initial program 68.9%

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

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

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

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
        12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
        13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
        16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
        17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
        18. *-lowering-*.f6486.1%

          \[\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) \]
      3. Simplified86.1%

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

        \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
      6. Step-by-step derivation
        1. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\left(-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}\right), \color{blue}{\left({x}^{2}\right)}\right) \]
      7. Simplified49.8%

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

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

          \[\leadsto \left(1 + x \cdot \left(x \cdot -2\right)\right) \cdot \frac{\frac{1}{c \cdot c} \cdot \frac{1}{s \cdot s}}{\color{blue}{x} \cdot x} \]
        3. frac-timesN/A

          \[\leadsto \left(1 + x \cdot \left(x \cdot -2\right)\right) \cdot \frac{\frac{1 \cdot 1}{\left(c \cdot c\right) \cdot \left(s \cdot s\right)}}{\color{blue}{x} \cdot x} \]
        4. metadata-evalN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 2.50000000000000012e-5 < x

      1. Initial program 55.6%

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

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

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

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
        12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
        13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
        16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
        17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
        18. *-lowering-*.f6481.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) \]
      3. Simplified81.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)}} \]
      4. Add Preprocessing
      5. Step-by-step derivation
        1. *-commutativeN/A

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\left(s \cdot c\right), \left(c \cdot x\right)\right), x\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(s, \mathsf{*.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(s, c\right), \left(c \cdot x\right)\right), x\right)\right)\right) \]
        12. *-lowering-*.f6484.9%

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

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

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

    Alternative 7: 77.8% accurate, 13.0× speedup?

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

      1. Initial program 69.2%

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

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

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

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
        12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
        13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
        16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
        17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
        18. *-lowering-*.f6486.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) \]
      3. Simplified86.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)}} \]
      4. Add Preprocessing
      5. Taylor expanded in x around 0

        \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
      6. Step-by-step derivation
        1. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\left(-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}\right), \color{blue}{\left({x}^{2}\right)}\right) \]
      7. Simplified49.2%

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

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

          \[\leadsto \left(1 + x \cdot \left(x \cdot -2\right)\right) \cdot \frac{\frac{1}{c \cdot c} \cdot \frac{1}{s \cdot s}}{\color{blue}{x} \cdot x} \]
        3. frac-timesN/A

          \[\leadsto \left(1 + x \cdot \left(x \cdot -2\right)\right) \cdot \frac{\frac{1 \cdot 1}{\left(c \cdot c\right) \cdot \left(s \cdot s\right)}}{\color{blue}{x} \cdot x} \]
        4. metadata-evalN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 8.50000000000000038e67 < x

      1. Initial program 49.7%

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

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

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

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
        12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
        13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
        16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
        17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
        18. *-lowering-*.f6478.1%

          \[\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) \]
      3. Simplified78.1%

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

        \[\leadsto \mathsf{/.f64}\left(\color{blue}{1}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right)\right)\right) \]
      6. Step-by-step derivation
        1. Simplified65.4%

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{1}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)}} \]
      7. Recombined 2 regimes into one program.
      8. Add Preprocessing

      Alternative 8: 73.5% accurate, 17.4× speedup?

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

        1. Initial program 65.1%

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

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

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

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

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
          12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
          13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
          16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
          17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
          18. *-lowering-*.f6485.2%

            \[\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) \]
        3. Simplified85.2%

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

          \[\leadsto \mathsf{/.f64}\left(\color{blue}{1}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right)\right)\right) \]
        6. Step-by-step derivation
          1. Simplified72.7%

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

          if 2.20000000000000001e-94 < c

          1. Initial program 66.6%

            \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
          2. 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(\left(x \cdot {s}^{2}\right) \cdot x\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(\left(x \cdot {s}^{2}\right) \cdot x\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(\left(x \cdot {s}^{2}\right) \cdot x\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 \left(x \cdot {s}^{2}\right)\right) \cdot \color{blue}{x}\right)\right) \]
            5. *-commutativeN/A

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

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

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
            12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
            13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
            16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
            17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
            18. *-lowering-*.f6484.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) \]
          3. Simplified84.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)}} \]
          4. Add Preprocessing
          5. Taylor expanded in x around 0

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{1}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right)\right)\right) \]
          6. Step-by-step derivation
            1. Simplified71.1%

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

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(x, \color{blue}{\left({c}^{2} \cdot \left({s}^{2} \cdot x\right)\right)}\right)\right) \]
            3. Step-by-step derivation
              1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{1}{x \cdot \color{blue}{\left(s \cdot \left(s \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)\right)}} \]
          7. Recombined 2 regimes into one program.
          8. Final simplification71.2%

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

          Alternative 9: 70.6% accurate, 17.4× speedup?

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

            1. Initial program 65.0%

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

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

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

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

                \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
              12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
              13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
              16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
              17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
              18. *-lowering-*.f6485.3%

                \[\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) \]
            3. Simplified85.3%

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

              \[\leadsto \mathsf{/.f64}\left(\color{blue}{1}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right)\right)\right) \]
            6. Step-by-step derivation
              1. Simplified72.8%

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

                \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left({c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)}\right) \]
              3. Step-by-step derivation
                1. unpow2N/A

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

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

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

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

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

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

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

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

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

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \color{blue}{x}\right)\right)\right)\right)\right)\right) \]
              4. Simplified64.0%

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

              if 3.3999999999999999e-149 < c

              1. Initial program 66.7%

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

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

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

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

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
                12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
                13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
                16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                18. *-lowering-*.f6484.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) \]
              3. Simplified84.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)}} \]
              4. Add Preprocessing
              5. Taylor expanded in x around 0

                \[\leadsto \mathsf{/.f64}\left(\color{blue}{1}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right)\right)\right) \]
              6. Step-by-step derivation
                1. Simplified70.9%

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

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(x, \color{blue}{\left({c}^{2} \cdot \left({s}^{2} \cdot x\right)\right)}\right)\right) \]
                3. Step-by-step derivation
                  1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{1}{x \cdot \color{blue}{\left(s \cdot \left(s \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)\right)}} \]
              7. Recombined 2 regimes into one program.
              8. Final simplification65.8%

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

              Alternative 10: 31.0% accurate, 19.5× speedup?

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

                1. Initial program 68.8%

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

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

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

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

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
                  12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
                  13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
                  16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                  17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                  18. *-lowering-*.f6486.3%

                    \[\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) \]
                3. Simplified86.3%

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

                  \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
                6. Step-by-step derivation
                  1. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\left(-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}\right), \color{blue}{\left({x}^{2}\right)}\right) \]
                7. Simplified49.1%

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

                  \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
                9. Step-by-step derivation
                  1. unpow2N/A

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

                    \[\leadsto \frac{-2}{\left(c \cdot c\right) \cdot \left(s \cdot \color{blue}{s}\right)} \]
                  3. unswap-sqrN/A

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

                    \[\leadsto \frac{\frac{-2}{c \cdot s}}{\color{blue}{c \cdot s}} \]
                  5. metadata-evalN/A

                    \[\leadsto \frac{\frac{\mathsf{neg}\left(2\right)}{c \cdot s}}{c \cdot s} \]
                  6. distribute-neg-fracN/A

                    \[\leadsto \frac{\mathsf{neg}\left(\frac{2}{c \cdot s}\right)}{\color{blue}{c} \cdot s} \]
                  7. metadata-evalN/A

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

                    \[\leadsto \frac{\mathsf{neg}\left(2 \cdot \frac{1}{c \cdot s}\right)}{c \cdot s} \]
                  9. /-lowering-/.f64N/A

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

                    \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\frac{2 \cdot 1}{c \cdot s}\right)\right), \left(c \cdot s\right)\right) \]
                  11. metadata-evalN/A

                    \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\frac{2}{c \cdot s}\right)\right), \left(c \cdot s\right)\right) \]
                  12. distribute-neg-fracN/A

                    \[\leadsto \mathsf{/.f64}\left(\left(\frac{\mathsf{neg}\left(2\right)}{c \cdot s}\right), \left(\color{blue}{c} \cdot s\right)\right) \]
                  13. metadata-evalN/A

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

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

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(c, s\right)\right), \left(c \cdot s\right)\right) \]
                  16. *-lowering-*.f6422.7%

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(c, s\right)\right), \mathsf{*.f64}\left(c, \color{blue}{s}\right)\right) \]
                10. Simplified22.7%

                  \[\leadsto \color{blue}{\frac{\frac{-2}{c \cdot s}}{c \cdot s}} \]
                11. Step-by-step derivation
                  1. associate-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \color{blue}{s}\right)\right)\right)\right) \]
                12. Applied egg-rr25.2%

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

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

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

                    \[\leadsto \frac{\frac{\frac{-2}{c}}{s}}{\color{blue}{c \cdot s}} \]
                  4. div-invN/A

                    \[\leadsto \frac{\frac{-2}{c} \cdot \frac{1}{s}}{\color{blue}{c} \cdot s} \]
                  5. *-commutativeN/A

                    \[\leadsto \frac{\frac{1}{s} \cdot \frac{-2}{c}}{\color{blue}{c} \cdot s} \]
                  6. associate-*r/N/A

                    \[\leadsto \frac{\frac{\frac{1}{s} \cdot -2}{c}}{\color{blue}{c} \cdot s} \]
                  7. associate-/l/N/A

                    \[\leadsto \frac{\frac{1}{s} \cdot -2}{\color{blue}{\left(c \cdot s\right) \cdot c}} \]
                  8. frac-2negN/A

                    \[\leadsto \frac{\mathsf{neg}\left(\frac{1}{s} \cdot -2\right)}{\color{blue}{\mathsf{neg}\left(\left(c \cdot s\right) \cdot c\right)}} \]
                  9. distribute-rgt-neg-outN/A

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

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

                    \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(-2 \cdot \frac{1}{s}\right)\right), \left(\left(\color{blue}{c} \cdot s\right) \cdot \left(\mathsf{neg}\left(c\right)\right)\right)\right) \]
                  12. distribute-lft-neg-inN/A

                    \[\leadsto \mathsf{/.f64}\left(\left(\left(\mathsf{neg}\left(-2\right)\right) \cdot \frac{1}{s}\right), \left(\color{blue}{\left(c \cdot s\right)} \cdot \left(\mathsf{neg}\left(c\right)\right)\right)\right) \]
                  13. metadata-evalN/A

                    \[\leadsto \mathsf{/.f64}\left(\left(2 \cdot \frac{1}{s}\right), \left(\left(\color{blue}{c} \cdot s\right) \cdot \left(\mathsf{neg}\left(c\right)\right)\right)\right) \]
                  14. un-div-invN/A

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

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

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

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(2, s\right), \left(s \cdot \color{blue}{\left(c \cdot \left(\mathsf{neg}\left(c\right)\right)\right)}\right)\right) \]
                  18. distribute-rgt-neg-inN/A

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

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

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

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(2, s\right), \mathsf{*.f64}\left(s, \mathsf{\_.f64}\left(0, \color{blue}{\left(c \cdot c\right)}\right)\right)\right) \]
                  22. *-lowering-*.f6436.9%

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(2, s\right), \mathsf{*.f64}\left(s, \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(c, \color{blue}{c}\right)\right)\right)\right) \]
                14. Applied egg-rr36.9%

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

                if 1.45e20 < x

                1. Initial program 55.0%

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

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

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

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

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
                  12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
                  13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
                  16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                  17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                  18. *-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) \]
                3. 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)}} \]
                4. Add Preprocessing
                5. Taylor expanded in x around 0

                  \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
                6. Step-by-step derivation
                  1. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\left(-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}\right), \color{blue}{\left({x}^{2}\right)}\right) \]
                7. Simplified17.8%

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

                  \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
                9. Step-by-step derivation
                  1. unpow2N/A

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

                    \[\leadsto \frac{-2}{\left(c \cdot c\right) \cdot \left(s \cdot \color{blue}{s}\right)} \]
                  3. unswap-sqrN/A

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

                    \[\leadsto \frac{\frac{-2}{c \cdot s}}{\color{blue}{c \cdot s}} \]
                  5. metadata-evalN/A

                    \[\leadsto \frac{\frac{\mathsf{neg}\left(2\right)}{c \cdot s}}{c \cdot s} \]
                  6. distribute-neg-fracN/A

                    \[\leadsto \frac{\mathsf{neg}\left(\frac{2}{c \cdot s}\right)}{\color{blue}{c} \cdot s} \]
                  7. metadata-evalN/A

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

                    \[\leadsto \frac{\mathsf{neg}\left(2 \cdot \frac{1}{c \cdot s}\right)}{c \cdot s} \]
                  9. /-lowering-/.f64N/A

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

                    \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\frac{2 \cdot 1}{c \cdot s}\right)\right), \left(c \cdot s\right)\right) \]
                  11. metadata-evalN/A

                    \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\frac{2}{c \cdot s}\right)\right), \left(c \cdot s\right)\right) \]
                  12. distribute-neg-fracN/A

                    \[\leadsto \mathsf{/.f64}\left(\left(\frac{\mathsf{neg}\left(2\right)}{c \cdot s}\right), \left(\color{blue}{c} \cdot s\right)\right) \]
                  13. metadata-evalN/A

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

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

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(c, s\right)\right), \left(c \cdot s\right)\right) \]
                  16. *-lowering-*.f6433.2%

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(c, s\right)\right), \mathsf{*.f64}\left(c, \color{blue}{s}\right)\right) \]
                10. Simplified33.2%

                  \[\leadsto \color{blue}{\frac{\frac{-2}{c \cdot s}}{c \cdot s}} \]
                11. Step-by-step derivation
                  1. associate-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \color{blue}{s}\right)\right)\right)\right) \]
                12. Applied egg-rr38.0%

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

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

              Alternative 11: 31.1% accurate, 19.5× speedup?

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

                1. Initial program 68.8%

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

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

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

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

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
                  12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
                  13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
                  16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                  17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                  18. *-lowering-*.f6486.3%

                    \[\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) \]
                3. Simplified86.3%

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

                  \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
                6. Step-by-step derivation
                  1. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\left(-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}\right), \color{blue}{\left({x}^{2}\right)}\right) \]
                7. Simplified49.1%

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

                  \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
                9. Step-by-step derivation
                  1. unpow2N/A

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

                    \[\leadsto \frac{-2}{\left(c \cdot c\right) \cdot \left(s \cdot \color{blue}{s}\right)} \]
                  3. unswap-sqrN/A

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

                    \[\leadsto \frac{\frac{-2}{c \cdot s}}{\color{blue}{c \cdot s}} \]
                  5. metadata-evalN/A

                    \[\leadsto \frac{\frac{\mathsf{neg}\left(2\right)}{c \cdot s}}{c \cdot s} \]
                  6. distribute-neg-fracN/A

                    \[\leadsto \frac{\mathsf{neg}\left(\frac{2}{c \cdot s}\right)}{\color{blue}{c} \cdot s} \]
                  7. metadata-evalN/A

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

                    \[\leadsto \frac{\mathsf{neg}\left(2 \cdot \frac{1}{c \cdot s}\right)}{c \cdot s} \]
                  9. /-lowering-/.f64N/A

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

                    \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\frac{2 \cdot 1}{c \cdot s}\right)\right), \left(c \cdot s\right)\right) \]
                  11. metadata-evalN/A

                    \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\frac{2}{c \cdot s}\right)\right), \left(c \cdot s\right)\right) \]
                  12. distribute-neg-fracN/A

                    \[\leadsto \mathsf{/.f64}\left(\left(\frac{\mathsf{neg}\left(2\right)}{c \cdot s}\right), \left(\color{blue}{c} \cdot s\right)\right) \]
                  13. metadata-evalN/A

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

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

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(c, s\right)\right), \left(c \cdot s\right)\right) \]
                  16. *-lowering-*.f6422.7%

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(c, s\right)\right), \mathsf{*.f64}\left(c, \color{blue}{s}\right)\right) \]
                10. Simplified22.7%

                  \[\leadsto \color{blue}{\frac{\frac{-2}{c \cdot s}}{c \cdot s}} \]
                11. Step-by-step derivation
                  1. associate-/l/N/A

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

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

                    \[\leadsto \frac{-2}{\left(s \cdot c\right) \cdot \left(s \cdot \color{blue}{c}\right)} \]
                  4. frac-2negN/A

                    \[\leadsto \frac{\mathsf{neg}\left(-2\right)}{\color{blue}{\mathsf{neg}\left(\left(s \cdot c\right) \cdot \left(s \cdot c\right)\right)}} \]
                  5. metadata-evalN/A

                    \[\leadsto \frac{2}{\mathsf{neg}\left(\color{blue}{\left(s \cdot c\right) \cdot \left(s \cdot c\right)}\right)} \]
                  6. sub0-negN/A

                    \[\leadsto \frac{2}{0 - \color{blue}{\left(s \cdot c\right) \cdot \left(s \cdot c\right)}} \]
                  7. metadata-evalN/A

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

                    \[\leadsto \mathsf{/.f64}\left(2, \color{blue}{\left(0 \cdot 0 - \left(s \cdot c\right) \cdot \left(s \cdot c\right)\right)}\right) \]
                  9. metadata-evalN/A

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{/.f64}\left(2, \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \color{blue}{\left(s \cdot s\right)}\right)\right)\right)\right) \]
                  18. *-lowering-*.f6447.9%

                    \[\leadsto \mathsf{/.f64}\left(2, \mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \color{blue}{s}\right)\right)\right)\right)\right) \]
                12. Applied egg-rr47.9%

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

                if 1.45e20 < x

                1. Initial program 55.0%

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

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

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

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

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
                  12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
                  13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
                  16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                  17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                  18. *-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) \]
                3. 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)}} \]
                4. Add Preprocessing
                5. Taylor expanded in x around 0

                  \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
                6. Step-by-step derivation
                  1. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\left(-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}\right), \color{blue}{\left({x}^{2}\right)}\right) \]
                7. Simplified17.8%

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

                  \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
                9. Step-by-step derivation
                  1. unpow2N/A

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

                    \[\leadsto \frac{-2}{\left(c \cdot c\right) \cdot \left(s \cdot \color{blue}{s}\right)} \]
                  3. unswap-sqrN/A

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

                    \[\leadsto \frac{\frac{-2}{c \cdot s}}{\color{blue}{c \cdot s}} \]
                  5. metadata-evalN/A

                    \[\leadsto \frac{\frac{\mathsf{neg}\left(2\right)}{c \cdot s}}{c \cdot s} \]
                  6. distribute-neg-fracN/A

                    \[\leadsto \frac{\mathsf{neg}\left(\frac{2}{c \cdot s}\right)}{\color{blue}{c} \cdot s} \]
                  7. metadata-evalN/A

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

                    \[\leadsto \frac{\mathsf{neg}\left(2 \cdot \frac{1}{c \cdot s}\right)}{c \cdot s} \]
                  9. /-lowering-/.f64N/A

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

                    \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\frac{2 \cdot 1}{c \cdot s}\right)\right), \left(c \cdot s\right)\right) \]
                  11. metadata-evalN/A

                    \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\frac{2}{c \cdot s}\right)\right), \left(c \cdot s\right)\right) \]
                  12. distribute-neg-fracN/A

                    \[\leadsto \mathsf{/.f64}\left(\left(\frac{\mathsf{neg}\left(2\right)}{c \cdot s}\right), \left(\color{blue}{c} \cdot s\right)\right) \]
                  13. metadata-evalN/A

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

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

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(c, s\right)\right), \left(c \cdot s\right)\right) \]
                  16. *-lowering-*.f6433.2%

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(c, s\right)\right), \mathsf{*.f64}\left(c, \color{blue}{s}\right)\right) \]
                10. Simplified33.2%

                  \[\leadsto \color{blue}{\frac{\frac{-2}{c \cdot s}}{c \cdot s}} \]
                11. Step-by-step derivation
                  1. associate-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \color{blue}{s}\right)\right)\right)\right) \]
                12. Applied egg-rr38.0%

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

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

              Alternative 12: 31.1% accurate, 19.5× speedup?

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

                1. Initial program 67.7%

                  \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                2. 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(\left(x \cdot {s}^{2}\right) \cdot x\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(\left(x \cdot {s}^{2}\right) \cdot x\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(\left(x \cdot {s}^{2}\right) \cdot x\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 \left(x \cdot {s}^{2}\right)\right) \cdot \color{blue}{x}\right)\right) \]
                  5. *-commutativeN/A

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

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

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
                  12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
                  13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
                  16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                  17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                  18. *-lowering-*.f6485.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) \]
                3. Simplified85.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)}} \]
                4. Add Preprocessing
                5. Taylor expanded in x around 0

                  \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
                6. Step-by-step derivation
                  1. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\left(-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}\right), \color{blue}{\left({x}^{2}\right)}\right) \]
                7. Simplified47.9%

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

                  \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
                9. Step-by-step derivation
                  1. unpow2N/A

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

                    \[\leadsto \frac{-2}{\left(c \cdot c\right) \cdot \left(s \cdot \color{blue}{s}\right)} \]
                  3. unswap-sqrN/A

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

                    \[\leadsto \frac{\frac{-2}{c \cdot s}}{\color{blue}{c \cdot s}} \]
                  5. metadata-evalN/A

                    \[\leadsto \frac{\frac{\mathsf{neg}\left(2\right)}{c \cdot s}}{c \cdot s} \]
                  6. distribute-neg-fracN/A

                    \[\leadsto \frac{\mathsf{neg}\left(\frac{2}{c \cdot s}\right)}{\color{blue}{c} \cdot s} \]
                  7. metadata-evalN/A

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

                    \[\leadsto \frac{\mathsf{neg}\left(2 \cdot \frac{1}{c \cdot s}\right)}{c \cdot s} \]
                  9. /-lowering-/.f64N/A

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

                    \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\frac{2 \cdot 1}{c \cdot s}\right)\right), \left(c \cdot s\right)\right) \]
                  11. metadata-evalN/A

                    \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\frac{2}{c \cdot s}\right)\right), \left(c \cdot s\right)\right) \]
                  12. distribute-neg-fracN/A

                    \[\leadsto \mathsf{/.f64}\left(\left(\frac{\mathsf{neg}\left(2\right)}{c \cdot s}\right), \left(\color{blue}{c} \cdot s\right)\right) \]
                  13. metadata-evalN/A

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

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

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(c, s\right)\right), \left(c \cdot s\right)\right) \]
                  16. *-lowering-*.f6423.3%

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(c, s\right)\right), \mathsf{*.f64}\left(c, \color{blue}{s}\right)\right) \]
                10. Simplified23.3%

                  \[\leadsto \color{blue}{\frac{\frac{-2}{c \cdot s}}{c \cdot s}} \]
                11. Step-by-step derivation
                  1. div-invN/A

                    \[\leadsto \frac{-2}{c \cdot s} \cdot \color{blue}{\frac{1}{c \cdot s}} \]
                  2. frac-2negN/A

                    \[\leadsto \frac{\mathsf{neg}\left(-2\right)}{\mathsf{neg}\left(c \cdot s\right)} \cdot \frac{\color{blue}{1}}{c \cdot s} \]
                  3. metadata-evalN/A

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

                    \[\leadsto \frac{2}{\mathsf{neg}\left(s \cdot c\right)} \cdot \frac{1}{c \cdot s} \]
                  5. *-commutativeN/A

                    \[\leadsto \frac{2}{\mathsf{neg}\left(s \cdot c\right)} \cdot \frac{1}{s \cdot \color{blue}{c}} \]
                  6. frac-timesN/A

                    \[\leadsto \frac{2 \cdot 1}{\color{blue}{\left(\mathsf{neg}\left(s \cdot c\right)\right) \cdot \left(s \cdot c\right)}} \]
                  7. metadata-evalN/A

                    \[\leadsto \frac{2}{\color{blue}{\left(\mathsf{neg}\left(s \cdot c\right)\right)} \cdot \left(s \cdot c\right)} \]
                  8. /-lowering-/.f64N/A

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

                    \[\leadsto \mathsf{/.f64}\left(2, \mathsf{*.f64}\left(\left(\mathsf{neg}\left(s \cdot c\right)\right), \color{blue}{\left(s \cdot c\right)}\right)\right) \]
                  10. sub0-negN/A

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

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

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

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

                    \[\leadsto \mathsf{/.f64}\left(2, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(c, s\right)\right), \left(c \cdot \color{blue}{s}\right)\right)\right) \]
                  15. *-lowering-*.f6426.4%

                    \[\leadsto \mathsf{/.f64}\left(2, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(c, s\right)\right), \mathsf{*.f64}\left(c, \color{blue}{s}\right)\right)\right) \]
                12. Applied egg-rr26.4%

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

                if 4.79999999999999988e-18 < x

                1. Initial program 60.1%

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

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

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

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

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
                  12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
                  13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
                  16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                  17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                  18. *-lowering-*.f6483.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) \]
                3. Simplified83.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)}} \]
                4. Add Preprocessing
                5. Taylor expanded in x around 0

                  \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
                6. Step-by-step derivation
                  1. /-lowering-/.f64N/A

                    \[\leadsto \mathsf{/.f64}\left(\left(-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}\right), \color{blue}{\left({x}^{2}\right)}\right) \]
                7. Simplified25.5%

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

                  \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
                9. Step-by-step derivation
                  1. unpow2N/A

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

                    \[\leadsto \frac{-2}{\left(c \cdot c\right) \cdot \left(s \cdot \color{blue}{s}\right)} \]
                  3. unswap-sqrN/A

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

                    \[\leadsto \frac{\frac{-2}{c \cdot s}}{\color{blue}{c \cdot s}} \]
                  5. metadata-evalN/A

                    \[\leadsto \frac{\frac{\mathsf{neg}\left(2\right)}{c \cdot s}}{c \cdot s} \]
                  6. distribute-neg-fracN/A

                    \[\leadsto \frac{\mathsf{neg}\left(\frac{2}{c \cdot s}\right)}{\color{blue}{c} \cdot s} \]
                  7. metadata-evalN/A

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

                    \[\leadsto \frac{\mathsf{neg}\left(2 \cdot \frac{1}{c \cdot s}\right)}{c \cdot s} \]
                  9. /-lowering-/.f64N/A

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

                    \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\frac{2 \cdot 1}{c \cdot s}\right)\right), \left(c \cdot s\right)\right) \]
                  11. metadata-evalN/A

                    \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\frac{2}{c \cdot s}\right)\right), \left(c \cdot s\right)\right) \]
                  12. distribute-neg-fracN/A

                    \[\leadsto \mathsf{/.f64}\left(\left(\frac{\mathsf{neg}\left(2\right)}{c \cdot s}\right), \left(\color{blue}{c} \cdot s\right)\right) \]
                  13. metadata-evalN/A

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

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

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

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(c, s\right)\right), \mathsf{*.f64}\left(c, \color{blue}{s}\right)\right) \]
                10. Simplified30.1%

                  \[\leadsto \color{blue}{\frac{\frac{-2}{c \cdot s}}{c \cdot s}} \]
                11. Step-by-step derivation
                  1. associate-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              Alternative 13: 78.2% accurate, 24.1× speedup?

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

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

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

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

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

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
                12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
                13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
                16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                18. *-lowering-*.f6485.1%

                  \[\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) \]
              3. Simplified85.1%

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

                \[\leadsto \mathsf{/.f64}\left(\color{blue}{1}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right)\right)\right) \]
              6. Step-by-step derivation
                1. Simplified72.0%

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

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

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

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

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

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

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

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

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

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

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

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

                Alternative 14: 75.2% accurate, 24.1× speedup?

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

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

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

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

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

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
                  12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
                  13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
                  16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                  17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                  18. *-lowering-*.f6485.1%

                    \[\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) \]
                3. Simplified85.1%

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

                  \[\leadsto \mathsf{/.f64}\left(\color{blue}{1}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right)\right)\right) \]
                6. Step-by-step derivation
                  1. Simplified72.0%

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

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

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

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

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

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

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

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

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

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

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

                  Alternative 15: 66.5% accurate, 24.1× speedup?

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

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

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

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

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

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
                    12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
                    13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
                    16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                    17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                    18. *-lowering-*.f6485.1%

                      \[\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) \]
                  3. Simplified85.1%

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

                    \[\leadsto \mathsf{/.f64}\left(\color{blue}{1}, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, s\right)\right)\right)\right)\right)\right) \]
                  6. Step-by-step derivation
                    1. Simplified72.0%

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

                      \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left({c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)}\right) \]
                    3. Step-by-step derivation
                      1. unpow2N/A

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

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

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

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

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

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

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

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

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

                        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(c, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(s, \mathsf{*.f64}\left(x, \color{blue}{x}\right)\right)\right)\right)\right)\right) \]
                    4. Simplified64.9%

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

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

                    Alternative 16: 31.1% accurate, 34.8× speedup?

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

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

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

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

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

                        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(2, x\right)\right), \mathsf{*.f64}\left(x, \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot \color{blue}{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. 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({c}^{2} \cdot \left(s \cdot \color{blue}{s}\right)\right)\right)\right)\right) \]
                      12. 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, \left(\left({c}^{2} \cdot s\right) \cdot \color{blue}{s}\right)\right)\right)\right) \]
                      13. *-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 \cdot \color{blue}{\left({c}^{2} \cdot s\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({c}^{2} \cdot s\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(\left(c \cdot c\right) \cdot s\right)\right)\right)\right)\right) \]
                      16. 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, \mathsf{*.f64}\left(s, \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                      17. *-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(c \cdot s\right)}\right)\right)\right)\right)\right) \]
                      18. *-lowering-*.f6485.1%

                        \[\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) \]
                    3. Simplified85.1%

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

                      \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
                    6. Step-by-step derivation
                      1. /-lowering-/.f64N/A

                        \[\leadsto \mathsf{/.f64}\left(\left(-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}\right), \color{blue}{\left({x}^{2}\right)}\right) \]
                    7. Simplified42.0%

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

                      \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
                    9. Step-by-step derivation
                      1. unpow2N/A

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

                        \[\leadsto \frac{-2}{\left(c \cdot c\right) \cdot \left(s \cdot \color{blue}{s}\right)} \]
                      3. unswap-sqrN/A

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

                        \[\leadsto \frac{\frac{-2}{c \cdot s}}{\color{blue}{c \cdot s}} \]
                      5. metadata-evalN/A

                        \[\leadsto \frac{\frac{\mathsf{neg}\left(2\right)}{c \cdot s}}{c \cdot s} \]
                      6. distribute-neg-fracN/A

                        \[\leadsto \frac{\mathsf{neg}\left(\frac{2}{c \cdot s}\right)}{\color{blue}{c} \cdot s} \]
                      7. metadata-evalN/A

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

                        \[\leadsto \frac{\mathsf{neg}\left(2 \cdot \frac{1}{c \cdot s}\right)}{c \cdot s} \]
                      9. /-lowering-/.f64N/A

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

                        \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\frac{2 \cdot 1}{c \cdot s}\right)\right), \left(c \cdot s\right)\right) \]
                      11. metadata-evalN/A

                        \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\frac{2}{c \cdot s}\right)\right), \left(c \cdot s\right)\right) \]
                      12. distribute-neg-fracN/A

                        \[\leadsto \mathsf{/.f64}\left(\left(\frac{\mathsf{neg}\left(2\right)}{c \cdot s}\right), \left(\color{blue}{c} \cdot s\right)\right) \]
                      13. metadata-evalN/A

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

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

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

                        \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(-2, \mathsf{*.f64}\left(c, s\right)\right), \mathsf{*.f64}\left(c, \color{blue}{s}\right)\right) \]
                    10. Simplified25.1%

                      \[\leadsto \color{blue}{\frac{\frac{-2}{c \cdot s}}{c \cdot s}} \]
                    11. Step-by-step derivation
                      1. associate-/l/N/A

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \color{blue}{\frac{-2}{c \cdot \left(c \cdot \left(s \cdot s\right)\right)}} \]
                    13. Add Preprocessing

                    Reproduce

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