mixedcos

Percentage Accurate: 66.8% → 99.1%
Time: 9.7s
Alternatives: 16
Speedup: 9.0×

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 16 alternatives:

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

Initial Program: 66.8% 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.1% accurate, 0.6× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \begin{array}{l} t_0 := \cos \left(x + x\right)\\ t_1 := c\_m \cdot \left(x \cdot s\right)\\ \mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c\_m}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq \infty:\\ \;\;\;\;\frac{\frac{t\_0}{t\_1}}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_0}{{\left(x \cdot \left(c\_m \cdot s\right)\right)}^{2}}\\ \end{array} \end{array} \]
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
 :precision binary64
 (let* ((t_0 (cos (+ x x))) (t_1 (* c_m (* x s))))
   (if (<=
        (/ (cos (* 2.0 x)) (* (pow c_m 2.0) (* x (* x (pow s 2.0)))))
        INFINITY)
     (/ (/ t_0 t_1) t_1)
     (/ t_0 (pow (* x (* c_m s)) 2.0)))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
	double t_0 = cos((x + x));
	double t_1 = c_m * (x * s);
	double tmp;
	if ((cos((2.0 * x)) / (pow(c_m, 2.0) * (x * (x * pow(s, 2.0))))) <= ((double) INFINITY)) {
		tmp = (t_0 / t_1) / t_1;
	} else {
		tmp = t_0 / pow((x * (c_m * s)), 2.0);
	}
	return tmp;
}
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
	double t_0 = Math.cos((x + x));
	double t_1 = c_m * (x * s);
	double tmp;
	if ((Math.cos((2.0 * x)) / (Math.pow(c_m, 2.0) * (x * (x * Math.pow(s, 2.0))))) <= Double.POSITIVE_INFINITY) {
		tmp = (t_0 / t_1) / t_1;
	} else {
		tmp = t_0 / Math.pow((x * (c_m * s)), 2.0);
	}
	return tmp;
}
c_m = math.fabs(c)
[x, c_m, s] = sort([x, c_m, s])
def code(x, c_m, s):
	t_0 = math.cos((x + x))
	t_1 = c_m * (x * s)
	tmp = 0
	if (math.cos((2.0 * x)) / (math.pow(c_m, 2.0) * (x * (x * math.pow(s, 2.0))))) <= math.inf:
		tmp = (t_0 / t_1) / t_1
	else:
		tmp = t_0 / math.pow((x * (c_m * s)), 2.0)
	return tmp
c_m = abs(c)
x, c_m, s = sort([x, c_m, s])
function code(x, c_m, s)
	t_0 = cos(Float64(x + x))
	t_1 = Float64(c_m * Float64(x * s))
	tmp = 0.0
	if (Float64(cos(Float64(2.0 * x)) / Float64((c_m ^ 2.0) * Float64(x * Float64(x * (s ^ 2.0))))) <= Inf)
		tmp = Float64(Float64(t_0 / t_1) / t_1);
	else
		tmp = Float64(t_0 / (Float64(x * Float64(c_m * s)) ^ 2.0));
	end
	return tmp
end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp_2 = code(x, c_m, s)
	t_0 = cos((x + x));
	t_1 = c_m * (x * s);
	tmp = 0.0;
	if ((cos((2.0 * x)) / ((c_m ^ 2.0) * (x * (x * (s ^ 2.0))))) <= Inf)
		tmp = (t_0 / t_1) / t_1;
	else
		tmp = t_0 / ((x * (c_m * s)) ^ 2.0);
	end
	tmp_2 = tmp;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c$95$m, 2.0], $MachinePrecision] * N[(x * N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(t$95$0 / t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision], N[(t$95$0 / N[Power[N[(x * N[(c$95$m * s), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \cos \left(x + x\right)\\
t_1 := c\_m \cdot \left(x \cdot s\right)\\
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c\_m}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq \infty:\\
\;\;\;\;\frac{\frac{t\_0}{t\_1}}{t\_1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < +inf.0

    1. Initial program 77.2%

      \[\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. *-commutativeN/A

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}} \]
      4. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot \left(x \cdot x\right)} \]
      5. pow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(c \cdot s\right)}^{2} \cdot \color{blue}{{x}^{2}}} \]
      6. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      7. pow-lowering-pow.f64N/A

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

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

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

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

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

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

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

        \[\leadsto \frac{\cos \color{blue}{\left(2 \cdot x\right)}}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}} \]
      2. unpow2N/A

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

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
      4. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(c \cdot s\right) \cdot x}}}{\left(c \cdot s\right) \cdot x} \]
      6. count-2N/A

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x} \]
      7. cos-lowering-cos.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(x + x\right)}}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x} \]
      8. +-lowering-+.f64N/A

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x} \]
      9. associate-*l*N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      10. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      11. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c \cdot \color{blue}{\left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      12. associate-*l*N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
      14. *-lowering-*.f6499.6

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

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

    if +inf.0 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x)))

    1. Initial program 0.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. *-commutativeN/A

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}} \]
      4. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot \left(x \cdot x\right)} \]
      5. pow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(c \cdot s\right)}^{2} \cdot \color{blue}{{x}^{2}}} \]
      6. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      7. pow-lowering-pow.f64N/A

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

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

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

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

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

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

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

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

