mixedcos

Percentage Accurate: 67.2% → 97.0%
Time: 10.9s
Alternatives: 16
Speedup: 2.4×

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: 67.2% accurate, 1.0× speedup?

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

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

Alternative 1: 97.0% accurate, 2.3× speedup?

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)}^{2}} \]
  4. Applied egg-rr96.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. 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. 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}} \]
    3. /-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}} \]
    4. /-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} \]
    5. 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} \]
    6. 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} \]
    7. +-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} \]
    8. *-commutativeN/A

      \[\leadsto \frac{\frac{\cos \left(x + x\right)}{\color{blue}{\left(s \cdot c\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}{s \cdot \left(c \cdot x\right)}}}{\left(c \cdot s\right) \cdot x} \]
    10. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 79.5% accurate, 0.5× speedup?

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

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{1}{\left(x \cdot s\right) \cdot \left(c \cdot \left(s \cdot \left(x \cdot c\right)\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 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))) < -9.99999999999999979e-150

    1. Initial program 61.9%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. 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-*.f6493.0

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

      \[\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{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    7. Simplified11.7%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x \cdot x, -2, 1\right) \cdot \frac{1}{c \cdot \left(c \cdot \left(s \cdot s\right)\right)}}{x \cdot x}} \]
    8. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
    9. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
      2. *-commutativeN/A

        \[\leadsto \frac{-2}{\color{blue}{{s}^{2} \cdot {c}^{2}}} \]
      3. unpow2N/A

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

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

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

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

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

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

        \[\leadsto \frac{-2}{s \cdot \color{blue}{\left(c \cdot \left(c \cdot s\right)\right)}} \]
      10. *-lowering-*.f6436.8

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

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

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

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

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

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

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

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

    if -9.99999999999999979e-150 < (/.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 82.6%

      \[\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-*.f6481.5

        \[\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. Simplified81.5%

      \[\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}{x \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)}} \]
      2. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(s \cdot x\right) \cdot \left(c \cdot \left(s \cdot \left(c \cdot x\right)\right)\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. 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-*.f6454.4

        \[\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. Simplified54.4%

      \[\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}{x \cdot \left(x \cdot \color{blue}{\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right)}\right)} \]
      2. *-commutativeN/A

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

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

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

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

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

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

