mixedcos

Percentage Accurate: 67.3% → 96.9%
Time: 10.3s
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: 96.9% accurate, 2.7× speedup?

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

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

    \[\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. *-commutative70.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 77.4% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;{s}^{2} \leq 5 \cdot 10^{+153}:\\
\;\;\;\;\frac{\cos \left(2 \cdot x\right)}{s \cdot \left(\left(c \cdot c\right) \cdot \left(s \cdot \left(x \cdot x\right)\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (pow.f64 s 2) < 5.00000000000000018e153

    1. Initial program 74.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. *-commutative74.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000000000000018e153 < (pow.f64 s 2)

    1. Initial program 62.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. *-commutative62.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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} \]
      10. pow-prod-down91.9%

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

        \[\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} \]
      12. metadata-eval91.9%

        \[\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)}} \]
      13. pow291.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{s}^{2} \leq 5 \cdot 10^{+153}:\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{s \cdot \left(\left(c \cdot c\right) \cdot \left(s \cdot \left(x \cdot x\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{1}{c \cdot \left(x \cdot s\right)}\right)}^{2}\\ \end{array} \]

Alternative 3: 72.2% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;s \leq 1.08 \cdot 10^{+123}:\\
\;\;\;\;\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \left(\left(s \cdot s\right) \cdot \left(c \cdot c\right)\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if s < 1.0799999999999999e123

    1. Initial program 71.0%

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

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

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

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

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

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

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

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

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

    if 1.0799999999999999e123 < s

    1. Initial program 65.1%

      \[\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. *-commutative65.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(c \cdot s\right)}^{-2} \cdot {x}^{\color{blue}{-2}} \]
      13. unpow-prod-down95.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;s \leq 1.08 \cdot 10^{+123}:\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \left(\left(s \cdot s\right) \cdot \left(c \cdot c\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}\\ \end{array} \]

Alternative 4: 79.0% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;s \leq 1.9 \cdot 10^{+144}:\\
\;\;\;\;\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(\left(c \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot s\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if s < 1.90000000000000013e144

    1. Initial program 70.9%

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

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

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

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

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

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

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

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

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

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

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

    if 1.90000000000000013e144 < s

    1. Initial program 64.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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} \]
      10. pow-prod-down99.9%

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

        \[\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} \]
      12. metadata-eval99.9%

        \[\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)}} \]
      13. pow299.9%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;s \leq 1.9 \cdot 10^{+144}:\\ \;\;\;\;\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(\left(c \cdot \left(x \cdot c\right)\right) \cdot \left(s \cdot s\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{1}{c \cdot \left(x \cdot s\right)}\right)}^{2}\\ \end{array} \]

Alternative 5: 94.6% accurate, 2.7× speedup?

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

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

    \[\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. *-commutative70.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 78.5% accurate, 2.9× speedup?

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

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

    \[\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. *-commutative70.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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} \]
    10. pow-prod-down79.7%

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

      \[\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} \]
    12. metadata-eval79.7%

      \[\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)}} \]
    13. pow279.7%

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

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

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

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

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

Alternative 7: 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 70.3%

    \[\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. *-commutative70.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 55.0% accurate, 24.1× speedup?

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

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

    \[\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. *-commutative70.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 77.1% accurate, 24.1× speedup?

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

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

    \[\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. *-commutative70.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 78.2% accurate, 24.1× speedup?

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

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

    \[\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. *-commutative70.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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