mixedcos

Percentage Accurate: 66.4% → 98.9%
Time: 11.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: 66.4% 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: 98.9% accurate, 1.0× speedup?

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

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


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

    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*56.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*56.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{{s}^{-0.5}}{c}}{x \cdot \sqrt{s}} \cdot \frac{\frac{{s}^{-0.5}}{c}}{x \cdot \sqrt{s}}} \]
    10. Step-by-step derivation
      1. unpow244.5%

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

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

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

    if 3.4999999999999997e-51 < x

    1. Initial program 77.5%

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

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

        \[\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*72.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. *-commutative72.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. unpow272.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*79.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*78.6%

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

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

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

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

        \[\leadsto \frac{\color{blue}{1 \cdot \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-frac78.7%

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

        \[\leadsto \frac{1}{s} \cdot \frac{\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.8%

        \[\leadsto \frac{1}{s} \cdot \frac{\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*95.2%

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

        \[\leadsto \frac{1}{s} \cdot \frac{\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-frac95.2%

        \[\leadsto \color{blue}{\frac{1 \cdot \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.1%

        \[\leadsto \frac{1 \cdot \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. *-un-lft-identity96.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. div-inv96.0%

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

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

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

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

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

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

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

Alternative 2: 85.3% accurate, 2.6× speedup?

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

\mathbf{elif}\;x \leq 4.6 \cdot 10^{+139}:\\
\;\;\;\;\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}:\\
\;\;\;\;\frac{1}{t_1 \cdot t_1}\\


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

    1. Initial program 64.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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)}} \]
    5. Taylor expanded in s around 0 95.4%

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

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

    if 9.19999999999999961e-15 < x < 4.6e139

    1. Initial program 81.7%

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left({s}^{2} \cdot \left(x \cdot x\right)\right)}} \]
      3. associate-*r*85.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. *-commutative85.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. unpow285.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*95.0%

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(x \cdot x\right) \cdot \color{blue}{\left(\left({c}^{2} \cdot s\right) \cdot s\right)}} \]
      7. associate-*r*91.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. *-commutative91.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. unpow291.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. Simplified91.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)}} \]

    if 4.6e139 < x

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 9.2 \cdot 10^{-15}:\\ \;\;\;\;\frac{1}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{+139}:\\ \;\;\;\;\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}:\\ \;\;\;\;\frac{1}{\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}\\ \end{array} \]

Alternative 3: 97.5% accurate, 2.6× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{t_0}{s} \cdot \frac{\frac{\frac{1}{s}}{x \cdot c}}{x \cdot c}\\


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

    1. Initial program 65.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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)}} \]
    5. Taylor expanded in s around 0 95.5%

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

    if 2.20000000000000008e23 < x

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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)}} \]
    5. Step-by-step derivation
      1. associate-/r*95.4%

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 82.6% accurate, 2.7× speedup?

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

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


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

    1. Initial program 67.7%

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

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

        \[\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*71.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. unpow271.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. unpow271.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. Simplified71.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)}} \]

    if 1.55e99 < s

    1. Initial program 70.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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)}} \]
    5. Taylor expanded in s around 0 89.6%

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

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

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

Alternative 5: 98.1% accurate, 2.7× speedup?

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

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


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

    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 \color{blue}{\left(x \cdot \left(x \cdot {s}^{2}\right)\right)}} \]
      2. associate-*r*60.8%

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

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

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

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

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

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

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

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

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

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

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

      \[\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)}} \]
    5. Taylor expanded in s around 0 95.6%

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

    if 1.09999999999999998e44 < x

    1. Initial program 72.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. *-commutative72.3%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.1 \cdot 10^{+44}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}\\ \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 6: 97.5% accurate, 2.7× speedup?

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

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


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

    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 \color{blue}{\left(x \cdot \left(x \cdot {s}^{2}\right)\right)}} \]
      2. associate-*r*60.8%

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

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

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

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

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

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

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

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

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

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

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

      \[\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)}} \]
    5. Taylor expanded in s around 0 95.6%

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

    if 4.00000000000000006e43 < x

    1. Initial program 72.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. *-commutative72.3%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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)}} \]
    5. Step-by-step derivation
      1. associate-/r*95.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 96.9% accurate, 2.7× speedup?

