mixedcos

Percentage Accurate: 66.3% → 97.5%
Time: 7.7s
Alternatives: 11
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 11 alternatives:

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

Initial Program: 66.3% accurate, 1.0× speedup?

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

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

Alternative 1: 97.5% accurate, 2.4× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 96.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(x + x\right)\\ \mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \leq \infty:\\ \;\;\;\;\frac{t\_0}{\left(\left(x \cdot c\right) \cdot s\right) \cdot \left(\left(s \cdot x\right) \cdot c\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_0}{x \cdot \left(\left(s \cdot c\right) \cdot \left(\left(c \cdot x\right) \cdot s\right)\right)}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (cos (+ x x))))
   (if (<=
        (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x)))
        INFINITY)
     (/ t_0 (* (* (* x c) s) (* (* s x) c)))
     (/ t_0 (* x (* (* s c) (* (* c x) s)))))))
double code(double x, double c, double s) {
	double t_0 = cos((x + x));
	double tmp;
	if ((cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x))) <= ((double) INFINITY)) {
		tmp = t_0 / (((x * c) * s) * ((s * x) * c));
	} else {
		tmp = t_0 / (x * ((s * c) * ((c * x) * s)));
	}
	return tmp;
}
public static double code(double x, double c, double s) {
	double t_0 = Math.cos((x + x));
	double tmp;
	if ((Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x))) <= Double.POSITIVE_INFINITY) {
		tmp = t_0 / (((x * c) * s) * ((s * x) * c));
	} else {
		tmp = t_0 / (x * ((s * c) * ((c * x) * s)));
	}
	return tmp;
}
def code(x, c, s):
	t_0 = math.cos((x + x))
	tmp = 0
	if (math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))) <= math.inf:
		tmp = t_0 / (((x * c) * s) * ((s * x) * c))
	else:
		tmp = t_0 / (x * ((s * c) * ((c * x) * s)))
	return tmp
