mixedcos

Percentage Accurate: 67.6% → 99.2%
Time: 12.9s
Alternatives: 13
Speedup: 24.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 13 alternatives:

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

Initial Program: 67.6% accurate, 1.0× speedup?

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

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

Alternative 1: 99.2% accurate, 2.6× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := s \cdot \left(x \cdot c\right)\\ t_1 := \cos \left(x \cdot 2\right)\\ \mathbf{if}\;x \leq 4.8 \cdot 10^{+75}:\\ \;\;\;\;\frac{\frac{1}{c}}{x \cdot s} \cdot \frac{t_1}{c \cdot \left(x \cdot s\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{t_0}{t_1} \cdot t_0}\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 (* s (* x c))) (t_1 (cos (* x 2.0))))
   (if (<= x 4.8e+75)
     (* (/ (/ 1.0 c) (* x s)) (/ t_1 (* c (* x s))))
     (/ 1.0 (* (/ t_0 t_1) t_0)))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double t_0 = s * (x * c);
	double t_1 = cos((x * 2.0));
	double tmp;
	if (x <= 4.8e+75) {
		tmp = ((1.0 / c) / (x * s)) * (t_1 / (c * (x * s)));
	} else {
		tmp = 1.0 / ((t_0 / t_1) * t_0);
	}
	return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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) :: t_1
    real(8) :: tmp
    t_0 = s * (x * c)
    t_1 = cos((x * 2.0d0))
    if (x <= 4.8d+75) then
        tmp = ((1.0d0 / c) / (x * s)) * (t_1 / (c * (x * s)))
    else
        tmp = 1.0d0 / ((t_0 / t_1) * t_0)
    end if
    code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double t_0 = s * (x * c);
	double t_1 = Math.cos((x * 2.0));
	double tmp;
	if (x <= 4.8e+75) {
		tmp = ((1.0 / c) / (x * s)) * (t_1 / (c * (x * s)));
	} else {
		tmp = 1.0 / ((t_0 / t_1) * t_0);
	}
	return tmp;
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	t_0 = s * (x * c)
	t_1 = math.cos((x * 2.0))
	tmp = 0
	if x <= 4.8e+75:
		tmp = ((1.0 / c) / (x * s)) * (t_1 / (c * (x * s)))
	else:
		tmp = 1.0 / ((t_0 / t_1) * t_0)
	return tmp
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	t_0 = Float64(s * Float64(x * c))
	t_1 = cos(Float64(x * 2.0))
	tmp = 0.0
	if (x <= 4.8e+75)
		tmp = Float64(Float64(Float64(1.0 / c) / Float64(x * s)) * Float64(t_1 / Float64(c * Float64(x * s))));
	else
		tmp = Float64(1.0 / Float64(Float64(t_0 / t_1) * t_0));
	end
	return tmp
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	t_0 = s * (x * c);
	t_1 = cos((x * 2.0));
	tmp = 0.0;
	if (x <= 4.8e+75)
		tmp = ((1.0 / c) / (x * s)) * (t_1 / (c * (x * s)));
	else
		tmp = 1.0 / ((t_0 / t_1) * t_0);
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 4.8e+75], N[(N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(t$95$0 / t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot c\right)\\
t_1 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;x \leq 4.8 \cdot 10^{+75}:\\
\;\;\;\;\frac{\frac{1}{c}}{x \cdot s} \cdot \frac{t_1}{c \cdot \left(x \cdot s\right)}\\

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


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

    1. Initial program 67.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. unpow267.3%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(c \cdot c\right)} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      2. *-commutative67.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)}} \]
      3. unpow267.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. Simplified67.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. *-un-lft-identity67.3%

        \[\leadsto \frac{\color{blue}{1 \cdot \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)} \]
      2. add-sqr-sqrt67.2%

        \[\leadsto \frac{1 \cdot \cos \left(2 \cdot x\right)}{\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)}}} \]
      3. times-frac67.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.8e75 < x

    1. Initial program 64.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. unpow264.4%

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

        \[\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)}} \]
      3. unpow264.4%

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

      \[\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. *-un-lft-identity64.4%

        \[\leadsto \frac{\color{blue}{1 \cdot \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)} \]
      2. add-sqr-sqrt64.4%

        \[\leadsto \frac{1 \cdot \cos \left(2 \cdot x\right)}{\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)}}} \]
      3. times-frac64.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 88.8% accurate, 2.6× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := \frac{1}{s \cdot \left(x \cdot c\right)}\\ \mathbf{if}\;x \leq 8.4 \cdot 10^{-29}:\\ \;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \mathbf{elif}\;x \leq 2.45 \cdot 10^{+154}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{s \cdot \left(\left(x \cdot x\right) \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot t_0\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 (* s (* x c)))))
   (if (<= x 8.4e-29)
     (pow (* c (* x s)) -2.0)
     (if (<= x 2.45e+154)
       (/ (cos (* x 2.0)) (* s (* (* x x) (* c (* c s)))))
       (* t_0 t_0)))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double t_0 = 1.0 / (s * (x * c));
	double tmp;
	if (x <= 8.4e-29) {
		tmp = pow((c * (x * s)), -2.0);
	} else if (x <= 2.45e+154) {
		tmp = cos((x * 2.0)) / (s * ((x * x) * (c * (c * s))));
	} else {
		tmp = t_0 * t_0;
	}
	return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 = 1.0d0 / (s * (x * c))
    if (x <= 8.4d-29) then
        tmp = (c * (x * s)) ** (-2.0d0)
    else if (x <= 2.45d+154) then
        tmp = cos((x * 2.0d0)) / (s * ((x * x) * (c * (c * s))))
    else
        tmp = t_0 * t_0
    end if
    code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double t_0 = 1.0 / (s * (x * c));
	double tmp;
	if (x <= 8.4e-29) {
		tmp = Math.pow((c * (x * s)), -2.0);
	} else if (x <= 2.45e+154) {
		tmp = Math.cos((x * 2.0)) / (s * ((x * x) * (c * (c * s))));
	} else {
		tmp = t_0 * t_0;
	}
	return tmp;
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	t_0 = 1.0 / (s * (x * c))
	tmp = 0
	if x <= 8.4e-29:
		tmp = math.pow((c * (x * s)), -2.0)
	elif x <= 2.45e+154:
		tmp = math.cos((x * 2.0)) / (s * ((x * x) * (c * (c * s))))
	else:
		tmp = t_0 * t_0
	return tmp
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	t_0 = Float64(1.0 / Float64(s * Float64(x * c)))
	tmp = 0.0
	if (x <= 8.4e-29)
		tmp = Float64(c * Float64(x * s)) ^ -2.0;
	elseif (x <= 2.45e+154)
		tmp = Float64(cos(Float64(x * 2.0)) / Float64(s * Float64(Float64(x * x) * Float64(c * Float64(c * s)))));
	else
		tmp = Float64(t_0 * t_0);
	end
	return tmp
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	t_0 = 1.0 / (s * (x * c));
	tmp = 0.0;
	if (x <= 8.4e-29)
		tmp = (c * (x * s)) ^ -2.0;
	elseif (x <= 2.45e+154)
		tmp = cos((x * 2.0)) / (s * ((x * x) * (c * (c * s))));
	else
		tmp = t_0 * t_0;
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 8.4e-29], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], If[LessEqual[x, 2.45e+154], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(s * N[(N[(x * x), $MachinePrecision] * N[(c * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \frac{1}{s \cdot \left(x \cdot c\right)}\\
\mathbf{if}\;x \leq 8.4 \cdot 10^{-29}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\

\mathbf{elif}\;x \leq 2.45 \cdot 10^{+154}:\\
\;\;\;\;\frac{\cos \left(x \cdot 2\right)}{s \cdot \left(\left(x \cdot x\right) \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;t_0 \cdot t_0\\


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

    1. Initial program 66.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(c \cdot \left(x \cdot s\right)\right)}^{-1} \cdot \color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{-1}} \]
      16. pow-prod-up88.1%

        \[\leadsto \color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{\left(-1 + -1\right)}} \]
      17. metadata-eval88.1%

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

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

    if 8.39999999999999958e-29 < x < 2.4500000000000001e154

    1. Initial program 77.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.4500000000000001e154 < x

    1. Initial program 61.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*61.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{c}}{s \cdot x} \cdot \frac{\frac{1}{c}}{s \cdot x}} \]
      16. associate-/l/69.7%

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

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

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

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

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

Alternative 3: 94.6% accurate, 2.6× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := \cos \left(x \cdot 2\right)\\ \mathbf{if}\;x \leq 2 \cdot 10^{-24}:\\ \;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{+178}:\\ \;\;\;\;\frac{t_0}{x \cdot \left(x \cdot \left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{x \cdot \left(\left(c \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot s\right)\right)}\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 2e-24)
     (pow (* c (* x s)) -2.0)
     (if (<= x 1.3e+178)
       (/ t_0 (* x (* x (* (* c s) (* c s)))))
       (/ t_0 (* x (* (* c (* x c)) (* s s))))))))
