mixedcos

Percentage Accurate: 67.2% → 96.9%
Time: 22.6s
Alternatives: 20
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 20 alternatives:

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

Initial Program: 67.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: 96.9% accurate, 0.7× speedup?

\[\begin{array}{l} s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := c \cdot \left(s \cdot x\right)\\ \frac{1}{t_0} \cdot \frac{{\cos x}^{4} - {\sin x}^{4}}{t_0} \end{array} \end{array} \]
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* c (* s x))))
   (* (/ 1.0 t_0) (/ (- (pow (cos x) 4.0) (pow (sin x) 4.0)) t_0))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double t_0 = c * (s * x);
	return (1.0 / t_0) * ((pow(cos(x), 4.0) - pow(sin(x), 4.0)) / t_0);
}
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: t_0
    t_0 = c * (s * x)
    code = (1.0d0 / t_0) * (((cos(x) ** 4.0d0) - (sin(x) ** 4.0d0)) / t_0)
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double t_0 = c * (s * x);
	return (1.0 / t_0) * ((Math.pow(Math.cos(x), 4.0) - Math.pow(Math.sin(x), 4.0)) / t_0);
}
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	t_0 = c * (s * x)
	return (1.0 / t_0) * ((math.pow(math.cos(x), 4.0) - math.pow(math.sin(x), 4.0)) / t_0)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	t_0 = Float64(c * Float64(s * x))
	return Float64(Float64(1.0 / t_0) * Float64(Float64((cos(x) ^ 4.0) - (sin(x) ^ 4.0)) / t_0))
end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	t_0 = c * (s * x);
	tmp = (1.0 / t_0) * (((cos(x) ^ 4.0) - (sin(x) ^ 4.0)) / t_0);
end
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(N[(N[Power[N[Cos[x], $MachinePrecision], 4.0], $MachinePrecision] - N[Power[N[Sin[x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(s \cdot x\right)\\
\frac{1}{t_0} \cdot \frac{{\cos x}^{4} - {\sin x}^{4}}{t_0}
\end{array}
\end{array}
Derivation
  1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\color{blue}{\cos x \cdot \cos x - \sin x \cdot \sin x}}{c \cdot \left(s \cdot x\right)} \]
    3. flip--98.0%

      \[\leadsto \frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\color{blue}{\frac{\left(\cos x \cdot \cos x\right) \cdot \left(\cos x \cdot \cos x\right) - \left(\sin x \cdot \sin x\right) \cdot \left(\sin x \cdot \sin x\right)}{\cos x \cdot \cos x + \sin x \cdot \sin x}}}{c \cdot \left(s \cdot x\right)} \]
    4. pow298.0%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{{\cos x}^{\color{blue}{4}} - {\sin x}^{2} \cdot {\sin x}^{2}}{{\cos x}^{2} + {\sin x}^{2}}}{c \cdot \left(s \cdot x\right)} \]
    3. pow-sqr98.0%

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

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

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

      \[\leadsto \frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{{\cos x}^{4} - {\sin x}^{4}}{\cos x \cdot \cos x + \color{blue}{\sin x \cdot \sin x}}}{c \cdot \left(s \cdot x\right)} \]
    7. cos-sin-sum98.0%

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

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

    \[\leadsto \frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{{\cos x}^{4} - {\sin x}^{4}}{c \cdot \left(s \cdot x\right)} \]

Alternative 2: 84.4% accurate, 2.6× speedup?

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

\mathbf{elif}\;x \leq 5 \cdot 10^{+30}:\\
\;\;\;\;\frac{t_0}{\left(x \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right)}\\

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


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

    1. Initial program 63.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. associate-/r*63.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.00000000000000039e-40 < x < 4.9999999999999998e30

    1. Initial program 90.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.9999999999999998e30 < x

    1. Initial program 61.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 82.7% accurate, 2.7× speedup?

\[\begin{array}{l} s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 5 \cdot 10^{-43}:\\ \;\;\;\;\frac{\frac{1}{c}}{s \cdot x} \cdot \left(\frac{1}{c} \cdot \frac{\frac{1}{s}}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(x \cdot \left(c \cdot \left(c \cdot \left(s \cdot s\right)\right)\right)\right)}\\ \end{array} \end{array} \]
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (if (<= x 5e-43)
   (* (/ (/ 1.0 c) (* s x)) (* (/ 1.0 c) (/ (/ 1.0 s) x)))
   (/ (cos (* x 2.0)) (* x (* x (* c (* c (* s s))))))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double tmp;
	if (x <= 5e-43) {
		tmp = ((1.0 / c) / (s * x)) * ((1.0 / c) * ((1.0 / s) / x));
	} else {
		tmp = cos((x * 2.0)) / (x * (x * (c * (c * (s * s)))));
	}
	return tmp;
}
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: tmp
    if (x <= 5d-43) then
        tmp = ((1.0d0 / c) / (s * x)) * ((1.0d0 / c) * ((1.0d0 / s) / x))
    else
        tmp = cos((x * 2.0d0)) / (x * (x * (c * (c * (s * s)))))
    end if
    code = tmp
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double tmp;
	if (x <= 5e-43) {
		tmp = ((1.0 / c) / (s * x)) * ((1.0 / c) * ((1.0 / s) / x));
	} else {
		tmp = Math.cos((x * 2.0)) / (x * (x * (c * (c * (s * s)))));
	}
	return tmp;
}
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	tmp = 0
	if x <= 5e-43:
		tmp = ((1.0 / c) / (s * x)) * ((1.0 / c) * ((1.0 / s) / x))
	else:
		tmp = math.cos((x * 2.0)) / (x * (x * (c * (c * (s * s)))))
	return tmp
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	tmp = 0.0
	if (x <= 5e-43)
		tmp = Float64(Float64(Float64(1.0 / c) / Float64(s * x)) * Float64(Float64(1.0 / c) * Float64(Float64(1.0 / s) / x)));
	else
		tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(x * Float64(c * Float64(c * Float64(s * s))))));
	end
	return tmp