Alternative 3: 79.0% accurate, 0.5× speedup?

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

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{1}{c \cdot \left(c \cdot \left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 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))) < -9.99999999999999979e-150

    1. Initial program 61.9%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. 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-*.f6493.0

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

      \[\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{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    7. Simplified11.7%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x \cdot x, -2, 1\right) \cdot \frac{1}{c \cdot \left(c \cdot \left(s \cdot s\right)\right)}}{x \cdot x}} \]
    8. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
    9. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
      2. *-commutativeN/A

        \[\leadsto \frac{-2}{\color{blue}{{s}^{2} \cdot {c}^{2}}} \]
      3. unpow2N/A

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

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

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

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

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

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

        \[\leadsto \frac{-2}{s \cdot \color{blue}{\left(c \cdot \left(c \cdot s\right)\right)}} \]
      10. *-lowering-*.f6436.8

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

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

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

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

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

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

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

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

    if -9.99999999999999979e-150 < (/.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 82.6%

      \[\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-*.f6481.5

        \[\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. Simplified81.5%

      \[\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 c\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
      6. pow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{c \cdot \left(c \cdot \left(\left(s \cdot x\right) \cdot \left(s \cdot x\right)\right)\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. 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-*.f6454.4

        \[\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. Simplified54.4%

      \[\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}{x \cdot \left(x \cdot \color{blue}{\left(\left(s \cdot c\right) \cdot \left(c \cdot s\right)\right)}\right)} \]
      2. *-commutativeN/A

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

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

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

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

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

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

Alternative 4: 77.1% accurate, 0.5× speedup?

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

\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{1}{c \cdot \left(c \cdot \left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 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))) < -9.99999999999999979e-150

    1. Initial program 61.9%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. 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-*.f6493.0

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

      \[\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{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    7. Simplified11.7%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x \cdot x, -2, 1\right) \cdot \frac{1}{c \cdot \left(c \cdot \left(s \cdot s\right)\right)}}{x \cdot x}} \]
    8. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
    9. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
      2. *-commutativeN/A

        \[\leadsto \frac{-2}{\color{blue}{{s}^{2} \cdot {c}^{2}}} \]
      3. unpow2N/A

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

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

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

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

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

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

        \[\leadsto \frac{-2}{s \cdot \color{blue}{\left(c \cdot \left(c \cdot s\right)\right)}} \]
      10. *-lowering-*.f6436.8

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

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

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

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

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

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

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

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

    if -9.99999999999999979e-150 < (/.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 82.6%

      \[\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-*.f6481.5

        \[\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. Simplified81.5%

      \[\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 c\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
      6. pow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{c \cdot \left(c \cdot \left(\left(s \cdot x\right) \cdot \left(s \cdot x\right)\right)\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-*.f6495.6

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 81.7% accurate, 0.9× speedup?

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

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


\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))) < -9.99999999999999979e-150

    1. Initial program 61.9%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. 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-*.f6493.0

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)}^{2}} \]
    4. Applied egg-rr93.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)}} \]
    6. Applied egg-rr99.3%

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999979e-150 < (/.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 64.0%

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

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

        \[\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.4%

      \[\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 c\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
      6. pow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 81.7% accurate, 0.9× speedup?

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

    1. Initial program 61.9%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. 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-*.f6493.0

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

      \[\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{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    7. Simplified11.7%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x \cdot x, -2, 1\right) \cdot \frac{1}{c \cdot \left(c \cdot \left(s \cdot s\right)\right)}}{x \cdot x}} \]
    8. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
    9. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
      2. *-commutativeN/A

        \[\leadsto \frac{-2}{\color{blue}{{s}^{2} \cdot {c}^{2}}} \]
      3. unpow2N/A

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

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

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

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

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

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

        \[\leadsto \frac{-2}{s \cdot \color{blue}{\left(c \cdot \left(c \cdot s\right)\right)}} \]
      10. *-lowering-*.f6436.8

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

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

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

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

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

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

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

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

    if -9.99999999999999979e-150 < (/.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 64.0%

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

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

        \[\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.4%

      \[\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 c\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
      6. pow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 81.7% accurate, 0.9× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_0 \cdot 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))) < -9.99999999999999979e-150

    1. Initial program 61.9%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. 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-*.f6493.0

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

      \[\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{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    7. Simplified11.7%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x \cdot x, -2, 1\right) \cdot \frac{1}{c \cdot \left(c \cdot \left(s \cdot s\right)\right)}}{x \cdot x}} \]
    8. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
    9. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
      2. *-commutativeN/A

        \[\leadsto \frac{-2}{\color{blue}{{s}^{2} \cdot {c}^{2}}} \]
      3. unpow2N/A

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

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

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

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

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

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

        \[\leadsto \frac{-2}{s \cdot \color{blue}{\left(c \cdot \left(c \cdot s\right)\right)}} \]
      10. *-lowering-*.f6436.8

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

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

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

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

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

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

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

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

    if -9.99999999999999979e-150 < (/.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 64.0%

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

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

        \[\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.4%

      \[\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 c\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
      6. pow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 81.6% accurate, 0.9× speedup?

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

\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_0 \cdot 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))) < -9.99999999999999979e-150

    1. Initial program 61.9%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. 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-*.f6493.0

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

      \[\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{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    7. Simplified11.7%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x \cdot x, -2, 1\right) \cdot \frac{1}{c \cdot \left(c \cdot \left(s \cdot s\right)\right)}}{x \cdot x}} \]
    8. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
    9. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
      2. *-commutativeN/A

        \[\leadsto \frac{-2}{\color{blue}{{s}^{2} \cdot {c}^{2}}} \]
      3. unpow2N/A

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

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

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

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

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

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

        \[\leadsto \frac{-2}{s \cdot \color{blue}{\left(c \cdot \left(c \cdot s\right)\right)}} \]
      10. *-lowering-*.f6436.8

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

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

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

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

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

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

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

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

    if -9.99999999999999979e-150 < (/.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 64.0%

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

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

        \[\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.4%

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

        \[\leadsto \color{blue}{\frac{1}{x \cdot \left(x \cdot \left(s \cdot \left(c \cdot \left(c \cdot s\right)\right)\right)\right)}} \]
      2. 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)}} \]
      3. *-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)}} \]
      4. 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)} \]
      5. *-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)} \]
      6. 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)}} \]
      7. *-lowering-*.f64N/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)}} \]
      8. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 75.7% accurate, 0.9× speedup?

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

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