Alternative 2: 82.3% accurate, 0.7× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \begin{array}{l} t_0 := c\_m \cdot \left(x \cdot s\right)\\ \mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c\_m}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq -2 \cdot 10^{-199}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x \cdot x, \frac{x}{c\_m \cdot s} \cdot \left(x \cdot \mathsf{fma}\left(x, x \cdot -0.08888888888888889, 0.6666666666666666\right)\right), \mathsf{fma}\left(x, x \cdot -2, 1\right) \cdot \frac{1}{c\_m \cdot s}\right)}{x}}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{t\_0}}{t\_0}\\ \end{array} \end{array} \]
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
 :precision binary64
 (let* ((t_0 (* c_m (* x s))))
   (if (<=
        (/ (cos (* 2.0 x)) (* (pow c_m 2.0) (* x (* x (pow s 2.0)))))
        -2e-199)
     (/
      (/
       (fma
        (* x x)
        (*
         (/ x (* c_m s))
         (* x (fma x (* x -0.08888888888888889) 0.6666666666666666)))
        (* (fma x (* x -2.0) 1.0) (/ 1.0 (* c_m s))))
       x)
      t_0)
     (/ (/ 1.0 t_0) t_0))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
	double t_0 = c_m * (x * s);
	double tmp;
	if ((cos((2.0 * x)) / (pow(c_m, 2.0) * (x * (x * pow(s, 2.0))))) <= -2e-199) {
		tmp = (fma((x * x), ((x / (c_m * s)) * (x * fma(x, (x * -0.08888888888888889), 0.6666666666666666))), (fma(x, (x * -2.0), 1.0) * (1.0 / (c_m * s)))) / x) / t_0;
	} else {
		tmp = (1.0 / t_0) / t_0;
	}
	return tmp;
}
c_m = abs(c)
x, c_m, s = sort([x, c_m, s])
function code(x, c_m, s)
	t_0 = Float64(c_m * Float64(x * s))
	tmp = 0.0
	if (Float64(cos(Float64(2.0 * x)) / Float64((c_m ^ 2.0) * Float64(x * Float64(x * (s ^ 2.0))))) <= -2e-199)
		tmp = Float64(Float64(fma(Float64(x * x), Float64(Float64(x / Float64(c_m * s)) * Float64(x * fma(x, Float64(x * -0.08888888888888889), 0.6666666666666666))), Float64(fma(x, Float64(x * -2.0), 1.0) * Float64(1.0 / Float64(c_m * s)))) / x) / t_0);
	else
		tmp = Float64(Float64(1.0 / t_0) / t_0);
	end
	return tmp
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c$95$m, 2.0], $MachinePrecision] * N[(x * N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-199], N[(N[(N[(N[(x * x), $MachinePrecision] * N[(N[(x / N[(c$95$m * s), $MachinePrecision]), $MachinePrecision] * N[(x * N[(x * N[(x * -0.08888888888888889), $MachinePrecision] + 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(x * N[(x * -2.0), $MachinePrecision] + 1.0), $MachinePrecision] * N[(1.0 / N[(c$95$m * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x \cdot s\right)\\
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c\_m}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq -2 \cdot 10^{-199}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(x \cdot x, \frac{x}{c\_m \cdot s} \cdot \left(x \cdot \mathsf{fma}\left(x, x \cdot -0.08888888888888889, 0.6666666666666666\right)\right), \mathsf{fma}\left(x, x \cdot -2, 1\right) \cdot \frac{1}{c\_m \cdot s}\right)}{x}}{t\_0}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < -1.99999999999999996e-199

    1. Initial program 52.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. *-commutativeN/A

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}} \]
      4. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot \left(x \cdot x\right)} \]
      5. pow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(c \cdot s\right)}^{2} \cdot \color{blue}{{x}^{2}}} \]
      6. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      7. pow-lowering-pow.f64N/A

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

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

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

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

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

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

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

        \[\leadsto \frac{\cos \color{blue}{\left(2 \cdot x\right)}}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}} \]
      2. unpow2N/A

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

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
      4. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(c \cdot s\right) \cdot x}}}{\left(c \cdot s\right) \cdot x} \]
      6. count-2N/A

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x} \]
      7. cos-lowering-cos.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(x + x\right)}}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x} \]
      8. +-lowering-+.f64N/A

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x} \]
      9. associate-*l*N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      10. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      11. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c \cdot \color{blue}{\left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      12. associate-*l*N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
      14. *-lowering-*.f6499.0

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

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

      \[\leadsto \frac{\color{blue}{\frac{{x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{-4}{45} \cdot \frac{{x}^{2}}{c \cdot s} + \frac{2}{3} \cdot \frac{1}{c \cdot s}\right) - 2 \cdot \frac{1}{c \cdot s}\right) + \frac{1}{c \cdot s}}{x}}}{c \cdot \left(s \cdot x\right)} \]
    10. Simplified29.5%

      \[\leadsto \frac{\color{blue}{\frac{\mathsf{fma}\left(x \cdot x, \frac{x}{c \cdot s} \cdot \left(x \cdot \mathsf{fma}\left(x, x \cdot -0.08888888888888889, 0.6666666666666666\right)\right), \mathsf{fma}\left(x, x \cdot -2, 1\right) \cdot \frac{1}{c \cdot s}\right)}{x}}}{c \cdot \left(s \cdot x\right)} \]

    if -1.99999999999999996e-199 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x)))

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

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}} \]
      6. *-lowering-*.f64N/A

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

        \[\leadsto \frac{1}{x \cdot \color{blue}{\left(x \cdot \left({c}^{2} \cdot {s}^{2}\right)\right)}} \]
      8. *-lowering-*.f64N/A

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

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

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

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

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

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

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(\left(s \cdot c\right) \cdot c\right)}\right)\right)} \]
      15. *-commutativeN/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      16. *-lowering-*.f64N/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      17. *-commutativeN/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)} \]
      18. *-lowering-*.f6475.8

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

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

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right) \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}} \]
      2. *-commutativeN/A

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

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
      4. *-commutativeN/A

        \[\leadsto \frac{1}{\left(\color{blue}{\left(c \cdot s\right)} \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
      5. swap-sqrN/A

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

        \[\leadsto \color{blue}{\frac{\frac{1}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{1}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
      8. /-lowering-/.f64N/A

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

        \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      10. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      11. *-lowering-*.f64N/A

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

        \[\leadsto \frac{\frac{1}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{1}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
      14. *-lowering-*.f6485.3

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

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

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

Alternative 3: 82.3% accurate, 0.8× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \begin{array}{l} t_0 := c\_m \cdot \left(x \cdot s\right)\\ \mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c\_m}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq -2 \cdot 10^{-199}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, -0.08888888888888889, 0.6666666666666666\right), -2\right), 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c\_m \cdot \left(c\_m \cdot s\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{t\_0}}{t\_0}\\ \end{array} \end{array} \]
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
 :precision binary64
 (let* ((t_0 (* c_m (* x s))))
   (if (<=
        (/ (cos (* 2.0 x)) (* (pow c_m 2.0) (* x (* x (pow s 2.0)))))
        -2e-199)
     (/
      (fma
       (* x x)
       (fma x (* x (fma (* x x) -0.08888888888888889 0.6666666666666666)) -2.0)
       1.0)
      (* x (* x (* s (* c_m (* c_m s))))))
     (/ (/ 1.0 t_0) t_0))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
	double t_0 = c_m * (x * s);
	double tmp;
	if ((cos((2.0 * x)) / (pow(c_m, 2.0) * (x * (x * pow(s, 2.0))))) <= -2e-199) {
		tmp = fma((x * x), fma(x, (x * fma((x * x), -0.08888888888888889, 0.6666666666666666)), -2.0), 1.0) / (x * (x * (s * (c_m * (c_m * s)))));
	} else {
		tmp = (1.0 / t_0) / t_0;
	}
	return tmp;
}
c_m = abs(c)
x, c_m, s = sort([x, c_m, s])
function code(x, c_m, s)
	t_0 = Float64(c_m * Float64(x * s))
	tmp = 0.0
	if (Float64(cos(Float64(2.0 * x)) / Float64((c_m ^ 2.0) * Float64(x * Float64(x * (s ^ 2.0))))) <= -2e-199)
		tmp = Float64(fma(Float64(x * x), fma(x, Float64(x * fma(Float64(x * x), -0.08888888888888889, 0.6666666666666666)), -2.0), 1.0) / Float64(x * Float64(x * Float64(s * Float64(c_m * Float64(c_m * s))))));
	else
		tmp = Float64(Float64(1.0 / t_0) / t_0);
	end
	return tmp
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c$95$m, 2.0], $MachinePrecision] * N[(x * N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-199], N[(N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * N[(N[(x * x), $MachinePrecision] * -0.08888888888888889 + 0.6666666666666666), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x * N[(x * N[(s * N[(c$95$m * N[(c$95$m * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x \cdot s\right)\\
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c\_m}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq -2 \cdot 10^{-199}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, -0.08888888888888889, 0.6666666666666666\right), -2\right), 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c\_m \cdot \left(c\_m \cdot s\right)\right)\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < -1.99999999999999996e-199

    1. Initial program 52.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. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
      2. cos-lowering-cos.f64N/A

        \[\leadsto \frac{\color{blue}{\cos \left(2 \cdot x\right)}}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)} \]
      3. *-lowering-*.f64N/A

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot {x}^{2}}} \]
      5. unpow2N/A

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

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

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{x \cdot \color{blue}{\left(x \cdot \left({c}^{2} \cdot {s}^{2}\right)\right)}} \]
      10. *-lowering-*.f64N/A

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \color{blue}{\left({s}^{2} \cdot {c}^{2}\right)}\right)} \]
      12. unpow2N/A

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \color{blue}{\left(s \cdot \left(s \cdot {c}^{2}\right)\right)}\right)} \]
      14. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \color{blue}{\left(s \cdot \left(s \cdot {c}^{2}\right)\right)}\right)} \]
      15. unpow2N/A

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(\left(s \cdot c\right) \cdot c\right)}\right)\right)} \]
      17. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      18. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      19. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)} \]
      20. *-lowering-*.f6452.0

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

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

      \[\leadsto \frac{\color{blue}{1 + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right) - 2\right)}}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{{x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right) - 2\right) + 1}}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({x}^{2}, {x}^{2} \cdot \left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right) - 2, 1\right)}}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      3. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{x \cdot x}, {x}^{2} \cdot \left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right) - 2, 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{x \cdot x}, {x}^{2} \cdot \left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right) - 2, 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      5. sub-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{2} \cdot \left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right) + \left(\mathsf{neg}\left(2\right)\right)}, 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      6. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right) + \left(\mathsf{neg}\left(2\right)\right), 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      7. associate-*l*N/A

        \[\leadsto \frac{\mathsf{fma}\left(x \cdot x, \color{blue}{x \cdot \left(x \cdot \left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right)\right)} + \left(\mathsf{neg}\left(2\right)\right), 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(x \cdot x, x \cdot \color{blue}{\left(\left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right) \cdot x\right)} + \left(\mathsf{neg}\left(2\right)\right), 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      9. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(x \cdot x, x \cdot \left(\left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right) \cdot x\right) + \color{blue}{-2}, 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      10. accelerator-lowering-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left(x, \left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right) \cdot x, -2\right)}, 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      11. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot \left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right)}, -2\right), 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      12. *-lowering-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot \left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right)}, -2\right), 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      13. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left(\frac{-4}{45} \cdot {x}^{2} + \frac{2}{3}\right)}, -2\right), 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      14. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\color{blue}{{x}^{2} \cdot \frac{-4}{45}} + \frac{2}{3}\right), -2\right), 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{-4}{45}, \frac{2}{3}\right)}, -2\right), 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      16. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{-4}{45}, \frac{2}{3}\right), -2\right), 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      17. *-lowering-*.f6429.5

        \[\leadsto \frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\color{blue}{x \cdot x}, -0.08888888888888889, 0.6666666666666666\right), -2\right), 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
    8. Simplified29.5%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, -0.08888888888888889, 0.6666666666666666\right), -2\right), 1\right)}}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]

    if -1.99999999999999996e-199 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x)))

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

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}} \]
      6. *-lowering-*.f64N/A

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

        \[\leadsto \frac{1}{x \cdot \color{blue}{\left(x \cdot \left({c}^{2} \cdot {s}^{2}\right)\right)}} \]
      8. *-lowering-*.f64N/A

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

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

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

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

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

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

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(\left(s \cdot c\right) \cdot c\right)}\right)\right)} \]
      15. *-commutativeN/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      16. *-lowering-*.f64N/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      17. *-commutativeN/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)} \]
      18. *-lowering-*.f6475.8

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

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

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right) \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}} \]
      2. *-commutativeN/A

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

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
      4. *-commutativeN/A

        \[\leadsto \frac{1}{\left(\color{blue}{\left(c \cdot s\right)} \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
      5. swap-sqrN/A

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

        \[\leadsto \color{blue}{\frac{\frac{1}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{1}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
      8. /-lowering-/.f64N/A

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

        \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      10. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      11. *-lowering-*.f64N/A

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

        \[\leadsto \frac{\frac{1}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{1}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
      14. *-lowering-*.f6485.3

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

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

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

Alternative 4: 82.3% accurate, 0.8× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \begin{array}{l} t_0 := c\_m \cdot \left(x \cdot s\right)\\ \mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c\_m}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq -2 \cdot 10^{-199}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot -0.08888888888888889, 0.6666666666666666\right), -2\right), 1\right)}{\left(x \cdot s\right) \cdot \left(s \cdot \left(x \cdot \left(c\_m \cdot c\_m\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{t\_0}}{t\_0}\\ \end{array} \end{array} \]
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
 :precision binary64
 (let* ((t_0 (* c_m (* x s))))
   (if (<=
        (/ (cos (* 2.0 x)) (* (pow c_m 2.0) (* x (* x (pow s 2.0)))))
        -2e-199)
     (/
      (fma
       x
       (*
        x
        (fma
         (* x x)
         (fma x (* x -0.08888888888888889) 0.6666666666666666)
         -2.0))
       1.0)
      (* (* x s) (* s (* x (* c_m c_m)))))
     (/ (/ 1.0 t_0) t_0))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
	double t_0 = c_m * (x * s);
	double tmp;
	if ((cos((2.0 * x)) / (pow(c_m, 2.0) * (x * (x * pow(s, 2.0))))) <= -2e-199) {
		tmp = fma(x, (x * fma((x * x), fma(x, (x * -0.08888888888888889), 0.6666666666666666), -2.0)), 1.0) / ((x * s) * (s * (x * (c_m * c_m))));
	} else {
		tmp = (1.0 / t_0) / t_0;
	}
	return tmp;
}
c_m = abs(c)
x, c_m, s = sort([x, c_m, s])
function code(x, c_m, s)
	t_0 = Float64(c_m * Float64(x * s))
	tmp = 0.0
	if (Float64(cos(Float64(2.0 * x)) / Float64((c_m ^ 2.0) * Float64(x * Float64(x * (s ^ 2.0))))) <= -2e-199)
		tmp = Float64(fma(x, Float64(x * fma(Float64(x * x), fma(x, Float64(x * -0.08888888888888889), 0.6666666666666666), -2.0)), 1.0) / Float64(Float64(x * s) * Float64(s * Float64(x * Float64(c_m * c_m)))));
	else
		tmp = Float64(Float64(1.0 / t_0) / t_0);
	end
	return tmp
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c$95$m, 2.0], $MachinePrecision] * N[(x * N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-199], N[(N[(x * N[(x * N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * -0.08888888888888889), $MachinePrecision] + 0.6666666666666666), $MachinePrecision] + -2.0), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] / N[(N[(x * s), $MachinePrecision] * N[(s * N[(x * N[(c$95$m * c$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x \cdot s\right)\\
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c\_m}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq -2 \cdot 10^{-199}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot -0.08888888888888889, 0.6666666666666666\right), -2\right), 1\right)}{\left(x \cdot s\right) \cdot \left(s \cdot \left(x \cdot \left(c\_m \cdot c\_m\right)\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < -1.99999999999999996e-199

    1. Initial program 52.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. *-commutativeN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\color{blue}{\left({c}^{2} \cdot x\right)} \cdot s\right) \cdot \left(s \cdot x\right)} \]
      10. unpow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\left(\color{blue}{\left(c \cdot c\right)} \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
      11. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\left(\left(\color{blue}{\left(c \cdot c\right)} \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
      12. *-lowering-*.f6466.4

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

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

      \[\leadsto \frac{\color{blue}{1 + {x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right) - 2\right)}}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \frac{\color{blue}{{x}^{2} \cdot \left({x}^{2} \cdot \left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right) - 2\right) + 1}}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
      2. unpow2N/A

        \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \left({x}^{2} \cdot \left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right) - 2\right) + 1}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
      3. associate-*l*N/A

        \[\leadsto \frac{\color{blue}{x \cdot \left(x \cdot \left({x}^{2} \cdot \left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right) - 2\right)\right)} + 1}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, x \cdot \left({x}^{2} \cdot \left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right) - 2\right), 1\right)}}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
      5. *-lowering-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(x, \color{blue}{x \cdot \left({x}^{2} \cdot \left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right) - 2\right)}, 1\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
      6. sub-negN/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right) + \left(\mathsf{neg}\left(2\right)\right)\right)}, 1\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
      7. metadata-evalN/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \left({x}^{2} \cdot \left(\frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}\right) + \color{blue}{-2}\right), 1\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
      8. accelerator-lowering-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}, -2\right)}, 1\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
      9. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}, -2\right), 1\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
      10. *-lowering-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{2}{3} + \frac{-4}{45} \cdot {x}^{2}, -2\right), 1\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
      11. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{-4}{45} \cdot {x}^{2} + \frac{2}{3}}, -2\right), 1\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
      12. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, \frac{-4}{45} \cdot \color{blue}{\left(x \cdot x\right)} + \frac{2}{3}, -2\right), 1\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
      13. associate-*r*N/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, \color{blue}{\left(\frac{-4}{45} \cdot x\right) \cdot x} + \frac{2}{3}, -2\right), 1\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
      14. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, \color{blue}{x \cdot \left(\frac{-4}{45} \cdot x\right)} + \frac{2}{3}, -2\right), 1\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left(x, \frac{-4}{45} \cdot x, \frac{2}{3}\right)}, -2\right), 1\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
      16. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{-4}{45}}, \frac{2}{3}\right), -2\right), 1\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
      17. *-lowering-*.f6429.0

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot -0.08888888888888889}, 0.6666666666666666\right), -2\right), 1\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]
    7. Simplified29.0%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot -0.08888888888888889, 0.6666666666666666\right), -2\right), 1\right)}}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \left(s \cdot x\right)} \]

    if -1.99999999999999996e-199 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x)))

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

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}} \]
      6. *-lowering-*.f64N/A

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

        \[\leadsto \frac{1}{x \cdot \color{blue}{\left(x \cdot \left({c}^{2} \cdot {s}^{2}\right)\right)}} \]
      8. *-lowering-*.f64N/A

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

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

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

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

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

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

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(\left(s \cdot c\right) \cdot c\right)}\right)\right)} \]
      15. *-commutativeN/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      16. *-lowering-*.f64N/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      17. *-commutativeN/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)} \]
      18. *-lowering-*.f6475.8

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

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

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right) \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}} \]
      2. *-commutativeN/A

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

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
      4. *-commutativeN/A

        \[\leadsto \frac{1}{\left(\color{blue}{\left(c \cdot s\right)} \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
      5. swap-sqrN/A

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

        \[\leadsto \color{blue}{\frac{\frac{1}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{1}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
      8. /-lowering-/.f64N/A

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

        \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      10. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      11. *-lowering-*.f64N/A

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

        \[\leadsto \frac{\frac{1}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{1}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
      14. *-lowering-*.f6485.3

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

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

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

Alternative 5: 82.3% accurate, 0.8× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \begin{array}{l} t_0 := c\_m \cdot \left(x \cdot s\right)\\ \mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c\_m}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq -2 \cdot 10^{-199}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(x, x \cdot -2, 1\right)}{t\_0}}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{t\_0}}{t\_0}\\ \end{array} \end{array} \]
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
 :precision binary64
 (let* ((t_0 (* c_m (* x s))))
   (if (<=
        (/ (cos (* 2.0 x)) (* (pow c_m 2.0) (* x (* x (pow s 2.0)))))
        -2e-199)
     (/ (/ (fma x (* x -2.0) 1.0) t_0) t_0)
     (/ (/ 1.0 t_0) t_0))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
	double t_0 = c_m * (x * s);
	double tmp;
	if ((cos((2.0 * x)) / (pow(c_m, 2.0) * (x * (x * pow(s, 2.0))))) <= -2e-199) {
		tmp = (fma(x, (x * -2.0), 1.0) / t_0) / t_0;
	} else {
		tmp = (1.0 / t_0) / t_0;
	}
	return tmp;
}
c_m = abs(c)
x, c_m, s = sort([x, c_m, s])
function code(x, c_m, s)
	t_0 = Float64(c_m * Float64(x * s))
	tmp = 0.0
	if (Float64(cos(Float64(2.0 * x)) / Float64((c_m ^ 2.0) * Float64(x * Float64(x * (s ^ 2.0))))) <= -2e-199)
		tmp = Float64(Float64(fma(x, Float64(x * -2.0), 1.0) / t_0) / t_0);
	else
		tmp = Float64(Float64(1.0 / t_0) / t_0);
	end
	return tmp
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c$95$m, 2.0], $MachinePrecision] * N[(x * N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-199], N[(N[(N[(x * N[(x * -2.0), $MachinePrecision] + 1.0), $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x \cdot s\right)\\
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c\_m}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq -2 \cdot 10^{-199}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(x, x \cdot -2, 1\right)}{t\_0}}{t\_0}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < -1.99999999999999996e-199

    1. Initial program 52.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. *-commutativeN/A

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}} \]
      4. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot \left(x \cdot x\right)} \]
      5. pow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(c \cdot s\right)}^{2} \cdot \color{blue}{{x}^{2}}} \]
      6. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      7. pow-lowering-pow.f64N/A

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

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

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

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

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

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

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

        \[\leadsto \frac{\cos \color{blue}{\left(2 \cdot x\right)}}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}} \]
      2. unpow2N/A

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

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
      4. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(c \cdot s\right) \cdot x}}}{\left(c \cdot s\right) \cdot x} \]
      6. count-2N/A

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x} \]
      7. cos-lowering-cos.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(x + x\right)}}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x} \]
      8. +-lowering-+.f64N/A

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x} \]
      9. associate-*l*N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      10. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      11. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c \cdot \color{blue}{\left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      12. associate-*l*N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
      14. *-lowering-*.f6499.0

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

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

      \[\leadsto \frac{\frac{\color{blue}{1 + -2 \cdot {x}^{2}}}{c \cdot \left(s \cdot x\right)}}{c \cdot \left(s \cdot x\right)} \]
    10. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \frac{\frac{-2 \cdot \color{blue}{\left(x \cdot x\right)} + 1}{c \cdot \left(s \cdot x\right)}}{c \cdot \left(s \cdot x\right)} \]
      3. associate-*r*N/A

        \[\leadsto \frac{\frac{\color{blue}{\left(-2 \cdot x\right) \cdot x} + 1}{c \cdot \left(s \cdot x\right)}}{c \cdot \left(s \cdot x\right)} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\frac{\color{blue}{x \cdot \left(-2 \cdot x\right)} + 1}{c \cdot \left(s \cdot x\right)}}{c \cdot \left(s \cdot x\right)} \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{\mathsf{fma}\left(x, -2 \cdot x, 1\right)}}{c \cdot \left(s \cdot x\right)}}{c \cdot \left(s \cdot x\right)} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\frac{\mathsf{fma}\left(x, \color{blue}{x \cdot -2}, 1\right)}{c \cdot \left(s \cdot x\right)}}{c \cdot \left(s \cdot x\right)} \]
      7. *-lowering-*.f6429.3

        \[\leadsto \frac{\frac{\mathsf{fma}\left(x, \color{blue}{x \cdot -2}, 1\right)}{c \cdot \left(s \cdot x\right)}}{c \cdot \left(s \cdot x\right)} \]
    11. Simplified29.3%

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

    if -1.99999999999999996e-199 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x)))

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

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}} \]
      6. *-lowering-*.f64N/A

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

        \[\leadsto \frac{1}{x \cdot \color{blue}{\left(x \cdot \left({c}^{2} \cdot {s}^{2}\right)\right)}} \]
      8. *-lowering-*.f64N/A

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

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

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

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

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

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

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(\left(s \cdot c\right) \cdot c\right)}\right)\right)} \]
      15. *-commutativeN/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      16. *-lowering-*.f64N/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      17. *-commutativeN/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)} \]
      18. *-lowering-*.f6475.8

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

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

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right) \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}} \]
      2. *-commutativeN/A

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

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
      4. *-commutativeN/A

        \[\leadsto \frac{1}{\left(\color{blue}{\left(c \cdot s\right)} \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
      5. swap-sqrN/A

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

        \[\leadsto \color{blue}{\frac{\frac{1}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{1}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
      8. /-lowering-/.f64N/A

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

        \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      10. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      11. *-lowering-*.f64N/A

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

        \[\leadsto \frac{\frac{1}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{1}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
      14. *-lowering-*.f6485.3

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

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

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

Alternative 6: 82.3% accurate, 0.9× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \begin{array}{l} t_0 := c\_m \cdot \left(x \cdot s\right)\\ \mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c\_m}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq -2 \cdot 10^{-199}:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, x \cdot -2, 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c\_m \cdot \left(c\_m \cdot s\right)\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{t\_0}}{t\_0}\\ \end{array} \end{array} \]
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
 :precision binary64
 (let* ((t_0 (* c_m (* x s))))
   (if (<=
        (/ (cos (* 2.0 x)) (* (pow c_m 2.0) (* x (* x (pow s 2.0)))))
        -2e-199)
     (/ (fma x (* x -2.0) 1.0) (* x (* x (* s (* c_m (* c_m s))))))
     (/ (/ 1.0 t_0) t_0))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
	double t_0 = c_m * (x * s);
	double tmp;
	if ((cos((2.0 * x)) / (pow(c_m, 2.0) * (x * (x * pow(s, 2.0))))) <= -2e-199) {
		tmp = fma(x, (x * -2.0), 1.0) / (x * (x * (s * (c_m * (c_m * s)))));
	} else {
		tmp = (1.0 / t_0) / t_0;
	}
	return tmp;
}
c_m = abs(c)
x, c_m, s = sort([x, c_m, s])
function code(x, c_m, s)
	t_0 = Float64(c_m * Float64(x * s))
	tmp = 0.0
	if (Float64(cos(Float64(2.0 * x)) / Float64((c_m ^ 2.0) * Float64(x * Float64(x * (s ^ 2.0))))) <= -2e-199)
		tmp = Float64(fma(x, Float64(x * -2.0), 1.0) / Float64(x * Float64(x * Float64(s * Float64(c_m * Float64(c_m * s))))));
	else
		tmp = Float64(Float64(1.0 / t_0) / t_0);
	end
	return tmp
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[c$95$m, 2.0], $MachinePrecision] * N[(x * N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-199], N[(N[(x * N[(x * -2.0), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x * N[(x * N[(s * N[(c$95$m * N[(c$95$m * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := c\_m \cdot \left(x \cdot s\right)\\
\mathbf{if}\;\frac{\cos \left(2 \cdot x\right)}{{c\_m}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq -2 \cdot 10^{-199}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x \cdot -2, 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c\_m \cdot \left(c\_m \cdot s\right)\right)\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x))) < -1.99999999999999996e-199

    1. Initial program 52.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. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
      2. cos-lowering-cos.f64N/A

        \[\leadsto \frac{\color{blue}{\cos \left(2 \cdot x\right)}}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)} \]
      3. *-lowering-*.f64N/A

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot {x}^{2}}} \]
      5. unpow2N/A

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

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

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{x \cdot \color{blue}{\left(x \cdot \left({c}^{2} \cdot {s}^{2}\right)\right)}} \]
      10. *-lowering-*.f64N/A

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \color{blue}{\left({s}^{2} \cdot {c}^{2}\right)}\right)} \]
      12. unpow2N/A

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \color{blue}{\left(s \cdot \left(s \cdot {c}^{2}\right)\right)}\right)} \]
      14. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \color{blue}{\left(s \cdot \left(s \cdot {c}^{2}\right)\right)}\right)} \]
      15. unpow2N/A

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(\left(s \cdot c\right) \cdot c\right)}\right)\right)} \]
      17. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      18. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      19. *-commutativeN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)} \]
      20. *-lowering-*.f6452.0

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

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

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

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

        \[\leadsto \frac{-2 \cdot \color{blue}{\left(x \cdot x\right)} + 1}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      3. associate-*r*N/A

        \[\leadsto \frac{\color{blue}{\left(-2 \cdot x\right) \cdot x} + 1}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      4. *-commutativeN/A

        \[\leadsto \frac{\color{blue}{x \cdot \left(-2 \cdot x\right)} + 1}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, -2 \cdot x, 1\right)}}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(x, \color{blue}{x \cdot -2}, 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      7. *-lowering-*.f6429.2

        \[\leadsto \frac{\mathsf{fma}\left(x, \color{blue}{x \cdot -2}, 1\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
    8. Simplified29.2%

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

    if -1.99999999999999996e-199 < (/.f64 (cos.f64 (*.f64 #s(literal 2 binary64) x)) (*.f64 (pow.f64 c #s(literal 2 binary64)) (*.f64 (*.f64 x (pow.f64 s #s(literal 2 binary64))) x)))

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

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}} \]
      6. *-lowering-*.f64N/A

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

        \[\leadsto \frac{1}{x \cdot \color{blue}{\left(x \cdot \left({c}^{2} \cdot {s}^{2}\right)\right)}} \]
      8. *-lowering-*.f64N/A

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

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

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

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

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

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

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(\left(s \cdot c\right) \cdot c\right)}\right)\right)} \]
      15. *-commutativeN/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      16. *-lowering-*.f64N/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      17. *-commutativeN/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)} \]
      18. *-lowering-*.f6475.8

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

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

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right) \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}} \]
      2. *-commutativeN/A

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

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
      4. *-commutativeN/A

        \[\leadsto \frac{1}{\left(\color{blue}{\left(c \cdot s\right)} \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
      5. swap-sqrN/A

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

        \[\leadsto \color{blue}{\frac{\frac{1}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{1}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
      8. /-lowering-/.f64N/A

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

        \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      10. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      11. *-lowering-*.f64N/A

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

        \[\leadsto \frac{\frac{1}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{1}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
      14. *-lowering-*.f6485.3

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

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

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

Alternative 7: 86.0% accurate, 2.2× speedup?

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

\mathbf{elif}\;x \leq 5 \cdot 10^{+127}:\\
\;\;\;\;\frac{t\_0}{\left(c\_m \cdot s\right) \cdot \left(\left(c\_m \cdot s\right) \cdot \left(x \cdot x\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{s \cdot \left(c\_m \cdot \left(x \cdot t\_1\right)\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 1.1e-145

    1. Initial program 59.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. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}} \]
      6. *-lowering-*.f64N/A

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

        \[\leadsto \frac{1}{x \cdot \color{blue}{\left(x \cdot \left({c}^{2} \cdot {s}^{2}\right)\right)}} \]
      8. *-lowering-*.f64N/A

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

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

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

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

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

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

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(\left(s \cdot c\right) \cdot c\right)}\right)\right)} \]
      15. *-commutativeN/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      16. *-lowering-*.f64N/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      17. *-commutativeN/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)} \]
      18. *-lowering-*.f6471.8

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

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

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right) \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}} \]
      2. *-commutativeN/A

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

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
      4. *-commutativeN/A

        \[\leadsto \frac{1}{\left(\color{blue}{\left(c \cdot s\right)} \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
      5. swap-sqrN/A

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

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

        \[\leadsto \frac{1}{\color{blue}{\left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right) \cdot \left(s \cdot x\right)}} \]
      8. *-lowering-*.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right) \cdot \left(s \cdot x\right)}} \]
      9. *-lowering-*.f64N/A

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

        \[\leadsto \frac{1}{\left(\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)} \cdot c\right) \cdot \left(s \cdot x\right)} \]
      11. *-lowering-*.f64N/A

        \[\leadsto \frac{1}{\left(\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)} \cdot c\right) \cdot \left(s \cdot x\right)} \]
      12. *-lowering-*.f64N/A

        \[\leadsto \frac{1}{\left(\left(c \cdot \color{blue}{\left(s \cdot x\right)}\right) \cdot c\right) \cdot \left(s \cdot x\right)} \]
      13. *-lowering-*.f6481.1

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

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

    if 1.1e-145 < x < 5.0000000000000004e127

    1. Initial program 66.3%

      \[\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. unpow2N/A

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

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

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{c \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      4. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{c \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
      5. /-lowering-/.f64N/A

        \[\leadsto \frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{c}}}{c \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      6. count-2N/A

        \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{c}}{c \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      7. cos-lowering-cos.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{\cos \left(x + x\right)}}{c}}{c \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      8. +-lowering-+.f64N/A

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

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c}}{\color{blue}{\left(\left(x \cdot {s}^{2}\right) \cdot x\right) \cdot c}} \]
      10. *-commutativeN/A

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

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c}}{\color{blue}{\left({s}^{2} \cdot \left(x \cdot x\right)\right)} \cdot c} \]
      12. associate-*l*N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c}}{\color{blue}{{s}^{2} \cdot \left(\left(x \cdot x\right) \cdot c\right)}} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c}}{\color{blue}{{s}^{2} \cdot \left(\left(x \cdot x\right) \cdot c\right)}} \]
      14. unpow2N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c}}{\color{blue}{\left(s \cdot s\right)} \cdot \left(\left(x \cdot x\right) \cdot c\right)} \]
      15. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c}}{\color{blue}{\left(s \cdot s\right)} \cdot \left(\left(x \cdot x\right) \cdot c\right)} \]
      16. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c}}{\left(s \cdot s\right) \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot c\right)}} \]
      17. *-lowering-*.f6470.7

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

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(x + x\right)}{c}}{\left(s \cdot s\right) \cdot \left(\left(x \cdot x\right) \cdot c\right)}} \]
    5. Step-by-step derivation
      1. count-2N/A

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

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(\left(s \cdot s\right) \cdot \left(\left(x \cdot x\right) \cdot c\right)\right) \cdot c}} \]
      3. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(\left(s \cdot s\right) \cdot \left(\left(x \cdot x\right) \cdot c\right)\right) \cdot c}} \]
      4. count-2N/A

        \[\leadsto \frac{\cos \color{blue}{\left(x + x\right)}}{\left(\left(s \cdot s\right) \cdot \left(\left(x \cdot x\right) \cdot c\right)\right) \cdot c} \]
      5. cos-lowering-cos.f64N/A

        \[\leadsto \frac{\color{blue}{\cos \left(x + x\right)}}{\left(\left(s \cdot s\right) \cdot \left(\left(x \cdot x\right) \cdot c\right)\right) \cdot c} \]
      6. +-lowering-+.f64N/A

        \[\leadsto \frac{\cos \color{blue}{\left(x + x\right)}}{\left(\left(s \cdot s\right) \cdot \left(\left(x \cdot x\right) \cdot c\right)\right) \cdot c} \]
      7. *-commutativeN/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{c \cdot \left(\left(s \cdot s\right) \cdot \left(\left(x \cdot x\right) \cdot c\right)\right)}} \]
      8. associate-*l*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{c \cdot \color{blue}{\left(s \cdot \left(s \cdot \left(\left(x \cdot x\right) \cdot c\right)\right)\right)}} \]
      9. associate-*r*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot s\right) \cdot \left(s \cdot \left(\left(x \cdot x\right) \cdot c\right)\right)}} \]
      10. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot s\right) \cdot \left(s \cdot \left(\left(x \cdot x\right) \cdot c\right)\right)}} \]
      11. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot s\right)} \cdot \left(s \cdot \left(\left(x \cdot x\right) \cdot c\right)\right)} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot s\right) \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(x \cdot x\right)\right)}\right)} \]
      13. associate-*r*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot s\right) \cdot \color{blue}{\left(\left(s \cdot c\right) \cdot \left(x \cdot x\right)\right)}} \]
      14. *-commutativeN/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot s\right) \cdot \left(\color{blue}{\left(c \cdot s\right)} \cdot \left(x \cdot x\right)\right)} \]
      15. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot s\right) \cdot \color{blue}{\left(\left(c \cdot s\right) \cdot \left(x \cdot x\right)\right)}} \]
      16. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot s\right) \cdot \left(\color{blue}{\left(c \cdot s\right)} \cdot \left(x \cdot x\right)\right)} \]
      17. *-lowering-*.f6499.4

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot s\right) \cdot \left(\left(c \cdot s\right) \cdot \color{blue}{\left(x \cdot x\right)}\right)} \]
    6. Applied egg-rr99.4%

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

    if 5.0000000000000004e127 < x

    1. Initial program 60.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. *-commutativeN/A

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}} \]
      4. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot \left(x \cdot x\right)} \]
      5. pow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(c \cdot s\right)}^{2} \cdot \color{blue}{{x}^{2}}} \]
      6. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      7. pow-lowering-pow.f64N/A

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

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

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

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

        \[\leadsto \frac{\cos \color{blue}{\left(x + x\right)}}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}} \]
      2. +-lowering-+.f6497.4

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

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

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

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}} \]
      3. associate-*r*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right) \cdot \left(s \cdot x\right)}} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right) \cdot \left(s \cdot x\right)}} \]
      5. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right)} \cdot \left(s \cdot x\right)} \]
      6. associate-*l*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)} \cdot c\right) \cdot \left(s \cdot x\right)} \]
      7. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)} \cdot c\right) \cdot \left(s \cdot x\right)} \]
      8. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(c \cdot \color{blue}{\left(s \cdot x\right)}\right) \cdot c\right) \cdot \left(s \cdot x\right)} \]
      9. *-lowering-*.f6495.8

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

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

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

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left(c \cdot s\right) \cdot \left(x \cdot c\right)\right)} \cdot \left(s \cdot x\right)} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(c \cdot s\right) \cdot \color{blue}{\left(c \cdot x\right)}\right) \cdot \left(s \cdot x\right)} \]
      4. associate-*r*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot s\right) \cdot \left(\left(c \cdot x\right) \cdot \left(s \cdot x\right)\right)}} \]
      5. associate-*r*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{c \cdot \left(s \cdot \left(\left(c \cdot x\right) \cdot \left(s \cdot x\right)\right)\right)}} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(s \cdot \left(\left(c \cdot x\right) \cdot \left(s \cdot x\right)\right)\right) \cdot c}} \]
      7. associate-*l*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{s \cdot \left(\left(\left(c \cdot x\right) \cdot \left(s \cdot x\right)\right) \cdot c\right)}} \]
      8. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{s \cdot \left(\left(\left(c \cdot x\right) \cdot \left(s \cdot x\right)\right) \cdot c\right)}} \]
      9. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{s \cdot \color{blue}{\left(\left(\left(c \cdot x\right) \cdot \left(s \cdot x\right)\right) \cdot c\right)}} \]
      10. *-commutativeN/A

        \[\leadsto \frac{\cos \left(x + x\right)}{s \cdot \left(\left(\color{blue}{\left(x \cdot c\right)} \cdot \left(s \cdot x\right)\right) \cdot c\right)} \]
      11. associate-*l*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{s \cdot \left(\color{blue}{\left(x \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)} \cdot c\right)} \]
      12. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{s \cdot \left(\color{blue}{\left(x \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)} \cdot c\right)} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{s \cdot \left(\left(x \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right) \cdot c\right)} \]
      14. *-commutativeN/A

        \[\leadsto \frac{\cos \left(x + x\right)}{s \cdot \left(\left(x \cdot \left(c \cdot \color{blue}{\left(x \cdot s\right)}\right)\right) \cdot c\right)} \]
      15. *-lowering-*.f6487.8

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

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

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