x = abs(x);
c = abs(c);
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 <= 2e-24) {
		tmp = pow((c * (x * s)), -2.0);
	} else if (x <= 1.3e+178) {
		tmp = t_0 / (x * (x * ((c * s) * (c * s))));
	} else {
		tmp = t_0 / (x * ((c * (x * c)) * (s * s)));
	}
	return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 <= 2d-24) then
        tmp = (c * (x * s)) ** (-2.0d0)
    else if (x <= 1.3d+178) then
        tmp = t_0 / (x * (x * ((c * s) * (c * s))))
    else
        tmp = t_0 / (x * ((c * (x * c)) * (s * s)))
    end if
    code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
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 <= 2e-24) {
		tmp = Math.pow((c * (x * s)), -2.0);
	} else if (x <= 1.3e+178) {
		tmp = t_0 / (x * (x * ((c * s) * (c * s))));
	} else {
		tmp = t_0 / (x * ((c * (x * c)) * (s * s)));
	}
	return tmp;
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	t_0 = math.cos((x * 2.0))
	tmp = 0
	if x <= 2e-24:
		tmp = math.pow((c * (x * s)), -2.0)
	elif x <= 1.3e+178:
		tmp = t_0 / (x * (x * ((c * s) * (c * s))))
	else:
		tmp = t_0 / (x * ((c * (x * c)) * (s * s)))
	return tmp
