mixedcos

Percentage Accurate: 67.0% → 97.4%
Time: 18.0s
Alternatives: 15
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 15 alternatives:

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

Initial Program: 67.0% accurate, 1.0× speedup?

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

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

Alternative 1: 97.4% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(c \cdot s\right)\\ \frac{1}{t_0} \cdot \frac{\cos \left(x \cdot 2\right)}{t_0} \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* x (* c s)))) (* (/ 1.0 t_0) (/ (cos (* x 2.0)) t_0))))
double code(double x, double c, double s) {
	double t_0 = x * (c * s);
	return (1.0 / t_0) * (cos((x * 2.0)) / t_0);
}
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 = x * (c * s)
    code = (1.0d0 / t_0) * (cos((x * 2.0d0)) / t_0)
end function
public static double code(double x, double c, double s) {
	double t_0 = x * (c * s);
	return (1.0 / t_0) * (Math.cos((x * 2.0)) / t_0);
}
def code(x, c, s):
	t_0 = x * (c * s)
	return (1.0 / t_0) * (math.cos((x * 2.0)) / t_0)
function code(x, c, s)
	t_0 = Float64(x * Float64(c * s))
	return Float64(Float64(1.0 / t_0) * Float64(cos(Float64(x * 2.0)) / t_0))
end
function tmp = code(x, c, s)
	t_0 = x * (c * s);
	tmp = (1.0 / t_0) * (cos((x * 2.0)) / t_0);
end
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \left(c \cdot s\right)\\
\frac{1}{t_0} \cdot \frac{\cos \left(x \cdot 2\right)}{t_0}
\end{array}
\end{array}
Derivation
  1. Initial program 67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 79.6% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(x \cdot 2\right)\\ \mathbf{if}\;x \leq 3.1 \cdot 10^{-5}:\\ \;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \left(\frac{1}{c} \cdot \left(-2 \cdot \frac{x}{s} + \frac{1}{x \cdot s}\right)\right)\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{+166}:\\ \;\;\;\;\frac{t_0}{x \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(c \cdot s\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{x \cdot \left(\left(s \cdot s\right) \cdot \left(c \cdot \left(x \cdot c\right)\right)\right)}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (cos (* x 2.0))))
   (if (<= x 3.1e-5)
     (*
      (/ 1.0 (* c (* x s)))
      (* (/ 1.0 c) (+ (* -2.0 (/ x s)) (/ 1.0 (* x s)))))
     (if (<= x 2.6e+166)
       (/ t_0 (* x (* x (* c (* s (* c s))))))
       (/ t_0 (* x (* (* s s) (* c (* x c)))))))))
double code(double x, double c, double s) {
	double t_0 = cos((x * 2.0));
	double tmp;
	if (x <= 3.1e-5) {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * ((-2.0 * (x / s)) + (1.0 / (x * s))));
	} else if (x <= 2.6e+166) {
		tmp = t_0 / (x * (x * (c * (s * (c * s)))));
	} else {
		tmp = t_0 / (x * ((s * s) * (c * (x * c))));
	}
	return tmp;
}
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 <= 3.1d-5) then
        tmp = (1.0d0 / (c * (x * s))) * ((1.0d0 / c) * (((-2.0d0) * (x / s)) + (1.0d0 / (x * s))))
    else if (x <= 2.6d+166) then
        tmp = t_0 / (x * (x * (c * (s * (c * s)))))
    else
        tmp = t_0 / (x * ((s * s) * (c * (x * c))))
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double t_0 = Math.cos((x * 2.0));
	double tmp;
	if (x <= 3.1e-5) {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * ((-2.0 * (x / s)) + (1.0 / (x * s))));
	} else if (x <= 2.6e+166) {
		tmp = t_0 / (x * (x * (c * (s * (c * s)))));
	} else {
		tmp = t_0 / (x * ((s * s) * (c * (x * c))));
	}
	return tmp;
}
def code(x, c, s):
	t_0 = math.cos((x * 2.0))
	tmp = 0
	if x <= 3.1e-5:
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * ((-2.0 * (x / s)) + (1.0 / (x * s))))
	elif x <= 2.6e+166:
		tmp = t_0 / (x * (x * (c * (s * (c * s)))))
	else:
		tmp = t_0 / (x * ((s * s) * (c * (x * c))))
	return tmp
