mixedcos

Percentage Accurate: 66.2% → 99.1%
Time: 8.9s
Alternatives: 10
Speedup: 9.0×

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 10 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.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.1% accurate, 0.6× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \begin{array}{l} t_0 := \cos \left(x \cdot 2\right)\\ t_1 := \left(s \cdot x\right) \cdot c\_m\\ \mathbf{if}\;\frac{t\_0}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c\_m}^{2}} \leq \infty:\\ \;\;\;\;\frac{\frac{\cos \left(x + x\right)}{t\_1}}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{{\left(\left(s \cdot c\_m\right) \cdot x\right)}^{2}}{t\_0}}\\ \end{array} \end{array} \]
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
 :precision binary64
 (let* ((t_0 (cos (* x 2.0))) (t_1 (* (* s x) c_m)))
   (if (<= (/ t_0 (* (* (* (pow s 2.0) x) x) (pow c_m 2.0))) INFINITY)
     (/ (/ (cos (+ x x)) t_1) t_1)
     (/ 1.0 (/ (pow (* (* s c_m) x) 2.0) t_0)))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
	double t_0 = cos((x * 2.0));
	double t_1 = (s * x) * c_m;
	double tmp;
	if ((t_0 / (((pow(s, 2.0) * x) * x) * pow(c_m, 2.0))) <= ((double) INFINITY)) {
		tmp = (cos((x + x)) / t_1) / t_1;
	} else {
		tmp = 1.0 / (pow(((s * c_m) * x), 2.0) / t_0);
	}
	return tmp;
}
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
	double t_0 = Math.cos((x * 2.0));
	double t_1 = (s * x) * c_m;
	double tmp;
	if ((t_0 / (((Math.pow(s, 2.0) * x) * x) * Math.pow(c_m, 2.0))) <= Double.POSITIVE_INFINITY) {
		tmp = (Math.cos((x + x)) / t_1) / t_1;
	} else {
		tmp = 1.0 / (Math.pow(((s * c_m) * x), 2.0) / t_0);
	}
	return tmp;
}
c_m = math.fabs(c)
[x, c_m, s] = sort([x, c_m, s])
def code(x, c_m, s):
	t_0 = math.cos((x * 2.0))
	t_1 = (s * x) * c_m
	tmp = 0
	if (t_0 / (((math.pow(s, 2.0) * x) * x) * math.pow(c_m, 2.0))) <= math.inf:
		tmp = (math.cos((x + x)) / t_1) / t_1
	else:
		tmp = 1.0 / (math.pow(((s * c_m) * x), 2.0) / t_0)
	return tmp
c_m = abs(c)
x, c_m, s = sort([x, c_m, s])
function code(x, c_m, s)
	t_0 = cos(Float64(x * 2.0))
	t_1 = Float64(Float64(s * x) * c_m)
	tmp = 0.0
	if (Float64(t_0 / Float64(Float64(Float64((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= Inf)
		tmp = Float64(Float64(cos(Float64(x + x)) / t_1) / t_1);
	else
		tmp = Float64(1.0 / Float64((Float64(Float64(s * c_m) * x) ^ 2.0) / t_0));
	end
	return tmp
end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp_2 = code(x, c_m, s)
	t_0 = cos((x * 2.0));
	t_1 = (s * x) * c_m;
	tmp = 0.0;
	if ((t_0 / ((((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= Inf)
		tmp = (cos((x + x)) / t_1) / t_1;
	else
		tmp = 1.0 / ((((s * c_m) * x) ^ 2.0) / t_0);
	end
	tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(s * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(N[(N[Power[s, 2.0], $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * N[Power[c$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision], N[(1.0 / N[(N[Power[N[(N[(s * c$95$m), $MachinePrecision] * x), $MachinePrecision], 2.0], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
t_1 := \left(s \cdot x\right) \cdot c\_m\\
\mathbf{if}\;\frac{t\_0}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c\_m}^{2}} \leq \infty:\\
\;\;\;\;\frac{\frac{\cos \left(x + x\right)}{t\_1}}{t\_1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < +inf.0

    1. Initial program 82.4%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      2. clear-numN/A

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

        \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{neg}\left({c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)\right)}{\mathsf{neg}\left(\cos \left(2 \cdot x\right)\right)}}} \]
      4. associate-/r/N/A

        \[\leadsto \color{blue}{\frac{1}{\mathsf{neg}\left({c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)\right)} \cdot \left(\mathsf{neg}\left(\cos \left(2 \cdot x\right)\right)\right)} \]
      5. lower-*.f64N/A

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

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

        \[\leadsto \color{blue}{\frac{-1}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}} \cdot \left(-\cos \left(x \cdot 2\right)\right)} \]
      2. lift-/.f64N/A

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(-\cos \left(x \cdot 2\right)\right)}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}}} \]
      4. lift-pow.f64N/A

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

        \[\leadsto \frac{-1 \cdot \left(-\cos \left(x \cdot 2\right)\right)}{\color{blue}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)}} \]
      6. mul-1-negN/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\left(-\cos \left(x \cdot 2\right)\right)\right)}}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)} \]
      7. lift-neg.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\cos \left(x \cdot 2\right)\right)\right)}\right)}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)} \]
      8. remove-double-negN/A

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

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(c \cdot s\right)}}{x \cdot \left(c \cdot s\right)}} \]
      10. lower-/.f64N/A

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

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

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(2 \cdot x\right)}}{\left(s \cdot x\right) \cdot c}}{\left(s \cdot x\right) \cdot c} \]
      2. count-2N/A

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{\left(s \cdot x\right) \cdot c}}{\left(s \cdot x\right) \cdot c} \]
      3. lower-+.f6499.7

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{\left(s \cdot x\right) \cdot c}}{\left(s \cdot x\right) \cdot c} \]
    8. Applied rewrites99.7%

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

    if +inf.0 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x)))

    1. Initial program 0.0%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      2. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}{\cos \left(2 \cdot x\right)}}} \]
      3. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}{\cos \left(2 \cdot x\right)}}} \]
      4. lower-/.f640.0

        \[\leadsto \frac{1}{\color{blue}{\frac{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}{\cos \left(2 \cdot x\right)}}} \]
      5. lift-*.f64N/A

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

        \[\leadsto \frac{1}{\frac{\color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right) \cdot {c}^{2}}}{\cos \left(2 \cdot x\right)}} \]
      7. lift-*.f64N/A

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

        \[\leadsto \frac{1}{\frac{\color{blue}{\left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \cdot {c}^{2}}{\cos \left(2 \cdot x\right)}} \]
      9. lift-*.f64N/A

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

        \[\leadsto \frac{1}{\frac{\color{blue}{\left(\left(x \cdot x\right) \cdot {s}^{2}\right)} \cdot {c}^{2}}{\cos \left(2 \cdot x\right)}} \]
      11. associate-*l*N/A

        \[\leadsto \frac{1}{\frac{\color{blue}{\left(x \cdot x\right) \cdot \left({s}^{2} \cdot {c}^{2}\right)}}{\cos \left(2 \cdot x\right)}} \]
      12. pow2N/A

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

        \[\leadsto \frac{1}{\frac{{x}^{2} \cdot \color{blue}{\left({c}^{2} \cdot {s}^{2}\right)}}{\cos \left(2 \cdot x\right)}} \]
      14. lift-pow.f64N/A

        \[\leadsto \frac{1}{\frac{{x}^{2} \cdot \left(\color{blue}{{c}^{2}} \cdot {s}^{2}\right)}{\cos \left(2 \cdot x\right)}} \]
      15. lift-pow.f64N/A

        \[\leadsto \frac{1}{\frac{{x}^{2} \cdot \left({c}^{2} \cdot \color{blue}{{s}^{2}}\right)}{\cos \left(2 \cdot x\right)}} \]
      16. pow-prod-downN/A

        \[\leadsto \frac{1}{\frac{{x}^{2} \cdot \color{blue}{{\left(c \cdot s\right)}^{2}}}{\cos \left(2 \cdot x\right)}} \]
      17. pow-prod-downN/A

        \[\leadsto \frac{1}{\frac{\color{blue}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}}}{\cos \left(2 \cdot x\right)}} \]
      18. lower-pow.f64N/A

        \[\leadsto \frac{1}{\frac{\color{blue}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}}}{\cos \left(2 \cdot x\right)}} \]
      19. lower-*.f64N/A

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

        \[\leadsto \frac{1}{\frac{{\left(x \cdot \color{blue}{\left(c \cdot s\right)}\right)}^{2}}{\cos \left(2 \cdot x\right)}} \]
      21. lift-*.f64N/A

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

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

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

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

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

