mixedcos

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

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

Initial Program: 67.2% accurate, 1.0× speedup?

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

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

Alternative 1: 98.6% accurate, 0.4× 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 c\_m\right) \cdot x\\ t_1 := \cos \left(x \cdot 2\right)\\ \mathbf{if}\;\frac{t\_1}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c\_m}^{2}} \leq 2 \cdot 10^{+206}:\\ \;\;\;\;{\left(\left(\left(-x\right) \cdot s\right) \cdot c\_m\right)}^{-2} \cdot t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{{\cos x}^{4} - {\sin x}^{4}}{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 c_m) x)) (t_1 (cos (* x 2.0))))
   (if (<= (/ t_1 (* (* (* (pow s 2.0) x) x) (pow c_m 2.0))) 2e+206)
     (* (pow (* (* (- x) s) c_m) -2.0) t_1)
     (/ (- (pow (cos x) 4.0) (pow (sin x) 4.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 * c_m) * x;
	double t_1 = cos((x * 2.0));
	double tmp;
	if ((t_1 / (((pow(s, 2.0) * x) * x) * pow(c_m, 2.0))) <= 2e+206) {
		tmp = pow(((-x * s) * c_m), -2.0) * t_1;
	} else {
		tmp = (pow(cos(x), 4.0) - pow(sin(x), 4.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 = (s * c_m) * x
    t_1 = cos((x * 2.0d0))
    if ((t_1 / ((((s ** 2.0d0) * x) * x) * (c_m ** 2.0d0))) <= 2d+206) then
        tmp = (((-x * s) * c_m) ** (-2.0d0)) * t_1
    else
        tmp = ((cos(x) ** 4.0d0) - (sin(x) ** 4.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 * c_m) * x;
	double t_1 = Math.cos((x * 2.0));
	double tmp;
	if ((t_1 / (((Math.pow(s, 2.0) * x) * x) * Math.pow(c_m, 2.0))) <= 2e+206) {
		tmp = Math.pow(((-x * s) * c_m), -2.0) * t_1;
	} else {
		tmp = (Math.pow(Math.cos(x), 4.0) - Math.pow(Math.sin(x), 4.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 * c_m) * x
	t_1 = math.cos((x * 2.0))
	tmp = 0
	if (t_1 / (((math.pow(s, 2.0) * x) * x) * math.pow(c_m, 2.0))) <= 2e+206:
		tmp = math.pow(((-x * s) * c_m), -2.0) * t_1
	else:
		tmp = (math.pow(math.cos(x), 4.0) - math.pow(math.sin(x), 4.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 * c_m) * x)
	t_1 = cos(Float64(x * 2.0))
	tmp = 0.0
	if (Float64(t_1 / Float64(Float64(Float64((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= 2e+206)
		tmp = Float64((Float64(Float64(Float64(-x) * s) * c_m) ^ -2.0) * t_1);
	else
		tmp = Float64(Float64((cos(x) ^ 4.0) - (sin(x) ^ 4.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 = (s * c_m) * x;
	t_1 = cos((x * 2.0));
	tmp = 0.0;
	if ((t_1 / ((((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= 2e+206)
		tmp = (((-x * s) * c_m) ^ -2.0) * t_1;
	else
		tmp = ((cos(x) ^ 4.0) - (sin(x) ^ 4.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 * c$95$m), $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$1 / N[(N[(N[(N[Power[s, 2.0], $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] * N[Power[c$95$m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+206], N[(N[Power[N[(N[((-x) * s), $MachinePrecision] * c$95$m), $MachinePrecision], -2.0], $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[Power[N[Cos[x], $MachinePrecision], 4.0], $MachinePrecision] - N[Power[N[Sin[x], $MachinePrecision], 4.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(s \cdot c\_m\right) \cdot x\\
t_1 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;\frac{t\_1}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c\_m}^{2}} \leq 2 \cdot 10^{+206}:\\
\;\;\;\;{\left(\left(\left(-x\right) \cdot s\right) \cdot c\_m\right)}^{-2} \cdot t\_1\\

\mathbf{else}:\\
\;\;\;\;\frac{{\cos x}^{4} - {\sin x}^{4}}{t\_0 \cdot 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))) < 2.0000000000000001e206

    1. Initial program 75.2%

      \[\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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.0000000000000001e206 < (/.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 49.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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(\cos x \cdot \cos x + \sin x \cdot \sin x\right) \cdot \color{blue}{\left(\cos x \cdot \cos x - \sin x \cdot \sin x\right)}}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)} \]
      7. difference-of-squaresN/A

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

        \[\leadsto \frac{\color{blue}{\left(\cos x \cdot \cos x\right) \cdot \left(\cos x \cdot \cos x\right) - \left(\sin x \cdot \sin x\right) \cdot \left(\sin x \cdot \sin x\right)}}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)} \]
      9. pow2N/A

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

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

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

        \[\leadsto \frac{{\cos x}^{\color{blue}{4}} - \left(\sin x \cdot \sin x\right) \cdot \left(\sin x \cdot \sin x\right)}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)} \]
      13. metadata-evalN/A

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

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

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

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

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

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

        \[\leadsto \frac{{\cos x}^{4} - \color{blue}{{\sin x}^{\left(2 + 2\right)}}}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)} \]
      20. metadata-evalN/A

        \[\leadsto \frac{{\cos x}^{4} - {\sin x}^{\color{blue}{4}}}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)} \]
      21. metadata-evalN/A

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

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

        \[\leadsto \frac{{\cos x}^{4} - {\color{blue}{\sin x}}^{\left(-2 \cdot -2\right)}}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)} \]
      24. metadata-eval98.3

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

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

    \[\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^{+206}:\\ \;\;\;\;{\left(\left(\left(-x\right) \cdot s\right) \cdot c\right)}^{-2} \cdot \cos \left(x \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{{\cos x}^{4} - {\sin x}^{4}}{\left(\left(s \cdot c\right) \cdot x\right) \cdot \left(\left(s \cdot c\right) \cdot x\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 98.6% 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 c\_m\right) \cdot x\\ \mathbf{if}\;\frac{t\_0}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c\_m}^{2}} \leq 0:\\ \;\;\;\;{\left(\left(\left(-x\right) \cdot s\right) \cdot c\_m\right)}^{-2} \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cos \left(x + x\right)}{t\_1}}{t\_1}\\ \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 c_m) x)))
   (if (<= (/ t_0 (* (* (* (pow s 2.0) x) x) (pow c_m 2.0))) 0.0)
     (* (pow (* (* (- x) s) c_m) -2.0) t_0)
     (/ (/ (cos (+ x x)) t_1) t_1))))
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 * c_m) * x;
	double tmp;
	if ((t_0 / (((pow(s, 2.0) * x) * x) * pow(c_m, 2.0))) <= 0.0) {
		tmp = pow(((-x * s) * c_m), -2.0) * t_0;
	} else {
		tmp = (cos((x + x)) / t_1) / t_1;
	}
	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 = cos((x * 2.0d0))
    t_1 = (s * c_m) * x
    if ((t_0 / ((((s ** 2.0d0) * x) * x) * (c_m ** 2.0d0))) <= 0.0d0) then
        tmp = (((-x * s) * c_m) ** (-2.0d0)) * t_0
    else
        tmp = (cos((x + x)) / t_1) / t_1
    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 = Math.cos((x * 2.0));
	double t_1 = (s * c_m) * x;
	double tmp;
	if ((t_0 / (((Math.pow(s, 2.0) * x) * x) * Math.pow(c_m, 2.0))) <= 0.0) {
		tmp = Math.pow(((-x * s) * c_m), -2.0) * t_0;
	} else {
		tmp = (Math.cos((x + x)) / t_1) / t_1;
	}
	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 * c_m) * x
	tmp = 0
	if (t_0 / (((math.pow(s, 2.0) * x) * x) * math.pow(c_m, 2.0))) <= 0.0:
		tmp = math.pow(((-x * s) * c_m), -2.0) * t_0
	else:
		tmp = (math.cos((x + x)) / t_1) / t_1
	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 * c_m) * x)
	tmp = 0.0
	if (Float64(t_0 / Float64(Float64(Float64((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= 0.0)
		tmp = Float64((Float64(Float64(Float64(-x) * s) * c_m) ^ -2.0) * t_0);
	else
		tmp = Float64(Float64(cos(Float64(x + x)) / t_1) / t_1);
	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 * c_m) * x;
	tmp = 0.0;
	if ((t_0 / ((((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= 0.0)
		tmp = (((-x * s) * c_m) ^ -2.0) * t_0;
	else
		tmp = (cos((x + x)) / t_1) / t_1;
	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 * c$95$m), $MachinePrecision] * x), $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], 0.0], N[(N[Power[N[(N[((-x) * s), $MachinePrecision] * c$95$m), $MachinePrecision], -2.0], $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / t$95$1), $MachinePrecision] / t$95$1), $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 c\_m\right) \cdot x\\
\mathbf{if}\;\frac{t\_0}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c\_m}^{2}} \leq 0:\\
\;\;\;\;{\left(\left(\left(-x\right) \cdot s\right) \cdot c\_m\right)}^{-2} \cdot t\_0\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cos \left(x + x\right)}{t\_1}}{t\_1}\\


\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))) < 0.0

    1. Initial program 71.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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.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 55.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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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 0:\\ \;\;\;\;{\left(\left(\left(-x\right) \cdot s\right) \cdot c\right)}^{-2} \cdot \cos \left(x \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cos \left(x + x\right)}{\left(s \cdot c\right) \cdot x}}{\left(s \cdot c\right) \cdot x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 82.1% 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 c\_m\right) \cdot x\\ t_1 := \left(c\_m \cdot x\right) \cdot s\\ \mathbf{if}\;\frac{\cos \left(x \cdot 2\right)}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c\_m}^{2}} \leq -1 \cdot 10^{-94}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x \cdot x, -2, 1\right)}{t\_0 \cdot t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{t\_1 \cdot t\_1}\\ \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 c_m) x)) (t_1 (* (* c_m x) s)))
   (if (<=
        (/ (cos (* x 2.0)) (* (* (* (pow s 2.0) x) x) (pow c_m 2.0)))
        -1e-94)
     (/ (fma (* x x) -2.0 1.0) (* t_0 t_0))
     (/ 1.0 (* t_1 t_1)))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
	double t_0 = (s * c_m) * x;
	double t_1 = (c_m * x) * s;
	double tmp;
	if ((cos((x * 2.0)) / (((pow(s, 2.0) * x) * x) * pow(c_m, 2.0))) <= -1e-94) {
		tmp = fma((x * x), -2.0, 1.0) / (t_0 * t_0);
	} else {
		tmp = 1.0 / (t_1 * t_1);
	}
	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 * c_m) * x)
	t_1 = Float64(Float64(c_m * x) * s)
	tmp = 0.0
	if (Float64(cos(Float64(x * 2.0)) / Float64(Float64(Float64((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= -1e-94)
		tmp = Float64(fma(Float64(x * x), -2.0, 1.0) / Float64(t_0 * t_0));
	else
		tmp = Float64(1.0 / Float64(t_1 * t_1));
	end
	return 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 * c$95$m), $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c$95$m * x), $MachinePrecision] * s), $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], -1e-94], N[(N[(N[(x * x), $MachinePrecision] * -2.0 + 1.0), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(t$95$1 * t$95$1), $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 c\_m\right) \cdot x\\
t_1 := \left(c\_m \cdot x\right) \cdot s\\
\mathbf{if}\;\frac{\cos \left(x \cdot 2\right)}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c\_m}^{2}} \leq -1 \cdot 10^{-94}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x \cdot x, -2, 1\right)}{t\_0 \cdot t\_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_1 \cdot t\_1}\\


