mixedcos

Percentage Accurate: 66.9% → 99.5%
Time: 11.4s
Alternatives: 14
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 14 alternatives:

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

Initial Program: 66.9% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 2.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 1.56 \cdot 10^{-41}:\\ \;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{t_0}}{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 1.56e-41)
     (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 <= 1.56e-41) {
		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 <= 1.56d-41) 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 <= 1.56e-41) {
		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 <= 1.56e-41:
		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 <= 1.56e-41)
		tmp = Float64(c * Float64(x * s)) ^ -2.0;
	else
		tmp = Float64(Float64(cos(Float64(x * 2.0)) / 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 <= 1.56e-41)
		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, 1.56e-41], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $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 1.56 \cdot 10^{-41}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\

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


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

    1. Initial program 64.1%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Step-by-step derivation
      1. *-commutative64.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*57.3%

        \[\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*57.4%

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

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

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

        \[\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.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. *-commutative95.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. *-commutative95.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. *-commutative95.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. *-commutative95.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. Simplified95.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. Step-by-step derivation
      1. associate-/r*95.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot c}}}{{s}^{2} \cdot {x}^{2}} \]
      5. associate-/r*52.9%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{c}}{s \cdot x} \cdot \frac{\frac{1}{c}}{s \cdot x}} \]
      12. associate-/r*84.2%

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

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

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

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

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

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

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

    if 1.5600000000000001e-41 < x

    1. Initial program 75.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. *-commutative75.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*73.0%

        \[\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*72.9%

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

        \[\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-sqr83.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. unpow283.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-sqr99.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. *-commutative99.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. *-commutative99.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. *-commutative99.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. *-commutative99.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. Simplified99.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. Step-by-step derivation
      1. associate-/r*99.6%

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

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

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

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

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

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

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

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

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

Alternative 2: 97.3% accurate, 1.5× 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} \cdot \cos \left(x \cdot 2\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
 (* (pow (* c (* x s)) -2.0) (cos (* x 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) * cos((x * 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)) * cos((x * 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) * Math.cos((x * 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) * math.cos((x * 2.0))
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64((Float64(c * Float64(x * s)) ^ -2.0) * cos(Float64(x * 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) * cos((x * 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[(N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision] * N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $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} \cdot \cos \left(x \cdot 2\right)
\end{array}
Derivation
  1. Initial program 67.6%

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

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

      \[\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*62.1%

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

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

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

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

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

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

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

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

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

    \[\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 inf 62.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto e^{\color{blue}{\log \cos \left(x \cdot 2\right) - \log \left({\left(c \cdot \left(x \cdot s\right)\right)}^{2}\right)}} \]
    11. log-pow48.9%

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

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

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

      \[\leadsto e^{\log \cos \left(x \cdot 2\right) - 2 \cdot \log \color{blue}{\left(s \cdot \left(x \cdot c\right)\right)}} \]
    15. cancel-sign-sub-inv49.7%

      \[\leadsto e^{\color{blue}{\log \cos \left(x \cdot 2\right) + \left(-2\right) \cdot \log \left(s \cdot \left(x \cdot c\right)\right)}} \]
  6. Simplified97.8%

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

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

Alternative 3: 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 := \cos \left(x \cdot 2\right)\\ \mathbf{if}\;x \leq 1.12 \cdot 10^{-20}:\\ \;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{+151}:\\ \;\;\;\;\frac{t_0}{s \cdot \left(\left(x \cdot x\right) \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}\\ \mathbf{elif}\;x \leq 8.8 \cdot 10^{+216}:\\ \;\;\;\;\frac{t_0}{\left(c \cdot c\right) \cdot \left(x \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{{\left(s \cdot \left(x \cdot c\right)\right)}^{2}}\\ \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 1.12e-20)
     (pow (* c (* x s)) -2.0)
     (if (<= x 4.6e+151)
       (/ t_0 (* s (* (* x x) (* c (* c s)))))
       (if (<= x 8.8e+216)
         (/ t_0 (* (* c c) (* x (* x (* s s)))))
         (/ 1.0 (pow (* s (* x c)) 2.0)))))))
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 <= 1.12e-20) {
		tmp = pow((c * (x * s)), -2.0);
	} else if (x <= 4.6e+151) {
		tmp = t_0 / (s * ((x * x) * (c * (c * s))));
	} else if (x <= 8.8e+216) {
		tmp = t_0 / ((c * c) * (x * (x * (s * s))));
	} else {
		tmp = 1.0 / pow((s * (x * c)), 2.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 = cos((x * 2.0d0))
    if (x <= 1.12d-20) then
        tmp = (c * (x * s)) ** (-2.0d0)
    else if (x <= 4.6d+151) then
        tmp = t_0 / (s * ((x * x) * (c * (c * s))))
    else if (x <= 8.8d+216) then
        tmp = t_0 / ((c * c) * (x * (x * (s * s))))
    else
        tmp = 1.0d0 / ((s * (x * c)) ** 2.0d0)
    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 <= 1.12e-20) {
		tmp = Math.pow((c * (x * s)), -2.0);
	} else if (x <= 4.6e+151) {
		tmp = t_0 / (s * ((x * x) * (c * (c * s))));
	} else if (x <= 8.8e+216) {
		tmp = t_0 / ((c * c) * (x * (x * (s * s))));
	} else {
		tmp = 1.0 / Math.pow((s * (x * c)), 2.0);
	}
	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 <= 1.12e-20:
		tmp = math.pow((c * (x * s)), -2.0)
	elif x <= 4.6e+151:
		tmp = t_0 / (s * ((x * x) * (c * (c * s))))
	elif x <= 8.8e+216:
		tmp = t_0 / ((c * c) * (x * (x * (s * s))))
	else:
		tmp = 1.0 / math.pow((s * (x * c)), 2.0)
	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 <= 1.12e-20)
		tmp = Float64(c * Float64(x * s)) ^ -2.0;
	elseif (x <= 4.6e+151)
		tmp = Float64(t_0 / Float64(s * Float64(Float64(x * x) * Float64(c * Float64(c * s)))));
	elseif (x <= 8.8e+216)
		tmp = Float64(t_0 / Float64(Float64(c * c) * Float64(x * Float64(x * Float64(s * s)))));
	else
		tmp = Float64(1.0 / (Float64(s * Float64(x * c)) ^ 2.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 = cos((x * 2.0));
	tmp = 0.0;
	if (x <= 1.12e-20)
		tmp = (c * (x * s)) ^ -2.0;
	elseif (x <= 4.6e+151)
		tmp = t_0 / (s * ((x * x) * (c * (c * s))));
	elseif (x <= 8.8e+216)
		tmp = t_0 / ((c * c) * (x * (x * (s * s))));
	else
		tmp = 1.0 / ((s * (x * c)) ^ 2.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[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1.12e-20], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], If[LessEqual[x, 4.6e+151], N[(t$95$0 / N[(s * N[(N[(x * x), $MachinePrecision] * N[(c * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.8e+216], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] * N[(x * N[(x * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Power[N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision], 2.0], $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 1.12 \cdot 10^{-20}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 1.12000000000000002e-20

    1. Initial program 64.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. *-commutative64.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*57.9%

        \[\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*58.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. unpow258.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-sqr75.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. unpow275.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.7%

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

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

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

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

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

      \[\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. associate-/r*96.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot c}}}{{s}^{2} \cdot {x}^{2}} \]
      5. associate-/r*53.6%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{c}}{s \cdot x} \cdot \frac{\frac{1}{c}}{s \cdot x}} \]
      12. associate-/r*84.6%

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

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

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

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

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

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

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

    if 1.12000000000000002e-20 < x < 4.6000000000000002e151

    1. Initial program 74.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. *-commutative74.3%

        \[\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*74.3%

        \[\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*76.3%

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

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

        \[\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*81.0%

        \[\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*83.0%

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

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

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

      \[\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 83.0%

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

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

        \[\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*95.6%

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

      \[\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 4.6000000000000002e151 < x < 8.8e216

    1. Initial program 89.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. unpow289.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. *-commutative89.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. unpow289.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. Simplified89.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)}} \]

    if 8.8e216 < x

    1. Initial program 70.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. *-commutative70.9%

        \[\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.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*64.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. unpow264.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-sqr94.0%

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

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

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

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

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

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

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

      \[\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 64.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.12 \cdot 10^{-20}:\\ \;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{+151}:\\ \;\;\;\;\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{elif}\;x \leq 8.8 \cdot 10^{+216}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot c\right) \cdot \left(x \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{{\left(s \cdot \left(x \cdot c\right)\right)}^{2}}\\ \end{array} \]

Alternative 4: 86.5% 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 5.5 \cdot 10^{-42}:\\ \;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\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)}\\ \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 5.5e-42)
   (pow (* c (* x s)) -2.0)
   (/ (cos (* x 2.0)) (* s (* (* x x) (* c (* 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 <= 5.5e-42) {
		tmp = pow((c * (x * s)), -2.0);
	} else {
		tmp = cos((x * 2.0)) / (s * ((x * x) * (c * (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 <= 5.5d-42) then
        tmp = (c * (x * s)) ** (-2.0d0)
    else
        tmp = cos((x * 2.0d0)) / (s * ((x * x) * (c * (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 <= 5.5e-42) {
		tmp = Math.pow((c * (x * s)), -2.0);
	} else {
		tmp = Math.cos((x * 2.0)) / (s * ((x * x) * (c * (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 <= 5.5e-42:
		tmp = math.pow((c * (x * s)), -2.0)
	else:
		tmp = math.cos((x * 2.0)) / (s * ((x * x) * (c * (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 <= 5.5e-42)
		tmp = Float64(c * Float64(x * s)) ^ -2.0;
	else
		tmp = Float64(cos(Float64(x * 2.0)) / Float64(s * Float64(Float64(x * x) * Float64(c * 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 <= 5.5e-42)
		tmp = (c * (x * s)) ^ -2.0;
	else
		tmp = cos((x * 2.0)) / (s * ((x * x) * (c * (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, 5.5e-42], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision], 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]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.5 \cdot 10^{-42}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\

\mathbf{else}:\\
\;\;\;\;\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)}\\


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

    1. Initial program 64.1%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Step-by-step derivation
      1. *-commutative64.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*57.3%

        \[\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*57.4%

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

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

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

        \[\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.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. *-commutative95.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. *-commutative95.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. *-commutative95.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. *-commutative95.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. Simplified95.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. Step-by-step derivation
      1. associate-/r*95.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot c}}}{{s}^{2} \cdot {x}^{2}} \]
      5. associate-/r*52.9%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{c}}{s \cdot x} \cdot \frac{\frac{1}{c}}{s \cdot x}} \]
      12. associate-/r*84.2%

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

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

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

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

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

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

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

    if 5.5e-42 < x

    1. Initial program 75.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. *-commutative75.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*73.0%

        \[\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*74.2%

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

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

        \[\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*78.3%

        \[\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*79.5%

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

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

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

      \[\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 79.5%

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

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

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

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

      \[\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)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification85.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 5.5 \cdot 10^{-42}:\\ \;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\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)}\\ \end{array} \]

Alternative 5: 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 10^{-20}:\\ \;\;\;\;{t_0}^{-2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t_0 \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 (* c (* x s))))
   (if (<= x 1e-20) (pow t_0 -2.0) (/ (cos (* x 2.0)) (* t_0 (* 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 = c * (x * s);
	double tmp;
	if (x <= 1e-20) {
		tmp = pow(t_0, -2.0);
	} else {
		tmp = cos((x * 2.0)) / (t_0 * (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 = c * (x * s)
    if (x <= 1d-20) then
        tmp = t_0 ** (-2.0d0)
    else
        tmp = cos((x * 2.0d0)) / (t_0 * (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 = c * (x * s);
	double tmp;
	if (x <= 1e-20) {
		tmp = Math.pow(t_0, -2.0);
	} else {
		tmp = Math.cos((x * 2.0)) / (t_0 * (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 = c * (x * s)
	tmp = 0
	if x <= 1e-20:
		tmp = math.pow(t_0, -2.0)
	else:
		tmp = math.cos((x * 2.0)) / (t_0 * (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 = Float64(c * Float64(x * s))
	tmp = 0.0
	if (x <= 1e-20)
		tmp = t_0 ^ -2.0;
	else
		tmp = Float64(cos(Float64(x * 2.0)) / Float64(t_0 * 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 = c * (x * s);
	tmp = 0.0;
	if (x <= 1e-20)
		tmp = t_0 ^ -2.0;
	else
		tmp = cos((x * 2.0)) / (t_0 * (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[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1e-20], N[Power[t$95$0, -2.0], $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $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 10^{-20}:\\
\;\;\;\;{t_0}^{-2}\\

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


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

    1. Initial program 64.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. *-commutative64.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*57.9%

        \[\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*58.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. unpow258.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-sqr75.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. unpow275.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.7%

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

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

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

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

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

      \[\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. associate-/r*96.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot c}}}{{s}^{2} \cdot {x}^{2}} \]
      5. associate-/r*53.6%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{c}}{s \cdot x} \cdot \frac{\frac{1}{c}}{s \cdot x}} \]
      12. associate-/r*84.6%

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

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

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

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

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

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

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

    if 9.99999999999999945e-21 < x

    1. Initial program 75.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. *-commutative75.4%

        \[\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*72.5%

        \[\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*72.4%

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

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

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

        \[\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-sqr99.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. *-commutative99.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. *-commutative99.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. *-commutative99.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. *-commutative99.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. Simplified99.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 s around 0 99.7%

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

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

Alternative 6: 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^{-21}:\\ \;\;\;\;{\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-21) (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-21) {
		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-21) 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-21) {
		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-21:
		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-21)
		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-21)
		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-21], 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^{-21}:\\
\;\;\;\;{\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.99999999999999926e-21

    1. Initial program 64.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. *-commutative64.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*57.9%

        \[\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*58.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. unpow258.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-sqr75.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. unpow275.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.7%

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

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

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

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

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

      \[\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. associate-/r*96.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot c}}}{{s}^{2} \cdot {x}^{2}} \]
      5. associate-/r*53.6%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{c}}{s \cdot x} \cdot \frac{\frac{1}{c}}{s \cdot x}} \]
      12. associate-/r*84.6%

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

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

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

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

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

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

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

    if 7.99999999999999926e-21 < x

    1. Initial program 75.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. *-commutative75.4%

        \[\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*72.5%

        \[\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*72.4%

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

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

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

        \[\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-sqr99.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. *-commutative99.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. *-commutative99.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. *-commutative99.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. *-commutative99.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. Simplified99.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)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification88.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 8 \cdot 10^{-21}:\\ \;\;\;\;{\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 7: 79.8% 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 67.6%

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

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

      \[\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*62.1%

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

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

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

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

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

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

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

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

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

    \[\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. associate-/r*97.0%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{{c}^{2}}}}{{s}^{2} \cdot {x}^{2}} \]
    4. unpow255.8%

      \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot c}}}{{s}^{2} \cdot {x}^{2}} \]
    5. associate-/r*56.3%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{c}}{s \cdot x} \cdot \frac{\frac{1}{c}}{s \cdot x}} \]
    12. associate-/r*80.3%

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

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

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

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

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

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

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

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

Alternative 8: 57.4% accurate, 20.8× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} \mathbf{if}\;s \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\frac{1}{\left(c \cdot c\right) \cdot \left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2}{\left(c \cdot c\right) \cdot \left(s \cdot s\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 (<= s 1.35e+154)
   (/ 1.0 (* (* c c) (* (* x x) (* s s))))
   (/ -2.0 (* (* c c) (* s s)))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	double tmp;
	if (s <= 1.35e+154) {
		tmp = 1.0 / ((c * c) * ((x * x) * (s * s)));
	} else {
		tmp = -2.0 / ((c * 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) :: tmp
    if (s <= 1.35d+154) then
        tmp = 1.0d0 / ((c * c) * ((x * x) * (s * s)))
    else
        tmp = (-2.0d0) / ((c * 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 tmp;
	if (s <= 1.35e+154) {
		tmp = 1.0 / ((c * c) * ((x * x) * (s * s)));
	} else {
		tmp = -2.0 / ((c * c) * (s * 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 s <= 1.35e+154:
		tmp = 1.0 / ((c * c) * ((x * x) * (s * s)))
	else:
		tmp = -2.0 / ((c * c) * (s * 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 (s <= 1.35e+154)
		tmp = Float64(1.0 / Float64(Float64(c * c) * Float64(Float64(x * x) * Float64(s * s))));
	else
		tmp = Float64(-2.0 / Float64(Float64(c * 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)
	tmp = 0.0;
	if (s <= 1.35e+154)
		tmp = 1.0 / ((c * c) * ((x * x) * (s * s)));
	else
		tmp = -2.0 / ((c * 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_] := If[LessEqual[s, 1.35e+154], N[(1.0 / N[(N[(c * c), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 / N[(N[(c * c), $MachinePrecision] * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;s \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{1}{\left(c \cdot c\right) \cdot \left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)}\\

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


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

    1. Initial program 70.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. *-commutative70.0%

        \[\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*63.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-sqr80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.35000000000000003e154 < s

    1. Initial program 55.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. *-commutative55.4%

        \[\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*52.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*52.4%

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

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

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

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

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

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

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

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

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

      \[\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. associate-/r*97.6%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-2}{{s}^{2} \cdot {c}^{2}}} \]
    9. Step-by-step derivation
      1. unpow255.4%

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

        \[\leadsto \frac{-2}{\left(s \cdot s\right) \cdot \color{blue}{\left(c \cdot c\right)}} \]
    10. Simplified55.4%

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

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

Alternative 9: 57.3% accurate, 20.8× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} \mathbf{if}\;s \leq 1.85 \cdot 10^{+215}:\\ \;\;\;\;\frac{1}{\left(c \cdot c\right) \cdot \left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-2 \cdot \frac{x}{c \cdot s}}{x \cdot \left(c \cdot s\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 (<= s 1.85e+215)
   (/ 1.0 (* (* c c) (* (* x x) (* s s))))
   (/ (* -2.0 (/ x (* c s))) (* x (* 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 (s <= 1.85e+215) {
		tmp = 1.0 / ((c * c) * ((x * x) * (s * s)));
	} else {
		tmp = (-2.0 * (x / (c * s))) / (x * (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 (s <= 1.85d+215) then
        tmp = 1.0d0 / ((c * c) * ((x * x) * (s * s)))
    else
        tmp = ((-2.0d0) * (x / (c * s))) / (x * (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 (s <= 1.85e+215) {
		tmp = 1.0 / ((c * c) * ((x * x) * (s * s)));
	} else {
		tmp = (-2.0 * (x / (c * s))) / (x * (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 s <= 1.85e+215:
		tmp = 1.0 / ((c * c) * ((x * x) * (s * s)))
	else:
		tmp = (-2.0 * (x / (c * s))) / (x * (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 (s <= 1.85e+215)
		tmp = Float64(1.0 / Float64(Float64(c * c) * Float64(Float64(x * x) * Float64(s * s))));
	else
		tmp = Float64(Float64(-2.0 * Float64(x / Float64(c * s))) / Float64(x * 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 (s <= 1.85e+215)
		tmp = 1.0 / ((c * c) * ((x * x) * (s * s)));
	else
		tmp = (-2.0 * (x / (c * s))) / (x * (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[s, 1.85e+215], N[(1.0 / N[(N[(c * c), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(x / N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
\mathbf{if}\;s \leq 1.85 \cdot 10^{+215}:\\
\;\;\;\;\frac{1}{\left(c \cdot c\right) \cdot \left(\left(x \cdot x\right) \cdot \left(s \cdot s\right)\right)}\\

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


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

    1. Initial program 69.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. *-commutative69.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*63.2%

        \[\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*63.3%

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

        \[\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-sqr79.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. unpow279.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-sqr96.8%

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

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

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

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

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

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

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

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

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

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

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

    if 1.84999999999999986e215 < s

    1. Initial program 56.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. *-commutative56.9%

        \[\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*53.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*53.1%

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

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

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

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

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

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

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

      \[\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. associate-/r*96.9%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 79.8% 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 67.6%

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

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

      \[\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*62.1%

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

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

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

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

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

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

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

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

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

    \[\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. associate-/r*97.0%

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

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

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

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

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

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

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

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

Alternative 11: 75.3% accurate, 24.1× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{\frac{1}{s}}{\left(x \cdot c\right) \cdot \left(s \cdot \left(x \cdot c\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 s) (* (* 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) {
	return (1.0 / s) / ((x * c) * (s * (x * c)));
}
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 / s) / ((x * c) * (s * (x * c)))
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 / s) / ((x * c) * (s * (x * c)));
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return (1.0 / s) / ((x * c) * (s * (x * c)))
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(Float64(1.0 / s) / Float64(Float64(x * c) * Float64(s * Float64(x * c))))
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 / s) / ((x * c) * (s * (x * c)));
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 / s), $MachinePrecision] / N[(N[(x * c), $MachinePrecision] * N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{1}{s}}{\left(x \cdot c\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}
\end{array}
Derivation
  1. Initial program 67.6%

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

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

      \[\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*62.1%

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

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

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

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

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

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

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

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

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

    \[\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. associate-/r*97.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 77.9% 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{\frac{1}{t_0}}{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(Float64(1.0 / 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[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $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{\frac{1}{t_0}}{t_0}
\end{array}
\end{array}
Derivation
  1. Initial program 67.6%

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

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

      \[\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*62.1%

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

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

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

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

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

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

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

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

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

    \[\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. associate-/r*97.0%

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

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

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

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

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

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

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

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

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

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

Alternative 13: 77.6% accurate, 24.1× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{\frac{\frac{1}{x \cdot c}}{s}}{s \cdot \left(x \cdot c\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 (* x c)) s) (* s (* x c))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return ((1.0 / (x * c)) / s) / (s * (x * c));
}
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 / (x * c)) / s) / (s * (x * c))
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 / (x * c)) / s) / (s * (x * c));
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return ((1.0 / (x * c)) / s) / (s * (x * c))
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(Float64(Float64(1.0 / Float64(x * c)) / s) / Float64(s * Float64(x * c)))
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 / (x * c)) / s) / (s * (x * c));
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[(N[(1.0 / N[(x * c), $MachinePrecision]), $MachinePrecision] / s), $MachinePrecision] / N[(s * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{\frac{\frac{1}{x \cdot c}}{s}}{s \cdot \left(x \cdot c\right)}
\end{array}
Derivation
  1. Initial program 67.6%

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

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

      \[\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*62.1%

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

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

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

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

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

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

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

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

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

    \[\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. associate-/r*97.0%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 28.0% accurate, 34.8× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ s = |s|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \frac{-2}{\left(c \cdot c\right) \cdot \left(s \cdot s\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 (/ -2.0 (* (* c c) (* s s))))
x = abs(x);
c = abs(c);
s = abs(s);
assert(c < s);
double code(double x, double c, double s) {
	return -2.0 / ((c * c) * (s * 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 = (-2.0d0) / ((c * c) * (s * 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 -2.0 / ((c * c) * (s * s));
}
x = abs(x)
c = abs(c)
s = abs(s)
[c, s] = sort([c, s])
def code(x, c, s):
	return -2.0 / ((c * c) * (s * s))
x = abs(x)
c = abs(c)
s = abs(s)
c, s = sort([c, s])
function code(x, c, s)
	return Float64(-2.0 / Float64(Float64(c * c) * Float64(s * s)))
end
x = abs(x)
c = abs(c)
s = abs(s)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	tmp = -2.0 / ((c * c) * (s * 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[(-2.0 / N[(N[(c * c), $MachinePrecision] * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
c = |c|\\
s = |s|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\frac{-2}{\left(c \cdot c\right) \cdot \left(s \cdot s\right)}
\end{array}
Derivation
  1. Initial program 67.6%

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

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

      \[\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*62.1%

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

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

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

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

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

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

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

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

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

    \[\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. associate-/r*97.0%

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{-2}{{s}^{2} \cdot {c}^{2}}} \]
  9. Step-by-step derivation
    1. unpow234.0%

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

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

    \[\leadsto \color{blue}{\frac{-2}{\left(s \cdot s\right) \cdot \left(c \cdot c\right)}} \]
  11. Final simplification34.0%

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

Reproduce

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