mixedcos

Percentage Accurate: 67.2% → 99.5%
Time: 12.0s
Alternatives: 12
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 12 alternatives:

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

Initial Program: 67.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 2.7× speedup?

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

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


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

    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. *-commutative67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.30000000000000035e-50 < x

    1. Initial program 54.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. *-commutative54.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 94.7% accurate, 2.6× speedup?

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

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

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


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

    1. Initial program 67.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. *-commutative67.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.19999999999999999e-8 < x < 1.45000000000000005e150

    1. Initial program 48.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*51.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.45000000000000005e150 < x

    1. Initial program 57.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*60.2%

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 82.5% accurate, 2.7× speedup?

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

\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 < 4.94999999999999993e33

    1. Initial program 63.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. *-commutative63.1%

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

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

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

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

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

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

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

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

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

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

    if 4.94999999999999993e33 < s

    1. Initial program 66.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 93.0% accurate, 2.7× speedup?

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

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


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

    1. Initial program 67.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. *-commutative67.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.20000000000000039e-9 < x

    1. Initial program 52.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*55.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 97.0% accurate, 2.7× speedup?

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

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


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

    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. *-commutative67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.0199999999999999e-50 < x

    1. Initial program 54.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. *-commutative54.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 99.3% accurate, 2.7× speedup?

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

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


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

    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. *-commutative67.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.0999999999999999e-50 < x

    1. Initial program 54.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. *-commutative54.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 79.8% accurate, 3.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 78.6% accurate, 20.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 79.8% accurate, 20.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{c}}{x \cdot s} \cdot \frac{\frac{1}{c}}{\color{blue}{\sqrt{s \cdot x} \cdot \sqrt{s \cdot x}}} \]
    16. add-sqr-sqrt77.4%

      \[\leadsto \frac{\frac{1}{c}}{x \cdot s} \cdot \frac{\frac{1}{c}}{\color{blue}{s \cdot x}} \]
    17. *-commutative77.4%

      \[\leadsto \frac{\frac{1}{c}}{x \cdot s} \cdot \frac{\frac{1}{c}}{\color{blue}{x \cdot s}} \]
  13. Applied egg-rr77.4%

    \[\leadsto \color{blue}{\frac{\frac{1}{c}}{x \cdot s} \cdot \frac{\frac{1}{c}}{x \cdot s}} \]
  14. Final simplification77.4%

    \[\leadsto \frac{\frac{1}{c}}{x \cdot s} \cdot \frac{\frac{1}{c}}{x \cdot s} \]

Alternative 10: 77.7% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 77.9% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 78.0% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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