\[\begin{array}{l} x = |x|\\ c = |c|\\ [c, s] = \mathsf{sort}([c, s])\\ \\ \begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ \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: 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)))) (/ (cos (* x 2.0)) (* t_0 t_0))))
x = abs(x);
c = abs(c);
assert(c < s);
double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	return cos((x * 2.0)) / (t_0 * t_0);
}
NOTE: x should be positive before calling this function
NOTE: c should be positive before calling this function
NOTE: c and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: t_0
    t_0 = c * (x * s)
    code = cos((x * 2.0d0)) / (t_0 * t_0)
end function
x = Math.abs(x);
c = Math.abs(c);
assert c < s;
public static double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	return Math.cos((x * 2.0)) / (t_0 * t_0);
}
x = abs(x)
c = abs(c)
[c, s] = sort([c, s])
def code(x, c, s):
	t_0 = c * (x * s)
	return math.cos((x * 2.0)) / (t_0 * t_0)
x = abs(x)
c = abs(c)
c, s = sort([c, s])
function code(x, c, s)
	t_0 = Float64(c * Float64(x * s))
	return Float64(cos(Float64(x * 2.0)) / Float64(t_0 * t_0))
end
x = abs(x)
c = abs(c)
c, s = num2cell(sort([c, s])){:}
function tmp = code(x, c, s)
	t_0 = c * (x * s);
	tmp = cos((x * 2.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: 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]}, 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|\\
[c, s] = \mathsf{sort}([c, s])\\
\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{\cos \left(x \cdot 2\right)}{t_0 \cdot t_0}
\end{array}
\end{array}
Derivation
  1. Initial program 68.2%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}} \]
  4. Taylor expanded in s around 0 93.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)}} \]
  5. Taylor expanded in s around 0 96.2%

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

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

Alternative 8: 62.2% accurate, 20.8× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < 2.9e12

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

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

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

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

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

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

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

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

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

    if 2.9e12 < c

    1. Initial program 64.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. associate-*r*63.1%

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

        \[\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*64.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. unpow264.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. unpow264.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. Simplified64.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 x around 0 62.9%

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

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

Alternative 9: 61.2% accurate, 24.1× speedup?

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

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

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

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

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

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(x \cdot x\right) \cdot \color{blue}{\left(\left({c}^{2} \cdot s\right) \cdot s\right)}} \]
    7. associate-*r*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. Taylor expanded in x around 0 62.7%

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

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

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

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

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

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

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

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

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

Alternative 10: 78.9% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(s \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot \left(x \cdot c\right)\right)}} \]
  4. Taylor expanded in s around 0 93.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)}} \]
  5. Taylor expanded in s around 0 96.2%

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

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

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

Alternative 11: 26.2% accurate, 34.8× speedup?

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

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

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

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

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

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

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

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

      \[\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.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 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*92.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(x \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot s\right)}} \]
    6. *-commutative92.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)}}{\left(x \cdot c\right) \cdot \color{blue}{\left(s \cdot \left(x \cdot c\right)\right)}} \]
    7. times-frac91.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*94.6%

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

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

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{s \cdot \left(x \cdot c\right)}}{s \cdot \left(x \cdot c\right)}} \]
  5. Applied egg-rr95.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. Taylor expanded in x around 0 65.4%

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

    \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
  8. Step-by-step derivation
    1. *-commutative31.5%

      \[\leadsto \frac{-2}{\color{blue}{{s}^{2} \cdot {c}^{2}}} \]
    2. unpow231.5%

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

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

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

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

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

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

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

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

Alternative 12: 27.8% accurate, 34.8× speedup?

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

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

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

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

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

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

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

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

      \[\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.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 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*92.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(x \cdot c\right) \cdot \left(\left(x \cdot c\right) \cdot s\right)}} \]
    6. *-commutative92.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)}}{\left(x \cdot c\right) \cdot \color{blue}{\left(s \cdot \left(x \cdot c\right)\right)}} \]
    7. times-frac91.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*94.6%

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

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

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{s \cdot \left(x \cdot c\right)}}{s \cdot \left(x \cdot c\right)}} \]
  5. Applied egg-rr95.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. Taylor expanded in x around 0 65.4%

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

    \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
  8. Step-by-step derivation
    1. associate-/l/31.5%

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

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

      \[\leadsto \frac{\frac{-2}{\color{blue}{s \cdot s}}}{c \cdot c} \]
  9. Simplified31.5%

    \[\leadsto \color{blue}{\frac{\frac{-2}{s \cdot s}}{c \cdot c}} \]
  10. Final simplification31.5%

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

Reproduce

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