x = abs(x)
c = abs(c)
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 <= 2e-24)
		tmp = Float64(c * Float64(x * s)) ^ -2.0;
	elseif (x <= 1.3e+178)
		tmp = Float64(t_0 / Float64(x * Float64(x * Float64(Float64(c * s) * Float64(c * s)))));
	else
		tmp = Float64(t_0 / Float64(x * Float64(Float64(c * Float64(x * c)) * Float64(s * s))));
	end
	return tmp
end
x = abs(x)
c = abs(c)
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 <= 2e-24)
		tmp = (c * (x * s)) ^ -2.0;
	elseif (x <= 1.3e+178)
		tmp = t_0 / (x * (x * ((c * s) * (c * s))));
	else
		tmp = t_0 / (x * ((c * (x * c)) * (s * s)));
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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, 2e-24], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], If[LessEqual[x, 1.3e+178], N[(t$95$0 / N[(x * N[(x * N[(N[(c * s), $MachinePrecision] * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(x * N[(N[(c * N[(x * c), $MachinePrecision]), $MachinePrecision] * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;x \leq 2 \cdot 10^{-24}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\

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

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


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

    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. *-commutative66.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{\left(-1 + -1\right)}} \]
      17. metadata-eval88.2%

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

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

    if 1.99999999999999985e-24 < x < 1.3e178

    1. Initial program 76.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*76.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.3e178 < x

    1. Initial program 60.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*63.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.0% accurate, 2.6× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := \cos \left(x \cdot 2\right)\\ t_1 := c \cdot \left(x \cdot s\right)\\ \mathbf{if}\;x \leq 2000000000:\\ \;\;\;\;\frac{\frac{t_0}{t_1}}{t_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s} \cdot \frac{t_0}{\left(x \cdot c\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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))) (t_1 (* c (* x s))))
   (if (<= x 2000000000.0)
     (/ (/ t_0 t_1) t_1)
     (* (/ 1.0 s) (/ t_0 (* (* x c) (* s (* x c))))))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double t_0 = cos((x * 2.0));
	double t_1 = c * (x * s);
	double tmp;
	if (x <= 2000000000.0) {
		tmp = (t_0 / t_1) / t_1;
	} else {
		tmp = (1.0 / s) * (t_0 / ((x * c) * (s * (x * c))));
	}
	return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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) :: t_1
    real(8) :: tmp
    t_0 = cos((x * 2.0d0))
    t_1 = c * (x * s)
    if (x <= 2000000000.0d0) then
        tmp = (t_0 / t_1) / t_1
    else
        tmp = (1.0d0 / s) * (t_0 / ((x * c) * (s * (x * c))))
    end if
    code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
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 t_1 = c * (x * s);
	double tmp;
	if (x <= 2000000000.0) {
		tmp = (t_0 / t_1) / t_1;
	} else {
		tmp = (1.0 / s) * (t_0 / ((x * c) * (s * (x * c))));
	}
	return tmp;
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	t_0 = math.cos((x * 2.0))
	t_1 = c * (x * s)
	tmp = 0
	if x <= 2000000000.0:
		tmp = (t_0 / t_1) / t_1
	else:
		tmp = (1.0 / s) * (t_0 / ((x * c) * (s * (x * c))))
	return tmp
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	t_0 = cos(Float64(x * 2.0))
	t_1 = Float64(c * Float64(x * s))
	tmp = 0.0
	if (x <= 2000000000.0)
		tmp = Float64(Float64(t_0 / t_1) / t_1);
	else
		tmp = Float64(Float64(1.0 / s) * Float64(t_0 / Float64(Float64(x * c) * Float64(s * Float64(x * c)))));
	end
	return tmp
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	t_0 = cos((x * 2.0));
	t_1 = c * (x * s);
	tmp = 0.0;
	if (x <= 2000000000.0)
		tmp = (t_0 / t_1) / t_1;
	else
		tmp = (1.0 / s) * (t_0 / ((x * c) * (s * (x * c))));
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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]}, Block[{t$95$1 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2000000000.0], N[(N[(t$95$0 / t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(1.0 / s), $MachinePrecision] * N[(t$95$0 / N[(N[(x * c), $MachinePrecision] * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
t_1 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;x \leq 2000000000:\\
\;\;\;\;\frac{\frac{t_0}{t_1}}{t_1}\\

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


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

    1. Initial program 66.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. unpow266.8%

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

        \[\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)}} \]
      3. unpow266.8%

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

      \[\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. *-un-lft-identity66.8%

        \[\leadsto \frac{\color{blue}{1 \cdot \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)} \]
      2. add-sqr-sqrt66.8%

        \[\leadsto \frac{1 \cdot \cos \left(2 \cdot x\right)}{\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)}}} \]
      3. times-frac66.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e9 < 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. *-commutative66.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 99.0% accurate, 2.6× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := \cos \left(x \cdot 2\right)\\ \mathbf{if}\;x \leq 1760000000:\\ \;\;\;\;\frac{\frac{1}{c}}{x \cdot s} \cdot \frac{t_0}{c \cdot \left(x \cdot s\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{s} \cdot \frac{t_0}{\left(x \cdot c\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 1760000000.0)
     (* (/ (/ 1.0 c) (* x s)) (/ t_0 (* c (* x s))))
     (* (/ 1.0 s) (/ t_0 (* (* x c) (* s (* x c))))))))
x = abs(x);
c = abs(c);
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 <= 1760000000.0) {
		tmp = ((1.0 / c) / (x * s)) * (t_0 / (c * (x * s)));
	} else {
		tmp = (1.0 / s) * (t_0 / ((x * c) * (s * (x * c))));
	}
	return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 <= 1760000000.0d0) then
        tmp = ((1.0d0 / c) / (x * s)) * (t_0 / (c * (x * s)))
    else
        tmp = (1.0d0 / s) * (t_0 / ((x * c) * (s * (x * c))))
    end if
    code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
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 <= 1760000000.0) {
		tmp = ((1.0 / c) / (x * s)) * (t_0 / (c * (x * s)));
	} else {
		tmp = (1.0 / s) * (t_0 / ((x * c) * (s * (x * c))));
	}
	return tmp;
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	t_0 = math.cos((x * 2.0))
	tmp = 0
	if x <= 1760000000.0:
		tmp = ((1.0 / c) / (x * s)) * (t_0 / (c * (x * s)))
	else:
		tmp = (1.0 / s) * (t_0 / ((x * c) * (s * (x * c))))
	return tmp
x = abs(x)
c = abs(c)
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 <= 1760000000.0)
		tmp = Float64(Float64(Float64(1.0 / c) / Float64(x * s)) * Float64(t_0 / Float64(c * Float64(x * s))));
	else
		tmp = Float64(Float64(1.0 / s) * Float64(t_0 / Float64(Float64(x * c) * Float64(s * Float64(x * c)))));
	end
	return tmp
end
x = abs(x)
c = abs(c)
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 <= 1760000000.0)
		tmp = ((1.0 / c) / (x * s)) * (t_0 / (c * (x * s)));
	else
		tmp = (1.0 / s) * (t_0 / ((x * c) * (s * (x * c))));
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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, 1760000000.0], N[(N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / s), $MachinePrecision] * N[(t$95$0 / N[(N[(x * c), $MachinePrecision] * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;x \leq 1760000000:\\
\;\;\;\;\frac{\frac{1}{c}}{x \cdot s} \cdot \frac{t_0}{c \cdot \left(x \cdot s\right)}\\

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


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

    1. Initial program 66.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. unpow266.8%

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

        \[\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)}} \]
      3. unpow266.8%

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

      \[\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. *-un-lft-identity66.8%

        \[\leadsto \frac{\color{blue}{1 \cdot \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)} \]
      2. add-sqr-sqrt66.8%

        \[\leadsto \frac{1 \cdot \cos \left(2 \cdot x\right)}{\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)}}} \]
      3. times-frac66.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.76e9 < 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. *-commutative66.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 93.1% accurate, 2.7× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} \mathbf{if}\;x \leq 3.6 \cdot 10^{-24}:\\ \;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(x \cdot \left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right)\right)}\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 3.6e-24)
   (pow (* c (* x s)) -2.0)
   (/ (cos (* x 2.0)) (* x (* x (* (* c s) (* c s)))))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double tmp;
	if (x <= 3.6e-24) {
		tmp = pow((c * (x * s)), -2.0);
	} else {
		tmp = cos((x * 2.0)) / (x * (x * ((c * s) * (c * s))));
	}
	return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 <= 3.6d-24) then
        tmp = (c * (x * s)) ** (-2.0d0)
    else
        tmp = cos((x * 2.0d0)) / (x * (x * ((c * s) * (c * s))))
    end if
    code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double tmp;
	if (x <= 3.6e-24) {
		tmp = Math.pow((c * (x * s)), -2.0);
	} else {
		tmp = Math.cos((x * 2.0)) / (x * (x * ((c * s) * (c * s))));
	}
	return tmp;
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	tmp = 0
	if x <= 3.6e-24:
		tmp = math.pow((c * (x * s)), -2.0)
	else:
		tmp = math.cos((x * 2.0)) / (x * (x * ((c * s) * (c * s))))
	return tmp
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	tmp = 0.0
	if (x <= 3.6e-24)
		tmp = Float64(c * Float64(x * s)) ^ -2.0;
	else
		tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(x * Float64(Float64(c * s) * Float64(c * s)))));
	end
	return tmp
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (x <= 3.6e-24)
		tmp = (c * (x * s)) ^ -2.0;
	else
		tmp = cos((x * 2.0)) / (x * (x * ((c * s) * (c * s))));
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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, 3.6e-24], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(x * N[(N[(c * s), $MachinePrecision] * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.6 \cdot 10^{-24}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\

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


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

    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. *-commutative66.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{\left(-1 + -1\right)}} \]
      17. metadata-eval88.2%

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

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

    if 3.6000000000000001e-24 < x

    1. Initial program 67.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 97.3% accurate, 2.7× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ \mathbf{if}\;x \leq 5 \cdot 10^{-31}:\\ \;\;\;\;{t_0}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{\left(s \cdot \left(x \cdot c\right)\right) \cdot t_0}\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 (* x s))))
   (if (<= x 5e-31) (pow t_0 -2.0) (/ (cos (* x 2.0)) (* (* s (* x c)) t_0)))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	double tmp;
	if (x <= 5e-31) {
		tmp = pow(t_0, -2.0);
	} else {
		tmp = cos((x * 2.0)) / ((s * (x * c)) * t_0);
	}
	return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 = c * (x * s)
    if (x <= 5d-31) then
        tmp = t_0 ** (-2.0d0)
    else
        tmp = cos((x * 2.0d0)) / ((s * (x * c)) * t_0)
    end if
    code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	double tmp;
	if (x <= 5e-31) {
		tmp = Math.pow(t_0, -2.0);
	} else {
		tmp = Math.cos((x * 2.0)) / ((s * (x * c)) * t_0);
	}
	return tmp;
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	t_0 = c * (x * s)
	tmp = 0
	if x <= 5e-31:
		tmp = math.pow(t_0, -2.0)
	else:
		tmp = math.cos((x * 2.0)) / ((s * (x * c)) * t_0)
	return tmp
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	t_0 = Float64(c * Float64(x * s))
	tmp = 0.0
	if (x <= 5e-31)
		tmp = t_0 ^ -2.0;
	else
		tmp = Float64(cos(Float64(x * 2.0)) / Float64(Float64(s * Float64(x * c)) * t_0));
	end
	return tmp
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	t_0 = c * (x * s);
	tmp = 0.0;
	if (x <= 5e-31)
		tmp = t_0 ^ -2.0;
	else
		tmp = cos((x * 2.0)) / ((s * (x * c)) * t_0);
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 5e-31], N[Power[t$95$0, -2.0], $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;x \leq 5 \cdot 10^{-31}:\\
\;\;\;\;{t_0}^{-2}\\

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


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

    1. Initial program 66.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(c \cdot \left(x \cdot s\right)\right)}^{-1} \cdot \color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{-1}} \]
      16. pow-prod-up88.1%

        \[\leadsto \color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{\left(-1 + -1\right)}} \]
      17. metadata-eval88.1%

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

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

    if 5e-31 < x

    1. Initial program 68.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. *-commutative68.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 99.4% accurate, 2.7× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := s \cdot \left(x \cdot c\right)\\ \mathbf{if}\;x \leq 8 \cdot 10^{-29}:\\ \;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t_0 \cdot t_0}\\ \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 (* s (* x c))))
   (if (<= x 8e-29) (pow (* c (* x s)) -2.0) (/ (cos (* x 2.0)) (* t_0 t_0)))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double t_0 = s * (x * c);
	double tmp;
	if (x <= 8e-29) {
		tmp = pow((c * (x * s)), -2.0);
	} else {
		tmp = cos((x * 2.0)) / (t_0 * t_0);
	}
	return tmp;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 = s * (x * c)
    if (x <= 8d-29) then
        tmp = (c * (x * s)) ** (-2.0d0)
    else
        tmp = cos((x * 2.0d0)) / (t_0 * t_0)
    end if
    code = tmp
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double t_0 = s * (x * c);
	double tmp;
	if (x <= 8e-29) {
		tmp = Math.pow((c * (x * s)), -2.0);
	} else {
		tmp = Math.cos((x * 2.0)) / (t_0 * t_0);
	}
	return tmp;
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	t_0 = s * (x * c)
	tmp = 0
	if x <= 8e-29:
		tmp = math.pow((c * (x * s)), -2.0)
	else:
		tmp = math.cos((x * 2.0)) / (t_0 * t_0)
	return tmp
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	t_0 = Float64(s * Float64(x * c))
	tmp = 0.0
	if (x <= 8e-29)
		tmp = Float64(c * Float64(x * s)) ^ -2.0;
	else
		tmp = Float64(cos(Float64(x * 2.0)) / Float64(t_0 * t_0));
	end
	return tmp
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp_2 = code(x, c, s)
	t_0 = s * (x * c);
	tmp = 0.0;
	if (x <= 8e-29)
		tmp = (c * (x * s)) ^ -2.0;
	else
		tmp = cos((x * 2.0)) / (t_0 * t_0);
	end
	tmp_2 = tmp;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 8e-29], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot c\right)\\