end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (x <= 5e-43)
		tmp = ((1.0 / c) / (s * x)) * ((1.0 / c) * ((1.0 / s) / x));
	else
		tmp = cos((x * 2.0)) / (x * (x * (c * (c * (s * s)))));
	end
	tmp_2 = tmp;
end
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := If[LessEqual[x, 5e-43], N[(N[(N[(1.0 / c), $MachinePrecision] / N[(s * x), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] * N[(N[(1.0 / s), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(x * N[(c * N[(c * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{-43}:\\
\;\;\;\;\frac{\frac{1}{c}}{s \cdot x} \cdot \left(\frac{1}{c} \cdot \frac{\frac{1}{s}}{x}\right)\\

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


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

    1. Initial program 63.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(1 \cdot \frac{\frac{1}{c}}{s \cdot x}\right)} \cdot \frac{\frac{1}{s \cdot x}}{c} \]
    11. Step-by-step derivation
      1. div-inv85.4%

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

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

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

    if 5.00000000000000019e-43 < x

    1. Initial program 66.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 84.9% accurate, 2.7× speedup?

\[\begin{array}{l} s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 5 \cdot 10^{-43}:\\ \;\;\;\;\frac{\frac{1}{c}}{s \cdot x} \cdot \left(\frac{1}{c} \cdot \frac{\frac{1}{s}}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(c \cdot s\right)\right)\right)\right)}\\ \end{array} \end{array} \]
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (if (<= x 5e-43)
   (* (/ (/ 1.0 c) (* s x)) (* (/ 1.0 c) (/ (/ 1.0 s) x)))
   (/ (cos (* x 2.0)) (* x (* x (* c (* s (* c s))))))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double tmp;
	if (x <= 5e-43) {
		tmp = ((1.0 / c) / (s * x)) * ((1.0 / c) * ((1.0 / s) / x));
	} else {
		tmp = cos((x * 2.0)) / (x * (x * (c * (s * (c * s)))));
	}
	return tmp;
}
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: tmp
    if (x <= 5d-43) then
        tmp = ((1.0d0 / c) / (s * x)) * ((1.0d0 / c) * ((1.0d0 / s) / x))
    else
        tmp = cos((x * 2.0d0)) / (x * (x * (c * (s * (c * s)))))
    end if
    code = tmp
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double tmp;
	if (x <= 5e-43) {
		tmp = ((1.0 / c) / (s * x)) * ((1.0 / c) * ((1.0 / s) / x));
	} else {
		tmp = Math.cos((x * 2.0)) / (x * (x * (c * (s * (c * s)))));
	}
	return tmp;
}
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	tmp = 0
	if x <= 5e-43:
		tmp = ((1.0 / c) / (s * x)) * ((1.0 / c) * ((1.0 / s) / x))
	else:
		tmp = math.cos((x * 2.0)) / (x * (x * (c * (s * (c * s)))))
	return tmp
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	tmp = 0.0
	if (x <= 5e-43)
		tmp = Float64(Float64(Float64(1.0 / c) / Float64(s * x)) * Float64(Float64(1.0 / c) * Float64(Float64(1.0 / s) / x)));
	else
		tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(x * Float64(c * Float64(s * Float64(c * s))))));
	end
	return tmp
end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (x <= 5e-43)
		tmp = ((1.0 / c) / (s * x)) * ((1.0 / c) * ((1.0 / s) / x));
	else
		tmp = cos((x * 2.0)) / (x * (x * (c * (s * (c * s)))));
	end
	tmp_2 = tmp;
end
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := If[LessEqual[x, 5e-43], N[(N[(N[(1.0 / c), $MachinePrecision] / N[(s * x), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] * N[(N[(1.0 / s), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(x * N[(c * N[(s * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{-43}:\\
\;\;\;\;\frac{\frac{1}{c}}{s \cdot x} \cdot \left(\frac{1}{c} \cdot \frac{\frac{1}{s}}{x}\right)\\

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


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

    1. Initial program 63.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(1 \cdot \frac{\frac{1}{c}}{s \cdot x}\right)} \cdot \frac{\frac{1}{s \cdot x}}{c} \]
    11. Step-by-step derivation
      1. div-inv85.4%

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

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

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

    if 5.00000000000000019e-43 < x

    1. Initial program 66.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 87.0% accurate, 2.7× speedup?

\[\begin{array}{l} s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} \mathbf{if}\;s \leq 9.5 \cdot 10^{+146}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(\left(s \cdot s\right) \cdot \left(c \cdot \left(c \cdot x\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{c}}{s \cdot x} \cdot \left(\frac{1}{c} \cdot \frac{\frac{1}{s}}{x}\right)\\ \end{array} \end{array} \]
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (if (<= s 9.5e+146)
   (/ (cos (* x 2.0)) (* x (* (* s s) (* c (* c x)))))
   (* (/ (/ 1.0 c) (* s x)) (* (/ 1.0 c) (/ (/ 1.0 s) x)))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double tmp;
	if (s <= 9.5e+146) {
		tmp = cos((x * 2.0)) / (x * ((s * s) * (c * (c * x))));
	} else {
		tmp = ((1.0 / c) / (s * x)) * ((1.0 / c) * ((1.0 / s) / x));
	}
	return tmp;
}
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: tmp
    if (s <= 9.5d+146) then
        tmp = cos((x * 2.0d0)) / (x * ((s * s) * (c * (c * x))))
    else
        tmp = ((1.0d0 / c) / (s * x)) * ((1.0d0 / c) * ((1.0d0 / s) / x))
    end if
    code = tmp
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double tmp;
	if (s <= 9.5e+146) {
		tmp = Math.cos((x * 2.0)) / (x * ((s * s) * (c * (c * x))));
	} else {
		tmp = ((1.0 / c) / (s * x)) * ((1.0 / c) * ((1.0 / s) / x));
	}
	return tmp;
}
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	tmp = 0
	if s <= 9.5e+146:
		tmp = math.cos((x * 2.0)) / (x * ((s * s) * (c * (c * x))))
	else:
		tmp = ((1.0 / c) / (s * x)) * ((1.0 / c) * ((1.0 / s) / x))
	return tmp
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	tmp = 0.0
	if (s <= 9.5e+146)
		tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(Float64(s * s) * Float64(c * Float64(c * x)))));
	else
		tmp = Float64(Float64(Float64(1.0 / c) / Float64(s * x)) * Float64(Float64(1.0 / c) * Float64(Float64(1.0 / s) / x)));
	end
	return tmp
end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (s <= 9.5e+146)
		tmp = cos((x * 2.0)) / (x * ((s * s) * (c * (c * x))));
	else
		tmp = ((1.0 / c) / (s * x)) * ((1.0 / c) * ((1.0 / s) / x));
	end
	tmp_2 = tmp;
end
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := If[LessEqual[s, 9.5e+146], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(N[(s * s), $MachinePrecision] * N[(c * N[(c * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / c), $MachinePrecision] / N[(s * x), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] * N[(N[(1.0 / s), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;s \leq 9.5 \cdot 10^{+146}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(\left(s \cdot s\right) \cdot \left(c \cdot \left(c \cdot x\right)\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if s < 9.49999999999999926e146

    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. associate-/r*64.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.49999999999999926e146 < s

    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. associate-/r*54.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;s \leq 9.5 \cdot 10^{+146}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(\left(s \cdot s\right) \cdot \left(c \cdot \left(c \cdot x\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{c}}{s \cdot x} \cdot \left(\frac{1}{c} \cdot \frac{\frac{1}{s}}{x}\right)\\ \end{array} \]

Alternative 6: 97.0% accurate, 2.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 97.0% accurate, 2.7× speedup?

\[\begin{array}{l} s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{\cos \left(x \cdot 2\right)}{s \cdot x}}{c} \end{array} \]
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (* (/ 1.0 (* c (* s x))) (/ (/ (cos (* x 2.0)) (* s x)) c)))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return (1.0 / (c * (s * x))) * ((cos((x * 2.0)) / (s * x)) / c);
}
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = (1.0d0 / (c * (s * x))) * ((cos((x * 2.0d0)) / (s * x)) / c)
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return (1.0 / (c * (s * x))) * ((Math.cos((x * 2.0)) / (s * x)) / c);
}
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return (1.0 / (c * (s * x))) * ((math.cos((x * 2.0)) / (s * x)) / c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(Float64(1.0 / Float64(c * Float64(s * x))) * Float64(Float64(cos(Float64(x * 2.0)) / Float64(s * x)) / c))
end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = (1.0 / (c * (s * x))) * ((cos((x * 2.0)) / (s * x)) / c);
end
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(N[(1.0 / N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(s * x), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{\cos \left(x \cdot 2\right)}{s \cdot x}}{c}
\end{array}
Derivation
  1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 79.1% accurate, 18.4× speedup?

\[\begin{array}{l} s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{\frac{1}{c}}{s \cdot x} \cdot \left(\frac{1}{c} \cdot \frac{\frac{1}{s}}{x}\right) \end{array} \]
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (* (/ (/ 1.0 c) (* s x)) (* (/ 1.0 c) (/ (/ 1.0 s) x))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return ((1.0 / c) / (s * x)) * ((1.0 / c) * ((1.0 / s) / x));
}
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = ((1.0d0 / c) / (s * x)) * ((1.0d0 / c) * ((1.0d0 / s) / x))
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return ((1.0 / c) / (s * x)) * ((1.0 / c) * ((1.0 / s) / x));
}
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return ((1.0 / c) / (s * x)) * ((1.0 / c) * ((1.0 / s) / x))
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(Float64(Float64(1.0 / c) / Float64(s * x)) * Float64(Float64(1.0 / c) * Float64(Float64(1.0 / s) / x)))
end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = ((1.0 / c) / (s * x)) * ((1.0 / c) * ((1.0 / s) / x));
end
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(N[(N[(1.0 / c), $MachinePrecision] / N[(s * x), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] * N[(N[(1.0 / s), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{1}{c}}{s \cdot x} \cdot \left(\frac{1}{c} \cdot \frac{\frac{1}{s}}{x}\right)
\end{array}
Derivation
  1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\left(1 \cdot \frac{\frac{1}{c}}{s \cdot x}\right)} \cdot \frac{\frac{1}{s \cdot x}}{c} \]
  11. Step-by-step derivation
    1. div-inv80.0%

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

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

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

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

Alternative 9: 73.0% accurate, 20.8× speedup?

\[\begin{array}{l} s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} \mathbf{if}\;c \leq 6 \cdot 10^{-77}:\\ \;\;\;\;\frac{1}{x \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(c \cdot s\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot x\right)\right)\right)\right)}\\ \end{array} \end{array} \]
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (if (<= c 6e-77)
   (/ 1.0 (* x (* x (* c (* s (* c s))))))
   (/ 1.0 (* s (* x (* s (* c (* c x))))))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double tmp;
	if (c <= 6e-77) {
		tmp = 1.0 / (x * (x * (c * (s * (c * s)))));
	} else {
		tmp = 1.0 / (s * (x * (s * (c * (c * x)))));
	}
	return tmp;
}
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: tmp
    if (c <= 6d-77) then
        tmp = 1.0d0 / (x * (x * (c * (s * (c * s)))))
    else
        tmp = 1.0d0 / (s * (x * (s * (c * (c * x)))))
    end if
    code = tmp
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double tmp;
	if (c <= 6e-77) {
		tmp = 1.0 / (x * (x * (c * (s * (c * s)))));
	} else {
		tmp = 1.0 / (s * (x * (s * (c * (c * x)))));
	}
	return tmp;
}
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	tmp = 0
	if c <= 6e-77:
		tmp = 1.0 / (x * (x * (c * (s * (c * s)))))
	else:
		tmp = 1.0 / (s * (x * (s * (c * (c * x)))))
	return tmp
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	tmp = 0.0
	if (c <= 6e-77)
		tmp = Float64(1.0 / Float64(x * Float64(x * Float64(c * Float64(s * Float64(c * s))))));
	else
		tmp = Float64(1.0 / Float64(s * Float64(x * Float64(s * Float64(c * Float64(c * x))))));
	end
	return tmp
end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (c <= 6e-77)
		tmp = 1.0 / (x * (x * (c * (s * (c * s)))));
	else
		tmp = 1.0 / (s * (x * (s * (c * (c * x)))));
	end
	tmp_2 = tmp;
end
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := If[LessEqual[c, 6e-77], N[(1.0 / N[(x * N[(x * N[(c * N[(s * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(s * N[(x * N[(s * N[(c * N[(c * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;c \leq 6 \cdot 10^{-77}:\\
\;\;\;\;\frac{1}{x \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(c \cdot s\right)\right)\right)\right)}\\

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


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

    1. Initial program 66.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.00000000000000033e-77 < c

    1. Initial program 59.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq 6 \cdot 10^{-77}:\\ \;\;\;\;\frac{1}{x \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(c \cdot s\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot x\right)\right)\right)\right)}\\ \end{array} \]

Alternative 10: 79.1% accurate, 20.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 79.2% accurate, 20.9× speedup?

\[\begin{array}{l} s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{1}{c}}{s \cdot x} \end{array} \]
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (* (/ 1.0 (* c (* s x))) (/ (/ 1.0 c) (* s x))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return (1.0 / (c * (s * x))) * ((1.0 / c) / (s * x));
}
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = (1.0d0 / (c * (s * x))) * ((1.0d0 / c) / (s * x))
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return (1.0 / (c * (s * x))) * ((1.0 / c) / (s * x));
}
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return (1.0 / (c * (s * x))) * ((1.0 / c) / (s * x))
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(Float64(1.0 / Float64(c * Float64(s * x))) * Float64(Float64(1.0 / c) / Float64(s * x)))
end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = (1.0 / (c * (s * x))) * ((1.0 / c) / (s * x));
end
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(N[(1.0 / N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] / N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{1}{c}}{s \cdot x}
\end{array}
Derivation
  1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 79.1% accurate, 20.9× speedup?

\[\begin{array}{l} s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{\frac{1}{x}}{s}}{c} \end{array} \]
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (* (/ 1.0 (* c (* s x))) (/ (/ (/ 1.0 x) s) c)))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return (1.0 / (c * (s * x))) * (((1.0 / x) / s) / c);
}
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = (1.0d0 / (c * (s * x))) * (((1.0d0 / x) / s) / c)
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return (1.0 / (c * (s * x))) * (((1.0 / x) / s) / c);
}
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return (1.0 / (c * (s * x))) * (((1.0 / x) / s) / c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(Float64(1.0 / Float64(c * Float64(s * x))) * Float64(Float64(Float64(1.0 / x) / s) / c))
end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = (1.0 / (c * (s * x))) * (((1.0 / x) / s) / c);
end
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(N[(1.0 / N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(1.0 / x), $MachinePrecision] / s), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{\frac{1}{x}}{s}}{c}
\end{array}
Derivation
  1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 79.1% accurate, 20.9× speedup?

\[\begin{array}{l} s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{\frac{1}{s}}{x}}{c} \end{array} \]
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (* (/ 1.0 (* c (* s x))) (/ (/ (/ 1.0 s) x) c)))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return (1.0 / (c * (s * x))) * (((1.0 / s) / x) / c);
}
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = (1.0d0 / (c * (s * x))) * (((1.0d0 / s) / x) / c)
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return (1.0 / (c * (s * x))) * (((1.0 / s) / x) / c);
}
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return (1.0 / (c * (s * x))) * (((1.0 / s) / x) / c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(Float64(1.0 / Float64(c * Float64(s * x))) * Float64(Float64(Float64(1.0 / s) / x) / c))
end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = (1.0 / (c * (s * x))) * (((1.0 / s) / x) / c);
end
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(N[(1.0 / N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(1.0 / s), $MachinePrecision] / x), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{c \cdot \left(s \cdot x\right)} \cdot \frac{\frac{\frac{1}{s}}{x}}{c}
\end{array}
Derivation
  1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 67.5% accurate, 24.1× speedup?

\[\begin{array}{l} s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{1}{s \cdot \left(\left(c \cdot s\right) \cdot \left(c \cdot \left(x \cdot x\right)\right)\right)} \end{array} \]
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s) :precision binary64 (/ 1.0 (* s (* (* c s) (* c (* x x))))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return 1.0 / (s * ((c * s) * (c * (x * x))));
}
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = 1.0d0 / (s * ((c * s) * (c * (x * x))))
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return 1.0 / (s * ((c * s) * (c * (x * x))));
}
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return 1.0 / (s * ((c * s) * (c * (x * x))))
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(1.0 / Float64(s * Float64(Float64(c * s) * Float64(c * Float64(x * x)))))
end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = 1.0 / (s * ((c * s) * (c * (x * x))));
end
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(1.0 / N[(s * N[(N[(c * s), $MachinePrecision] * N[(c * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{s \cdot \left(\left(c \cdot s\right) \cdot \left(c \cdot \left(x \cdot x\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 72.3% accurate, 24.1× speedup?

\[\begin{array}{l} s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{1}{s \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot x\right)\right)\right)\right)} \end{array} \]
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s) :precision binary64 (/ 1.0 (* s (* x (* s (* c (* c x)))))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return 1.0 / (s * (x * (s * (c * (c * x)))));
}
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = 1.0d0 / (s * (x * (s * (c * (c * x)))))
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return 1.0 / (s * (x * (s * (c * (c * x)))));
}
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return 1.0 / (s * (x * (s * (c * (c * x)))))
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(1.0 / Float64(s * Float64(x * Float64(s * Float64(c * Float64(c * x))))))
end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = 1.0 / (s * (x * (s * (c * (c * x)))));
end
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(1.0 / N[(s * N[(x * N[(s * N[(c * N[(c * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{s \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot x\right)\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 76.4% accurate, 24.1× speedup?

\[\begin{array}{l} s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{1}{\left(c \cdot s\right) \cdot \left(x \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)} \end{array} \]
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s) :precision binary64 (/ 1.0 (* (* c s) (* x (* c (* s x))))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return 1.0 / ((c * s) * (x * (c * (s * x))));
}
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = 1.0d0 / ((c * s) * (x * (c * (s * x))))
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return 1.0 / ((c * s) * (x * (c * (s * x))));
}
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return 1.0 / ((c * s) * (x * (c * (s * x))))
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(1.0 / Float64(Float64(c * s) * Float64(x * Float64(c * Float64(s * x)))))
end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = 1.0 / ((c * s) * (x * (c * (s * x))));
end
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(1.0 / N[(N[(c * s), $MachinePrecision] * N[(x * N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{\left(c \cdot s\right) \cdot \left(x \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 17: 79.0% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 18: 77.8% accurate, 24.1× speedup?

\[\begin{array}{l} s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{1}{c \cdot \left(\left(s \cdot x\right) \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)} \end{array} \]
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s) :precision binary64 (/ 1.0 (* c (* (* s x) (* c (* s x))))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return 1.0 / (c * ((s * x) * (c * (s * x))));
}
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = 1.0d0 / (c * ((s * x) * (c * (s * x))))
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return 1.0 / (c * ((s * x) * (c * (s * x))));
}
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return 1.0 / (c * ((s * x) * (c * (s * x))))
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(1.0 / Float64(c * Float64(Float64(s * x) * Float64(c * Float64(s * x)))))
end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = 1.0 / (c * ((s * x) * (c * (s * x))));
end
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(1.0 / N[(c * N[(N[(s * x), $MachinePrecision] * N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{c \cdot \left(\left(s \cdot x\right) \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 19: 23.8% accurate, 28.5× speedup?

\[\begin{array}{l} s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{1}{\frac{\frac{c \cdot \left(-x\right)}{x}}{-c}} \end{array} \]
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s) :precision binary64 (/ 1.0 (/ (/ (* c (- x)) x) (- c))))
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return 1.0 / (((c * -x) / x) / -c);
}
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = 1.0d0 / (((c * -x) / x) / -c)
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return 1.0 / (((c * -x) / x) / -c);
}
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return 1.0 / (((c * -x) / x) / -c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(1.0 / Float64(Float64(Float64(c * Float64(-x)) / x) / Float64(-c)))
end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = 1.0 / (((c * -x) / x) / -c);
end
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(1.0 / N[(N[(N[(c * (-x)), $MachinePrecision] / x), $MachinePrecision] / (-c)), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{\frac{\frac{c \cdot \left(-x\right)}{x}}{-c}}
\end{array}
Derivation
  1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{1}{\color{blue}{\frac{-\frac{\left(c \cdot x\right) \cdot s}{x \cdot s}}{-c}}} \]
  12. Step-by-step derivation
    1. times-frac26.7%

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

      \[\leadsto \frac{1}{\frac{-\frac{c \cdot x}{x} \cdot \color{blue}{1}}{-c}} \]
    3. associate-*l/26.7%

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

      \[\leadsto \frac{1}{\frac{-\frac{\color{blue}{c \cdot x}}{x}}{-c}} \]
  13. Simplified26.7%

    \[\leadsto \frac{1}{\color{blue}{\frac{-\frac{c \cdot x}{x}}{-c}}} \]
  14. Final simplification26.7%

    \[\leadsto \frac{1}{\frac{\frac{c \cdot \left(-x\right)}{x}}{-c}} \]

Alternative 20: 3.5% accurate, 313.0× speedup?

\[\begin{array}{l} s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ 1 \end{array} \]
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
(FPCore (x c s) :precision binary64 1.0)
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return 1.0;
}
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = 1.0d0
end function
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return 1.0;
}
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return 1.0
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return 1.0
end
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = 1.0;
end
NOTE: s should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := 1.0
\begin{array}{l}
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
1
\end{array}
Derivation
  1. Initial program 64.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{x \cdot \color{blue}{\left({c}^{2} \cdot \left(x \cdot {s}^{2}\right)\right)}} \]
    3. unpow258.5%

      \[\leadsto \frac{1}{x \cdot \left(\color{blue}{\left(c \cdot c\right)} \cdot \left(x \cdot {s}^{2}\right)\right)} \]
    4. unpow258.5%

      \[\leadsto \frac{1}{x \cdot \left(\left(c \cdot c\right) \cdot \left(x \cdot \color{blue}{\left(s \cdot s\right)}\right)\right)} \]
  10. Simplified58.5%

    \[\leadsto \frac{1}{x \cdot \color{blue}{\left(\left(c \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}} \]
  11. Applied egg-rr22.9%

    \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{c}{\frac{\left(c \cdot x\right) \cdot s}{x \cdot s}}}}} \]
  12. Step-by-step derivation
    1. associate-/r/24.0%

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\frac{c}{\left(c \cdot x\right) \cdot s} \cdot \left(x \cdot s\right)}}} \]
    2. associate-*l/8.1%

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\frac{c \cdot \left(x \cdot s\right)}{\left(c \cdot x\right) \cdot s}}}} \]
    3. associate-*r*2.3%

      \[\leadsto \frac{1}{\frac{1}{\frac{\color{blue}{\left(c \cdot x\right) \cdot s}}{\left(c \cdot x\right) \cdot s}}} \]
    4. *-inverses3.6%

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{1}}} \]
    5. metadata-eval3.6%

      \[\leadsto \frac{1}{\color{blue}{1}} \]
  13. Simplified3.6%

    \[\leadsto \frac{1}{\color{blue}{1}} \]
  14. Final simplification3.6%

    \[\leadsto 1 \]

Reproduce

?
herbie shell --seed 2023279 
(FPCore (x c s)
  :name "mixedcos"
  :precision binary64
  (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))))