mixedcos

Percentage Accurate: 66.8% → 99.1%
Time: 14.8s
Alternatives: 8
Speedup: 24.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 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.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.1% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 81.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{\left(-c\right)}^{2}}}{x \cdot \left(x \cdot {s}^{2}\right)} \]
      8. distribute-rgt-neg-in81.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\cos \color{blue}{\left(\sqrt{2 \cdot x} \cdot \sqrt{2 \cdot x}\right)}}{\left({s}^{2} \cdot {x}^{2}\right) \cdot {c}^{2}} \]
      13. add-sqr-sqrt72.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(c \cdot \left(s \cdot x\right)\right)}^{-2} \cdot \cos \left(x \cdot 2\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. Step-by-step derivation
      1. associate-/r*0.0%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{\left(-c\right)}^{2}}}{x \cdot \left(x \cdot {s}^{2}\right)} \]
      8. distribute-rgt-neg-in0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(c \cdot \left(s \cdot x\right)\right)}^{-2} \cdot \cos \left(x \cdot 2\right)} \]
    10. Step-by-step derivation
      1. *-un-lft-identity79.6%

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

      \[\leadsto \color{blue}{\left(1 \cdot {\left(c \cdot \left(s \cdot x\right)\right)}^{-2}\right)} \cdot \cos \left(x \cdot 2\right) \]
    12. Step-by-step derivation
      1. *-lft-identity79.6%

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

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

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

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

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

Alternative 2: 86.7% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{-8}:\\
\;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\

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


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

    1. Initial program 63.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{\left(c \cdot x\right) \cdot s} \cdot \frac{1}{\left(c \cdot x\right) \cdot s}} \]
      12. unpow-182.4%

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

        \[\leadsto {\left(\left(c \cdot x\right) \cdot s\right)}^{-1} \cdot \color{blue}{{\left(\left(c \cdot x\right) \cdot s\right)}^{-1}} \]
      14. pow-sqr82.4%

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

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

        \[\leadsto {\left(c \cdot \color{blue}{\left(s \cdot x\right)}\right)}^{\left(2 \cdot -1\right)} \]
      17. metadata-eval82.7%

        \[\leadsto {\left(c \cdot \left(s \cdot x\right)\right)}^{\color{blue}{-2}} \]
    10. Simplified82.7%

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

    if 2e-8 < x

    1. Initial program 67.9%

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{\left(-c\right)}^{2}}}{x \cdot \left(x \cdot {s}^{2}\right)} \]
      8. distribute-rgt-neg-in68.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(c \cdot \left(s \cdot x\right)\right)}^{-2} \cdot \cos \left(x \cdot 2\right)} \]
    10. Step-by-step derivation
      1. *-un-lft-identity95.6%

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

      \[\leadsto \color{blue}{\left(1 \cdot {\left(c \cdot \left(s \cdot x\right)\right)}^{-2}\right)} \cdot \cos \left(x \cdot 2\right) \]
    12. Step-by-step derivation
      1. *-lft-identity95.6%

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\left(c \cdot x\right) \cdot s\right)}^{\color{blue}{\left(-1 + -1\right)}} \cdot \cos \left(x \cdot 2\right) \]
      6. pow-prod-up98.1%

        \[\leadsto \color{blue}{\left({\left(\left(c \cdot x\right) \cdot s\right)}^{-1} \cdot {\left(\left(c \cdot x\right) \cdot s\right)}^{-1}\right)} \cdot \cos \left(x \cdot 2\right) \]
      7. inv-pow98.1%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 97.3% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(c \cdot s\right)\\ \frac{\frac{\cos \left(2 \cdot x\right)}{t\_0}}{t\_0} \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* x (* c s)))) (/ (/ (cos (* 2.0 x)) t_0) t_0)))
double code(double x, double c, double s) {
	double t_0 = x * (c * s);
	return (cos((2.0 * 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((2.0d0 * 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((2.0 * x)) / t_0) / t_0;
}
def code(x, c, s):
	t_0 = x * (c * s)
	return (math.cos((2.0 * x)) / t_0) / t_0
function code(x, c, s)
	t_0 = Float64(x * Float64(c * s))
	return Float64(Float64(cos(Float64(2.0 * x)) / t_0) / t_0)
end
function tmp = code(x, c, s)
	t_0 = x * (c * s);
	tmp = (cos((2.0 * x)) / t_0) / t_0;
end
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{\left(-c\right)}^{2}}}{x \cdot \left(x \cdot {s}^{2}\right)} \]
    8. distribute-rgt-neg-in65.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{\left(c \cdot \left(s \cdot x\right)\right)}^{-2} \cdot \cos \left(x \cdot 2\right)} \]
  10. Step-by-step derivation
    1. *-un-lft-identity95.6%

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

    \[\leadsto \color{blue}{\left(1 \cdot {\left(c \cdot \left(s \cdot x\right)\right)}^{-2}\right)} \cdot \cos \left(x \cdot 2\right) \]
  12. Step-by-step derivation
    1. *-lft-identity95.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 78.2% accurate, 3.0× speedup?

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