\mathbf{if}\;x \leq 8 \cdot 10^{-29}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\

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


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

    1. Initial program 66.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(c \cdot \left(x \cdot s\right)\right)}^{-1} \cdot \color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{-1}} \]
      16. pow-prod-up88.1%

        \[\leadsto \color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{\left(-1 + -1\right)}} \]
      17. metadata-eval88.1%

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

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

    if 7.99999999999999955e-29 < x

    1. Initial program 68.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. *-commutative68.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 80.4% accurate, 3.0× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ {\left(c \cdot \left(x \cdot s\right)\right)}^{-2} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 (pow (* c (* x s)) -2.0))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return pow((c * (x * s)), -2.0);
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 = (c * (x * s)) ** (-2.0d0)
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return Math.pow((c * (x * s)), -2.0);
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return math.pow((c * (x * s)), -2.0)
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(c * Float64(x * s)) ^ -2.0
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = (c * (x * s)) ^ -2.0;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}
\end{array}
Derivation
  1. Initial program 66.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{-1}} \cdot \frac{1}{c \cdot \left(x \cdot s\right)} \]
    15. inv-pow81.7%

      \[\leadsto {\left(c \cdot \left(x \cdot s\right)\right)}^{-1} \cdot \color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{-1}} \]
    16. pow-prod-up81.7%

      \[\leadsto \color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{\left(-1 + -1\right)}} \]
    17. metadata-eval81.7%

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

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

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