Alternative 8: 96.2% accurate, 2.3× speedup?

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 2.7e50

    1. Initial program 62.2%

      \[\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. *-commutativeN/A

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}} \]
      4. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot \left(x \cdot x\right)} \]
      5. pow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(c \cdot s\right)}^{2} \cdot \color{blue}{{x}^{2}}} \]
      6. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      7. pow-lowering-pow.f64N/A

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

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

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)}} \]
      2. swap-sqrN/A

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)} \cdot \left(x \cdot x\right)} \]
      5. *-commutativeN/A

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)}} \]
      8. count-2N/A

        \[\leadsto \frac{\cos \color{blue}{\left(x + x\right)}}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      9. cos-lowering-cos.f64N/A

        \[\leadsto \frac{\color{blue}{\cos \left(x + x\right)}}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      10. +-lowering-+.f64N/A

        \[\leadsto \frac{\cos \color{blue}{\left(x + x\right)}}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
      11. associate-*r*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(x \cdot x\right) \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right) \cdot \left(x \cdot x\right)}} \]
      13. associate-*r*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
      14. *-commutativeN/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\color{blue}{\left(c \cdot s\right)} \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
      15. swap-sqrN/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)}} \]
      16. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)}} \]
      17. associate-*l*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)} \cdot \left(\left(c \cdot s\right) \cdot x\right)} \]
      18. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)} \cdot \left(\left(c \cdot s\right) \cdot x\right)} \]
      19. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot \color{blue}{\left(s \cdot x\right)}\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)} \]
      20. associate-*l*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}} \]
      21. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}} \]
      22. *-lowering-*.f6497.9

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

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

    if 2.7e50 < x

    1. Initial program 57.4%

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

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}} \]
      4. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot \left(x \cdot x\right)} \]
      5. pow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(c \cdot s\right)}^{2} \cdot \color{blue}{{x}^{2}}} \]
      6. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      7. pow-lowering-pow.f64N/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)} \cdot \left(\left(c \cdot s\right) \cdot x\right)} \]
      3. associate-*l*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}} \]
      4. swap-sqrN/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot c\right) \cdot \left(\left(s \cdot x\right) \cdot \left(s \cdot x\right)\right)}} \]
      5. associate-*l*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left(c \cdot c\right) \cdot \left(s \cdot x\right)\right) \cdot \left(s \cdot x\right)}} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(c \cdot c\right) \cdot \color{blue}{\left(x \cdot s\right)}\right) \cdot \left(s \cdot x\right)} \]
      7. associate-*l*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right)} \cdot \left(s \cdot x\right)} \]
      8. *-commutativeN/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot \color{blue}{\left(x \cdot s\right)}} \]
      9. associate-*r*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot x\right) \cdot s}} \]
      10. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot x\right) \cdot s}} \]
      11. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left(\left(\left(c \cdot c\right) \cdot x\right) \cdot s\right) \cdot x\right)} \cdot s} \]
      12. *-commutativeN/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\color{blue}{\left(s \cdot \left(\left(c \cdot c\right) \cdot x\right)\right)} \cdot x\right) \cdot s} \]
      13. associate-*l*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(s \cdot \color{blue}{\left(c \cdot \left(c \cdot x\right)\right)}\right) \cdot x\right) \cdot s} \]
      14. associate-*r*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\color{blue}{\left(\left(s \cdot c\right) \cdot \left(c \cdot x\right)\right)} \cdot x\right) \cdot s} \]
      15. *-commutativeN/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(\color{blue}{\left(c \cdot s\right)} \cdot \left(c \cdot x\right)\right) \cdot x\right) \cdot s} \]
      16. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\color{blue}{\left(\left(c \cdot s\right) \cdot \left(c \cdot x\right)\right)} \cdot x\right) \cdot s} \]
      17. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(\color{blue}{\left(c \cdot s\right)} \cdot \left(c \cdot x\right)\right) \cdot x\right) \cdot s} \]
      18. *-lowering-*.f6477.3

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

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

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