function code(x, c, s)
	t_0 = cos(Float64(x * 2.0))
	tmp = 0.0
	if (x <= 3.1e-5)
		tmp = Float64(Float64(1.0 / Float64(c * Float64(x * s))) * Float64(Float64(1.0 / c) * Float64(Float64(-2.0 * Float64(x / s)) + Float64(1.0 / Float64(x * s)))));
	elseif (x <= 2.6e+166)
		tmp = Float64(t_0 / Float64(x * Float64(x * Float64(c * Float64(s * Float64(c * s))))));
	else
		tmp = Float64(t_0 / Float64(x * Float64(Float64(s * s) * Float64(c * Float64(x * c)))));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	t_0 = cos((x * 2.0));
	tmp = 0.0;
	if (x <= 3.1e-5)
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * ((-2.0 * (x / s)) + (1.0 / (x * s))));
	elseif (x <= 2.6e+166)
		tmp = t_0 / (x * (x * (c * (s * (c * s)))));
	else
		tmp = t_0 / (x * ((s * s) * (c * (x * c))));
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := Block[{t$95$0 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 3.1e-5], N[(N[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] * N[(N[(-2.0 * N[(x / s), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.6e+166], N[(t$95$0 / N[(x * N[(x * N[(c * N[(s * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(x * N[(N[(s * s), $MachinePrecision] * N[(c * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;x \leq 3.1 \cdot 10^{-5}:\\
\;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \left(\frac{1}{c} \cdot \left(-2 \cdot \frac{x}{s} + \frac{1}{x \cdot s}\right)\right)\\

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

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


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

    1. Initial program 66.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.10000000000000014e-5 < x < 2.5999999999999999e166

    1. Initial program 84.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.5999999999999999e166 < x

    1. Initial program 55.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 84.5% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(x \cdot 2\right)\\ \mathbf{if}\;x \leq 1.05 \cdot 10^{-25}:\\ \;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \left(\frac{1}{c} \cdot \frac{1}{x \cdot s}\right)\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;\frac{\frac{t_0}{c \cdot s}}{s \cdot \left(c \cdot \left(x \cdot x\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{x \cdot \left(\left(s \cdot s\right) \cdot \left(c \cdot \left(x \cdot c\right)\right)\right)}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (cos (* x 2.0))))
   (if (<= x 1.05e-25)
     (* (/ 1.0 (* c (* x s))) (* (/ 1.0 c) (/ 1.0 (* x s))))
     (if (<= x 1.35e+154)
       (/ (/ t_0 (* c s)) (* s (* c (* x x))))
       (/ t_0 (* x (* (* s s) (* c (* x c)))))))))
double code(double x, double c, double s) {
	double t_0 = cos((x * 2.0));
	double tmp;
	if (x <= 1.05e-25) {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * (1.0 / (x * s)));
	} else if (x <= 1.35e+154) {
		tmp = (t_0 / (c * s)) / (s * (c * (x * x)));
	} else {
		tmp = t_0 / (x * ((s * s) * (c * (x * c))));
	}
	return tmp;
}
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.05d-25) then
        tmp = (1.0d0 / (c * (x * s))) * ((1.0d0 / c) * (1.0d0 / (x * s)))
    else if (x <= 1.35d+154) then
        tmp = (t_0 / (c * s)) / (s * (c * (x * x)))
    else
        tmp = t_0 / (x * ((s * s) * (c * (x * c))))
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double t_0 = Math.cos((x * 2.0));
	double tmp;
	if (x <= 1.05e-25) {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * (1.0 / (x * s)));
	} else if (x <= 1.35e+154) {
		tmp = (t_0 / (c * s)) / (s * (c * (x * x)));
	} else {
		tmp = t_0 / (x * ((s * s) * (c * (x * c))));
	}
	return tmp;
}
def code(x, c, s):
	t_0 = math.cos((x * 2.0))
	tmp = 0
	if x <= 1.05e-25:
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * (1.0 / (x * s)))
	elif x <= 1.35e+154:
		tmp = (t_0 / (c * s)) / (s * (c * (x * x)))
	else:
		tmp = t_0 / (x * ((s * s) * (c * (x * c))))
	return tmp
function code(x, c, s)
	t_0 = cos(Float64(x * 2.0))
	tmp = 0.0
	if (x <= 1.05e-25)
		tmp = Float64(Float64(1.0 / Float64(c * Float64(x * s))) * Float64(Float64(1.0 / c) * Float64(1.0 / Float64(x * s))));
	elseif (x <= 1.35e+154)
		tmp = Float64(Float64(t_0 / Float64(c * s)) / Float64(s * Float64(c * Float64(x * x))));
	else
		tmp = Float64(t_0 / Float64(x * Float64(Float64(s * s) * Float64(c * Float64(x * c)))));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	t_0 = cos((x * 2.0));
	tmp = 0.0;
	if (x <= 1.05e-25)
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * (1.0 / (x * s)));
	elseif (x <= 1.35e+154)
		tmp = (t_0 / (c * s)) / (s * (c * (x * x)));
	else
		tmp = t_0 / (x * ((s * s) * (c * (x * c))));
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := Block[{t$95$0 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1.05e-25], N[(N[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] * N[(1.0 / N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.35e+154], N[(N[(t$95$0 / N[(c * s), $MachinePrecision]), $MachinePrecision] / N[(s * N[(c * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(x * N[(N[(s * s), $MachinePrecision] * N[(c * N[(x * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;x \leq 1.05 \cdot 10^{-25}:\\
\;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \left(\frac{1}{c} \cdot \frac{1}{x \cdot s}\right)\\

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

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


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

    1. Initial program 65.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(c \cdot c\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      11. associate-*r*65.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)}} \]
      12. unpow265.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. Simplified65.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.05000000000000001e-25 < x < 1.35000000000000003e154

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.35000000000000003e154 < x

    1. Initial program 57.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 77.5% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 3.1 \cdot 10^{-5}:\\ \;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \left(\frac{1}{c} \cdot \left(-2 \cdot \frac{x}{s} + \frac{1}{x \cdot s}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(x \cdot \left(c \cdot \left(c \cdot \left(s \cdot s\right)\right)\right)\right)}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (if (<= x 3.1e-5)
   (* (/ 1.0 (* c (* x s))) (* (/ 1.0 c) (+ (* -2.0 (/ x s)) (/ 1.0 (* x s)))))
   (/ (cos (* x 2.0)) (* x (* x (* c (* c (* s s))))))))
double code(double x, double c, double s) {
	double tmp;
	if (x <= 3.1e-5) {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * ((-2.0 * (x / s)) + (1.0 / (x * s))));
	} else {
		tmp = cos((x * 2.0)) / (x * (x * (c * (c * (s * s)))));
	}
	return tmp;
}
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: tmp
    if (x <= 3.1d-5) then
        tmp = (1.0d0 / (c * (x * s))) * ((1.0d0 / c) * (((-2.0d0) * (x / s)) + (1.0d0 / (x * s))))
    else
        tmp = cos((x * 2.0d0)) / (x * (x * (c * (c * (s * s)))))
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double tmp;
	if (x <= 3.1e-5) {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * ((-2.0 * (x / s)) + (1.0 / (x * s))));
	} else {
		tmp = Math.cos((x * 2.0)) / (x * (x * (c * (c * (s * s)))));
	}
	return tmp;
}
def code(x, c, s):
	tmp = 0
	if x <= 3.1e-5:
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * ((-2.0 * (x / s)) + (1.0 / (x * s))))
	else:
		tmp = math.cos((x * 2.0)) / (x * (x * (c * (c * (s * s)))))
	return tmp
function code(x, c, s)
	tmp = 0.0
	if (x <= 3.1e-5)
		tmp = Float64(Float64(1.0 / Float64(c * Float64(x * s))) * Float64(Float64(1.0 / c) * Float64(Float64(-2.0 * Float64(x / s)) + Float64(1.0 / Float64(x * s)))));
	else
		tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(x * Float64(c * Float64(c * Float64(s * s))))));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (x <= 3.1e-5)
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * ((-2.0 * (x / s)) + (1.0 / (x * s))));
	else
		tmp = cos((x * 2.0)) / (x * (x * (c * (c * (s * s)))));
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := If[LessEqual[x, 3.1e-5], N[(N[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] * N[(N[(-2.0 * N[(x / s), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(x * N[(c * N[(c * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.1 \cdot 10^{-5}:\\
\;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \left(\frac{1}{c} \cdot \left(-2 \cdot \frac{x}{s} + \frac{1}{x \cdot s}\right)\right)\\

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


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

    1. Initial program 66.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.10000000000000014e-5 < x

    1. Initial program 70.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 79.9% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 6.8 \cdot 10^{-6}:\\ \;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \left(\frac{1}{c} \cdot \left(-2 \cdot \frac{x}{s} + \frac{1}{x \cdot s}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(c \cdot s\right)\right)\right)\right)}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (if (<= x 6.8e-6)
   (* (/ 1.0 (* c (* x s))) (* (/ 1.0 c) (+ (* -2.0 (/ x s)) (/ 1.0 (* x s)))))
   (/ (cos (* x 2.0)) (* x (* x (* c (* s (* c s))))))))
double code(double x, double c, double s) {
	double tmp;
	if (x <= 6.8e-6) {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * ((-2.0 * (x / s)) + (1.0 / (x * s))));
	} else {
		tmp = cos((x * 2.0)) / (x * (x * (c * (s * (c * s)))));
	}
	return tmp;
}
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 <= 6.8d-6) then
        tmp = (1.0d0 / (c * (x * s))) * ((1.0d0 / c) * (((-2.0d0) * (x / s)) + (1.0d0 / (x * s))))
    else
        tmp = cos((x * 2.0d0)) / (x * (x * (c * (s * (c * s)))))
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double tmp;
	if (x <= 6.8e-6) {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * ((-2.0 * (x / s)) + (1.0 / (x * s))));
	} else {
		tmp = Math.cos((x * 2.0)) / (x * (x * (c * (s * (c * s)))));
	}
	return tmp;
}
def code(x, c, s):
	tmp = 0
	if x <= 6.8e-6:
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * ((-2.0 * (x / s)) + (1.0 / (x * s))))
	else:
		tmp = math.cos((x * 2.0)) / (x * (x * (c * (s * (c * s)))))
	return tmp
function code(x, c, s)
	tmp = 0.0
	if (x <= 6.8e-6)
		tmp = Float64(Float64(1.0 / Float64(c * Float64(x * s))) * Float64(Float64(1.0 / c) * Float64(Float64(-2.0 * Float64(x / s)) + Float64(1.0 / Float64(x * s)))));
	else
		tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(x * Float64(c * Float64(s * Float64(c * s))))));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (x <= 6.8e-6)
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * ((-2.0 * (x / s)) + (1.0 / (x * s))));
	else
		tmp = cos((x * 2.0)) / (x * (x * (c * (s * (c * s)))));
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := If[LessEqual[x, 6.8e-6], N[(N[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] * N[(N[(-2.0 * N[(x / s), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(x * N[(c * N[(s * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.8 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \left(\frac{1}{c} \cdot \left(-2 \cdot \frac{x}{s} + \frac{1}{x \cdot s}\right)\right)\\

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


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

    1. Initial program 66.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.80000000000000012e-6 < x

    1. Initial program 70.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 97.3% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{1}{t_0} \cdot \frac{\cos \left(x \cdot 2\right)}{t_0}
\end{array}
\end{array}
Derivation
  1. Initial program 67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 64.9% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;s \leq 2.6 \cdot 10^{-177}:\\ \;\;\;\;\frac{1}{c} \cdot \frac{\frac{1}{c \cdot \left(x \cdot x\right)} - \frac{2}{c}}{s \cdot s}\\ \mathbf{else}:\\ \;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (if (<= s 2.6e-177)
   (* (/ 1.0 c) (/ (- (/ 1.0 (* c (* x x))) (/ 2.0 c)) (* s s)))
   (pow (* c (* x s)) -2.0)))
double code(double x, double c, double s) {
	double tmp;
	if (s <= 2.6e-177) {
		tmp = (1.0 / c) * (((1.0 / (c * (x * x))) - (2.0 / c)) / (s * s));
	} else {
		tmp = pow((c * (x * s)), -2.0);
	}
	return tmp;
}
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 <= 2.6d-177) then
        tmp = (1.0d0 / c) * (((1.0d0 / (c * (x * x))) - (2.0d0 / c)) / (s * s))
    else
        tmp = (c * (x * s)) ** (-2.0d0)
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double tmp;
	if (s <= 2.6e-177) {
		tmp = (1.0 / c) * (((1.0 / (c * (x * x))) - (2.0 / c)) / (s * s));
	} else {
		tmp = Math.pow((c * (x * s)), -2.0);
	}
	return tmp;
}
def code(x, c, s):
	tmp = 0
	if s <= 2.6e-177:
		tmp = (1.0 / c) * (((1.0 / (c * (x * x))) - (2.0 / c)) / (s * s))
	else:
		tmp = math.pow((c * (x * s)), -2.0)
	return tmp
function code(x, c, s)
	tmp = 0.0
	if (s <= 2.6e-177)
		tmp = Float64(Float64(1.0 / c) * Float64(Float64(Float64(1.0 / Float64(c * Float64(x * x))) - Float64(2.0 / c)) / Float64(s * s)));
	else
		tmp = Float64(c * Float64(x * s)) ^ -2.0;
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (s <= 2.6e-177)
		tmp = (1.0 / c) * (((1.0 / (c * (x * x))) - (2.0 / c)) / (s * s));
	else
		tmp = (c * (x * s)) ^ -2.0;
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := If[LessEqual[s, 2.6e-177], N[(N[(1.0 / c), $MachinePrecision] * N[(N[(N[(1.0 / N[(c * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(2.0 / c), $MachinePrecision]), $MachinePrecision] / N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;s \leq 2.6 \cdot 10^{-177}:\\
\;\;\;\;\frac{1}{c} \cdot \frac{\frac{1}{c \cdot \left(x \cdot x\right)} - \frac{2}{c}}{s \cdot s}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if s < 2.6000000000000001e-177

    1. Initial program 64.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(c \cdot c\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      11. associate-*r*64.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)}} \]
      12. unpow264.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. Simplified64.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.6000000000000001e-177 < s

    1. Initial program 70.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{c \cdot c}}{{s}^{2} \cdot {x}^{2}}} \]
      3. unpow262.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}}^{\left(-2\right)} \]
      5. metadata-eval91.0%

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

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

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

Alternative 8: 65.0% accurate, 14.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;s \leq 1.8 \cdot 10^{-179}:\\ \;\;\;\;\frac{1}{c} \cdot \frac{\frac{1}{c \cdot \left(x \cdot x\right)} - \frac{2}{c}}{s \cdot s}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \left(\frac{1}{c} \cdot \frac{1}{x \cdot s}\right)\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (if (<= s 1.8e-179)
   (* (/ 1.0 c) (/ (- (/ 1.0 (* c (* x x))) (/ 2.0 c)) (* s s)))
   (* (/ 1.0 (* c (* x s))) (* (/ 1.0 c) (/ 1.0 (* x s))))))
double code(double x, double c, double s) {
	double tmp;
	if (s <= 1.8e-179) {
		tmp = (1.0 / c) * (((1.0 / (c * (x * x))) - (2.0 / c)) / (s * s));
	} else {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * (1.0 / (x * s)));
	}
	return tmp;
}
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.8d-179) then
        tmp = (1.0d0 / c) * (((1.0d0 / (c * (x * x))) - (2.0d0 / c)) / (s * s))
    else
        tmp = (1.0d0 / (c * (x * s))) * ((1.0d0 / c) * (1.0d0 / (x * s)))
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double tmp;
	if (s <= 1.8e-179) {
		tmp = (1.0 / c) * (((1.0 / (c * (x * x))) - (2.0 / c)) / (s * s));
	} else {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * (1.0 / (x * s)));
	}
	return tmp;
}
def code(x, c, s):
	tmp = 0
	if s <= 1.8e-179:
		tmp = (1.0 / c) * (((1.0 / (c * (x * x))) - (2.0 / c)) / (s * s))
	else:
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * (1.0 / (x * s)))
	return tmp
function code(x, c, s)
	tmp = 0.0
	if (s <= 1.8e-179)
		tmp = Float64(Float64(1.0 / c) * Float64(Float64(Float64(1.0 / Float64(c * Float64(x * x))) - Float64(2.0 / c)) / Float64(s * s)));
	else
		tmp = Float64(Float64(1.0 / Float64(c * Float64(x * s))) * Float64(Float64(1.0 / c) * Float64(1.0 / Float64(x * s))));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (s <= 1.8e-179)
		tmp = (1.0 / c) * (((1.0 / (c * (x * x))) - (2.0 / c)) / (s * s));
	else
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * (1.0 / (x * s)));
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := If[LessEqual[s, 1.8e-179], N[(N[(1.0 / c), $MachinePrecision] * N[(N[(N[(1.0 / N[(c * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(2.0 / c), $MachinePrecision]), $MachinePrecision] / N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] * N[(1.0 / N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;s \leq 1.8 \cdot 10^{-179}:\\
\;\;\;\;\frac{1}{c} \cdot \frac{\frac{1}{c \cdot \left(x \cdot x\right)} - \frac{2}{c}}{s \cdot s}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if s < 1.80000000000000004e-179

    1. Initial program 64.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(c \cdot c\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot {s}^{2}\right)} \]
      11. associate-*r*64.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)}} \]
      12. unpow264.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. Simplified64.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.80000000000000004e-179 < s

    1. Initial program 70.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 78.7% accurate, 18.4× speedup?

\[\begin{array}{l} \\ \frac{1}{c \cdot \left(x \cdot s\right)} \cdot \left(\frac{1}{c} \cdot \frac{1}{x \cdot s}\right) \end{array} \]
(FPCore (x c s)
 :precision binary64
 (* (/ 1.0 (* c (* x s))) (* (/ 1.0 c) (/ 1.0 (* x s)))))
double code(double x, double c, double s) {
	return (1.0 / (c * (x * s))) * ((1.0 / c) * (1.0 / (x * s)));
}
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = (1.0d0 / (c * (x * s))) * ((1.0d0 / c) * (1.0d0 / (x * s)))
end function
public static double code(double x, double c, double s) {
	return (1.0 / (c * (x * s))) * ((1.0 / c) * (1.0 / (x * s)));
}
def code(x, c, s):
	return (1.0 / (c * (x * s))) * ((1.0 / c) * (1.0 / (x * s)))
function code(x, c, s)
	return Float64(Float64(1.0 / Float64(c * Float64(x * s))) * Float64(Float64(1.0 / c) * Float64(1.0 / Float64(x * s))))
end
function tmp = code(x, c, s)
	tmp = (1.0 / (c * (x * s))) * ((1.0 / c) * (1.0 / (x * s)));
end
code[x_, c_, s_] := N[(N[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] * N[(1.0 / N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \left(\frac{1}{c} \cdot \frac{1}{x \cdot s}\right)
\end{array}
Derivation
  1. Initial program 67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 78.8% accurate, 20.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{c \cdot \left(x \cdot s\right)}\\ t_0 \cdot t_0 \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (/ 1.0 (* c (* x s))))) (* t_0 t_0)))
double code(double x, double c, double s) {
	double t_0 = 1.0 / (c * (x * s));
	return t_0 * t_0;
}
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
public static double code(double x, double c, double s) {
	double t_0 = 1.0 / (c * (x * s));
	return t_0 * t_0;
}
def code(x, c, s):
	t_0 = 1.0 / (c * (x * s))
	return t_0 * t_0
function code(x, c, s)
	t_0 = Float64(1.0 / Float64(c * Float64(x * s)))
	return Float64(t_0 * t_0)
end
function tmp = code(x, c, s)
	t_0 = 1.0 / (c * (x * s));
	tmp = t_0 * t_0;
end
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}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 64.4% accurate, 24.1× speedup?

\[\begin{array}{l} \\ \frac{1}{x \cdot \left(x \cdot \left(c \cdot \left(c \cdot \left(s \cdot s\right)\right)\right)\right)} \end{array} \]
(FPCore (x c s) :precision binary64 (/ 1.0 (* x (* x (* c (* c (* s s)))))))
double code(double x, double c, double s) {
	return 1.0 / (x * (x * (c * (c * (s * s)))));
}
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 * (x * (c * (c * (s * s)))))
end function
public static double code(double x, double c, double s) {
	return 1.0 / (x * (x * (c * (c * (s * s)))));
}
def code(x, c, s):
	return 1.0 / (x * (x * (c * (c * (s * s)))))
function code(x, c, s)
	return Float64(1.0 / Float64(x * Float64(x * Float64(c * Float64(c * Float64(s * s))))))
end
function tmp = code(x, c, s)
	tmp = 1.0 / (x * (x * (c * (c * (s * s)))));
end
code[x_, c_, s_] := N[(1.0 / N[(x * N[(x * N[(c * N[(c * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{x \cdot \left(x \cdot \left(c \cdot \left(c \cdot \left(s \cdot s\right)\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 70.8% accurate, 24.1× speedup?

\[\begin{array}{l} \\ \frac{1}{x \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(c \cdot s\right)\right)\right)\right)} \end{array} \]
(FPCore (x c s) :precision binary64 (/ 1.0 (* x (* x (* c (* s (* c s)))))))
double code(double x, double c, double s) {
	return 1.0 / (x * (x * (c * (s * (c * s)))));
}
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 * (x * (c * (s * (c * s)))))
end function
public static double code(double x, double c, double s) {
	return 1.0 / (x * (x * (c * (s * (c * s)))));
}
def code(x, c, s):
	return 1.0 / (x * (x * (c * (s * (c * s)))))
function code(x, c, s)
	return Float64(1.0 / Float64(x * Float64(x * Float64(c * Float64(s * Float64(c * s))))))
end
function tmp = code(x, c, s)
	tmp = 1.0 / (x * (x * (c * (s * (c * s)))));
end
code[x_, c_, s_] := N[(1.0 / N[(x * N[(x * N[(c * N[(s * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{x \cdot \left(x \cdot \left(c \cdot \left(s \cdot \left(c \cdot s\right)\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 78.7% accurate, 24.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ \frac{1}{t_0 \cdot t_0} \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* c (* x s)))) (/ 1.0 (* t_0 t_0))))
double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	return 1.0 / (t_0 * t_0);
}
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: t_0
    t_0 = c * (x * s)
    code = 1.0d0 / (t_0 * t_0)
end function
public static double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	return 1.0 / (t_0 * t_0);
}
def code(x, c, s):
	t_0 = c * (x * s)
	return 1.0 / (t_0 * t_0)
function code(x, c, s)
	t_0 = Float64(c * Float64(x * s))
	return Float64(1.0 / Float64(t_0 * t_0))
end
function tmp = code(x, c, s)
	t_0 = c * (x * s);
	tmp = 1.0 / (t_0 * t_0);
end
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{1}{t_0 \cdot t_0}
\end{array}
\end{array}
Derivation
  1. Initial program 67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 27.9% accurate, 28.5× speedup?

\[\begin{array}{l} \\ \frac{1}{c} \cdot \frac{\frac{-2}{c}}{s \cdot s} \end{array} \]
(FPCore (x c s) :precision binary64 (* (/ 1.0 c) (/ (/ -2.0 c) (* s s))))
double code(double x, double c, double s) {
	return (1.0 / c) * ((-2.0 / c) / (s * s));
}
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = (1.0d0 / c) * (((-2.0d0) / c) / (s * s))
end function
public static double code(double x, double c, double s) {
	return (1.0 / c) * ((-2.0 / c) / (s * s));
}
def code(x, c, s):
	return (1.0 / c) * ((-2.0 / c) / (s * s))
function code(x, c, s)
	return Float64(Float64(1.0 / c) * Float64(Float64(-2.0 / c) / Float64(s * s)))
end
function tmp = code(x, c, s)
	tmp = (1.0 / c) * ((-2.0 / c) / (s * s));
end
code[x_, c_, s_] := N[(N[(1.0 / c), $MachinePrecision] * N[(N[(-2.0 / c), $MachinePrecision] / N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{c} \cdot \frac{\frac{-2}{c}}{s \cdot s}
\end{array}
Derivation
  1. Initial program 67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{1}{c} \cdot \color{blue}{\frac{-2}{c \cdot {s}^{2}}} \]
  10. Step-by-step derivation
    1. associate-/r*28.0%

      \[\leadsto \frac{1}{c} \cdot \color{blue}{\frac{\frac{-2}{c}}{{s}^{2}}} \]
    2. unpow228.0%

      \[\leadsto \frac{1}{c} \cdot \frac{\frac{-2}{c}}{\color{blue}{s \cdot s}} \]
  11. Simplified28.0%

    \[\leadsto \frac{1}{c} \cdot \color{blue}{\frac{\frac{-2}{c}}{s \cdot s}} \]
  12. Final simplification28.0%

    \[\leadsto \frac{1}{c} \cdot \frac{\frac{-2}{c}}{s \cdot s} \]

Alternative 15: 27.7% accurate, 34.8× speedup?

\[\begin{array}{l} \\ \frac{\frac{-2}{s \cdot s}}{c \cdot c} \end{array} \]
(FPCore (x c s) :precision binary64 (/ (/ -2.0 (* s s)) (* c c)))
double code(double x, double c, double s) {
	return (-2.0 / (s * s)) / (c * c);
}
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) / (s * s)) / (c * c)
end function
public static double code(double x, double c, double s) {
	return (-2.0 / (s * s)) / (c * c);
}
def code(x, c, s):
	return (-2.0 / (s * s)) / (c * c)
function code(x, c, s)
	return Float64(Float64(-2.0 / Float64(s * s)) / Float64(c * c))
end
function tmp = code(x, c, s)
	tmp = (-2.0 / (s * s)) / (c * c);
end
code[x_, c_, s_] := N[(N[(-2.0 / N[(s * s), $MachinePrecision]), $MachinePrecision] / N[(c * c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{-2}{s \cdot s}}{c \cdot c}
\end{array}
Derivation
  1. Initial program 67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{-2}{{s}^{2} \cdot {c}^{2}}} \]
  10. Step-by-step derivation
    1. associate-/r*28.4%

      \[\leadsto \color{blue}{\frac{\frac{-2}{{s}^{2}}}{{c}^{2}}} \]
    2. unpow228.4%

      \[\leadsto \frac{\frac{-2}{\color{blue}{s \cdot s}}}{{c}^{2}} \]
    3. unpow228.4%

      \[\leadsto \frac{\frac{-2}{s \cdot s}}{\color{blue}{c \cdot c}} \]
  11. Simplified28.4%

    \[\leadsto \color{blue}{\frac{\frac{-2}{s \cdot s}}{c \cdot c}} \]
  12. Final simplification28.4%

    \[\leadsto \frac{\frac{-2}{s \cdot s}}{c \cdot c} \]

Reproduce

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