Alternative 10: 80.3% accurate, 20.9× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := \frac{1}{c \cdot \left(x \cdot s\right)}\\ t_0 \cdot t_0 \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 (* x s))))) (* t_0 t_0)))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double t_0 = 1.0 / (c * (x * s));
	return t_0 * t_0;
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 * (x * s))
    code = t_0 * t_0
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double t_0 = 1.0 / (c * (x * s));
	return t_0 * t_0;
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	t_0 = 1.0 / (c * (x * s))
	return t_0 * t_0
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	t_0 = Float64(1.0 / Float64(c * Float64(x * s)))
	return Float64(t_0 * t_0)
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	t_0 = 1.0 / (c * (x * s));
	tmp = t_0 * t_0;
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := \frac{1}{c \cdot \left(x \cdot s\right)}\\
t_0 \cdot t_0
\end{array}
\end{array}
Derivation
  1. Initial program 66.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 56.4% accurate, 24.1× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{1}{\left(c \cdot c\right) \cdot \left(\left(s \cdot s\right) \cdot \left(x \cdot x\right)\right)} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 c) (* (* s s) (* x x)))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return 1.0 / ((c * c) * ((s * s) * (x * x)));
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 * c) * ((s * s) * (x * x)))
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return 1.0 / ((c * c) * ((s * s) * (x * x)));
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return 1.0 / ((c * c) * ((s * s) * (x * x)))
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(1.0 / Float64(Float64(c * c) * Float64(Float64(s * s) * Float64(x * x))))
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = 1.0 / ((c * c) * ((s * s) * (x * x)));
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 * c), $MachinePrecision] * N[(N[(s * s), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{1}{\left(c \cdot c\right) \cdot \left(\left(s \cdot s\right) \cdot \left(x \cdot x\right)\right)}
\end{array}
Derivation
  1. Initial program 66.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 78.3% accurate, 24.1× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := s \cdot \left(x \cdot c\right)\\ \frac{1}{t_0 \cdot t_0} \end{array} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 (* s (* x c)))) (/ 1.0 (* t_0 t_0))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double t_0 = s * (x * c);
	return 1.0 / (t_0 * t_0);
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 = s * (x * c)
    code = 1.0d0 / (t_0 * t_0)
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	double t_0 = s * (x * c);
	return 1.0 / (t_0 * t_0);
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	t_0 = s * (x * c)
	return 1.0 / (t_0 * t_0)
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	t_0 = Float64(s * Float64(x * c))
	return Float64(1.0 / Float64(t_0 * t_0))
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	t_0 = s * (x * c);
	tmp = 1.0 / (t_0 * t_0);
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := s \cdot \left(x \cdot c\right)\\
\frac{1}{t_0 \cdot t_0}
\end{array}
\end{array}
Derivation
  1. Initial program 66.7%

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Step-by-step derivation
    1. unpow266.7%

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

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

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

    \[\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. *-un-lft-identity66.7%

      \[\leadsto \frac{\color{blue}{1 \cdot \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)} \]
    2. add-sqr-sqrt66.7%

      \[\leadsto \frac{1 \cdot \cos \left(2 \cdot x\right)}{\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)}}} \]
    3. times-frac66.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 79.7% accurate, 24.1× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{\frac{1}{c}}{\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)} \end{array} \]
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 s) (* c (* x s)))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return (1.0 / c) / ((x * s) * (c * (x * s)));
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 * s) * (c * (x * s)))
end function
x = Math.abs(x);
c = Math.abs(c);
s = Math.abs(s);
assert c < s;
public static double code(double x, double c, double s) {
	return (1.0 / c) / ((x * s) * (c * (x * s)));
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return (1.0 / c) / ((x * s) * (c * (x * s)))
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(Float64(1.0 / c) / Float64(Float64(x * s) * Float64(c * Float64(x * s))))
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = (1.0 / c) / ((x * s) * (c * (x * s)));
end
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
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 / c), $MachinePrecision] / N[(N[(x * s), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{1}{c}}{\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}
\end{array}
Derivation
  1. Initial program 66.7%

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Step-by-step derivation
    1. unpow266.7%

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

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

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

    \[\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. *-un-lft-identity66.7%

      \[\leadsto \frac{\color{blue}{1 \cdot \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)} \]
    2. add-sqr-sqrt66.7%

      \[\leadsto \frac{1 \cdot \cos \left(2 \cdot x\right)}{\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)}}} \]
    3. times-frac66.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\left(c \cdot \left(x \cdot s\right)\right)}^{-1} \cdot \color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{-1}} \]
    14. pow-sqr81.7%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{-1} \cdot {\left(c \cdot \left(x \cdot s\right)\right)}^{-1}} \]
    5. inv-pow81.7%

      \[\leadsto \color{blue}{\frac{1}{c \cdot \left(x \cdot s\right)}} \cdot {\left(c \cdot \left(x \cdot s\right)\right)}^{-1} \]
    6. inv-pow81.7%

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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