Alternative 9: 85.3% accurate, 2.3× speedup?

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

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


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

    1. Initial program 59.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. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}} \]
      6. *-lowering-*.f64N/A

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

        \[\leadsto \frac{1}{x \cdot \color{blue}{\left(x \cdot \left({c}^{2} \cdot {s}^{2}\right)\right)}} \]
      8. *-lowering-*.f64N/A

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

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

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

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

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

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

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(\left(s \cdot c\right) \cdot c\right)}\right)\right)} \]
      15. *-commutativeN/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      16. *-lowering-*.f64N/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      17. *-commutativeN/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)} \]
      18. *-lowering-*.f6470.1

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

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

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right) \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}} \]
      2. *-commutativeN/A

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

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
      4. *-commutativeN/A

        \[\leadsto \frac{1}{\left(\color{blue}{\left(c \cdot s\right)} \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
      5. swap-sqrN/A

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

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

        \[\leadsto \frac{1}{\color{blue}{\left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right) \cdot \left(s \cdot x\right)}} \]
      8. *-lowering-*.f64N/A

        \[\leadsto \frac{1}{\color{blue}{\left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right) \cdot \left(s \cdot x\right)}} \]
      9. *-lowering-*.f64N/A

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

        \[\leadsto \frac{1}{\left(\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)} \cdot c\right) \cdot \left(s \cdot x\right)} \]
      11. *-lowering-*.f64N/A

        \[\leadsto \frac{1}{\left(\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)} \cdot c\right) \cdot \left(s \cdot x\right)} \]
      12. *-lowering-*.f64N/A

        \[\leadsto \frac{1}{\left(\left(c \cdot \color{blue}{\left(s \cdot x\right)}\right) \cdot c\right) \cdot \left(s \cdot x\right)} \]
      13. *-lowering-*.f6479.9

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

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

    if 1.65000000000000006e-176 < x

    1. Initial program 63.5%

      \[\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. *-commutativeN/A

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}} \]
      4. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot \left(x \cdot x\right)} \]
      5. pow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(c \cdot s\right)}^{2} \cdot \color{blue}{{x}^{2}}} \]
      6. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      7. pow-lowering-pow.f64N/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot s\right) \cdot \left(x \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)}} \]
      3. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot s\right) \cdot \left(x \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)}} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot s\right)} \cdot \left(x \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)} \]
      5. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot s\right) \cdot \color{blue}{\left(x \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)}} \]
      6. associate-*l*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot s\right) \cdot \left(x \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)} \]
      7. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot s\right) \cdot \left(x \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)} \]
      8. *-lowering-*.f6494.6

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

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

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

