mixedcos

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

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

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

Alternative 1: 97.3% accurate, 2.7× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\ \\ \begin{array}{l} t_0 := \left(x \cdot c\_m\right) \cdot s\_m\\ \frac{\frac{\cos \left(x \cdot 2\right)}{t\_0}}{t\_0} \end{array} \end{array} \]
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
 :precision binary64
 (let* ((t_0 (* (* x c_m) s_m))) (/ (/ (cos (* x 2.0)) t_0) t_0)))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
	double t_0 = (x * c_m) * s_m;
	return (cos((x * 2.0)) / t_0) / t_0;
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s_m
    real(8) :: t_0
    t_0 = (x * c_m) * s_m
    code = (cos((x * 2.0d0)) / t_0) / t_0
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
	double t_0 = (x * c_m) * s_m;
	return (Math.cos((x * 2.0)) / t_0) / t_0;
}
c_m = math.fabs(c)
s_m = math.fabs(s)
[x, c_m, s_m] = sort([x, c_m, s_m])
def code(x, c_m, s_m):
	t_0 = (x * c_m) * s_m
	return (math.cos((x * 2.0)) / t_0) / t_0
c_m = abs(c)
s_m = abs(s)
x, c_m, s_m = sort([x, c_m, s_m])
function code(x, c_m, s_m)
	t_0 = Float64(Float64(x * c_m) * s_m)
	return Float64(Float64(cos(Float64(x * 2.0)) / t_0) / t_0)
end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
	t_0 = (x * c_m) * s_m;
	tmp = (cos((x * 2.0)) / t_0) / t_0;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(N[(x * c$95$m), $MachinePrecision] * s$95$m), $MachinePrecision]}, N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := \left(x \cdot c\_m\right) \cdot s\_m\\
