mixedcos

Percentage Accurate: 66.9% → 97.3%
Time: 14.1s
Alternatives: 6
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 6 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.9% accurate, 1.0× speedup?

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

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

Alternative 1: 97.3% accurate, 2.6× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.5% 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.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 97.3% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \left(x \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 (* c (* x s)))) (/ (/ (cos (* 2.0 x)) t_0) t_0)))
double code(double x, double c, double s) {
	double t_0 = c * (x * 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 = c * (x * 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 = c * (x * s);
	return (Math.cos((2.0 * x)) / t_0) / t_0;
}
def code(x, c, s):
	t_0 = c * (x * s)
	return (math.cos((2.0 * x)) / t_0) / t_0
function code(x, c, s)
	t_0 = Float64(c * Float64(x * s))
	return Float64(Float64(cos(Float64(2.0 * x)) / t_0) / t_0)
end
function tmp = code(x, c, s)
	t_0 = c * (x * s);
	tmp = (cos((2.0 * x)) / t_0) / t_0;
end
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * 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 := c \cdot \left(x \cdot s\right)\\
\frac{\frac{\cos \left(2 \cdot x\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 58.3% accurate, 2.8× speedup?

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

\\
\frac{\frac{\frac{1}{c}}{x \cdot s}}{c \cdot \left|x \cdot s\right|}
\end{array}
Derivation
  1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{c \cdot \sqrt{{\left(s \cdot x\right)}^{2}}} \cdot \frac{\cos \left(2 \cdot x\right)}{c \cdot \sqrt{{\left(s \cdot x\right)}^{2}}}} \]
  7. Step-by-step derivation
    1. associate-*l/85.8%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{1}{c \cdot \left|s \cdot x\right|}}}{c \cdot \left|x \cdot s\right|} \]
  10. Step-by-step derivation
    1. associate-/r*78.8%

      \[\leadsto \frac{\color{blue}{\frac{\frac{1}{c}}{\left|s \cdot x\right|}}}{c \cdot \left|x \cdot s\right|} \]
    2. *-commutative78.8%

      \[\leadsto \frac{\frac{\frac{1}{c}}{\left|\color{blue}{x \cdot s}\right|}}{c \cdot \left|x \cdot s\right|} \]
    3. rem-square-sqrt43.0%

      \[\leadsto \frac{\frac{\frac{1}{c}}{\left|\color{blue}{\sqrt{x \cdot s} \cdot \sqrt{x \cdot s}}\right|}}{c \cdot \left|x \cdot s\right|} \]
    4. fabs-sqr43.0%

      \[\leadsto \frac{\frac{\frac{1}{c}}{\color{blue}{\sqrt{x \cdot s} \cdot \sqrt{x \cdot s}}}}{c \cdot \left|x \cdot s\right|} \]
    5. rem-square-sqrt57.6%

      \[\leadsto \frac{\frac{\frac{1}{c}}{\color{blue}{x \cdot s}}}{c \cdot \left|x \cdot s\right|} \]
    6. *-commutative57.6%

      \[\leadsto \frac{\frac{\frac{1}{c}}{\color{blue}{s \cdot x}}}{c \cdot \left|x \cdot s\right|} \]
  11. Simplified57.6%

    \[\leadsto \frac{\color{blue}{\frac{\frac{1}{c}}{s \cdot x}}}{c \cdot \left|x \cdot s\right|} \]
  12. Final simplification57.6%

    \[\leadsto \frac{\frac{\frac{1}{c}}{x \cdot s}}{c \cdot \left|x \cdot s\right|} \]
  13. Add Preprocessing

Alternative 5: 78.5% 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.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\sqrt{{\left(c \cdot \left|x \cdot s\right|\right)}^{2}} \cdot \sqrt{{\left(c \cdot \left|x \cdot s\right|\right)}^{2}}}} \]
    5. add-sqr-sqrt78.8%

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

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

      \[\leadsto {\left(c \cdot \left|\color{blue}{\sqrt{x \cdot s} \cdot \sqrt{x \cdot s}}\right|\right)}^{\left(-2\right)} \]
    8. fabs-sqr43.0%

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

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

      \[\leadsto {\left(c \cdot \left(x \cdot s\right)\right)}^{\color{blue}{-2}} \]
  9. Applied egg-rr78.8%

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

Alternative 6: 78.4% 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.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\sqrt{{\left(c \cdot \left|x \cdot s\right|\right)}^{2}} \cdot \sqrt{{\left(c \cdot \left|x \cdot s\right|\right)}^{2}}}} \]
    5. add-sqr-sqrt78.8%

      \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left|x \cdot s\right|\right)}^{2}}} \]
    6. unpow278.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. add-sqr-sqrt43.0%

      \[\leadsto \frac{1}{\left(c \cdot \left|\color{blue}{\sqrt{x \cdot s} \cdot \sqrt{x \cdot s}}\right|\right) \cdot \left(c \cdot \left|x \cdot s\right|\right)} \]
    8. fabs-sqr43.0%

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

      \[\leadsto \frac{1}{\left(c \cdot \color{blue}{\left(x \cdot s\right)}\right) \cdot \left(c \cdot \left|x \cdot s\right|\right)} \]
    10. add-sqr-sqrt37.0%

      \[\leadsto \frac{1}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(c \cdot \left|\color{blue}{\sqrt{x \cdot s} \cdot \sqrt{x \cdot s}}\right|\right)} \]
    11. fabs-sqr37.0%

      \[\leadsto \frac{1}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(c \cdot \color{blue}{\left(\sqrt{x \cdot s} \cdot \sqrt{x \cdot s}\right)}\right)} \]
    12. add-sqr-sqrt78.8%

      \[\leadsto \frac{1}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(c \cdot \color{blue}{\left(x \cdot s\right)}\right)} \]
  9. Applied egg-rr78.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)}} \]
  10. Add Preprocessing

Reproduce

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