Alternative 10: 86.3% accurate, 2.3× speedup?

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

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


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

    1. Initial program 63.2%

      \[\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

      \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}} \]
      6. *-lowering-*.f64N/A

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

        \[\leadsto \frac{1}{x \cdot \color{blue}{\left(x \cdot \left({c}^{2} \cdot {s}^{2}\right)\right)}} \]
      8. *-lowering-*.f64N/A

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

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

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

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

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

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

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(\left(s \cdot c\right) \cdot c\right)}\right)\right)} \]
      15. *-commutativeN/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      16. *-lowering-*.f64N/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
      17. *-commutativeN/A

        \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)} \]
      18. *-lowering-*.f6473.9

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

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

        \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right) \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}} \]
      2. *-commutativeN/A

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

        \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
      4. *-commutativeN/A

        \[\leadsto \frac{1}{\left(\color{blue}{\left(c \cdot s\right)} \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
      5. swap-sqrN/A

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

        \[\leadsto \color{blue}{\frac{\frac{1}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{\frac{1}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
      8. /-lowering-/.f64N/A

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

        \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      10. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
      11. *-lowering-*.f64N/A

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

        \[\leadsto \frac{\frac{1}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \frac{\frac{1}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
      14. *-lowering-*.f6484.8

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

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

    if 1.3e-11 < x

    1. Initial program 55.4%

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

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

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

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}} \]
      4. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot \left(x \cdot x\right)} \]
      5. pow2N/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(c \cdot s\right)}^{2} \cdot \color{blue}{{x}^{2}}} \]
      6. pow-prod-downN/A

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
      7. pow-lowering-pow.f64N/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}} \]
      3. associate-*r*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right) \cdot \left(s \cdot x\right)}} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right) \cdot \left(s \cdot x\right)}} \]
      5. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left(\left(c \cdot s\right) \cdot x\right) \cdot c\right)} \cdot \left(s \cdot x\right)} \]
      6. associate-*l*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)} \cdot c\right) \cdot \left(s \cdot x\right)} \]
      7. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)} \cdot c\right) \cdot \left(s \cdot x\right)} \]
      8. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(c \cdot \color{blue}{\left(s \cdot x\right)}\right) \cdot c\right) \cdot \left(s \cdot x\right)} \]
      9. *-lowering-*.f6492.4

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

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

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

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left(c \cdot s\right) \cdot \left(x \cdot c\right)\right)} \cdot \left(s \cdot x\right)} \]
      3. *-commutativeN/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\left(\left(c \cdot s\right) \cdot \color{blue}{\left(c \cdot x\right)}\right) \cdot \left(s \cdot x\right)} \]
      4. associate-*r*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot s\right) \cdot \left(\left(c \cdot x\right) \cdot \left(s \cdot x\right)\right)}} \]
      5. associate-*r*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{c \cdot \left(s \cdot \left(\left(c \cdot x\right) \cdot \left(s \cdot x\right)\right)\right)}} \]
      6. *-commutativeN/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(s \cdot \left(\left(c \cdot x\right) \cdot \left(s \cdot x\right)\right)\right) \cdot c}} \]
      7. associate-*l*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{s \cdot \left(\left(\left(c \cdot x\right) \cdot \left(s \cdot x\right)\right) \cdot c\right)}} \]
      8. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{s \cdot \left(\left(\left(c \cdot x\right) \cdot \left(s \cdot x\right)\right) \cdot c\right)}} \]
      9. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{s \cdot \color{blue}{\left(\left(\left(c \cdot x\right) \cdot \left(s \cdot x\right)\right) \cdot c\right)}} \]
      10. *-commutativeN/A

        \[\leadsto \frac{\cos \left(x + x\right)}{s \cdot \left(\left(\color{blue}{\left(x \cdot c\right)} \cdot \left(s \cdot x\right)\right) \cdot c\right)} \]
      11. associate-*l*N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{s \cdot \left(\color{blue}{\left(x \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)} \cdot c\right)} \]
      12. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{s \cdot \left(\color{blue}{\left(x \cdot \left(c \cdot \left(s \cdot x\right)\right)\right)} \cdot c\right)} \]
      13. *-lowering-*.f64N/A

        \[\leadsto \frac{\cos \left(x + x\right)}{s \cdot \left(\left(x \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right) \cdot c\right)} \]
      14. *-commutativeN/A

        \[\leadsto \frac{\cos \left(x + x\right)}{s \cdot \left(\left(x \cdot \left(c \cdot \color{blue}{\left(x \cdot s\right)}\right)\right) \cdot c\right)} \]
      15. *-lowering-*.f6485.3

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

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

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