\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))) < -9.99999999999999979e-150

    1. Initial program 61.9%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. 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-*.f6493.0

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

      \[\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{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
    7. Simplified11.7%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x \cdot x, -2, 1\right) \cdot \frac{1}{c \cdot \left(c \cdot \left(s \cdot s\right)\right)}}{x \cdot x}} \]
    8. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
    9. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
      2. *-commutativeN/A

        \[\leadsto \frac{-2}{\color{blue}{{s}^{2} \cdot {c}^{2}}} \]
      3. unpow2N/A

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

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

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

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

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

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

        \[\leadsto \frac{-2}{s \cdot \color{blue}{\left(c \cdot \left(c \cdot s\right)\right)}} \]
      10. *-lowering-*.f6436.8

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

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

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

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

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

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

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

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

    if -9.99999999999999979e-150 < (/.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 64.0%

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

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

        \[\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.4%

      \[\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 c\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
      6. pow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 84.4% accurate, 1.4× speedup?

\[\begin{array}{l} [x, c, s] = \mathsf{sort}([x, c, s])\\ \\ \begin{array}{l} t_0 := x \cdot \left(s \cdot c\right)\\ \mathbf{if}\;{s}^{2} \leq 2 \cdot 10^{+248}:\\ \;\;\;\;\frac{\cos \left(x + x\right)}{c \cdot \left(\left(x \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{t\_0}}{t\_0}\\ \end{array} \end{array} \]
NOTE: x, c, and s should be sorted in increasing order before calling this function.
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* x (* s c))))
   (if (<= (pow s 2.0) 2e+248)
     (/ (cos (+ x x)) (* c (* (* x c) (* x (* s s)))))
     (/ (/ 1.0 t_0) t_0))))
assert(x < c && c < s);
double code(double x, double c, double s) {
	double t_0 = x * (s * c);
	double tmp;
	if (pow(s, 2.0) <= 2e+248) {
		tmp = cos((x + x)) / (c * ((x * c) * (x * (s * s))));
	} else {
		tmp = (1.0 / t_0) / t_0;
	}
	return tmp;
}
NOTE: x, c, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x * (s * c)
    if ((s ** 2.0d0) <= 2d+248) then
        tmp = cos((x + x)) / (c * ((x * c) * (x * (s * s))))
    else
        tmp = (1.0d0 / t_0) / t_0
    end if
    code = tmp
end function
assert x < c && c < s;
public static double code(double x, double c, double s) {
	double t_0 = x * (s * c);
	double tmp;
	if (Math.pow(s, 2.0) <= 2e+248) {
		tmp = Math.cos((x + x)) / (c * ((x * c) * (x * (s * s))));
	} else {
		tmp = (1.0 / t_0) / t_0;
	}
	return tmp;
}
[x, c, s] = sort([x, c, s])
def code(x, c, s):
	t_0 = x * (s * c)
	tmp = 0
	if math.pow(s, 2.0) <= 2e+248:
		tmp = math.cos((x + x)) / (c * ((x * c) * (x * (s * s))))
	else:
		tmp = (1.0 / t_0) / t_0
	return tmp
x, c, s = sort([x, c, s])
function code(x, c, s)
	t_0 = Float64(x * Float64(s * c))
	tmp = 0.0
	if ((s ^ 2.0) <= 2e+248)
		tmp = Float64(cos(Float64(x + x)) / Float64(c * Float64(Float64(x * c) * Float64(x * Float64(s * s)))));
	else
		tmp = Float64(Float64(1.0 / t_0) / t_0);
	end
	return tmp
end
x, c, s = num2cell(sort([x, c, s])){:}
function tmp_2 = code(x, c, s)
	t_0 = x * (s * c);
	tmp = 0.0;
	if ((s ^ 2.0) <= 2e+248)
		tmp = cos((x + x)) / (c * ((x * c) * (x * (s * s))));
	else
		tmp = (1.0 / t_0) / t_0;
	end
	tmp_2 = tmp;