\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))) < -9.9999999999999996e-95

    1. Initial program 59.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 \frac{\color{blue}{1 + -2 \cdot {x}^{2}}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{x \cdot x}, -2, 1\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      5. lower-*.f6441.3

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{x \cdot x}, -2, 1\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    5. Applied rewrites41.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(x \cdot x, -2, 1\right)}{\color{blue}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)}} \]
      16. lift-*.f6441.3

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

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

        \[\leadsto \frac{\mathsf{fma}\left(x \cdot x, -2, 1\right)}{\color{blue}{\left(\left(s \cdot c\right) \cdot x\right)} \cdot \left(x \cdot \left(s \cdot c\right)\right)} \]
      19. lower-*.f6441.3

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

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

        \[\leadsto \frac{\mathsf{fma}\left(x \cdot x, -2, 1\right)}{\left(\color{blue}{\left(c \cdot s\right)} \cdot x\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)} \]
      22. lower-*.f6441.3

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

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

        \[\leadsto \frac{\mathsf{fma}\left(x \cdot x, -2, 1\right)}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \color{blue}{\left(\left(s \cdot c\right) \cdot x\right)}} \]
      25. lower-*.f6441.3

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

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

        \[\leadsto \frac{\mathsf{fma}\left(x \cdot x, -2, 1\right)}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)} \]
      28. lower-*.f6441.3

        \[\leadsto \frac{\mathsf{fma}\left(x \cdot x, -2, 1\right)}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)} \]
    7. Applied rewrites41.3%

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

    if -9.9999999999999996e-95 < (/.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 63.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. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)}} \]
        17. remove-double-negN/A

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

          \[\leadsto \frac{1}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)}\right)\right)\right)} \]
        19. distribute-rgt-neg-inN/A

          \[\leadsto \frac{1}{\mathsf{neg}\left(\color{blue}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(\mathsf{neg}\left(x \cdot \left(s \cdot c\right)\right)\right)}\right)} \]
        20. distribute-lft-neg-inN/A

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

          \[\leadsto \frac{1}{\color{blue}{\left(\mathsf{neg}\left(x \cdot \left(s \cdot c\right)\right)\right) \cdot \left(\mathsf{neg}\left(x \cdot \left(s \cdot c\right)\right)\right)}} \]
      3. Applied rewrites82.6%

        \[\leadsto \frac{1}{\color{blue}{\left(\left(-s\right) \cdot \left(c \cdot x\right)\right) \cdot \left(\left(-s\right) \cdot \left(c \cdot x\right)\right)}} \]
    5. Recombined 2 regimes into one program.
    6. Final simplification79.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 -1 \cdot 10^{-94}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x \cdot x, -2, 1\right)}{\left(\left(s \cdot c\right) \cdot x\right) \cdot \left(\left(s \cdot c\right) \cdot x\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(\left(c \cdot x\right) \cdot s\right) \cdot \left(\left(c \cdot x\right) \cdot s\right)}\\ \end{array} \]
    7. Add Preprocessing

    Alternative 4: 78.3% 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(c\_m \cdot x\right) \cdot s\\ \mathbf{if}\;\frac{\cos \left(x \cdot 2\right)}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c\_m}^{2}} \leq -1 \cdot 10^{+154}:\\ \;\;\;\;\frac{1}{t\_0 \cdot \left(\left(s \cdot c\_m\right) \cdot x\right)}\\ \mathbf{else}:\\ \;\;\;\;\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 (* (* c_m x) s)))
       (if (<=
            (/ (cos (* x 2.0)) (* (* (* (pow s 2.0) x) x) (pow c_m 2.0)))
            -1e+154)
         (/ 1.0 (* t_0 (* (* s c_m) x)))
         (/ 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 = (c_m * x) * s;
    	double tmp;
    	if ((cos((x * 2.0)) / (((pow(s, 2.0) * x) * x) * pow(c_m, 2.0))) <= -1e+154) {
    		tmp = 1.0 / (t_0 * ((s * c_m) * x));
    	} 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 = (c_m * x) * s
        if ((cos((x * 2.0d0)) / ((((s ** 2.0d0) * x) * x) * (c_m ** 2.0d0))) <= (-1d+154)) then
            tmp = 1.0d0 / (t_0 * ((s * c_m) * x))
        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 = (c_m * x) * s;
    	double tmp;
    	if ((Math.cos((x * 2.0)) / (((Math.pow(s, 2.0) * x) * x) * Math.pow(c_m, 2.0))) <= -1e+154) {
    		tmp = 1.0 / (t_0 * ((s * c_m) * x));
    	} 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 = (c_m * x) * s
    	tmp = 0
    	if (math.cos((x * 2.0)) / (((math.pow(s, 2.0) * x) * x) * math.pow(c_m, 2.0))) <= -1e+154:
    		tmp = 1.0 / (t_0 * ((s * c_m) * x))
    	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(c_m * x) * s)
    	tmp = 0.0
    	if (Float64(cos(Float64(x * 2.0)) / Float64(Float64(Float64((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= -1e+154)
    		tmp = Float64(1.0 / Float64(t_0 * Float64(Float64(s * c_m) * x)));
    	else
    		tmp = Float64(1.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;
    	tmp = 0.0;
    	if ((cos((x * 2.0)) / ((((s ^ 2.0) * x) * x) * (c_m ^ 2.0))) <= -1e+154)
    		tmp = 1.0 / (t_0 * ((s * c_m) * x));
    	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[(c$95$m * x), $MachinePrecision] * s), $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], -1e+154], N[(1.0 / N[(t$95$0 * N[(N[(s * c$95$m), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]), $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(c\_m \cdot x\right) \cdot s\\
    \mathbf{if}\;\frac{\cos \left(x \cdot 2\right)}{\left(\left({s}^{2} \cdot x\right) \cdot x\right) \cdot {c\_m}^{2}} \leq -1 \cdot 10^{+154}:\\
    \;\;\;\;\frac{1}{t\_0 \cdot \left(\left(s \cdot c\_m\right) \cdot x\right)}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{1}{t\_0 \cdot 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.00000000000000004e154

      1. Initial program 52.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. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)}} \]
          16. lift-*.f641.0

            \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)}} \]
          17. remove-double-negN/A

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

            \[\leadsto \frac{1}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)}\right)\right)\right)} \]
          19. distribute-rgt-neg-inN/A

            \[\leadsto \frac{1}{\mathsf{neg}\left(\color{blue}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(\mathsf{neg}\left(x \cdot \left(s \cdot c\right)\right)\right)}\right)} \]
          20. distribute-lft-neg-inN/A

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

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

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

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

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

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

            \[\leadsto \frac{1}{\left(\left(\color{blue}{\left(\mathsf{neg}\left(s\right)\right)} \cdot c\right) \cdot x\right) \cdot \left(\left(-s\right) \cdot \left(c \cdot x\right)\right)} \]
          5. distribute-lft-neg-outN/A

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

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

            \[\leadsto \frac{1}{\left(\left(\mathsf{neg}\left(\color{blue}{c \cdot s}\right)\right) \cdot x\right) \cdot \left(\left(-s\right) \cdot \left(c \cdot x\right)\right)} \]
          8. distribute-lft-neg-inN/A

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

            \[\leadsto \frac{1}{\left(\mathsf{neg}\left(\color{blue}{\left(c \cdot s\right) \cdot x}\right)\right) \cdot \left(\left(-s\right) \cdot \left(c \cdot x\right)\right)} \]
          10. neg-sub0N/A

            \[\leadsto \frac{1}{\color{blue}{\left(0 - \left(c \cdot s\right) \cdot x\right)} \cdot \left(\left(-s\right) \cdot \left(c \cdot x\right)\right)} \]
          11. lower--.f6423.8

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

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

            \[\leadsto \frac{1}{\left(0 - \color{blue}{\left(s \cdot c\right)} \cdot x\right) \cdot \left(\left(-s\right) \cdot \left(c \cdot x\right)\right)} \]
          14. lift-*.f6423.8

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

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

        if -1.00000000000000004e154 < (/.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 63.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{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
        4. Step-by-step derivation
          1. Applied rewrites60.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)}} \]
            17. remove-double-negN/A

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

              \[\leadsto \frac{1}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)}\right)\right)\right)} \]
            19. distribute-rgt-neg-inN/A

              \[\leadsto \frac{1}{\mathsf{neg}\left(\color{blue}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(\mathsf{neg}\left(x \cdot \left(s \cdot c\right)\right)\right)}\right)} \]
            20. distribute-lft-neg-inN/A

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

              \[\leadsto \frac{1}{\color{blue}{\left(\mathsf{neg}\left(x \cdot \left(s \cdot c\right)\right)\right) \cdot \left(\mathsf{neg}\left(x \cdot \left(s \cdot c\right)\right)\right)}} \]
          3. Applied rewrites81.6%

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

          \[\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 -1 \cdot 10^{+154}:\\ \;\;\;\;\frac{1}{\left(\left(c \cdot x\right) \cdot s\right) \cdot \left(\left(s \cdot c\right) \cdot x\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(\left(c \cdot x\right) \cdot s\right) \cdot \left(\left(c \cdot x\right) \cdot s\right)}\\ \end{array} \]
        7. Add Preprocessing

        Alternative 5: 84.9% 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} \mathbf{if}\;x \leq 6.2 \cdot 10^{-53}:\\ \;\;\;\;\frac{\frac{1}{\left(s \cdot c\_m\right) \cdot x}}{\left(s \cdot x\right) \cdot c\_m}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x + x\right)}{\left(\left(\left(c\_m \cdot x\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot c\_m\right)}\\ \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
         (if (<= x 6.2e-53)
           (/ (/ 1.0 (* (* s c_m) x)) (* (* s x) c_m))
           (/ (cos (+ x x)) (* (* (* (* c_m x) x) s) (* s c_m)))))
        c_m = fabs(c);
        assert(x < c_m && c_m < s);
        double code(double x, double c_m, double s) {
        	double tmp;
        	if (x <= 6.2e-53) {
        		tmp = (1.0 / ((s * c_m) * x)) / ((s * x) * c_m);
        	} else {
        		tmp = cos((x + x)) / ((((c_m * x) * x) * s) * (s * c_m));
        	}
        	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) :: tmp
            if (x <= 6.2d-53) then
                tmp = (1.0d0 / ((s * c_m) * x)) / ((s * x) * c_m)
            else
                tmp = cos((x + x)) / ((((c_m * x) * x) * s) * (s * c_m))
            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 tmp;
        	if (x <= 6.2e-53) {
        		tmp = (1.0 / ((s * c_m) * x)) / ((s * x) * c_m);
        	} else {
        		tmp = Math.cos((x + x)) / ((((c_m * x) * x) * s) * (s * c_m));
        	}
        	return tmp;
        }
        
        c_m = math.fabs(c)
        [x, c_m, s] = sort([x, c_m, s])
        def code(x, c_m, s):
        	tmp = 0
        	if x <= 6.2e-53:
        		tmp = (1.0 / ((s * c_m) * x)) / ((s * x) * c_m)
        	else:
        		tmp = math.cos((x + x)) / ((((c_m * x) * x) * s) * (s * c_m))
        	return tmp
        
        c_m = abs(c)
        x, c_m, s = sort([x, c_m, s])
        function code(x, c_m, s)
        	tmp = 0.0
        	if (x <= 6.2e-53)
        		tmp = Float64(Float64(1.0 / Float64(Float64(s * c_m) * x)) / Float64(Float64(s * x) * c_m));
        	else
        		tmp = Float64(cos(Float64(x + x)) / Float64(Float64(Float64(Float64(c_m * x) * x) * s) * Float64(s * c_m)));
        	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)
        	tmp = 0.0;
        	if (x <= 6.2e-53)
        		tmp = (1.0 / ((s * c_m) * x)) / ((s * x) * c_m);
        	else
        		tmp = cos((x + x)) / ((((c_m * x) * x) * s) * (s * c_m));
        	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_] := If[LessEqual[x, 6.2e-53], N[(N[(1.0 / N[(N[(s * c$95$m), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / N[(N[(s * x), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(N[(N[(N[(c$95$m * x), $MachinePrecision] * x), $MachinePrecision] * s), $MachinePrecision] * N[(s * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        c_m = \left|c\right|
        \\
        [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
        \\
        \begin{array}{l}
        \mathbf{if}\;x \leq 6.2 \cdot 10^{-53}:\\
        \;\;\;\;\frac{\frac{1}{\left(s \cdot c\_m\right) \cdot x}}{\left(s \cdot x\right) \cdot c\_m}\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{\cos \left(x + x\right)}{\left(\left(\left(c\_m \cdot x\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot c\_m\right)}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if x < 6.20000000000000031e-53

          1. Initial program 62.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. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)}} \]
              16. lift-*.f6481.9

                \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)}} \]
              17. remove-double-negN/A

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

                \[\leadsto \frac{1}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)}\right)\right)\right)} \]
              19. distribute-rgt-neg-inN/A

                \[\leadsto \frac{1}{\mathsf{neg}\left(\color{blue}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(\mathsf{neg}\left(x \cdot \left(s \cdot c\right)\right)\right)}\right)} \]
              20. distribute-lft-neg-inN/A

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

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

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

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

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

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

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

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

            if 6.20000000000000031e-53 < x

            1. Initial program 63.9%

              \[\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. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 6: 97.0% 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(s \cdot c\_m\right) \cdot x\\ \frac{\frac{\cos \left(x + x\right)}{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 c_m) x))) (/ (/ (cos (+ x x)) 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 * c_m) * x;
          	return (cos((x + x)) / 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 * c_m) * x
              code = (cos((x + x)) / 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 * c_m) * x;
          	return (Math.cos((x + x)) / 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 * c_m) * x
          	return (math.cos((x + x)) / 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 * c_m) * x)
          	return Float64(Float64(cos(Float64(x + x)) / 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 * c_m) * x;
          	tmp = (cos((x + x)) / 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 * c$95$m), $MachinePrecision] * x), $MachinePrecision]}, N[(N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / 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 c\_m\right) \cdot x\\
          \frac{\frac{\cos \left(x + x\right)}{t\_0}}{t\_0}
          \end{array}
          \end{array}
          
          Derivation
          1. Initial program 63.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 \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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(s \cdot c\right)}}{x \cdot \left(s \cdot c\right)}} \]
            5. lower-/.f6496.6

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\frac{\cos \left(x + x\right)}{\left(s \cdot c\right) \cdot x}}{\left(s \cdot c\right) \cdot x} \]
          10. Add Preprocessing

          Alternative 7: 75.2% 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} \mathbf{if}\;{c\_m}^{2} \leq 0.001:\\ \;\;\;\;\frac{1}{\left(\left(s \cdot x\right) \cdot x\right) \cdot \left(\left(s \cdot c\_m\right) \cdot c\_m\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(\left(s \cdot x\right) \cdot s\right) \cdot \left(\left(c\_m \cdot x\right) \cdot c\_m\right)}\\ \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
           (if (<= (pow c_m 2.0) 0.001)
             (/ 1.0 (* (* (* s x) x) (* (* s c_m) c_m)))
             (/ 1.0 (* (* (* s x) s) (* (* c_m x) c_m)))))
          c_m = fabs(c);
          assert(x < c_m && c_m < s);
          double code(double x, double c_m, double s) {
          	double tmp;
          	if (pow(c_m, 2.0) <= 0.001) {
          		tmp = 1.0 / (((s * x) * x) * ((s * c_m) * c_m));
          	} else {
          		tmp = 1.0 / (((s * x) * s) * ((c_m * x) * c_m));
          	}
          	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) :: tmp
              if ((c_m ** 2.0d0) <= 0.001d0) then
                  tmp = 1.0d0 / (((s * x) * x) * ((s * c_m) * c_m))
              else
                  tmp = 1.0d0 / (((s * x) * s) * ((c_m * x) * c_m))
              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 tmp;
          	if (Math.pow(c_m, 2.0) <= 0.001) {
          		tmp = 1.0 / (((s * x) * x) * ((s * c_m) * c_m));
          	} else {
          		tmp = 1.0 / (((s * x) * s) * ((c_m * x) * c_m));
          	}
          	return tmp;
          }
          
          c_m = math.fabs(c)
          [x, c_m, s] = sort([x, c_m, s])
          def code(x, c_m, s):
          	tmp = 0
          	if math.pow(c_m, 2.0) <= 0.001:
          		tmp = 1.0 / (((s * x) * x) * ((s * c_m) * c_m))
          	else:
          		tmp = 1.0 / (((s * x) * s) * ((c_m * x) * c_m))
          	return tmp
          
          c_m = abs(c)
          x, c_m, s = sort([x, c_m, s])
          function code(x, c_m, s)
          	tmp = 0.0
          	if ((c_m ^ 2.0) <= 0.001)
          		tmp = Float64(1.0 / Float64(Float64(Float64(s * x) * x) * Float64(Float64(s * c_m) * c_m)));
          	else
          		tmp = Float64(1.0 / Float64(Float64(Float64(s * x) * s) * Float64(Float64(c_m * x) * c_m)));
          	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)
          	tmp = 0.0;
          	if ((c_m ^ 2.0) <= 0.001)
          		tmp = 1.0 / (((s * x) * x) * ((s * c_m) * c_m));
          	else
          		tmp = 1.0 / (((s * x) * s) * ((c_m * x) * c_m));
          	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_] := If[LessEqual[N[Power[c$95$m, 2.0], $MachinePrecision], 0.001], N[(1.0 / N[(N[(N[(s * x), $MachinePrecision] * x), $MachinePrecision] * N[(N[(s * c$95$m), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(s * x), $MachinePrecision] * s), $MachinePrecision] * N[(N[(c$95$m * x), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
          
          \begin{array}{l}
          c_m = \left|c\right|
          \\
          [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
          \\
          \begin{array}{l}
          \mathbf{if}\;{c\_m}^{2} \leq 0.001:\\
          \;\;\;\;\frac{1}{\left(\left(s \cdot x\right) \cdot x\right) \cdot \left(\left(s \cdot c\_m\right) \cdot c\_m\right)}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{1}{\left(\left(s \cdot x\right) \cdot s\right) \cdot \left(\left(c\_m \cdot x\right) \cdot c\_m\right)}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (pow.f64 c #s(literal 2 binary64)) < 1e-3

            1. Initial program 65.3%

              \[\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{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
            4. Step-by-step derivation
              1. Applied rewrites57.4%

                \[\leadsto \frac{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \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}{\color{blue}{\left({s}^{2} \cdot {x}^{2}\right) \cdot {c}^{2}}} \]
                2. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \frac{1}{\left(\left(c \cdot x\right) \cdot c\right) \cdot \left(\color{blue}{\left(s \cdot x\right)} \cdot s\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. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                if 1e-3 < (pow.f64 c #s(literal 2 binary64))

                1. Initial program 60.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{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
                4. Step-by-step derivation
                  1. Applied rewrites54.8%

                    \[\leadsto \frac{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \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}{\color{blue}{\left({s}^{2} \cdot {x}^{2}\right) \cdot {c}^{2}}} \]
                    2. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  Alternative 8: 96.8% accurate, 2.4× 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 c\_m\right) \cdot x\\ \frac{\cos \left(x + x\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 (* (* s c_m) x))) (/ (cos (+ x x)) (* 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 * c_m) * x;
                  	return cos((x + x)) / (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 * c_m) * x
                      code = cos((x + x)) / (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 * c_m) * x;
                  	return Math.cos((x + x)) / (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 * c_m) * x
                  	return math.cos((x + x)) / (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 * c_m) * x)
                  	return Float64(cos(Float64(x + x)) / 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 * c_m) * x;
                  	tmp = cos((x + x)) / (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 * c$95$m), $MachinePrecision] * x), $MachinePrecision]}, N[(N[Cos[N[(x + x), $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(s \cdot c\_m\right) \cdot x\\
                  \frac{\cos \left(x + x\right)}{t\_0 \cdot t\_0}
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Initial program 63.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 \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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(s \cdot c\right) \cdot x\right) \cdot \left(\left(s \cdot c\right) \cdot x\right)} \]
                  8. Add Preprocessing

                  Alternative 9: 78.3% 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(c\_m \cdot x\right) \cdot s\\ \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 (* (* c_m x) s))) (/ 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 = (c_m * x) * s;
                  	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 = (c_m * x) * s
                      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 = (c_m * x) * s;
                  	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 = (c_m * x) * s
                  	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(c_m * x) * s)
                  	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 = (c_m * x) * s;
                  	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[(c$95$m * x), $MachinePrecision] * s), $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(c\_m \cdot x\right) \cdot s\\
                  \frac{1}{t\_0 \cdot t\_0}
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Initial program 63.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. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)}} \]
                      17. remove-double-negN/A

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

                        \[\leadsto \frac{1}{\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)}\right)\right)\right)} \]
                      19. distribute-rgt-neg-inN/A

                        \[\leadsto \frac{1}{\mathsf{neg}\left(\color{blue}{\left(x \cdot \left(s \cdot c\right)\right) \cdot \left(\mathsf{neg}\left(x \cdot \left(s \cdot c\right)\right)\right)}\right)} \]
                      20. distribute-lft-neg-inN/A

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

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

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

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

                    Alternative 10: 78.6% 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 c\_m\right) \cdot x\\ \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 c_m) x))) (/ 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 * c_m) * x;
                    	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 * c_m) * x
                        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 * c_m) * x;
                    	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 * c_m) * x
                    	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 * c_m) * x)
                    	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 * c_m) * x;
                    	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 * c$95$m), $MachinePrecision] * x), $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 c\_m\right) \cdot x\\
                    \frac{1}{t\_0 \cdot t\_0}
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Initial program 63.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. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      Alternative 11: 70.1% 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(s \cdot x\right) \cdot s\right) \cdot \left(\left(c\_m \cdot x\right) \cdot c\_m\right)} \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 x) s) (* (* c_m 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 * x) * s) * ((c_m * 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 * x) * s) * ((c_m * 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 * x) * s) * ((c_m * 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 * x) * s) * ((c_m * 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(s * x) * s) * Float64(Float64(c_m * 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 * x) * s) * ((c_m * 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[(s * x), $MachinePrecision] * s), $MachinePrecision] * N[(N[(c$95$m * x), $MachinePrecision] * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                      
                      \begin{array}{l}
                      c_m = \left|c\right|
                      \\
                      [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
                      \\
                      \frac{1}{\left(\left(s \cdot x\right) \cdot s\right) \cdot \left(\left(c\_m \cdot x\right) \cdot c\_m\right)}
                      \end{array}
                      
                      Derivation
                      1. Initial program 63.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. Taylor expanded in x around 0

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

                          \[\leadsto \frac{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \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}{\color{blue}{\left({s}^{2} \cdot {x}^{2}\right) \cdot {c}^{2}}} \]
                          2. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          Alternative 12: 65.9% 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(c\_m \cdot c\_m\right) \cdot x\right) \cdot \left(\left(s \cdot x\right) \cdot s\right)} \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 c_m) x) (* (* s x) 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 * c_m) * x) * ((s * x) * 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 * c_m) * x) * ((s * x) * 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 * c_m) * x) * ((s * x) * 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 * c_m) * x) * ((s * x) * 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(c_m * c_m) * x) * Float64(Float64(s * x) * 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 * c_m) * x) * ((s * x) * 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[(c$95$m * c$95$m), $MachinePrecision] * x), $MachinePrecision] * N[(N[(s * x), $MachinePrecision] * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                          
                          \begin{array}{l}
                          c_m = \left|c\right|
                          \\
                          [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
                          \\
                          \frac{1}{\left(\left(c\_m \cdot c\_m\right) \cdot x\right) \cdot \left(\left(s \cdot x\right) \cdot s\right)}
                          \end{array}
                          
                          Derivation
                          1. Initial program 63.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. Taylor expanded in x around 0

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

                              \[\leadsto \frac{\color{blue}{1}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \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}{\color{blue}{\left({s}^{2} \cdot {x}^{2}\right) \cdot {c}^{2}}} \]
                              2. unpow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            Reproduce

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