\frac{\frac{\cos \left(x \cdot 2\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 66.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 88.3% accurate, 2.6× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\ \\ \begin{array}{l} t_0 := c\_m \cdot \left(x \cdot s\_m\right)\\ \mathbf{if}\;x \leq 4 \cdot 10^{-49}:\\ \;\;\;\;\frac{\frac{1}{t\_0}}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{s\_m}}{\left(x \cdot c\_m\right) \cdot \left(x \cdot \left(c\_m \cdot s\_m\right)\right)}\\ \end{array} \end{array} \]
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
 :precision binary64
 (let* ((t_0 (* c_m (* x s_m))))
   (if (<= x 4e-49)
     (/ (/ 1.0 t_0) t_0)
     (/ (/ (cos (* x 2.0)) s_m) (* (* x c_m) (* x (* c_m s_m)))))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
	double t_0 = c_m * (x * s_m);
	double tmp;
	if (x <= 4e-49) {
		tmp = (1.0 / t_0) / t_0;
	} else {
		tmp = (cos((x * 2.0)) / s_m) / ((x * c_m) * (x * (c_m * s_m)));
	}
	return tmp;
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = c_m * (x * s_m)
    if (x <= 4d-49) then
        tmp = (1.0d0 / t_0) / t_0
    else
        tmp = (cos((x * 2.0d0)) / s_m) / ((x * c_m) * (x * (c_m * s_m)))
    end if
    code = tmp
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
	double t_0 = c_m * (x * s_m);
	double tmp;
	if (x <= 4e-49) {
		tmp = (1.0 / t_0) / t_0;
	} else {
		tmp = (Math.cos((x * 2.0)) / s_m) / ((x * c_m) * (x * (c_m * s_m)));
	}
	return tmp;
}
c_m = math.fabs(c)
s_m = math.fabs(s)
[x, c_m, s_m] = sort([x, c_m, s_m])
def code(x, c_m, s_m):
	t_0 = c_m * (x * s_m)
	tmp = 0
	if x <= 4e-49:
		tmp = (1.0 / t_0) / t_0
	else:
		tmp = (math.cos((x * 2.0)) / s_m) / ((x * c_m) * (x * (c_m * s_m)))
	return tmp
c_m = abs(c)
s_m = abs(s)
x, c_m, s_m = sort([x, c_m, s_m])
function code(x, c_m, s_m)
	t_0 = Float64(c_m * Float64(x * s_m))
	tmp = 0.0
	if (x <= 4e-49)
		tmp = Float64(Float64(1.0 / t_0) / t_0);
	else
		tmp = Float64(Float64(cos(Float64(x * 2.0)) / s_m) / Float64(Float64(x * c_m) * Float64(x * Float64(c_m * s_m))));
	end
	return tmp
end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
	t_0 = c_m * (x * s_m);
	tmp = 0.0;
	if (x <= 4e-49)
		tmp = (1.0 / t_0) / t_0;
	else
		tmp = (cos((x * 2.0)) / s_m) / ((x * c_m) * (x * (c_m * s_m)));
	end
	tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 4e-49], N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / s$95$m), $MachinePrecision] / N[(N[(x * c$95$m), $MachinePrecision] * N[(x * N[(c$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x \cdot s\_m\right)\\
\mathbf{if}\;x \leq 4 \cdot 10^{-49}:\\
\;\;\;\;\frac{\frac{1}{t\_0}}{t\_0}\\

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


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

    1. Initial program 68.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.99999999999999975e-49 < x

    1. Initial program 61.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*61.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 86.5% accurate, 2.6× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\ \\ \begin{array}{l} t_0 := c\_m \cdot \left(x \cdot s\_m\right)\\ \mathbf{if}\;x \leq 1.04 \cdot 10^{-82}:\\ \;\;\;\;\frac{\frac{1}{t\_0}}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{c\_m}}{\left(\left(x \cdot c\_m\right) \cdot s\_m\right) \cdot \left(x \cdot s\_m\right)}\\ \end{array} \end{array} \]
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
 :precision binary64
 (let* ((t_0 (* c_m (* x s_m))))
   (if (<= x 1.04e-82)
     (/ (/ 1.0 t_0) t_0)
     (/ (/ (cos (* x 2.0)) c_m) (* (* (* x c_m) s_m) (* x s_m))))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
	double t_0 = c_m * (x * s_m);
	double tmp;
	if (x <= 1.04e-82) {
		tmp = (1.0 / t_0) / t_0;
	} else {
		tmp = (cos((x * 2.0)) / c_m) / (((x * c_m) * s_m) * (x * s_m));
	}
	return tmp;
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s_m
    real(8) :: t_0
    real(8) :: tmp
    t_0 = c_m * (x * s_m)
    if (x <= 1.04d-82) then
        tmp = (1.0d0 / t_0) / t_0
    else
        tmp = (cos((x * 2.0d0)) / c_m) / (((x * c_m) * s_m) * (x * s_m))
    end if
    code = tmp
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
	double t_0 = c_m * (x * s_m);
	double tmp;
	if (x <= 1.04e-82) {
		tmp = (1.0 / t_0) / t_0;
	} else {
		tmp = (Math.cos((x * 2.0)) / c_m) / (((x * c_m) * s_m) * (x * s_m));
	}
	return tmp;
}
c_m = math.fabs(c)
s_m = math.fabs(s)
[x, c_m, s_m] = sort([x, c_m, s_m])
def code(x, c_m, s_m):
	t_0 = c_m * (x * s_m)
	tmp = 0
	if x <= 1.04e-82:
		tmp = (1.0 / t_0) / t_0
	else:
		tmp = (math.cos((x * 2.0)) / c_m) / (((x * c_m) * s_m) * (x * s_m))
	return tmp
c_m = abs(c)
s_m = abs(s)
x, c_m, s_m = sort([x, c_m, s_m])
function code(x, c_m, s_m)
	t_0 = Float64(c_m * Float64(x * s_m))
	tmp = 0.0
	if (x <= 1.04e-82)
		tmp = Float64(Float64(1.0 / t_0) / t_0);
	else
		tmp = Float64(Float64(cos(Float64(x * 2.0)) / c_m) / Float64(Float64(Float64(x * c_m) * s_m) * Float64(x * s_m)));
	end
	return tmp
end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp_2 = code(x, c_m, s_m)
	t_0 = c_m * (x * s_m);
	tmp = 0.0;
	if (x <= 1.04e-82)
		tmp = (1.0 / t_0) / t_0;
	else
		tmp = (cos((x * 2.0)) / c_m) / (((x * c_m) * s_m) * (x * s_m));
	end
	tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.04e-82], N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / c$95$m), $MachinePrecision] / N[(N[(N[(x * c$95$m), $MachinePrecision] * s$95$m), $MachinePrecision] * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x \cdot s\_m\right)\\
\mathbf{if}\;x \leq 1.04 \cdot 10^{-82}:\\
\;\;\;\;\frac{\frac{1}{t\_0}}{t\_0}\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.04000000000000004e-82 < x

    1. Initial program 63.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 94.9% accurate, 2.7× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\ \\ \frac{\frac{\cos \left(x \cdot 2\right)}{\left(x \cdot c\_m\right) \cdot s\_m}}{c\_m \cdot \left(x \cdot s\_m\right)} \end{array} \]
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
 :precision binary64
 (/ (/ (cos (* x 2.0)) (* (* x c_m) s_m)) (* c_m (* x s_m))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
	return (cos((x * 2.0)) / ((x * c_m) * s_m)) / (c_m * (x * s_m));
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s_m
    code = (cos((x * 2.0d0)) / ((x * c_m) * s_m)) / (c_m * (x * s_m))
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
	return (Math.cos((x * 2.0)) / ((x * c_m) * s_m)) / (c_m * (x * s_m));
}
c_m = math.fabs(c)
s_m = math.fabs(s)
[x, c_m, s_m] = sort([x, c_m, s_m])
def code(x, c_m, s_m):
	return (math.cos((x * 2.0)) / ((x * c_m) * s_m)) / (c_m * (x * s_m))