end
NOTE: x, c, and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[s, 2.0], $MachinePrecision], 2e+248], N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(c * N[(N[(x * c), $MachinePrecision] * N[(x * N[(s * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}
[x, c, s] = \mathsf{sort}([x, c, s])\\
\\
\begin{array}{l}
t_0 := x \cdot \left(s \cdot c\right)\\
\mathbf{if}\;{s}^{2} \leq 2 \cdot 10^{+248}:\\
\;\;\;\;\frac{\cos \left(x + x\right)}{c \cdot \left(\left(x \cdot c\right) \cdot \left(x \cdot \left(s \cdot s\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 (pow.f64 s #s(literal 2 binary64)) < 2.00000000000000009e248

    1. Initial program 66.9%

      \[\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-*.f6495.9

        \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)}^{2}} \]
    4. Applied egg-rr95.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)}} \]
    6. Applied egg-rr97.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000009e248 < (pow.f64 s #s(literal 2 binary64))

    1. Initial program 58.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-*.f6482.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. Simplified82.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 c\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
      6. pow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 83.7% accurate, 2.2× speedup?

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

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

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


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

    1. Initial program 64.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-*.f6471.6

        \[\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.6%

      \[\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 c\right) \cdot \left(s \cdot s\right)\right)} \cdot \left(x \cdot x\right)} \]
      6. pow2N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.90000000000000025e-7 < x < 3.9000000000000001e114

    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. 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-*.f6499.7

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

      \[\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)}} \]
    6. Applied egg-rr95.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.9000000000000001e114 < x

    1. Initial program 63.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-*.f6493.7

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

      \[\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)}} \]
    6. Applied egg-rr95.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 96.7% accurate, 2.4× speedup?

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

      \[\leadsto \frac{\cos \left(2 \cdot x\right)}{{\left(\color{blue}{\left(c \cdot s\right)} \cdot x\right)}^{2}} \]
  4. Applied egg-rr96.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. 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)}} \]
  6. Applied egg-rr97.3%

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

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

Alternative 13: 27.8% accurate, 12.4× speedup?

\[\begin{array}{l} [x, c, s] = \mathsf{sort}([x, c, s])\\ \\ \frac{-2}{c \cdot \left(s \cdot \left(s \cdot c\right)\right)} \end{array} \]
NOTE: x, c, and s should be sorted in increasing order before calling this function.
(FPCore (x c s) :precision binary64 (/ -2.0 (* c (* s (* s c)))))
assert(x < c && c < s);
double code(double x, double c, double s) {
	return -2.0 / (c * (s * (s * c)));
}
NOTE: x, c, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = (-2.0d0) / (c * (s * (s * c)))
end function
assert x < c && c < s;
public static double code(double x, double c, double s) {
	return -2.0 / (c * (s * (s * c)));
}
[x, c, s] = sort([x, c, s])
def code(x, c, s):
	return -2.0 / (c * (s * (s * c)))
x, c, s = sort([x, c, s])
function code(x, c, s)
	return Float64(-2.0 / Float64(c * Float64(s * Float64(s * c))))
end
x, c, s = num2cell(sort([x, c, s])){:}
function tmp = code(x, c, s)
	tmp = -2.0 / (c * (s * (s * c)));
