mixedcos

Percentage Accurate: 68.0% → 99.6%
Time: 12.8s
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: 68.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: 99.6% accurate, 1.4× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_1}{t\_0}}{t\_0}\\


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

    1. Initial program 67.1%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity67.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.20000000000000001e-27 < x

    1. Initial program 54.8%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity54.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.6% accurate, 2.5× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_1}{t\_0}}{t\_0}\\


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

    1. Initial program 67.1%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity67.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.7999999999999999e-27 < x

    1. Initial program 54.8%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity54.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.6% accurate, 2.6× speedup?

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

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


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

    1. Initial program 67.1%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity67.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{\left|s \cdot x\right| \cdot \left|s \cdot x\right|}} \]
      3. sqr-abs70.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(e^{\color{blue}{2 \cdot \log \left(c \cdot \left(s \cdot x\right)\right)}}\right)}^{-1} \]
      13. exp-prod54.5%

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

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

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

        \[\leadsto e^{\color{blue}{-2} \cdot \log \left(c \cdot \left(s \cdot x\right)\right)} \]
      17. *-commutative54.5%

        \[\leadsto e^{\color{blue}{\log \left(c \cdot \left(s \cdot x\right)\right) \cdot -2}} \]
      18. exp-to-pow86.9%

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

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

    if 1.5000000000000001e-27 < x

    1. Initial program 54.8%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity54.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 97.0% accurate, 2.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 79.6% accurate, 3.0× speedup?

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

    \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. *-un-lft-identity64.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{{c}^{2}}}{\color{blue}{\left|s \cdot x\right| \cdot \left|s \cdot x\right|}} \]
    3. sqr-abs64.7%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left({\left(c \cdot \left(s \cdot x\right)\right)}^{2}\right)}^{-1}} \]
    11. exp-to-pow46.3%

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

      \[\leadsto {\left(e^{\color{blue}{2 \cdot \log \left(c \cdot \left(s \cdot x\right)\right)}}\right)}^{-1} \]
    13. exp-prod46.5%

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

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

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

      \[\leadsto e^{\color{blue}{-2} \cdot \log \left(c \cdot \left(s \cdot x\right)\right)} \]
    17. *-commutative46.5%

      \[\leadsto e^{\color{blue}{\log \left(c \cdot \left(s \cdot x\right)\right) \cdot -2}} \]
    18. exp-to-pow78.7%

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

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

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

Alternative 6: 79.6% accurate, 20.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 79.5% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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