Alternative 11: 97.1% accurate, 2.3× speedup?

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

    \[\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. *-commutativeN/A

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

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}} \]
    4. pow-prod-downN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot \left(x \cdot x\right)} \]
    5. pow2N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(c \cdot s\right)}^{2} \cdot \color{blue}{{x}^{2}}} \]
    6. pow-prod-downN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
    7. pow-lowering-pow.f64N/A

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

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

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

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

      \[\leadsto \frac{\cos \color{blue}{\left(x + x\right)}}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}} \]
    2. +-lowering-+.f6497.9

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

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

      \[\leadsto \frac{\cos \color{blue}{\left(2 \cdot x\right)}}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}} \]
    2. unpow2N/A

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

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
    4. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{\cos \left(2 \cdot x\right)}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
    5. /-lowering-/.f64N/A

      \[\leadsto \frac{\color{blue}{\frac{\cos \left(2 \cdot x\right)}{\left(c \cdot s\right) \cdot x}}}{\left(c \cdot s\right) \cdot x} \]
    6. count-2N/A

      \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x} \]
    7. cos-lowering-cos.f64N/A

      \[\leadsto \frac{\frac{\color{blue}{\cos \left(x + x\right)}}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x} \]
    8. +-lowering-+.f64N/A

      \[\leadsto \frac{\frac{\cos \color{blue}{\left(x + x\right)}}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x} \]
    9. associate-*l*N/A

      \[\leadsto \frac{\frac{\cos \left(x + x\right)}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
    10. *-lowering-*.f64N/A

      \[\leadsto \frac{\frac{\cos \left(x + x\right)}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
    11. *-lowering-*.f64N/A

      \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c \cdot \color{blue}{\left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
    12. associate-*l*N/A

      \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
    13. *-lowering-*.f64N/A

      \[\leadsto \frac{\frac{\cos \left(x + x\right)}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
    14. *-lowering-*.f6498.4

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

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

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

Alternative 12: 96.9% accurate, 2.4× speedup?

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

    \[\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. *-commutativeN/A

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

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}} \]
    4. pow-prod-downN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot \left(x \cdot x\right)} \]
    5. pow2N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(c \cdot s\right)}^{2} \cdot \color{blue}{{x}^{2}}} \]
    6. pow-prod-downN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
    7. pow-lowering-pow.f64N/A

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

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

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

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)}} \]
    2. swap-sqrN/A

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

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)} \cdot \left(x \cdot x\right)} \]
    5. *-commutativeN/A

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)}} \]
    7. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)}} \]
    8. count-2N/A

      \[\leadsto \frac{\cos \color{blue}{\left(x + x\right)}}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
    9. cos-lowering-cos.f64N/A

      \[\leadsto \frac{\color{blue}{\cos \left(x + x\right)}}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
    10. +-lowering-+.f64N/A

      \[\leadsto \frac{\cos \color{blue}{\left(x + x\right)}}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)} \]
    11. associate-*r*N/A

      \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(x \cdot x\right) \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}} \]
    12. *-commutativeN/A

      \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right) \cdot \left(x \cdot x\right)}} \]
    13. associate-*r*N/A

      \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
    14. *-commutativeN/A

      \[\leadsto \frac{\cos \left(x + x\right)}{\left(\color{blue}{\left(c \cdot s\right)} \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
    15. swap-sqrN/A

      \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)}} \]
    16. *-lowering-*.f64N/A

      \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(\left(c \cdot s\right) \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)}} \]
    17. associate-*l*N/A

      \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)} \cdot \left(\left(c \cdot s\right) \cdot x\right)} \]
    18. *-lowering-*.f64N/A

      \[\leadsto \frac{\cos \left(x + x\right)}{\color{blue}{\left(c \cdot \left(s \cdot x\right)\right)} \cdot \left(\left(c \cdot s\right) \cdot x\right)} \]
    19. *-lowering-*.f64N/A

      \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot \color{blue}{\left(s \cdot x\right)}\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)} \]
    20. associate-*l*N/A

      \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}} \]
    21. *-lowering-*.f64N/A

      \[\leadsto \frac{\cos \left(x + x\right)}{\left(c \cdot \left(s \cdot x\right)\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}} \]
    22. *-lowering-*.f6498.3

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

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

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