end
NOTE: x, c, and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(-2.0 / N[(c * N[(s * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, c, s] = \mathsf{sort}([x, c, s])\\
\\
\frac{-2}{c \cdot \left(s \cdot \left(s \cdot c\right)\right)}
\end{array}
Derivation
  1. Initial program 63.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-*.f6496.8

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

    \[\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{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
  6. Step-by-step derivation
    1. /-lowering-/.f64N/A

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x \cdot x, -2, 1\right) \cdot \frac{1}{c \cdot \left(c \cdot \left(s \cdot s\right)\right)}}{x \cdot x}} \]
  8. Taylor expanded in x around inf

    \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
  9. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
    2. *-commutativeN/A

      \[\leadsto \frac{-2}{\color{blue}{{s}^{2} \cdot {c}^{2}}} \]
    3. unpow2N/A

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

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

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

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

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

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

      \[\leadsto \frac{-2}{s \cdot \color{blue}{\left(c \cdot \left(c \cdot s\right)\right)}} \]
    10. *-lowering-*.f6428.9

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

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

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

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

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

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

      \[\leadsto \frac{-2}{\color{blue}{\left(s \cdot \left(s \cdot c\right)\right)} \cdot c} \]
    6. *-lowering-*.f6428.6

      \[\leadsto \frac{-2}{\left(s \cdot \color{blue}{\left(s \cdot c\right)}\right) \cdot c} \]
  12. Applied egg-rr28.6%

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

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

Alternative 14: 29.2% accurate, 12.4× speedup?

\[\begin{array}{l} [x, c, s] = \mathsf{sort}([x, c, s])\\ \\ \frac{-2}{\left(s \cdot s\right) \cdot \left(c \cdot c\right)} \end{array} \]
NOTE: x, c, and s should be sorted in increasing order before calling this function.
(FPCore (x c s) :precision binary64 (/ -2.0 (* (* s s) (* c c))))
assert(x < c && c < s);
double code(double x, double c, double s) {
	return -2.0 / ((s * s) * (c * c));
}
NOTE: x, c, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = (-2.0d0) / ((s * s) * (c * c))
end function
assert x < c && c < s;
public static double code(double x, double c, double s) {
	return -2.0 / ((s * s) * (c * c));
}
[x, c, s] = sort([x, c, s])
def code(x, c, s):
	return -2.0 / ((s * s) * (c * c))
x, c, s = sort([x, c, s])
function code(x, c, s)
	return Float64(-2.0 / Float64(Float64(s * s) * Float64(c * c)))
end
x, c, s = num2cell(sort([x, c, s])){:}
function tmp = code(x, c, s)
	tmp = -2.0 / ((s * s) * (c * c));
end
NOTE: x, c, and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(-2.0 / N[(N[(s * s), $MachinePrecision] * N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, c, s] = \mathsf{sort}([x, c, s])\\
\\
\frac{-2}{\left(s \cdot s\right) \cdot \left(c \cdot c\right)}
\end{array}
Derivation
  1. Initial program 63.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-*.f6496.8

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

    \[\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{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
  6. Step-by-step derivation
    1. /-lowering-/.f64N/A

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x \cdot x, -2, 1\right) \cdot \frac{1}{c \cdot \left(c \cdot \left(s \cdot s\right)\right)}}{x \cdot x}} \]
  8. Taylor expanded in x around inf

    \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
  9. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
    2. *-commutativeN/A

      \[\leadsto \frac{-2}{\color{blue}{{s}^{2} \cdot {c}^{2}}} \]
    3. unpow2N/A

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

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

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

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

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

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

      \[\leadsto \frac{-2}{s \cdot \color{blue}{\left(c \cdot \left(c \cdot s\right)\right)}} \]
    10. *-lowering-*.f6428.9

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

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

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

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

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

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

      \[\leadsto \frac{-2}{\color{blue}{\left(s \cdot s\right)} \cdot \left(c \cdot c\right)} \]
    6. *-lowering-*.f6430.0

      \[\leadsto \frac{-2}{\left(s \cdot s\right) \cdot \color{blue}{\left(c \cdot c\right)}} \]
  12. Applied egg-rr30.0%

    \[\leadsto \frac{-2}{\color{blue}{\left(s \cdot s\right) \cdot \left(c \cdot c\right)}} \]
  13. Add Preprocessing

Alternative 15: 26.6% accurate, 12.4× speedup?

\[\begin{array}{l} [x, c, s] = \mathsf{sort}([x, c, s])\\ \\ \frac{-2}{\left(s \cdot c\right) \cdot \left(s \cdot c\right)} \end{array} \]
NOTE: x, c, and s should be sorted in increasing order before calling this function.
(FPCore (x c s) :precision binary64 (/ -2.0 (* (* s c) (* s c))))
assert(x < c && c < s);
double code(double x, double c, double s) {
	return -2.0 / ((s * c) * (s * c));
}
NOTE: x, c, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = (-2.0d0) / ((s * c) * (s * c))
end function
assert x < c && c < s;
public static double code(double x, double c, double s) {
	return -2.0 / ((s * c) * (s * c));
}
[x, c, s] = sort([x, c, s])
def code(x, c, s):
	return -2.0 / ((s * c) * (s * c))
x, c, s = sort([x, c, s])
function code(x, c, s)
	return Float64(-2.0 / Float64(Float64(s * c) * Float64(s * c)))
end
x, c, s = num2cell(sort([x, c, s])){:}
function tmp = code(x, c, s)
	tmp = -2.0 / ((s * c) * (s * c));
end
NOTE: x, c, and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(-2.0 / N[(N[(s * c), $MachinePrecision] * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, c, s] = \mathsf{sort}([x, c, s])\\
\\
\frac{-2}{\left(s \cdot c\right) \cdot \left(s \cdot c\right)}
\end{array}
Derivation
  1. Initial program 63.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-*.f6496.8

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

    \[\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{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
  6. Step-by-step derivation
    1. /-lowering-/.f64N/A

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x \cdot x, -2, 1\right) \cdot \frac{1}{c \cdot \left(c \cdot \left(s \cdot s\right)\right)}}{x \cdot x}} \]
  8. Taylor expanded in x around inf

    \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
  9. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
    2. *-commutativeN/A

      \[\leadsto \frac{-2}{\color{blue}{{s}^{2} \cdot {c}^{2}}} \]
    3. unpow2N/A

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

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

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

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

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

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

      \[\leadsto \frac{-2}{s \cdot \color{blue}{\left(c \cdot \left(c \cdot s\right)\right)}} \]
    10. *-lowering-*.f6428.9

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

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

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

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

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

      \[\leadsto \frac{-2}{\color{blue}{\left(s \cdot c\right)} \cdot \left(s \cdot c\right)} \]
    5. *-lowering-*.f6427.5

      \[\leadsto \frac{-2}{\left(s \cdot c\right) \cdot \color{blue}{\left(s \cdot c\right)}} \]
  12. Applied egg-rr27.5%

    \[\leadsto \frac{-2}{\color{blue}{\left(s \cdot c\right) \cdot \left(s \cdot c\right)}} \]
  13. Add Preprocessing

Alternative 16: 27.6% accurate, 12.4× speedup?

\[\begin{array}{l} [x, c, s] = \mathsf{sort}([x, c, s])\\ \\ \frac{-2}{s \cdot \left(c \cdot \left(s \cdot c\right)\right)} \end{array} \]
NOTE: x, c, and s should be sorted in increasing order before calling this function.
(FPCore (x c s) :precision binary64 (/ -2.0 (* s (* c (* s c)))))
assert(x < c && c < s);
double code(double x, double c, double s) {
	return -2.0 / (s * (c * (s * c)));
}
NOTE: x, c, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = (-2.0d0) / (s * (c * (s * c)))
end function
assert x < c && c < s;
public static double code(double x, double c, double s) {
	return -2.0 / (s * (c * (s * c)));
}
[x, c, s] = sort([x, c, s])
def code(x, c, s):
	return -2.0 / (s * (c * (s * c)))
x, c, s = sort([x, c, s])
function code(x, c, s)
	return Float64(-2.0 / Float64(s * Float64(c * Float64(s * c))))
end
x, c, s = num2cell(sort([x, c, s])){:}
function tmp = code(x, c, s)
	tmp = -2.0 / (s * (c * (s * c)));
end
NOTE: x, c, and s should be sorted in increasing order before calling this function.
code[x_, c_, s_] := N[(-2.0 / N[(s * N[(c * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, c, s] = \mathsf{sort}([x, c, s])\\
\\
\frac{-2}{s \cdot \left(c \cdot \left(s \cdot c\right)\right)}
\end{array}
Derivation
  1. Initial program 63.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-*.f6496.8

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

    \[\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{-2 \cdot \frac{{x}^{2}}{{c}^{2} \cdot {s}^{2}} + \frac{1}{{c}^{2} \cdot {s}^{2}}}{{x}^{2}}} \]
  6. Step-by-step derivation
    1. /-lowering-/.f64N/A

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x \cdot x, -2, 1\right) \cdot \frac{1}{c \cdot \left(c \cdot \left(s \cdot s\right)\right)}}{x \cdot x}} \]
  8. Taylor expanded in x around inf

    \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
  9. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{-2}{{c}^{2} \cdot {s}^{2}}} \]
    2. *-commutativeN/A

      \[\leadsto \frac{-2}{\color{blue}{{s}^{2} \cdot {c}^{2}}} \]
    3. unpow2N/A

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

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

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

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

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

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

      \[\leadsto \frac{-2}{s \cdot \color{blue}{\left(c \cdot \left(c \cdot s\right)\right)}} \]
    10. *-lowering-*.f6428.9

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

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

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

Reproduce

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