function code(x, c, s)
	t_0 = cos(Float64(x + x))
	tmp = 0.0
	if (Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) <= Inf)
		tmp = Float64(t_0 / Float64(Float64(Float64(x * c) * s) * Float64(Float64(s * x) * c)));
	else
		tmp = Float64(t_0 / Float64(x * Float64(Float64(s * c) * Float64(Float64(c * x) * s))));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	t_0 = cos((x + x));
	tmp = 0.0;
	if ((cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x))) <= Inf)
		tmp = t_0 / (((x * c) * s) * ((s * x) * c));
	else
		tmp = t_0 / (x * ((s * c) * ((c * x) * s)));
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := Block[{t$95$0 = N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[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], Infinity], N[(t$95$0 / N[(N[(N[(x * c), $MachinePrecision] * s), $MachinePrecision] * N[(N[(s * x), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(x * N[(N[(s * c), $MachinePrecision] * N[(N[(c * x), $MachinePrecision] * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(x + x\right)\\
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \leq \infty:\\
\;\;\;\;\frac{t\_0}{\left(\left(x \cdot c\right) \cdot s\right) \cdot \left(\left(s \cdot x\right) \cdot c\right)}\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\cos \left(x + x\right)}{x \cdot \color{blue}{\left(\left(s \cdot c\right) \cdot \left(\left(c \cdot x\right) \cdot s\right)\right)}} \]
      9. Recombined 2 regimes into one program.
      10. Add Preprocessing

      Alternative 3: 82.2% accurate, 0.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x \cdot c\right) \cdot s\\ \mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \leq -2 \cdot 10^{-221}:\\ \;\;\;\;\frac{-2 \cdot \left(x \cdot x\right)}{t\_0 \cdot t\_0}\\ \mathbf{else}:\\ \;\;\;\;{\left(\left(s \cdot x\right) \cdot c\right)}^{-2}\\ \end{array} \end{array} \]
      (FPCore (x c s)
       :precision binary64
       (let* ((t_0 (* (* x c) s)))
         (if (<= (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))) -2e-221)
           (/ (* -2.0 (* x x)) (* t_0 t_0))
           (pow (* (* s x) c) -2.0))))
      double code(double x, double c, double s) {
      	double t_0 = (x * c) * s;
      	double tmp;
      	if ((cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x))) <= -2e-221) {
      		tmp = (-2.0 * (x * x)) / (t_0 * t_0);
      	} else {
      		tmp = pow(((s * x) * c), -2.0);
      	}
      	return tmp;
      }
      
      real(8) function code(x, c, s)
          real(8), intent (in) :: x
          real(8), intent (in) :: c
          real(8), intent (in) :: s
          real(8) :: t_0
          real(8) :: tmp
          t_0 = (x * c) * s
          if ((cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))) <= (-2d-221)) then
              tmp = ((-2.0d0) * (x * x)) / (t_0 * t_0)
          else
              tmp = ((s * x) * c) ** (-2.0d0)
          end if
          code = tmp
      end function
      
      public static double code(double x, double c, double s) {
      	double t_0 = (x * c) * s;
      	double tmp;
      	if ((Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x))) <= -2e-221) {
      		tmp = (-2.0 * (x * x)) / (t_0 * t_0);
      	} else {
      		tmp = Math.pow(((s * x) * c), -2.0);
      	}
      	return tmp;
      }
      
      def code(x, c, s):
      	t_0 = (x * c) * s
      	tmp = 0
      	if (math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))) <= -2e-221:
      		tmp = (-2.0 * (x * x)) / (t_0 * t_0)
      	else:
      		tmp = math.pow(((s * x) * c), -2.0)
      	return tmp
      
      function code(x, c, s)
      	t_0 = Float64(Float64(x * c) * s)
      	tmp = 0.0
      	if (Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) <= -2e-221)
      		tmp = Float64(Float64(-2.0 * Float64(x * x)) / Float64(t_0 * t_0));
      	else
      		tmp = Float64(Float64(s * x) * c) ^ -2.0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, c, s)
      	t_0 = (x * c) * s;
      	tmp = 0.0;
      	if ((cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x))) <= -2e-221)
      		tmp = (-2.0 * (x * x)) / (t_0 * t_0);
      	else
      		tmp = ((s * x) * c) ^ -2.0;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, c_, s_] := Block[{t$95$0 = N[(N[(x * c), $MachinePrecision] * s), $MachinePrecision]}, If[LessEqual[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], -2e-221], N[(N[(-2.0 * N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[Power[N[(N[(s * x), $MachinePrecision] * c), $MachinePrecision], -2.0], $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \left(x \cdot c\right) \cdot s\\
      \mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \leq -2 \cdot 10^{-221}:\\
      \;\;\;\;\frac{-2 \cdot \left(x \cdot x\right)}{t\_0 \cdot t\_0}\\
      
      \mathbf{else}:\\
      \;\;\;\;{\left(\left(s \cdot x\right) \cdot c\right)}^{-2}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < -2.00000000000000003e-221

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          if -2.00000000000000003e-221 < (/.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 70.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 \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
          4. Step-by-step derivation
            1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto {\left(\left(s \cdot x\right) \cdot c\right)}^{-2} \]
            3. Recombined 2 regimes into one program.
            4. Add Preprocessing

            Alternative 4: 82.4% accurate, 0.7× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(x \cdot c\right) \cdot s\\ \mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \leq -2 \cdot 10^{-221}:\\ \;\;\;\;\frac{-2 \cdot \left(x \cdot x\right)}{t\_0 \cdot t\_0}\\ \mathbf{else}:\\ \;\;\;\;{\left(\left(c \cdot x\right) \cdot s\right)}^{-2}\\ \end{array} \end{array} \]
            (FPCore (x c s)
             :precision binary64
             (let* ((t_0 (* (* x c) s)))
               (if (<= (/ (cos (* 2.0 x)) (* (pow c 2.0) (* (* x (pow s 2.0)) x))) -2e-221)
                 (/ (* -2.0 (* x x)) (* t_0 t_0))
                 (pow (* (* c x) s) -2.0))))
            double code(double x, double c, double s) {
            	double t_0 = (x * c) * s;
            	double tmp;
            	if ((cos((2.0 * x)) / (pow(c, 2.0) * ((x * pow(s, 2.0)) * x))) <= -2e-221) {
            		tmp = (-2.0 * (x * x)) / (t_0 * t_0);
            	} else {
            		tmp = pow(((c * x) * s), -2.0);
            	}
            	return tmp;
            }
            
            real(8) function code(x, c, s)
                real(8), intent (in) :: x
                real(8), intent (in) :: c
                real(8), intent (in) :: s
                real(8) :: t_0
                real(8) :: tmp
                t_0 = (x * c) * s
                if ((cos((2.0d0 * x)) / ((c ** 2.0d0) * ((x * (s ** 2.0d0)) * x))) <= (-2d-221)) then
                    tmp = ((-2.0d0) * (x * x)) / (t_0 * t_0)
                else
                    tmp = ((c * x) * s) ** (-2.0d0)
                end if
                code = tmp
            end function
            
            public static double code(double x, double c, double s) {
            	double t_0 = (x * c) * s;
            	double tmp;
            	if ((Math.cos((2.0 * x)) / (Math.pow(c, 2.0) * ((x * Math.pow(s, 2.0)) * x))) <= -2e-221) {
            		tmp = (-2.0 * (x * x)) / (t_0 * t_0);
            	} else {
            		tmp = Math.pow(((c * x) * s), -2.0);
            	}
            	return tmp;
            }
            
            def code(x, c, s):
            	t_0 = (x * c) * s
            	tmp = 0
            	if (math.cos((2.0 * x)) / (math.pow(c, 2.0) * ((x * math.pow(s, 2.0)) * x))) <= -2e-221:
            		tmp = (-2.0 * (x * x)) / (t_0 * t_0)
            	else:
            		tmp = math.pow(((c * x) * s), -2.0)
            	return tmp
            
            function code(x, c, s)
            	t_0 = Float64(Float64(x * c) * s)
            	tmp = 0.0
            	if (Float64(cos(Float64(2.0 * x)) / Float64((c ^ 2.0) * Float64(Float64(x * (s ^ 2.0)) * x))) <= -2e-221)
            		tmp = Float64(Float64(-2.0 * Float64(x * x)) / Float64(t_0 * t_0));
            	else
            		tmp = Float64(Float64(c * x) * s) ^ -2.0;
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, c, s)
            	t_0 = (x * c) * s;
            	tmp = 0.0;
            	if ((cos((2.0 * x)) / ((c ^ 2.0) * ((x * (s ^ 2.0)) * x))) <= -2e-221)
            		tmp = (-2.0 * (x * x)) / (t_0 * t_0);
            	else
            		tmp = ((c * x) * s) ^ -2.0;
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, c_, s_] := Block[{t$95$0 = N[(N[(x * c), $MachinePrecision] * s), $MachinePrecision]}, If[LessEqual[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], -2e-221], N[(N[(-2.0 * N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], N[Power[N[(N[(c * x), $MachinePrecision] * s), $MachinePrecision], -2.0], $MachinePrecision]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := \left(x \cdot c\right) \cdot s\\
            \mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \leq -2 \cdot 10^{-221}:\\
            \;\;\;\;\frac{-2 \cdot \left(x \cdot x\right)}{t\_0 \cdot t\_0}\\
            
            \mathbf{else}:\\
            \;\;\;\;{\left(\left(c \cdot x\right) \cdot s\right)}^{-2}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < -2.00000000000000003e-221

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                if -2.00000000000000003e-221 < (/.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 70.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 \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
                4. Step-by-step derivation
                  1. associate-*r*N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{{\left(\left(c \cdot x\right) \cdot s\right)}^{-2}} \]
                7. Recombined 2 regimes into one program.
                8. Add Preprocessing

                Alternative 5: 82.3% accurate, 0.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    if -2.00000000000000003e-221 < (/.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 70.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{\cos \left(2 \cdot x\right)}{\color{blue}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
                    4. Step-by-step derivation
                      1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    Alternative 6: 87.6% accurate, 2.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                          if 4.99999999999999997e-56 < x

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            Alternative 7: 86.7% accurate, 2.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                  if 1.16e-17 < x

                                  1. Initial program 70.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                      \[\leadsto \frac{\cos \left(x + x\right)}{x \cdot \color{blue}{\left(\left(s \cdot c\right) \cdot \left(\left(c \cdot x\right) \cdot s\right)\right)}} \]
                                  9. Recombined 2 regimes into one program.
                                  10. Add Preprocessing

                                  Alternative 8: 78.9% accurate, 9.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    Alternative 9: 75.4% accurate, 9.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                        Alternative 10: 74.3% accurate, 9.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                            Alternative 11: 70.4% accurate, 9.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                  Reproduce

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