mixedcos

Percentage Accurate: 67.3% → 97.4%
Time: 13.0s
Alternatives: 10
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 10 alternatives:

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

Initial Program: 67.3% accurate, 1.0× speedup?

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

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

Alternative 1: 97.4% accurate, 2.6× speedup?

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

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

    \[\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*66.0%

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

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

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

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

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

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

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

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

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

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

    \[\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 inf 62.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 86.2% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\frac{1}{c}}{s \cdot x}\\
\mathbf{if}\;x \leq 1.75 \cdot 10^{-208}:\\
\;\;\;\;t\_0 \cdot t\_0\\

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


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

    1. Initial program 64.7%

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{\left(x \cdot x\right)} \cdot \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-sqr80.7%

        \[\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. unpow280.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)} \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)}^{-1} \]
      4. unpow-prod-down80.6%

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

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

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

        \[\leadsto \color{blue}{{\left(c \cdot \left(s \cdot x\right)\right)}^{-2}} \]
      8. unpow-prod-down65.9%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{c} \cdot \frac{1}{c}}{\color{blue}{\left(s \cdot x\right) \cdot \left(s \cdot x\right)}} \]
      17. times-frac80.7%

        \[\leadsto \color{blue}{\frac{\frac{1}{c}}{s \cdot x} \cdot \frac{\frac{1}{c}}{s \cdot x}} \]
    9. Applied egg-rr80.7%

      \[\leadsto \color{blue}{\frac{\frac{1}{c}}{s \cdot x} \cdot \frac{\frac{1}{c}}{s \cdot x}} \]

    if 1.74999999999999996e-208 < x

    1. Initial program 68.7%

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

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

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

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

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

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

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

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

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

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

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

      \[\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 inf 63.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 97.3% accurate, 2.7× speedup?

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

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

    \[\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*66.0%

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

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

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

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

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

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

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

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

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

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

    \[\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 inf 62.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 97.0% accurate, 2.7× speedup?

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

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

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Add Preprocessing
  3. Applied egg-rr83.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 97.0% accurate, 2.7× speedup?

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

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

    \[\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*66.0%

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

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

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

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

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

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

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

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

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

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

    \[\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 inf 62.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 78.8% accurate, 3.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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-sqr80.0%

      \[\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. unpow280.0%

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

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

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

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

      \[\leadsto 1 \cdot \color{blue}{{\left(c \cdot \left(s \cdot x\right)\right)}^{\left(-2\right)}} \]
    3. metadata-eval80.0%

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

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

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

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

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

Alternative 7: 76.0% accurate, 17.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2.2 \cdot 10^{-210}:\\ \;\;\;\;\frac{1}{x \cdot \left(c \cdot \left(\left(s \cdot x\right) \cdot \left(c \cdot s\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(c \cdot s\right) \cdot \left(x \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (if (<= x 2.2e-210)
   (/ 1.0 (* x (* c (* (* s x) (* c s)))))
   (/ 1.0 (* (* c s) (* x (* c (* s x)))))))
double code(double x, double c, double s) {
	double tmp;
	if (x <= 2.2e-210) {
		tmp = 1.0 / (x * (c * ((s * x) * (c * s))));
	} else {
		tmp = 1.0 / ((c * s) * (x * (c * (s * x))));
	}
	return tmp;
}
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: tmp
    if (x <= 2.2d-210) then
        tmp = 1.0d0 / (x * (c * ((s * x) * (c * s))))
    else
        tmp = 1.0d0 / ((c * s) * (x * (c * (s * x))))
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double tmp;
	if (x <= 2.2e-210) {
		tmp = 1.0 / (x * (c * ((s * x) * (c * s))));
	} else {
		tmp = 1.0 / ((c * s) * (x * (c * (s * x))));
	}
	return tmp;
}
def code(x, c, s):
	tmp = 0
	if x <= 2.2e-210:
		tmp = 1.0 / (x * (c * ((s * x) * (c * s))))
	else:
		tmp = 1.0 / ((c * s) * (x * (c * (s * x))))
	return tmp
function code(x, c, s)
	tmp = 0.0
	if (x <= 2.2e-210)
		tmp = Float64(1.0 / Float64(x * Float64(c * Float64(Float64(s * x) * Float64(c * s)))));
	else
		tmp = Float64(1.0 / Float64(Float64(c * s) * Float64(x * Float64(c * Float64(s * x)))));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (x <= 2.2e-210)
		tmp = 1.0 / (x * (c * ((s * x) * (c * s))));
	else
		tmp = 1.0 / ((c * s) * (x * (c * (s * x))));
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := If[LessEqual[x, 2.2e-210], N[(1.0 / N[(x * N[(c * N[(N[(s * x), $MachinePrecision] * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(c * s), $MachinePrecision] * N[(x * N[(c * N[(s * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.2 \cdot 10^{-210}:\\
\;\;\;\;\frac{1}{x \cdot \left(c \cdot \left(\left(s \cdot x\right) \cdot \left(c \cdot s\right)\right)\right)}\\

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


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

    1. Initial program 64.7%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Applied egg-rr82.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {c}^{-2} \cdot {\left(s \cdot x\right)}^{\color{blue}{-2}} \]
      9. unpow-prod-down80.7%

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

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

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

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

        \[\leadsto \color{blue}{{\left(\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)}^{-1}} \]
      14. associate-*r*78.8%

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

        \[\leadsto {\color{blue}{\left(\left(c \cdot s\right) \cdot \left(x \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)\right)}}^{-1} \]
      16. inv-pow73.3%

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

        \[\leadsto \color{blue}{\frac{\frac{1}{c \cdot s}}{x \cdot \left(c \cdot \left(s \cdot x\right)\right)}} \]
      18. clear-num73.3%

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{x \cdot \left(c \cdot \frac{s \cdot x}{\frac{1}{c \cdot s}}\right)}} \]
      3. div-inv76.4%

        \[\leadsto \frac{1}{x \cdot \left(c \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \frac{1}{\frac{1}{c \cdot s}}\right)}\right)} \]
      4. remove-double-div76.4%

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

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

    if 2.19999999999999989e-210 < x

    1. Initial program 68.7%

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

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

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

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

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

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

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

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

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

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

        \[\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-sqr79.0%

        \[\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. unpow279.0%

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

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

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

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

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

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

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

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

Alternative 8: 75.2% accurate, 24.1× speedup?

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

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

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Add Preprocessing
  3. Applied egg-rr83.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {c}^{-2} \cdot {\left(s \cdot x\right)}^{\color{blue}{-2}} \]
    9. unpow-prod-down80.0%

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

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

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

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

      \[\leadsto \color{blue}{{\left(\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)}^{-1}} \]
    14. associate-*r*78.9%

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

      \[\leadsto {\color{blue}{\left(\left(c \cdot s\right) \cdot \left(x \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)\right)}}^{-1} \]
    16. inv-pow75.6%

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

      \[\leadsto \color{blue}{\frac{\frac{1}{c \cdot s}}{x \cdot \left(c \cdot \left(s \cdot x\right)\right)}} \]
    18. clear-num75.5%

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{c \cdot \left(x \cdot \frac{s \cdot x}{\frac{1}{c \cdot s}}\right)}} \]
    4. div-inv73.8%

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

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

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

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

Alternative 9: 75.2% accurate, 24.1× speedup?

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

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

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Add Preprocessing
  3. Applied egg-rr83.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {c}^{-2} \cdot {\left(s \cdot x\right)}^{\color{blue}{-2}} \]
    9. unpow-prod-down80.0%

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

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

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

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

      \[\leadsto \color{blue}{{\left(\left(c \cdot \left(s \cdot x\right)\right) \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)}^{-1}} \]
    14. associate-*r*78.9%

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

      \[\leadsto {\color{blue}{\left(\left(c \cdot s\right) \cdot \left(x \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)\right)}}^{-1} \]
    16. inv-pow75.6%

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

      \[\leadsto \color{blue}{\frac{\frac{1}{c \cdot s}}{x \cdot \left(c \cdot \left(s \cdot x\right)\right)}} \]
    18. clear-num75.5%

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{x \cdot \left(c \cdot \frac{s \cdot x}{\frac{1}{c \cdot s}}\right)}} \]
    3. div-inv74.9%

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

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

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

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

Alternative 10: 78.7% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\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-sqr80.0%

      \[\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. unpow280.0%

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

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

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

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

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

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

Reproduce

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