Alternative 2: 99.1% accurate, 0.6× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \begin{array}{l} t_0 := \cos \left(x \cdot 2\right)\\ t_1 := \left(s \cdot x\right) \cdot c\_m\\ \mathbf{if}\;\frac{t\_0}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c\_m}^{2}} \leq \infty:\\ \;\;\;\;\frac{\frac{\cos \left(x + x\right)}{t\_1}}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_0}{{\left(\left(s \cdot c\_m\right) \cdot x\right)}^{2}}\\ \end{array} \end{array} \]
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
 :precision binary64
 (let* ((t_0 (cos (* x 2.0))) (t_1 (* (* s x) c_m)))
   (if (<= (/ t_0 (* (* (* (pow s 2.0) x) x) (pow c_m 2.0))) INFINITY)
     (/ (/ (cos (+ x x)) t_1) t_1)
     (/ t_0 (pow (* (* s c_m) x) 2.0)))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
	double t_0 = cos((x * 2.0));
	double t_1 = (s * x) * c_m;
	double tmp;
	if ((t_0 / (((pow(s, 2.0) * x) * x) * pow(c_m, 2.0))) <= ((double) INFINITY)) {
		tmp = (cos((x + x)) / t_1) / t_1;
	} else {
		tmp = t_0 / pow(((s * c_m) * x), 2.0);
	}
	return tmp;
}
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
	double t_0 = Math.cos((x * 2.0));
	double t_1 = (s * x) * c_m;
	double tmp;
	if ((t_0 / (((Math.pow(s, 2.0) * x) * x) * Math.pow(c_m, 2.0))) <= Double.POSITIVE_INFINITY) {
		tmp = (Math.cos((x + x)) / t_1) / t_1;
	} else {
		tmp = t_0 / Math.pow(((s * c_m) * x), 2.0);
	}
	return tmp;
}
c_m = math.fabs(c)
[x, c_m, s] = sort([x, c_m, s])
def code(x, c_m, s):
	t_0 = math.cos((x * 2.0))
	t_1 = (s * x) * c_m
	tmp = 0
	if (t_0 / (((math.pow(s, 2.0) * x) * x) * math.pow(c_m, 2.0))) <= math.inf:
		tmp = (math.cos((x + x)) / t_1) / t_1
	else:
		tmp = t_0 / math.pow(((s * c_m) * x), 2.0)
	return tmp