Alternative 13: 78.6% accurate, 7.8× speedup?

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

    \[\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

    \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
  4. Step-by-step derivation
    1. /-lowering-/.f64N/A

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}} \]
    6. *-lowering-*.f64N/A

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

      \[\leadsto \frac{1}{x \cdot \color{blue}{\left(x \cdot \left({c}^{2} \cdot {s}^{2}\right)\right)}} \]
    8. *-lowering-*.f64N/A

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

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

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

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

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

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

      \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(\left(s \cdot c\right) \cdot c\right)}\right)\right)} \]
    15. *-commutativeN/A

      \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
    16. *-lowering-*.f64N/A

      \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
    17. *-commutativeN/A

      \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)} \]
    18. *-lowering-*.f6469.9

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right) \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}} \]
    2. *-commutativeN/A

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

      \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
    4. *-commutativeN/A

      \[\leadsto \frac{1}{\left(\color{blue}{\left(c \cdot s\right)} \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
    5. swap-sqrN/A

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
    7. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{1}{\left(c \cdot s\right) \cdot x}}{\left(c \cdot s\right) \cdot x}} \]
    8. /-lowering-/.f64N/A

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

      \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
    10. *-lowering-*.f64N/A

      \[\leadsto \frac{\frac{1}{\color{blue}{c \cdot \left(s \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
    11. *-lowering-*.f64N/A

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

      \[\leadsto \frac{\frac{1}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
    13. *-lowering-*.f64N/A

      \[\leadsto \frac{\frac{1}{c \cdot \left(s \cdot x\right)}}{\color{blue}{c \cdot \left(s \cdot x\right)}} \]
    14. *-lowering-*.f6478.7

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

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

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

Alternative 14: 77.3% accurate, 9.0× speedup?

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

    \[\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

    \[\leadsto \color{blue}{\frac{1}{{c}^{2} \cdot \left({s}^{2} \cdot {x}^{2}\right)}} \]
  4. Step-by-step derivation
    1. /-lowering-/.f64N/A

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left({c}^{2} \cdot {s}^{2}\right) \cdot x\right)}} \]
    6. *-lowering-*.f64N/A

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

      \[\leadsto \frac{1}{x \cdot \color{blue}{\left(x \cdot \left({c}^{2} \cdot {s}^{2}\right)\right)}} \]
    8. *-lowering-*.f64N/A

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

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

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

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

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

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

      \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(\left(s \cdot c\right) \cdot c\right)}\right)\right)} \]
    15. *-commutativeN/A

      \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
    16. *-lowering-*.f64N/A

      \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \color{blue}{\left(c \cdot \left(s \cdot c\right)\right)}\right)\right)} \]
    17. *-commutativeN/A

      \[\leadsto \frac{1}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \color{blue}{\left(c \cdot s\right)}\right)\right)\right)} \]
    18. *-lowering-*.f6469.9

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(x \cdot x\right) \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}} \]
    2. *-commutativeN/A

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

      \[\leadsto \frac{1}{\color{blue}{\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
    4. *-commutativeN/A

      \[\leadsto \frac{1}{\left(\color{blue}{\left(c \cdot s\right)} \cdot \left(c \cdot s\right)\right) \cdot \left(x \cdot x\right)} \]
    5. swap-sqrN/A

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

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

      \[\leadsto \frac{1}{\color{blue}{c \cdot \left(\left(s \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)}} \]
    8. *-lowering-*.f64N/A

      \[\leadsto \frac{1}{\color{blue}{c \cdot \left(\left(s \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)}} \]
    9. *-lowering-*.f64N/A

      \[\leadsto \frac{1}{c \cdot \color{blue}{\left(\left(s \cdot x\right) \cdot \left(\left(c \cdot s\right) \cdot x\right)\right)}} \]
    10. *-lowering-*.f64N/A

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

      \[\leadsto \frac{1}{c \cdot \left(\left(s \cdot x\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)} \]
    12. *-lowering-*.f64N/A

      \[\leadsto \frac{1}{c \cdot \left(\left(s \cdot x\right) \cdot \color{blue}{\left(c \cdot \left(s \cdot x\right)\right)}\right)} \]
    13. *-lowering-*.f6476.4

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

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

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

Alternative 15: 74.9% accurate, 9.0× speedup?

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

    \[\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. *-commutativeN/A

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

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}} \]
    4. pow-prod-downN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot \left(x \cdot x\right)} \]
    5. pow2N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(c \cdot s\right)}^{2} \cdot \color{blue}{{x}^{2}}} \]
    6. pow-prod-downN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
    7. pow-lowering-pow.f64N/A

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot \left({s}^{2} \cdot {x}^{2}\right)} \]
    3. associate-*l*N/A

      \[\leadsto \frac{1}{\color{blue}{c \cdot \left(c \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)}} \]
    4. *-lowering-*.f64N/A

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

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

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

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

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

      \[\leadsto \frac{1}{c \cdot \color{blue}{\left(s \cdot \left(s \cdot \left(c \cdot {x}^{2}\right)\right)\right)}} \]
    10. *-lowering-*.f64N/A

      \[\leadsto \frac{1}{c \cdot \color{blue}{\left(s \cdot \left(s \cdot \left(c \cdot {x}^{2}\right)\right)\right)}} \]
    11. *-lowering-*.f64N/A

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

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

      \[\leadsto \frac{1}{c \cdot \left(s \cdot \left(s \cdot \left(c \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right)} \]
    14. *-lowering-*.f6465.0

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

    \[\leadsto \color{blue}{\frac{1}{c \cdot \left(s \cdot \left(s \cdot \left(c \cdot \left(x \cdot x\right)\right)\right)\right)}} \]
  8. Step-by-step derivation
    1. *-commutativeN/A

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

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

      \[\leadsto \frac{1}{c \cdot \left(s \cdot \color{blue}{\left(\left(c \cdot x\right) \cdot \left(x \cdot s\right)\right)}\right)} \]
    4. *-commutativeN/A

      \[\leadsto \frac{1}{c \cdot \left(s \cdot \left(\left(c \cdot x\right) \cdot \color{blue}{\left(s \cdot x\right)}\right)\right)} \]
    5. *-lowering-*.f64N/A

      \[\leadsto \frac{1}{c \cdot \left(s \cdot \color{blue}{\left(\left(c \cdot x\right) \cdot \left(s \cdot x\right)\right)}\right)} \]
    6. *-lowering-*.f64N/A

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

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

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

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

Alternative 16: 66.1% accurate, 9.0× speedup?

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

    \[\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. *-commutativeN/A

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

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{\left({c}^{2} \cdot {s}^{2}\right) \cdot \left(x \cdot x\right)}} \]
    4. pow-prod-downN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(c \cdot s\right)}^{2}} \cdot \left(x \cdot x\right)} \]
    5. pow2N/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(c \cdot s\right)}^{2} \cdot \color{blue}{{x}^{2}}} \]
    6. pow-prod-downN/A

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{\color{blue}{{\left(\left(c \cdot s\right) \cdot x\right)}^{2}}} \]
    7. pow-lowering-pow.f64N/A

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot \left({s}^{2} \cdot {x}^{2}\right)} \]
    3. associate-*l*N/A

      \[\leadsto \frac{1}{\color{blue}{c \cdot \left(c \cdot \left({s}^{2} \cdot {x}^{2}\right)\right)}} \]
    4. *-lowering-*.f64N/A

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

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

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

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

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

      \[\leadsto \frac{1}{c \cdot \color{blue}{\left(s \cdot \left(s \cdot \left(c \cdot {x}^{2}\right)\right)\right)}} \]
    10. *-lowering-*.f64N/A

      \[\leadsto \frac{1}{c \cdot \color{blue}{\left(s \cdot \left(s \cdot \left(c \cdot {x}^{2}\right)\right)\right)}} \]
    11. *-lowering-*.f64N/A

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

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

      \[\leadsto \frac{1}{c \cdot \left(s \cdot \left(s \cdot \left(c \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right)} \]
    14. *-lowering-*.f6465.0

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

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

Reproduce

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