mixedcos

Percentage Accurate: 66.0% → 96.8%
Time: 15.8s
Alternatives: 14
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 14 alternatives:

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

Initial Program: 66.0% 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.8% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
t_0 := x \cdot \left(s \cdot c\right)\\
\frac{\frac{\cos \left(x \cdot 2\right)}{t_0}}{t_0}
\end{array}
\end{array}
Derivation
  1. Initial program 69.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*69.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 81.8% accurate, 2.7× speedup?

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

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

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


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

    1. Initial program 71.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.4500000000000001e-8 < x

    1. Initial program 65.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 84.5% accurate, 2.7× speedup?

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

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

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


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

    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.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.8e-51 < x

    1. Initial program 68.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*68.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 96.9% accurate, 2.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 63.8% accurate, 2.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < 2.90000000000000006e-289

    1. Initial program 69.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.90000000000000006e-289 < c

    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. associate-/r*70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 63.9% accurate, 2.9× speedup?

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

    1. Initial program 69.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.90000000000000006e-289 < c

    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. associate-/r*70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 63.8% accurate, 14.9× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{1}{c \cdot \left(x \cdot s\right)}\\
\mathbf{if}\;c \leq 2.9 \cdot 10^{-289}:\\
\;\;\;\;\frac{1 + -2 \cdot \left(x \cdot x\right)}{x \cdot \left(x \cdot \left(c \cdot \left(c \cdot \left(s \cdot s\right)\right)\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;t_0 \cdot t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < 2.90000000000000006e-289

    1. Initial program 69.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.90000000000000006e-289 < c

    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. associate-/r*70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 64.3% accurate, 20.8× speedup?

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

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

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


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

    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.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.80000000000000003e-51 < x

    1. Initial program 68.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*68.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.8 \cdot 10^{-51}:\\ \;\;\;\;\frac{1}{x \cdot \left(\left(c \cdot c\right) \cdot \left(s \cdot \left(x \cdot s\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot \left(x \cdot \left(c \cdot \left(c \cdot \left(s \cdot s\right)\right)\right)\right)}\\ \end{array} \]

Alternative 9: 78.5% accurate, 20.9× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{1}{c \cdot \left(x \cdot s\right)}\\
t_0 \cdot t_0
\end{array}
\end{array}
Derivation
  1. Initial program 69.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*69.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 63.5% accurate, 24.1× speedup?

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

\\
\frac{1}{x \cdot \left(x \cdot \left(c \cdot \left(c \cdot \left(s \cdot s\right)\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 69.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*69.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 78.3% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 77.0% accurate, 24.1× speedup?

\[\begin{array}{l} \\ \frac{\frac{1}{c \cdot \left(x \cdot s\right)}}{x \cdot \left(s \cdot c\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(Float64(1.0 / 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[(N[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{1}{c \cdot \left(x \cdot s\right)}}{x \cdot \left(s \cdot c\right)}
\end{array}
Derivation
  1. Initial program 69.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*69.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 78.0% accurate, 24.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(s \cdot c\right)\\ \frac{\frac{1}{t_0}}{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(Float64(1.0 / 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[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \left(s \cdot c\right)\\
\frac{\frac{1}{t_0}}{t_0}
\end{array}
\end{array}
Derivation
  1. Initial program 69.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*69.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 27.6% accurate, 34.8× speedup?

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

\\
\frac{-2}{\left(s \cdot s\right) \cdot \left(c \cdot c\right)}
\end{array}
Derivation
  1. Initial program 69.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*69.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{1 + -2 \cdot \left(x \cdot x\right)}}{\left(x \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot \left(c \cdot s\right)\right)} \]
  7. Taylor expanded in x around inf 27.2%

    \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
  8. Step-by-step derivation
    1. unpow227.2%

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

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

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

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

Reproduce

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