c_m = abs(c)
x, c_m, s = sort([x, c_m, s])
function code(x, c_m, s)
	t_0 = cos(Float64(x * 2.0))
	t_1 = Float64(Float64(s * x) * c_m)
	tmp = 0.0
	if (Float64(t_0 / Float64(Float64(Float64((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= Inf)
		tmp = Float64(Float64(cos(Float64(x + x)) / t_1) / t_1);
	else
		tmp = Float64(t_0 / (Float64(Float64(s * c_m) * x) ^ 2.0));
	end
	return tmp
end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp_2 = code(x, c_m, s)
	t_0 = cos((x * 2.0));
	t_1 = (s * x) * c_m;
	tmp = 0.0;
	if ((t_0 / ((((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= Inf)
		tmp = (cos((x + x)) / t_1) / t_1;
	else
		tmp = t_0 / (((s * c_m) * x) ^ 2.0);
	end
	tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(s * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(N[(N[Power[s, 2.0], $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * N[Power[c$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision], N[(t$95$0 / N[Power[N[(N[(s * c$95$m), $MachinePrecision] * x), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(x \cdot 2\right)\\
t_1 := \left(s \cdot x\right) \cdot c\_m\\
\mathbf{if}\;\frac{t\_0}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c\_m}^{2}} \leq \infty:\\
\;\;\;\;\frac{\frac{\cos \left(x + x\right)}{t\_1}}{t\_1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < +inf.0

    1. Initial program 82.4%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      2. clear-numN/A

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

        \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{neg}\left({c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)\right)}{\mathsf{neg}\left(\cos \left(2 \cdot x\right)\right)}}} \]
      4. associate-/r/N/A

        \[\leadsto \color{blue}{\frac{1}{\mathsf{neg}\left({c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)\right)} \cdot \left(\mathsf{neg}\left(\cos \left(2 \cdot x\right)\right)\right)} \]
      5. lower-*.f64N/A

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

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

        \[\leadsto \color{blue}{\frac{-1}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}} \cdot \left(-\cos \left(x \cdot 2\right)\right)} \]
      2. lift-/.f64N/A

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \left(-\cos \left(x \cdot 2\right)\right)}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}}} \]
      4. lift-pow.f64N/A

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

        \[\leadsto \frac{-1 \cdot \left(-\cos \left(x \cdot 2\right)\right)}{\color{blue}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)}} \]
      6. mul-1-negN/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\left(-\cos \left(x \cdot 2\right)\right)\right)}}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)} \]
      7. lift-neg.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\cos \left(x \cdot 2\right)\right)\right)}\right)}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)} \]
      8. remove-double-negN/A

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

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(c \cdot s\right)}}{x \cdot \left(c \cdot s\right)}} \]
      10. lower-/.f64N/A

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

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

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(2 \cdot x\right)}}{\left(s \cdot x\right) \cdot c}}{\left(s \cdot x\right) \cdot c} \]
      2. count-2N/A

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{\left(s \cdot x\right) \cdot c}}{\left(s \cdot x\right) \cdot c} \]
      3. lower-+.f6499.7

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{\left(s \cdot x\right) \cdot c}}{\left(s \cdot x\right) \cdot c} \]
    8. Applied rewrites99.7%

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

    if +inf.0 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x)))

    1. Initial program 0.0%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\cos \left(x \cdot 2\right)}{\color{blue}{\left(x \cdot x\right) \cdot \left({s}^{2} \cdot {c}^{2}\right)}} \]
      11. pow2N/A

        \[\leadsto \frac{\cos \left(x \cdot 2\right)}{\color{blue}{{x}^{2}} \cdot \left({s}^{2} \cdot {c}^{2}\right)} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\cos \left(x \cdot 2\right)}{{x}^{2} \cdot \color{blue}{\left({c}^{2} \cdot {s}^{2}\right)}} \]
      13. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(x \cdot 2\right)}{{x}^{2} \cdot \left(\color{blue}{{c}^{2}} \cdot {s}^{2}\right)} \]
      14. lift-pow.f64N/A

        \[\leadsto \frac{\cos \left(x \cdot 2\right)}{{x}^{2} \cdot \left({c}^{2} \cdot \color{blue}{{s}^{2}}\right)} \]
      15. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(x \cdot 2\right)}{{x}^{2} \cdot \color{blue}{{\left(c \cdot s\right)}^{2}}} \]
      16. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(x \cdot 2\right)}{\color{blue}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}}} \]
      17. lower-pow.f64N/A

        \[\leadsto \frac{\cos \left(x \cdot 2\right)}{\color{blue}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}}} \]
      18. lower-*.f64N/A

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\cos \left(x \cdot 2\right)}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c}^{2}} \leq \infty:\\ \;\;\;\;\frac{\frac{\cos \left(x + x\right)}{\left(s \cdot x\right) \cdot c}}{\left(s \cdot x\right) \cdot c}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{{\left(\left(s \cdot c\right) \cdot x\right)}^{2}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 82.0% accurate, 0.9× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{t\_0}}{t\_0}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < -1.9999999999999999e-69

    1. Initial program 51.5%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      2. clear-numN/A

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

        \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{neg}\left({c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)\right)}{\mathsf{neg}\left(\cos \left(2 \cdot x\right)\right)}}} \]
      4. associate-/r/N/A

        \[\leadsto \color{blue}{\frac{1}{\mathsf{neg}\left({c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)\right)} \cdot \left(\mathsf{neg}\left(\cos \left(2 \cdot x\right)\right)\right)} \]
      5. lower-*.f64N/A

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

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

      \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    6. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    7. Applied rewrites19.9%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-2, x \cdot x, 1\right) \cdot \frac{\frac{1}{s \cdot c}}{s \cdot c}}{x \cdot x}} \]
    8. Taylor expanded in x around inf

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

        \[\leadsto \frac{\frac{\frac{\frac{-2}{s}}{s}}{c}}{\color{blue}{c}} \]

      if -1.9999999999999999e-69 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x)))

      1. Initial program 67.1%

        \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
        2. clear-numN/A

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

          \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{neg}\left({c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)\right)}{\mathsf{neg}\left(\cos \left(2 \cdot x\right)\right)}}} \]
        4. associate-/r/N/A

          \[\leadsto \color{blue}{\frac{1}{\mathsf{neg}\left({c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)\right)} \cdot \left(\mathsf{neg}\left(\cos \left(2 \cdot x\right)\right)\right)} \]
        5. lower-*.f64N/A

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

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

          \[\leadsto \color{blue}{\frac{-1}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}} \cdot \left(-\cos \left(x \cdot 2\right)\right)} \]
        2. lift-/.f64N/A

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

          \[\leadsto \color{blue}{\frac{-1 \cdot \left(-\cos \left(x \cdot 2\right)\right)}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}}} \]
        4. lift-pow.f64N/A

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

          \[\leadsto \frac{-1 \cdot \left(-\cos \left(x \cdot 2\right)\right)}{\color{blue}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)}} \]
        6. mul-1-negN/A

          \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\left(-\cos \left(x \cdot 2\right)\right)\right)}}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)} \]
        7. lift-neg.f64N/A

          \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\cos \left(x \cdot 2\right)\right)\right)}\right)}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)} \]
        8. remove-double-negN/A

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

          \[\leadsto \color{blue}{\frac{\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(c \cdot s\right)}}{x \cdot \left(c \cdot s\right)}} \]
        10. lower-/.f64N/A

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

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

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

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

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

      Alternative 4: 83.1% accurate, 2.2× speedup?

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

        1. Initial program 62.6%

          \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. lift-/.f64N/A

            \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
          2. clear-numN/A

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

            \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{neg}\left({c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)\right)}{\mathsf{neg}\left(\cos \left(2 \cdot x\right)\right)}}} \]
          4. associate-/r/N/A

            \[\leadsto \color{blue}{\frac{1}{\mathsf{neg}\left({c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)\right)} \cdot \left(\mathsf{neg}\left(\cos \left(2 \cdot x\right)\right)\right)} \]
          5. lower-*.f64N/A

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

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

            \[\leadsto \color{blue}{\frac{-1}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}} \cdot \left(-\cos \left(x \cdot 2\right)\right)} \]
          2. lift-/.f64N/A

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

            \[\leadsto \color{blue}{\frac{-1 \cdot \left(-\cos \left(x \cdot 2\right)\right)}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}}} \]
          4. lift-pow.f64N/A

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

            \[\leadsto \frac{-1 \cdot \left(-\cos \left(x \cdot 2\right)\right)}{\color{blue}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)}} \]
          6. mul-1-negN/A

            \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\left(-\cos \left(x \cdot 2\right)\right)\right)}}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)} \]
          7. lift-neg.f64N/A

            \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\cos \left(x \cdot 2\right)\right)\right)}\right)}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)} \]
          8. remove-double-negN/A

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

            \[\leadsto \color{blue}{\frac{\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(c \cdot s\right)}}{x \cdot \left(c \cdot s\right)}} \]
          10. lower-/.f64N/A

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

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

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

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

          if 1.1e-26 < x < 1.40000000000000005e150

          1. Initial program 61.4%

            \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. lift-*.f64N/A

              \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
            2. lift-*.f64N/A

              \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
            3. lift-*.f64N/A

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

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

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

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

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

              \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({s}^{2} \cdot {c}^{2}\right)} \cdot \left(x \cdot x\right)} \]
            9. lift-pow.f64N/A

              \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\color{blue}{{s}^{2}} \cdot {c}^{2}\right) \cdot \left(x \cdot x\right)} \]
            10. lift-pow.f64N/A

              \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left({s}^{2} \cdot \color{blue}{{c}^{2}}\right) \cdot \left(x \cdot x\right)} \]
            11. pow-prod-downN/A

              \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(s \cdot c\right)}^{2}} \cdot \left(x \cdot x\right)} \]
            12. lower-pow.f64N/A

              \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(s \cdot c\right)}^{2}} \cdot \left(x \cdot x\right)} \]
            13. lower-*.f64N/A

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

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

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

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

              \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(s \cdot c\right) \cdot \left(s \cdot c\right)\right)} \cdot \left(x \cdot x\right)} \]
            3. lift-*.f64N/A

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

              \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(\left(s \cdot c\right) \cdot s\right) \cdot c\right)} \cdot \left(x \cdot x\right)} \]
            5. lift-*.f64N/A

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

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

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

              \[\leadsto \frac{\cos \color{blue}{\left(2 \cdot x\right)}}{\left(\left(\left(s \cdot c\right) \cdot s\right) \cdot c\right) \cdot \left(x \cdot x\right)} \]
            2. count-2N/A

              \[\leadsto \frac{\cos \color{blue}{\left(x + x\right)}}{\left(\left(\left(s \cdot c\right) \cdot s\right) \cdot c\right) \cdot \left(x \cdot x\right)} \]
            3. lower-+.f6489.7

              \[\leadsto \frac{\cos \color{blue}{\left(x + x\right)}}{\left(\left(\left(s \cdot c\right) \cdot s\right) \cdot c\right) \cdot \left(x \cdot x\right)} \]
          8. Applied rewrites89.7%

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

          if 1.40000000000000005e150 < x

          1. Initial program 89.1%

            \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
          2. Add Preprocessing
          3. Taylor expanded in x around 0

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

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

              \[\leadsto \color{blue}{\frac{\frac{1}{{x}^{2}}}{{c}^{2} \cdot {s}^{2}}} \]
            3. unpow2N/A

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

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

              \[\leadsto \color{blue}{\frac{\frac{\frac{1}{{x}^{2}}}{c}}{c \cdot {s}^{2}}} \]
            6. lower-/.f64N/A

              \[\leadsto \color{blue}{\frac{\frac{\frac{1}{{x}^{2}}}{c}}{c \cdot {s}^{2}}} \]
            7. lower-/.f64N/A

              \[\leadsto \frac{\color{blue}{\frac{\frac{1}{{x}^{2}}}{c}}}{c \cdot {s}^{2}} \]
            8. unpow2N/A

              \[\leadsto \frac{\frac{\frac{1}{\color{blue}{x \cdot x}}}{c}}{c \cdot {s}^{2}} \]
            9. associate-/r*N/A

              \[\leadsto \frac{\frac{\color{blue}{\frac{\frac{1}{x}}{x}}}{c}}{c \cdot {s}^{2}} \]
            10. lower-/.f64N/A

              \[\leadsto \frac{\frac{\color{blue}{\frac{\frac{1}{x}}{x}}}{c}}{c \cdot {s}^{2}} \]
            11. lower-/.f64N/A

              \[\leadsto \frac{\frac{\frac{\color{blue}{\frac{1}{x}}}{x}}{c}}{c \cdot {s}^{2}} \]
            12. unpow2N/A

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

              \[\leadsto \frac{\frac{\frac{\frac{1}{x}}{x}}{c}}{\color{blue}{\left(c \cdot s\right) \cdot s}} \]
            14. *-commutativeN/A

              \[\leadsto \frac{\frac{\frac{\frac{1}{x}}{x}}{c}}{\color{blue}{\left(s \cdot c\right)} \cdot s} \]
            15. lower-*.f64N/A

              \[\leadsto \frac{\frac{\frac{\frac{1}{x}}{x}}{c}}{\color{blue}{\left(s \cdot c\right) \cdot s}} \]
            16. lower-*.f6475.3

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

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.1 \cdot 10^{-26}:\\ \;\;\;\;\frac{\frac{1}{\left(s \cdot x\right) \cdot c}}{\left(s \cdot x\right) \cdot c}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{+150}:\\ \;\;\;\;\frac{\cos \left(x + x\right)}{\left(x \cdot x\right) \cdot \left(\left(\left(s \cdot c\right) \cdot s\right) \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-1}{{\left(c \cdot x\right)}^{2} \cdot s}}{-s}\\ \end{array} \]
          9. Add Preprocessing

          Alternative 5: 97.6% accurate, 2.2× speedup?

          \[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \begin{array}{l} t_0 := \left(c\_m \cdot x\right) \cdot s\\ t_1 := \left(s \cdot x\right) \cdot c\_m\\ \mathbf{if}\;x \leq 3.1 \cdot 10^{+38}:\\ \;\;\;\;\frac{\frac{\cos \left(x + x\right)}{t\_1}}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t\_0 \cdot t\_0}\\ \end{array} \end{array} \]
          c_m = (fabs.f64 c)
          NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
          (FPCore (x c_m s)
           :precision binary64
           (let* ((t_0 (* (* c_m x) s)) (t_1 (* (* s x) c_m)))
             (if (<= x 3.1e+38)
               (/ (/ (cos (+ x x)) t_1) t_1)
               (/ (cos (* x 2.0)) (* t_0 t_0)))))
          c_m = fabs(c);
          assert(x < c_m && c_m < s);
          double code(double x, double c_m, double s) {
          	double t_0 = (c_m * x) * s;
          	double t_1 = (s * x) * c_m;
          	double tmp;
          	if (x <= 3.1e+38) {
          		tmp = (cos((x + x)) / t_1) / t_1;
          	} else {
          		tmp = cos((x * 2.0)) / (t_0 * t_0);
          	}
          	return tmp;
          }
          
          c_m = abs(c)
          NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
          real(8) function code(x, c_m, s)
              real(8), intent (in) :: x
              real(8), intent (in) :: c_m
              real(8), intent (in) :: s
              real(8) :: t_0
              real(8) :: t_1
              real(8) :: tmp
              t_0 = (c_m * x) * s
              t_1 = (s * x) * c_m
              if (x <= 3.1d+38) then
                  tmp = (cos((x + x)) / t_1) / t_1
              else
                  tmp = cos((x * 2.0d0)) / (t_0 * t_0)
              end if
              code = tmp
          end function
          
          c_m = Math.abs(c);
          assert x < c_m && c_m < s;
          public static double code(double x, double c_m, double s) {
          	double t_0 = (c_m * x) * s;
          	double t_1 = (s * x) * c_m;
          	double tmp;
          	if (x <= 3.1e+38) {
          		tmp = (Math.cos((x + x)) / t_1) / t_1;
          	} else {
          		tmp = Math.cos((x * 2.0)) / (t_0 * t_0);
          	}
          	return tmp;
          }
          
          c_m = math.fabs(c)
          [x, c_m, s] = sort([x, c_m, s])
          def code(x, c_m, s):
          	t_0 = (c_m * x) * s
          	t_1 = (s * x) * c_m
          	tmp = 0
          	if x <= 3.1e+38:
          		tmp = (math.cos((x + x)) / t_1) / t_1
          	else:
          		tmp = math.cos((x * 2.0)) / (t_0 * t_0)
          	return tmp
          
          c_m = abs(c)
          x, c_m, s = sort([x, c_m, s])
          function code(x, c_m, s)
          	t_0 = Float64(Float64(c_m * x) * s)
          	t_1 = Float64(Float64(s * x) * c_m)
          	tmp = 0.0
          	if (x <= 3.1e+38)
          		tmp = Float64(Float64(cos(Float64(x + x)) / t_1) / t_1);
          	else
          		tmp = Float64(cos(Float64(x * 2.0)) / Float64(t_0 * t_0));
          	end
          	return tmp
          end
          
          c_m = abs(c);
          x, c_m, s = num2cell(sort([x, c_m, s])){:}
          function tmp_2 = code(x, c_m, s)
          	t_0 = (c_m * x) * s;
          	t_1 = (s * x) * c_m;
          	tmp = 0.0;
          	if (x <= 3.1e+38)
          		tmp = (cos((x + x)) / t_1) / t_1;
          	else
          		tmp = cos((x * 2.0)) / (t_0 * t_0);
          	end
          	tmp_2 = tmp;
          end
          
          c_m = N[Abs[c], $MachinePrecision]
          NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
          code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(N[(c$95$m * x), $MachinePrecision] * s), $MachinePrecision]}, Block[{t$95$1 = N[(N[(s * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, If[LessEqual[x, 3.1e+38], N[(N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]]
          
          \begin{array}{l}
          c_m = \left|c\right|
          \\
          [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
          \\
          \begin{array}{l}
          t_0 := \left(c\_m \cdot x\right) \cdot s\\
          t_1 := \left(s \cdot x\right) \cdot c\_m\\
          \mathbf{if}\;x \leq 3.1 \cdot 10^{+38}:\\
          \;\;\;\;\frac{\frac{\cos \left(x + x\right)}{t\_1}}{t\_1}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t\_0 \cdot t\_0}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if x < 3.10000000000000018e38

            1. Initial program 61.7%

              \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
            2. Add Preprocessing
            3. Step-by-step derivation
              1. lift-/.f64N/A

                \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
              2. clear-numN/A

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

                \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{neg}\left({c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)\right)}{\mathsf{neg}\left(\cos \left(2 \cdot x\right)\right)}}} \]
              4. associate-/r/N/A

                \[\leadsto \color{blue}{\frac{1}{\mathsf{neg}\left({c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)\right)} \cdot \left(\mathsf{neg}\left(\cos \left(2 \cdot x\right)\right)\right)} \]
              5. lower-*.f64N/A

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

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

                \[\leadsto \color{blue}{\frac{-1}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}} \cdot \left(-\cos \left(x \cdot 2\right)\right)} \]
              2. lift-/.f64N/A

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

                \[\leadsto \color{blue}{\frac{-1 \cdot \left(-\cos \left(x \cdot 2\right)\right)}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}}} \]
              4. lift-pow.f64N/A

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

                \[\leadsto \frac{-1 \cdot \left(-\cos \left(x \cdot 2\right)\right)}{\color{blue}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)}} \]
              6. mul-1-negN/A

                \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\left(-\cos \left(x \cdot 2\right)\right)\right)}}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)} \]
              7. lift-neg.f64N/A

                \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\cos \left(x \cdot 2\right)\right)\right)}\right)}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)} \]
              8. remove-double-negN/A

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

                \[\leadsto \color{blue}{\frac{\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(c \cdot s\right)}}{x \cdot \left(c \cdot s\right)}} \]
              10. lower-/.f64N/A

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

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

                \[\leadsto \frac{\frac{\cos \color{blue}{\left(2 \cdot x\right)}}{\left(s \cdot x\right) \cdot c}}{\left(s \cdot x\right) \cdot c} \]
              2. count-2N/A

                \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{\left(s \cdot x\right) \cdot c}}{\left(s \cdot x\right) \cdot c} \]
              3. lower-+.f6496.8

                \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{\left(s \cdot x\right) \cdot c}}{\left(s \cdot x\right) \cdot c} \]
            8. Applied rewrites96.8%

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

            if 3.10000000000000018e38 < x

            1. Initial program 79.8%

              \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
            2. Add Preprocessing
            3. Taylor expanded in x around 0

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

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

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

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

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

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

                \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right)} \cdot {s}^{2}} \]
              7. unpow2N/A

                \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot \color{blue}{\left(s \cdot s\right)}} \]
              8. unswap-sqrN/A

                \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(x \cdot c\right) \cdot s\right) \cdot \left(\left(x \cdot c\right) \cdot s\right)}} \]
              9. lower-*.f64N/A

                \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(x \cdot c\right) \cdot s\right) \cdot \left(\left(x \cdot c\right) \cdot s\right)}} \]
              10. lower-*.f64N/A

                \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(x \cdot c\right) \cdot s\right)} \cdot \left(\left(x \cdot c\right) \cdot s\right)} \]
              11. lower-*.f64N/A

                \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\color{blue}{\left(x \cdot c\right)} \cdot s\right) \cdot \left(\left(x \cdot c\right) \cdot s\right)} \]
              12. lower-*.f64N/A

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

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

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

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

          Alternative 6: 88.6% accurate, 2.3× speedup?

          \[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \begin{array}{l} t_0 := \left(c\_m \cdot x\right) \cdot s\\ t_1 := \left(s \cdot x\right) \cdot c\_m\\ \mathbf{if}\;x \leq 5 \cdot 10^{-14}:\\ \;\;\;\;\frac{\frac{1}{t\_1}}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t\_0 \cdot t\_0}\\ \end{array} \end{array} \]
          c_m = (fabs.f64 c)
          NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
          (FPCore (x c_m s)
           :precision binary64
           (let* ((t_0 (* (* c_m x) s)) (t_1 (* (* s x) c_m)))
             (if (<= x 5e-14) (/ (/ 1.0 t_1) t_1) (/ (cos (* x 2.0)) (* t_0 t_0)))))
          c_m = fabs(c);
          assert(x < c_m && c_m < s);
          double code(double x, double c_m, double s) {
          	double t_0 = (c_m * x) * s;
          	double t_1 = (s * x) * c_m;
          	double tmp;
          	if (x <= 5e-14) {
          		tmp = (1.0 / t_1) / t_1;
          	} else {
          		tmp = cos((x * 2.0)) / (t_0 * t_0);
          	}
          	return tmp;
          }
          
          c_m = abs(c)
          NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
          real(8) function code(x, c_m, s)
              real(8), intent (in) :: x
              real(8), intent (in) :: c_m
              real(8), intent (in) :: s
              real(8) :: t_0
              real(8) :: t_1
              real(8) :: tmp
              t_0 = (c_m * x) * s
              t_1 = (s * x) * c_m
              if (x <= 5d-14) then
                  tmp = (1.0d0 / t_1) / t_1
              else
                  tmp = cos((x * 2.0d0)) / (t_0 * t_0)
              end if
              code = tmp
          end function
          
          c_m = Math.abs(c);
          assert x < c_m && c_m < s;
          public static double code(double x, double c_m, double s) {
          	double t_0 = (c_m * x) * s;
          	double t_1 = (s * x) * c_m;
          	double tmp;
          	if (x <= 5e-14) {
          		tmp = (1.0 / t_1) / t_1;
          	} else {
          		tmp = Math.cos((x * 2.0)) / (t_0 * t_0);
          	}
          	return tmp;
          }
          
          c_m = math.fabs(c)
          [x, c_m, s] = sort([x, c_m, s])
          def code(x, c_m, s):
          	t_0 = (c_m * x) * s
          	t_1 = (s * x) * c_m
          	tmp = 0
          	if x <= 5e-14:
          		tmp = (1.0 / t_1) / t_1
          	else:
          		tmp = math.cos((x * 2.0)) / (t_0 * t_0)
          	return tmp
          
          c_m = abs(c)
          x, c_m, s = sort([x, c_m, s])
          function code(x, c_m, s)
          	t_0 = Float64(Float64(c_m * x) * s)
          	t_1 = Float64(Float64(s * x) * c_m)
          	tmp = 0.0
          	if (x <= 5e-14)
          		tmp = Float64(Float64(1.0 / t_1) / t_1);
          	else
          		tmp = Float64(cos(Float64(x * 2.0)) / Float64(t_0 * t_0));
          	end
          	return tmp
          end
          
          c_m = abs(c);
          x, c_m, s = num2cell(sort([x, c_m, s])){:}
          function tmp_2 = code(x, c_m, s)
          	t_0 = (c_m * x) * s;
          	t_1 = (s * x) * c_m;
          	tmp = 0.0;
          	if (x <= 5e-14)
          		tmp = (1.0 / t_1) / t_1;
          	else
          		tmp = cos((x * 2.0)) / (t_0 * t_0);
          	end
          	tmp_2 = tmp;
          end
          
          c_m = N[Abs[c], $MachinePrecision]
          NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
          code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(N[(c$95$m * x), $MachinePrecision] * s), $MachinePrecision]}, Block[{t$95$1 = N[(N[(s * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, If[LessEqual[x, 5e-14], N[(N[(1.0 / t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]]
          
          \begin{array}{l}
          c_m = \left|c\right|
          \\
          [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
          \\
          \begin{array}{l}
          t_0 := \left(c\_m \cdot x\right) \cdot s\\
          t_1 := \left(s \cdot x\right) \cdot c\_m\\
          \mathbf{if}\;x \leq 5 \cdot 10^{-14}:\\
          \;\;\;\;\frac{\frac{1}{t\_1}}{t\_1}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{t\_0 \cdot t\_0}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if x < 5.0000000000000002e-14

            1. Initial program 62.1%

              \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
            2. Add Preprocessing
            3. Step-by-step derivation
              1. lift-/.f64N/A

                \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
              2. clear-numN/A

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

                \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{neg}\left({c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)\right)}{\mathsf{neg}\left(\cos \left(2 \cdot x\right)\right)}}} \]
              4. associate-/r/N/A

                \[\leadsto \color{blue}{\frac{1}{\mathsf{neg}\left({c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)\right)} \cdot \left(\mathsf{neg}\left(\cos \left(2 \cdot x\right)\right)\right)} \]
              5. lower-*.f64N/A

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

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

                \[\leadsto \color{blue}{\frac{-1}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}} \cdot \left(-\cos \left(x \cdot 2\right)\right)} \]
              2. lift-/.f64N/A

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

                \[\leadsto \color{blue}{\frac{-1 \cdot \left(-\cos \left(x \cdot 2\right)\right)}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}}} \]
              4. lift-pow.f64N/A

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

                \[\leadsto \frac{-1 \cdot \left(-\cos \left(x \cdot 2\right)\right)}{\color{blue}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)}} \]
              6. mul-1-negN/A

                \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\left(-\cos \left(x \cdot 2\right)\right)\right)}}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)} \]
              7. lift-neg.f64N/A

                \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\cos \left(x \cdot 2\right)\right)\right)}\right)}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)} \]
              8. remove-double-negN/A

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

                \[\leadsto \color{blue}{\frac{\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(c \cdot s\right)}}{x \cdot \left(c \cdot s\right)}} \]
              10. lower-/.f64N/A

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

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

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

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

              if 5.0000000000000002e-14 < x

              1. Initial program 75.8%

                \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
              2. Add Preprocessing
              3. Taylor expanded in x around 0

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

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

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

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

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

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

                  \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right)} \cdot {s}^{2}} \]
                7. unpow2N/A

                  \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\left(x \cdot c\right) \cdot \left(x \cdot c\right)\right) \cdot \color{blue}{\left(s \cdot s\right)}} \]
                8. unswap-sqrN/A

                  \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(x \cdot c\right) \cdot s\right) \cdot \left(\left(x \cdot c\right) \cdot s\right)}} \]
                9. lower-*.f64N/A

                  \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(x \cdot c\right) \cdot s\right) \cdot \left(\left(x \cdot c\right) \cdot s\right)}} \]
                10. lower-*.f64N/A

                  \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(x \cdot c\right) \cdot s\right)} \cdot \left(\left(x \cdot c\right) \cdot s\right)} \]
                11. lower-*.f64N/A

                  \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\color{blue}{\left(x \cdot c\right)} \cdot s\right) \cdot \left(\left(x \cdot c\right) \cdot s\right)} \]
                12. lower-*.f64N/A

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

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

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

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

            Alternative 7: 78.6% accurate, 7.8× speedup?

            \[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \begin{array}{l} t_0 := \left(s \cdot x\right) \cdot c\_m\\ \frac{\frac{1}{t\_0}}{t\_0} \end{array} \end{array} \]
            c_m = (fabs.f64 c)
            NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
            (FPCore (x c_m s)
             :precision binary64
             (let* ((t_0 (* (* s x) c_m))) (/ (/ 1.0 t_0) t_0)))
            c_m = fabs(c);
            assert(x < c_m && c_m < s);
            double code(double x, double c_m, double s) {
            	double t_0 = (s * x) * c_m;
            	return (1.0 / t_0) / t_0;
            }
            
            c_m = abs(c)
            NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
            real(8) function code(x, c_m, s)
                real(8), intent (in) :: x
                real(8), intent (in) :: c_m
                real(8), intent (in) :: s
                real(8) :: t_0
                t_0 = (s * x) * c_m
                code = (1.0d0 / t_0) / t_0
            end function
            
            c_m = Math.abs(c);
            assert x < c_m && c_m < s;
            public static double code(double x, double c_m, double s) {
            	double t_0 = (s * x) * c_m;
            	return (1.0 / t_0) / t_0;
            }
            
            c_m = math.fabs(c)
            [x, c_m, s] = sort([x, c_m, s])
            def code(x, c_m, s):
            	t_0 = (s * x) * c_m
            	return (1.0 / t_0) / t_0
            
            c_m = abs(c)
            x, c_m, s = sort([x, c_m, s])
            function code(x, c_m, s)
            	t_0 = Float64(Float64(s * x) * c_m)
            	return Float64(Float64(1.0 / t_0) / t_0)
            end
            
            c_m = abs(c);
            x, c_m, s = num2cell(sort([x, c_m, s])){:}
            function tmp = code(x, c_m, s)
            	t_0 = (s * x) * c_m;
            	tmp = (1.0 / t_0) / t_0;
            end
            
            c_m = N[Abs[c], $MachinePrecision]
            NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
            code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(N[(s * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
            
            \begin{array}{l}
            c_m = \left|c\right|
            \\
            [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
            \\
            \begin{array}{l}
            t_0 := \left(s \cdot x\right) \cdot c\_m\\
            \frac{\frac{1}{t\_0}}{t\_0}
            \end{array}
            \end{array}
            
            Derivation
            1. Initial program 65.7%

              \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
            2. Add Preprocessing
            3. Step-by-step derivation
              1. lift-/.f64N/A

                \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
              2. clear-numN/A

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

                \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{neg}\left({c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)\right)}{\mathsf{neg}\left(\cos \left(2 \cdot x\right)\right)}}} \]
              4. associate-/r/N/A

                \[\leadsto \color{blue}{\frac{1}{\mathsf{neg}\left({c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)\right)} \cdot \left(\mathsf{neg}\left(\cos \left(2 \cdot x\right)\right)\right)} \]
              5. lower-*.f64N/A

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

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

                \[\leadsto \color{blue}{\frac{-1}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}} \cdot \left(-\cos \left(x \cdot 2\right)\right)} \]
              2. lift-/.f64N/A

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

                \[\leadsto \color{blue}{\frac{-1 \cdot \left(-\cos \left(x \cdot 2\right)\right)}{{\left(x \cdot \left(c \cdot s\right)\right)}^{2}}} \]
              4. lift-pow.f64N/A

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

                \[\leadsto \frac{-1 \cdot \left(-\cos \left(x \cdot 2\right)\right)}{\color{blue}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)}} \]
              6. mul-1-negN/A

                \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\left(-\cos \left(x \cdot 2\right)\right)\right)}}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)} \]
              7. lift-neg.f64N/A

                \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\cos \left(x \cdot 2\right)\right)\right)}\right)}{\left(x \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot \left(c \cdot s\right)\right)} \]
              8. remove-double-negN/A

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

                \[\leadsto \color{blue}{\frac{\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(c \cdot s\right)}}{x \cdot \left(c \cdot s\right)}} \]
              10. lower-/.f64N/A

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

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

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

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

              Alternative 8: 78.5% accurate, 9.0× speedup?

              \[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \begin{array}{l} t_0 := \left(s \cdot x\right) \cdot c\_m\\ \frac{1}{t\_0 \cdot t\_0} \end{array} \end{array} \]
              c_m = (fabs.f64 c)
              NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
              (FPCore (x c_m s)
               :precision binary64
               (let* ((t_0 (* (* s x) c_m))) (/ 1.0 (* t_0 t_0))))
              c_m = fabs(c);
              assert(x < c_m && c_m < s);
              double code(double x, double c_m, double s) {
              	double t_0 = (s * x) * c_m;
              	return 1.0 / (t_0 * t_0);
              }
              
              c_m = abs(c)
              NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
              real(8) function code(x, c_m, s)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: c_m
                  real(8), intent (in) :: s
                  real(8) :: t_0
                  t_0 = (s * x) * c_m
                  code = 1.0d0 / (t_0 * t_0)
              end function
              
              c_m = Math.abs(c);
              assert x < c_m && c_m < s;
              public static double code(double x, double c_m, double s) {
              	double t_0 = (s * x) * c_m;
              	return 1.0 / (t_0 * t_0);
              }
              
              c_m = math.fabs(c)
              [x, c_m, s] = sort([x, c_m, s])
              def code(x, c_m, s):
              	t_0 = (s * x) * c_m
              	return 1.0 / (t_0 * t_0)
              
              c_m = abs(c)
              x, c_m, s = sort([x, c_m, s])
              function code(x, c_m, s)
              	t_0 = Float64(Float64(s * x) * c_m)
              	return Float64(1.0 / Float64(t_0 * t_0))
              end
              
              c_m = abs(c);
              x, c_m, s = num2cell(sort([x, c_m, s])){:}
              function tmp = code(x, c_m, s)
              	t_0 = (s * x) * c_m;
              	tmp = 1.0 / (t_0 * t_0);
              end
              
              c_m = N[Abs[c], $MachinePrecision]
              NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
              code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(N[(s * x), $MachinePrecision] * c$95$m), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
              
              \begin{array}{l}
              c_m = \left|c\right|
              \\
              [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
              \\
              \begin{array}{l}
              t_0 := \left(s \cdot x\right) \cdot c\_m\\
              \frac{1}{t\_0 \cdot t\_0}
              \end{array}
              \end{array}
              
              Derivation
              1. Initial program 65.7%

                \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
              2. Add Preprocessing
              3. Step-by-step derivation
                1. lift-*.f64N/A

                  \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
                2. lift-*.f64N/A

                  \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
                3. lift-*.f64N/A

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

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

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

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

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

                  \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({s}^{2} \cdot {c}^{2}\right)} \cdot \left(x \cdot x\right)} \]
                9. lift-pow.f64N/A

                  \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\color{blue}{{s}^{2}} \cdot {c}^{2}\right) \cdot \left(x \cdot x\right)} \]
                10. lift-pow.f64N/A

                  \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left({s}^{2} \cdot \color{blue}{{c}^{2}}\right) \cdot \left(x \cdot x\right)} \]
                11. pow-prod-downN/A

                  \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(s \cdot c\right)}^{2}} \cdot \left(x \cdot x\right)} \]
                12. lower-pow.f64N/A

                  \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(s \cdot c\right)}^{2}} \cdot \left(x \cdot x\right)} \]
                13. lower-*.f64N/A

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

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

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

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

                  \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(s \cdot c\right) \cdot \left(s \cdot c\right)\right)} \cdot \left(x \cdot x\right)} \]
                3. lift-*.f64N/A

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

                  \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(\left(s \cdot c\right) \cdot s\right) \cdot c\right)} \cdot \left(x \cdot x\right)} \]
                5. lift-*.f64N/A

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

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

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

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

                  \[\leadsto \frac{\color{blue}{1}}{\left(\left(\left(s \cdot c\right) \cdot s\right) \cdot c\right) \cdot \left(x \cdot x\right)} \]
                2. Step-by-step derivation
                  1. lift-*.f64N/A

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

                    \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right) \cdot \left(\left(\left(s \cdot c\right) \cdot s\right) \cdot c\right)}} \]
                  3. lift-*.f64N/A

                    \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \color{blue}{\left(\left(\left(s \cdot c\right) \cdot s\right) \cdot c\right)}} \]
                  4. lift-*.f64N/A

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

                    \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \color{blue}{\left(\left(s \cdot c\right) \cdot \left(s \cdot c\right)\right)}} \]
                  6. lift-*.f64N/A

                    \[\leadsto \frac{1}{\left(x \cdot x\right) \cdot \left(\left(s \cdot c\right) \cdot \color{blue}{\left(s \cdot c\right)}\right)} \]
                  7. lift-*.f64N/A

                    \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right)} \cdot \left(\left(s \cdot c\right) \cdot \left(s \cdot c\right)\right)} \]
                  8. pow2N/A

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

                    \[\leadsto \frac{1}{{x}^{2} \cdot \color{blue}{{\left(s \cdot c\right)}^{2}}} \]
                  10. unpow-prod-downN/A

                    \[\leadsto \frac{1}{\color{blue}{{\left(x \cdot \left(s \cdot c\right)\right)}^{2}}} \]
                  11. lift-*.f64N/A

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

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

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

                    \[\leadsto \frac{1}{{\color{blue}{\left(\left(x \cdot s\right) \cdot c\right)}}^{2}} \]
                  15. *-commutativeN/A

                    \[\leadsto \frac{1}{{\left(\color{blue}{\left(s \cdot x\right)} \cdot c\right)}^{2}} \]
                  16. lift-*.f64N/A

                    \[\leadsto \frac{1}{{\left(\color{blue}{\left(s \cdot x\right)} \cdot c\right)}^{2}} \]
                  17. lift-*.f64N/A

                    \[\leadsto \frac{1}{{\color{blue}{\left(\left(s \cdot x\right) \cdot c\right)}}^{2}} \]
                  18. pow2N/A

                    \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot x\right) \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot c\right)}} \]
                  19. lower-*.f6477.0

                    \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot x\right) \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot c\right)}} \]
                  20. lift-*.f64N/A

                    \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot x\right) \cdot c\right)} \cdot \left(\left(s \cdot x\right) \cdot c\right)} \]
                  21. *-commutativeN/A

                    \[\leadsto \frac{1}{\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)} \cdot \left(\left(s \cdot x\right) \cdot c\right)} \]
                  22. lower-*.f6477.0

                    \[\leadsto \frac{1}{\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)} \cdot \left(\left(s \cdot x\right) \cdot c\right)} \]
                  23. lift-*.f64N/A

                    \[\leadsto \frac{1}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot c\right)}} \]
                  24. *-commutativeN/A

                    \[\leadsto \frac{1}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}} \]
                  25. lower-*.f6477.0

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

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

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

                Alternative 9: 69.5% accurate, 9.0× speedup?

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

                  \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                2. Add Preprocessing
                3. Step-by-step derivation
                  1. lift-*.f64N/A

                    \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
                  2. lift-*.f64N/A

                    \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
                  3. lift-*.f64N/A

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

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

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

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

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

                    \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({s}^{2} \cdot {c}^{2}\right)} \cdot \left(x \cdot x\right)} \]
                  9. lift-pow.f64N/A

                    \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\color{blue}{{s}^{2}} \cdot {c}^{2}\right) \cdot \left(x \cdot x\right)} \]
                  10. lift-pow.f64N/A

                    \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left({s}^{2} \cdot \color{blue}{{c}^{2}}\right) \cdot \left(x \cdot x\right)} \]
                  11. pow-prod-downN/A

                    \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(s \cdot c\right)}^{2}} \cdot \left(x \cdot x\right)} \]
                  12. lower-pow.f64N/A

                    \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(s \cdot c\right)}^{2}} \cdot \left(x \cdot x\right)} \]
                  13. lower-*.f64N/A

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

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

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

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

                    \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(s \cdot c\right) \cdot \left(s \cdot c\right)\right)} \cdot \left(x \cdot x\right)} \]
                  3. lift-*.f64N/A

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

                    \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(\left(s \cdot c\right) \cdot s\right) \cdot c\right)} \cdot \left(x \cdot x\right)} \]
                  5. lift-*.f64N/A

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

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

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

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

                    \[\leadsto \frac{\color{blue}{1}}{\left(\left(\left(s \cdot c\right) \cdot s\right) \cdot c\right) \cdot \left(x \cdot x\right)} \]
                  2. Step-by-step derivation
                    1. lift-*.f64N/A

                      \[\leadsto \frac{1}{\color{blue}{\left(\left(\left(s \cdot c\right) \cdot s\right) \cdot c\right) \cdot \left(x \cdot x\right)}} \]
                    2. lift-*.f64N/A

                      \[\leadsto \frac{1}{\color{blue}{\left(\left(\left(s \cdot c\right) \cdot s\right) \cdot c\right)} \cdot \left(x \cdot x\right)} \]
                    3. lift-*.f64N/A

                      \[\leadsto \frac{1}{\left(\left(\color{blue}{\left(s \cdot c\right)} \cdot s\right) \cdot c\right) \cdot \left(x \cdot x\right)} \]
                    4. *-commutativeN/A

                      \[\leadsto \frac{1}{\left(\left(\color{blue}{\left(c \cdot s\right)} \cdot s\right) \cdot c\right) \cdot \left(x \cdot x\right)} \]
                    5. lift-*.f64N/A

                      \[\leadsto \frac{1}{\left(\left(\color{blue}{\left(c \cdot s\right)} \cdot s\right) \cdot c\right) \cdot \left(x \cdot x\right)} \]
                    6. *-commutativeN/A

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

                      \[\leadsto \frac{1}{\color{blue}{c \cdot \left(\left(\left(c \cdot s\right) \cdot s\right) \cdot \left(x \cdot x\right)\right)}} \]
                    8. lift-*.f64N/A

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

                      \[\leadsto \frac{1}{c \cdot \color{blue}{\left(\left(\left(\left(c \cdot s\right) \cdot s\right) \cdot x\right) \cdot x\right)}} \]
                    10. lift-*.f64N/A

                      \[\leadsto \frac{1}{c \cdot \left(\color{blue}{\left(\left(\left(c \cdot s\right) \cdot s\right) \cdot x\right)} \cdot x\right)} \]
                    11. lower-*.f64N/A

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

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

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

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

                  Alternative 10: 68.4% accurate, 9.0× speedup?

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

                    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                  2. Add Preprocessing
                  3. Step-by-step derivation
                    1. lift-*.f64N/A

                      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
                    2. lift-*.f64N/A

                      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
                    3. lift-*.f64N/A

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

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

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

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

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

                      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({s}^{2} \cdot {c}^{2}\right)} \cdot \left(x \cdot x\right)} \]
                    9. lift-pow.f64N/A

                      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\color{blue}{{s}^{2}} \cdot {c}^{2}\right) \cdot \left(x \cdot x\right)} \]
                    10. lift-pow.f64N/A

                      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left({s}^{2} \cdot \color{blue}{{c}^{2}}\right) \cdot \left(x \cdot x\right)} \]
                    11. pow-prod-downN/A

                      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(s \cdot c\right)}^{2}} \cdot \left(x \cdot x\right)} \]
                    12. lower-pow.f64N/A

                      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(s \cdot c\right)}^{2}} \cdot \left(x \cdot x\right)} \]
                    13. lower-*.f64N/A

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

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

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

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

                      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(s \cdot c\right) \cdot \left(s \cdot c\right)\right)} \cdot \left(x \cdot x\right)} \]
                    3. lift-*.f64N/A

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

                      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(\left(s \cdot c\right) \cdot s\right) \cdot c\right)} \cdot \left(x \cdot x\right)} \]
                    5. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

                        \[\leadsto \frac{1}{\color{blue}{\left(\left({c}^{2} \cdot {x}^{2}\right) \cdot s\right) \cdot s}} \]
                      5. lower-*.f64N/A

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

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

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

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

                        \[\leadsto \frac{1}{\left(\color{blue}{\left(\left({x}^{2} \cdot c\right) \cdot c\right)} \cdot s\right) \cdot s} \]
                      10. *-commutativeN/A

                        \[\leadsto \frac{1}{\left(\left(\color{blue}{\left(c \cdot {x}^{2}\right)} \cdot c\right) \cdot s\right) \cdot s} \]
                      11. lower-*.f64N/A

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

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

                        \[\leadsto \frac{1}{\left(\left(\color{blue}{\left(\left(c \cdot x\right) \cdot x\right)} \cdot c\right) \cdot s\right) \cdot s} \]
                      14. lower-*.f64N/A

                        \[\leadsto \frac{1}{\left(\left(\color{blue}{\left(\left(c \cdot x\right) \cdot x\right)} \cdot c\right) \cdot s\right) \cdot s} \]
                      15. lower-*.f6469.6

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

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

                    Reproduce

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