c_m = abs(c)
s_m = abs(s)
x, c_m, s_m = sort([x, c_m, s_m])
function code(x, c_m, s_m)
	return Float64(Float64(cos(Float64(x * 2.0)) / Float64(Float64(x * c_m) * s_m)) / Float64(c_m * Float64(x * s_m)))
end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
	tmp = (cos((x * 2.0)) / ((x * c_m) * s_m)) / (c_m * (x * s_m));
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(N[(x * c$95$m), $MachinePrecision] * s$95$m), $MachinePrecision]), $MachinePrecision] / N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\frac{\frac{\cos \left(x \cdot 2\right)}{\left(x \cdot c\_m\right) \cdot s\_m}}{c\_m \cdot \left(x \cdot s\_m\right)}
\end{array}
Derivation
  1. Initial program 66.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 91.8% accurate, 2.7× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\ \\ \frac{\frac{\cos \left(x \cdot 2\right)}{c\_m}}{\left(x \cdot s\_m\right) \cdot \left(x \cdot \left(c\_m \cdot s\_m\right)\right)} \end{array} \]
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
 :precision binary64
 (/ (/ (cos (* x 2.0)) c_m) (* (* x s_m) (* x (* c_m s_m)))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
	return (cos((x * 2.0)) / c_m) / ((x * s_m) * (x * (c_m * s_m)));
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s_m
    code = (cos((x * 2.0d0)) / c_m) / ((x * s_m) * (x * (c_m * s_m)))
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
	return (Math.cos((x * 2.0)) / c_m) / ((x * s_m) * (x * (c_m * s_m)));
}
c_m = math.fabs(c)
s_m = math.fabs(s)
[x, c_m, s_m] = sort([x, c_m, s_m])
def code(x, c_m, s_m):
	return (math.cos((x * 2.0)) / c_m) / ((x * s_m) * (x * (c_m * s_m)))
c_m = abs(c)
s_m = abs(s)
x, c_m, s_m = sort([x, c_m, s_m])
function code(x, c_m, s_m)
	return Float64(Float64(cos(Float64(x * 2.0)) / c_m) / Float64(Float64(x * s_m) * Float64(x * Float64(c_m * s_m))))