\\
{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}
\end{array}
Derivation
  1. Initial program 65.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{\left(-c\right)}^{2}}}{x \cdot \left(x \cdot {s}^{2}\right)} \]
    8. distribute-rgt-neg-in65.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\left(c \cdot x\right) \cdot s} \cdot \frac{1}{\left(c \cdot x\right) \cdot s}} \]
    12. unpow-177.8%

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

      \[\leadsto {\left(\left(c \cdot x\right) \cdot s\right)}^{-1} \cdot \color{blue}{{\left(\left(c \cdot x\right) \cdot s\right)}^{-1}} \]
    14. pow-sqr77.9%

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

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

      \[\leadsto {\left(c \cdot \color{blue}{\left(s \cdot x\right)}\right)}^{\left(2 \cdot -1\right)} \]
    17. metadata-eval77.9%

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

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

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

Alternative 5: 78.1% accurate, 18.4× speedup?

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

\\
\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \left(\frac{1}{c} \cdot \frac{\frac{1}{s}}{x}\right)
\end{array}
Derivation
  1. Initial program 65.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{\left(-c\right)}^{2}}}{x \cdot \left(x \cdot {s}^{2}\right)} \]
    8. distribute-rgt-neg-in65.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 78.2% accurate, 20.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{c \cdot \left(x \cdot s\right)}\\ t\_0 \cdot t\_0 \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (/ 1.0 (* c (* x s))))) (* t_0 t_0)))
double code(double x, double c, double s) {
	double t_0 = 1.0 / (c * (x * s));
	return 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 = 1.0d0 / (c * (x * s))
    code = t_0 * t_0
end function
public static double code(double x, double c, double s) {
	double t_0 = 1.0 / (c * (x * s));
	return t_0 * t_0;
}
def code(x, c, s):
	t_0 = 1.0 / (c * (x * s))
	return t_0 * t_0
function code(x, c, s)
	t_0 = Float64(1.0 / Float64(c * Float64(x * s)))
	return Float64(t_0 * t_0)
end
function tmp = code(x, c, s)
	t_0 = 1.0 / (c * (x * s));
	tmp = t_0 * t_0;
end
code[x_, c_, s_] := Block[{t$95$0 = N[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0), $MachinePrecision]]
\begin{array}{l}

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{\left(-c\right)}^{2}}}{x \cdot \left(x \cdot {s}^{2}\right)} \]
    8. distribute-rgt-neg-in65.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 78.2% accurate, 24.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ \frac{\frac{1}{t\_0}}{t\_0} \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* c (* x s)))) (/ (/ 1.0 t_0) t_0)))
double code(double x, double c, double s) {
	double t_0 = c * (x * 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 = c * (x * s)
    code = (1.0d0 / t_0) / t_0
end function
public static double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	return (1.0 / t_0) / t_0;
}
def code(x, c, s):
	t_0 = c * (x * s)
	return (1.0 / t_0) / t_0
function code(x, c, s)
	t_0 = Float64(c * Float64(x * s))
	return Float64(Float64(1.0 / t_0) / t_0)
end
function tmp = code(x, c, s)
	t_0 = c * (x * s);
	tmp = (1.0 / t_0) / t_0;
end
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{\left(-c\right)}^{2}}}{x \cdot \left(x \cdot {s}^{2}\right)} \]
    8. distribute-rgt-neg-in65.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 78.1% accurate, 24.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ \frac{1}{t\_0 \cdot t\_0} \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* c (* x s)))) (/ 1.0 (* t_0 t_0))))
double code(double x, double c, double s) {
	double t_0 = c * (x * 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 = c * (x * s)
    code = 1.0d0 / (t_0 * t_0)
end function
public static double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	return 1.0 / (t_0 * t_0);
}
def code(x, c, s):
	t_0 = c * (x * s)
	return 1.0 / (t_0 * t_0)
function code(x, c, s)
	t_0 = Float64(c * Float64(x * s))
	return Float64(1.0 / Float64(t_0 * t_0))
end
function tmp = code(x, c, s)
	t_0 = c * (x * s);
	tmp = 1.0 / (t_0 * t_0);
end
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{\cos \left(-\color{blue}{x \cdot 2}\right)}{{\left(-c\right)}^{2}}}{x \cdot \left(x \cdot {s}^{2}\right)} \]
    8. distribute-rgt-neg-in65.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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