end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
	tmp = (cos((x * 2.0)) / c_m) / ((x * s_m) * (x * (c_m * s_m)));
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / c$95$m), $MachinePrecision] / N[(N[(x * s$95$m), $MachinePrecision] * N[(x * N[(c$95$m * s$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\frac{\frac{\cos \left(x \cdot 2\right)}{c\_m}}{\left(x \cdot s\_m\right) \cdot \left(x \cdot \left(c\_m \cdot s\_m\right)\right)}
\end{array}
Derivation
  1. Initial program 66.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 79.3% accurate, 24.1× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\ \\ \begin{array}{l} t_0 := c\_m \cdot \left(x \cdot s\_m\right)\\ \frac{\frac{1}{t\_0}}{t\_0} \end{array} \end{array} \]
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
 :precision binary64
 (let* ((t_0 (* c_m (* x s_m)))) (/ (/ 1.0 t_0) t_0)))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
	double t_0 = c_m * (x * s_m);
	return (1.0 / t_0) / t_0;
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s_m
    real(8) :: t_0
    t_0 = c_m * (x * s_m)
    code = (1.0d0 / t_0) / t_0
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
	double t_0 = c_m * (x * s_m);
	return (1.0 / t_0) / t_0;
}
c_m = math.fabs(c)
s_m = math.fabs(s)
[x, c_m, s_m] = sort([x, c_m, s_m])
def code(x, c_m, s_m):
	t_0 = c_m * (x * s_m)
	return (1.0 / t_0) / t_0
c_m = abs(c)
s_m = abs(s)
x, c_m, s_m = sort([x, c_m, s_m])
function code(x, c_m, s_m)
	t_0 = Float64(c_m * Float64(x * s_m))
	return Float64(Float64(1.0 / t_0) / t_0)
end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
	t_0 = c_m * (x * s_m);
	tmp = (1.0 / t_0) / t_0;
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x \cdot s\_m\right)\\
\frac{\frac{1}{t\_0}}{t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 66.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 79.2% accurate, 24.1× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ s_m = \left|s\right| \\ [x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\ \\ \begin{array}{l} t_0 := c\_m \cdot \left(x \cdot s\_m\right)\\ \frac{1}{t\_0 \cdot t\_0} \end{array} \end{array} \]
c_m = (fabs.f64 c)
s_m = (fabs.f64 s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
(FPCore (x c_m s_m)
 :precision binary64
 (let* ((t_0 (* c_m (* x s_m)))) (/ 1.0 (* t_0 t_0))))
c_m = fabs(c);
s_m = fabs(s);
assert(x < c_m && c_m < s_m);
double code(double x, double c_m, double s_m) {
	double t_0 = c_m * (x * s_m);
	return 1.0 / (t_0 * t_0);
}
c_m = abs(c)
s_m = abs(s)
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s_m)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s_m
    real(8) :: t_0
    t_0 = c_m * (x * s_m)
    code = 1.0d0 / (t_0 * t_0)
end function
c_m = Math.abs(c);
s_m = Math.abs(s);
assert x < c_m && c_m < s_m;
public static double code(double x, double c_m, double s_m) {
	double t_0 = c_m * (x * s_m);
	return 1.0 / (t_0 * t_0);
}
c_m = math.fabs(c)
s_m = math.fabs(s)
[x, c_m, s_m] = sort([x, c_m, s_m])
def code(x, c_m, s_m):
	t_0 = c_m * (x * s_m)
	return 1.0 / (t_0 * t_0)
c_m = abs(c)
s_m = abs(s)
x, c_m, s_m = sort([x, c_m, s_m])
function code(x, c_m, s_m)
	t_0 = Float64(c_m * Float64(x * s_m))
	return Float64(1.0 / Float64(t_0 * t_0))
end
c_m = abs(c);
s_m = abs(s);
x, c_m, s_m = num2cell(sort([x, c_m, s_m])){:}
function tmp = code(x, c_m, s_m)
	t_0 = c_m * (x * s_m);
	tmp = 1.0 / (t_0 * t_0);
end
c_m = N[Abs[c], $MachinePrecision]
s_m = N[Abs[s], $MachinePrecision]
NOTE: x, c_m, and s_m should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s$95$m_] := Block[{t$95$0 = N[(c$95$m * N[(x * s$95$m), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
s_m = \left|s\right|
\\
[x, c_m, s_m] = \mathsf{sort}([x, c_m, s_m])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x \cdot s\_m\right)\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 66.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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