mixedcos

Percentage Accurate: 66.5% → 99.2%
Time: 18.3s
Alternatives: 13
Speedup: 24.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 13 alternatives:

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

Initial Program: 66.5% accurate, 1.0× speedup?

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

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

Alternative 1: 99.2% accurate, 0.5× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} t_0 := c \cdot \left(x\_m \cdot s\right)\\ t_1 := \cos \left(2 \cdot x\_m\right)\\ t_2 := \left(c \cdot s\right) \cdot \sqrt{x\_m}\\ \mathbf{if}\;\frac{t\_1}{{c}^{2} \cdot \left(x\_m \cdot \left(x\_m \cdot {s}^{2}\right)\right)} \leq \infty:\\ \;\;\;\;\frac{1}{t\_0} \cdot \frac{t\_1}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{t\_1}{x\_m}}{t\_2}}{t\_2}\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m c s)
 :precision binary64
 (let* ((t_0 (* c (* x_m s)))
        (t_1 (cos (* 2.0 x_m)))
        (t_2 (* (* c s) (sqrt x_m))))
   (if (<= (/ t_1 (* (pow c 2.0) (* x_m (* x_m (pow s 2.0))))) INFINITY)
     (* (/ 1.0 t_0) (/ t_1 t_0))
     (/ (/ (/ t_1 x_m) t_2) t_2))))
x_m = fabs(x);
double code(double x_m, double c, double s) {
	double t_0 = c * (x_m * s);
	double t_1 = cos((2.0 * x_m));
	double t_2 = (c * s) * sqrt(x_m);
	double tmp;
	if ((t_1 / (pow(c, 2.0) * (x_m * (x_m * pow(s, 2.0))))) <= ((double) INFINITY)) {
		tmp = (1.0 / t_0) * (t_1 / t_0);
	} else {
		tmp = ((t_1 / x_m) / t_2) / t_2;
	}
	return tmp;
}
x_m = Math.abs(x);
public static double code(double x_m, double c, double s) {
	double t_0 = c * (x_m * s);
	double t_1 = Math.cos((2.0 * x_m));
	double t_2 = (c * s) * Math.sqrt(x_m);
	double tmp;
	if ((t_1 / (Math.pow(c, 2.0) * (x_m * (x_m * Math.pow(s, 2.0))))) <= Double.POSITIVE_INFINITY) {
		tmp = (1.0 / t_0) * (t_1 / t_0);
	} else {
		tmp = ((t_1 / x_m) / t_2) / t_2;
	}
	return tmp;
}
x_m = math.fabs(x)
def code(x_m, c, s):
	t_0 = c * (x_m * s)
	t_1 = math.cos((2.0 * x_m))
	t_2 = (c * s) * math.sqrt(x_m)
	tmp = 0
	if (t_1 / (math.pow(c, 2.0) * (x_m * (x_m * math.pow(s, 2.0))))) <= math.inf:
		tmp = (1.0 / t_0) * (t_1 / t_0)
	else:
		tmp = ((t_1 / x_m) / t_2) / t_2
	return tmp
x_m = abs(x)
function code(x_m, c, s)
	t_0 = Float64(c * Float64(x_m * s))
	t_1 = cos(Float64(2.0 * x_m))
	t_2 = Float64(Float64(c * s) * sqrt(x_m))
	tmp = 0.0
	if (Float64(t_1 / Float64((c ^ 2.0) * Float64(x_m * Float64(x_m * (s ^ 2.0))))) <= Inf)
		tmp = Float64(Float64(1.0 / t_0) * Float64(t_1 / t_0));
	else
		tmp = Float64(Float64(Float64(t_1 / x_m) / t_2) / t_2);
	end
	return tmp
end
x_m = abs(x);
function tmp_2 = code(x_m, c, s)
	t_0 = c * (x_m * s);
	t_1 = cos((2.0 * x_m));
	t_2 = (c * s) * sqrt(x_m);
	tmp = 0.0;
	if ((t_1 / ((c ^ 2.0) * (x_m * (x_m * (s ^ 2.0))))) <= Inf)
		tmp = (1.0 / t_0) * (t_1 / t_0);
	else
		tmp = ((t_1 / x_m) / t_2) / t_2;
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, c_, s_] := Block[{t$95$0 = N[(c * N[(x$95$m * s), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(2.0 * x$95$m), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * s), $MachinePrecision] * N[Sqrt[x$95$m], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$1 / N[(N[Power[c, 2.0], $MachinePrecision] * N[(x$95$m * N[(x$95$m * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(t$95$1 / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$1 / x$95$m), $MachinePrecision] / t$95$2), $MachinePrecision] / t$95$2), $MachinePrecision]]]]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
t_0 := c \cdot \left(x\_m \cdot s\right)\\
t_1 := \cos \left(2 \cdot x\_m\right)\\
t_2 := \left(c \cdot s\right) \cdot \sqrt{x\_m}\\
\mathbf{if}\;\frac{t\_1}{{c}^{2} \cdot \left(x\_m \cdot \left(x\_m \cdot {s}^{2}\right)\right)} \leq \infty:\\
\;\;\;\;\frac{1}{t\_0} \cdot \frac{t\_1}{t\_0}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{t\_1}{x\_m}}{t\_2}}{t\_2}\\


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

    1. Initial program 80.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. Step-by-step derivation
      1. *-un-lft-identity80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    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. *-un-lft-identity0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.7% accurate, 0.5× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} t_0 := c \cdot \left(x\_m \cdot s\right)\\ t_1 := \cos \left(2 \cdot x\_m\right)\\ \mathbf{if}\;\frac{t\_1}{{c}^{2} \cdot \left(x\_m \cdot \left(x\_m \cdot {s}^{2}\right)\right)} \leq \infty:\\ \;\;\;\;\frac{1}{t\_0} \cdot \frac{t\_1}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{1}{\left(c \cdot s\right) \cdot \sqrt{x\_m}}\right)}^{2} \cdot \frac{t\_1}{x\_m}\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m c s)
 :precision binary64
 (let* ((t_0 (* c (* x_m s))) (t_1 (cos (* 2.0 x_m))))
   (if (<= (/ t_1 (* (pow c 2.0) (* x_m (* x_m (pow s 2.0))))) INFINITY)
     (* (/ 1.0 t_0) (/ t_1 t_0))
     (* (pow (/ 1.0 (* (* c s) (sqrt x_m))) 2.0) (/ t_1 x_m)))))
x_m = fabs(x);
double code(double x_m, double c, double s) {
	double t_0 = c * (x_m * s);
	double t_1 = cos((2.0 * x_m));
	double tmp;
	if ((t_1 / (pow(c, 2.0) * (x_m * (x_m * pow(s, 2.0))))) <= ((double) INFINITY)) {
		tmp = (1.0 / t_0) * (t_1 / t_0);
	} else {
		tmp = pow((1.0 / ((c * s) * sqrt(x_m))), 2.0) * (t_1 / x_m);
	}
	return tmp;
}
x_m = Math.abs(x);
public static double code(double x_m, double c, double s) {
	double t_0 = c * (x_m * s);
	double t_1 = Math.cos((2.0 * x_m));
	double tmp;
	if ((t_1 / (Math.pow(c, 2.0) * (x_m * (x_m * Math.pow(s, 2.0))))) <= Double.POSITIVE_INFINITY) {
		tmp = (1.0 / t_0) * (t_1 / t_0);
	} else {
		tmp = Math.pow((1.0 / ((c * s) * Math.sqrt(x_m))), 2.0) * (t_1 / x_m);
	}
	return tmp;
}
x_m = math.fabs(x)
def code(x_m, c, s):
	t_0 = c * (x_m * s)
	t_1 = math.cos((2.0 * x_m))
	tmp = 0
	if (t_1 / (math.pow(c, 2.0) * (x_m * (x_m * math.pow(s, 2.0))))) <= math.inf:
		tmp = (1.0 / t_0) * (t_1 / t_0)
	else:
		tmp = math.pow((1.0 / ((c * s) * math.sqrt(x_m))), 2.0) * (t_1 / x_m)
	return tmp
x_m = abs(x)
function code(x_m, c, s)
	t_0 = Float64(c * Float64(x_m * s))
	t_1 = cos(Float64(2.0 * x_m))
	tmp = 0.0
	if (Float64(t_1 / Float64((c ^ 2.0) * Float64(x_m * Float64(x_m * (s ^ 2.0))))) <= Inf)
		tmp = Float64(Float64(1.0 / t_0) * Float64(t_1 / t_0));
	else
		tmp = Float64((Float64(1.0 / Float64(Float64(c * s) * sqrt(x_m))) ^ 2.0) * Float64(t_1 / x_m));
	end
	return tmp
end
x_m = abs(x);
function tmp_2 = code(x_m, c, s)
	t_0 = c * (x_m * s);
	t_1 = cos((2.0 * x_m));
	tmp = 0.0;
	if ((t_1 / ((c ^ 2.0) * (x_m * (x_m * (s ^ 2.0))))) <= Inf)
		tmp = (1.0 / t_0) * (t_1 / t_0);
	else
		tmp = ((1.0 / ((c * s) * sqrt(x_m))) ^ 2.0) * (t_1 / x_m);
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, c_, s_] := Block[{t$95$0 = N[(c * N[(x$95$m * s), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(2.0 * x$95$m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$1 / N[(N[Power[c, 2.0], $MachinePrecision] * N[(x$95$m * N[(x$95$m * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(t$95$1 / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[(1.0 / N[(N[(c * s), $MachinePrecision] * N[Sqrt[x$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(t$95$1 / x$95$m), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
t_0 := c \cdot \left(x\_m \cdot s\right)\\
t_1 := \cos \left(2 \cdot x\_m\right)\\
\mathbf{if}\;\frac{t\_1}{{c}^{2} \cdot \left(x\_m \cdot \left(x\_m \cdot {s}^{2}\right)\right)} \leq \infty:\\
\;\;\;\;\frac{1}{t\_0} \cdot \frac{t\_1}{t\_0}\\

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


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

    1. Initial program 80.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. Step-by-step derivation
      1. *-un-lft-identity80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    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. *-un-lft-identity0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 93.3% accurate, 2.6× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} t_0 := \frac{\frac{1}{c}}{x\_m \cdot s}\\ \mathbf{if}\;x\_m \leq 4.4 \cdot 10^{-45}:\\ \;\;\;\;t\_0 \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cos \left(2 \cdot x\_m\right)}{c \cdot \left(\left(x\_m \cdot s\right) \cdot \left(x\_m \cdot c\right)\right)}}{s}\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m c s)
 :precision binary64
 (let* ((t_0 (/ (/ 1.0 c) (* x_m s))))
   (if (<= x_m 4.4e-45)
     (* t_0 t_0)
     (/ (/ (cos (* 2.0 x_m)) (* c (* (* x_m s) (* x_m c)))) s))))
x_m = fabs(x);
double code(double x_m, double c, double s) {
	double t_0 = (1.0 / c) / (x_m * s);
	double tmp;
	if (x_m <= 4.4e-45) {
		tmp = t_0 * t_0;
	} else {
		tmp = (cos((2.0 * x_m)) / (c * ((x_m * s) * (x_m * c)))) / s;
	}
	return tmp;
}
x_m = abs(x)
real(8) function code(x_m, c, s)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (1.0d0 / c) / (x_m * s)
    if (x_m <= 4.4d-45) then
        tmp = t_0 * t_0
    else
        tmp = (cos((2.0d0 * x_m)) / (c * ((x_m * s) * (x_m * c)))) / s
    end if
    code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double c, double s) {
	double t_0 = (1.0 / c) / (x_m * s);
	double tmp;
	if (x_m <= 4.4e-45) {
		tmp = t_0 * t_0;
	} else {
		tmp = (Math.cos((2.0 * x_m)) / (c * ((x_m * s) * (x_m * c)))) / s;
	}
	return tmp;
}
x_m = math.fabs(x)
def code(x_m, c, s):
	t_0 = (1.0 / c) / (x_m * s)
	tmp = 0
	if x_m <= 4.4e-45:
		tmp = t_0 * t_0
	else:
		tmp = (math.cos((2.0 * x_m)) / (c * ((x_m * s) * (x_m * c)))) / s
	return tmp
x_m = abs(x)
function code(x_m, c, s)
	t_0 = Float64(Float64(1.0 / c) / Float64(x_m * s))
	tmp = 0.0
	if (x_m <= 4.4e-45)
		tmp = Float64(t_0 * t_0);
	else
		tmp = Float64(Float64(cos(Float64(2.0 * x_m)) / Float64(c * Float64(Float64(x_m * s) * Float64(x_m * c)))) / s);
	end
	return tmp
end
x_m = abs(x);
function tmp_2 = code(x_m, c, s)
	t_0 = (1.0 / c) / (x_m * s);
	tmp = 0.0;
	if (x_m <= 4.4e-45)
		tmp = t_0 * t_0;
	else
		tmp = (cos((2.0 * x_m)) / (c * ((x_m * s) * (x_m * c)))) / s;
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, c_, s_] := Block[{t$95$0 = N[(N[(1.0 / c), $MachinePrecision] / N[(x$95$m * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$95$m, 4.4e-45], N[(t$95$0 * t$95$0), $MachinePrecision], N[(N[(N[Cos[N[(2.0 * x$95$m), $MachinePrecision]], $MachinePrecision] / N[(c * N[(N[(x$95$m * s), $MachinePrecision] * N[(x$95$m * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / s), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
t_0 := \frac{\frac{1}{c}}{x\_m \cdot s}\\
\mathbf{if}\;x\_m \leq 4.4 \cdot 10^{-45}:\\
\;\;\;\;t\_0 \cdot t\_0\\

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


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

    1. Initial program 64.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 52.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{c}}{x \cdot s} \cdot \color{blue}{\frac{\frac{1}{c}}{x \cdot s}} \]
    7. Applied egg-rr79.4%

      \[\leadsto \color{blue}{\frac{\frac{1}{c}}{x \cdot s} \cdot \frac{\frac{1}{c}}{x \cdot s}} \]

    if 4.39999999999999987e-45 < x

    1. Initial program 70.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 93.8% accurate, 2.6× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} t_0 := \frac{\frac{1}{c}}{x\_m \cdot s}\\ \mathbf{if}\;x\_m \leq 6.8 \cdot 10^{-46}:\\ \;\;\;\;t\_0 \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{\cos \left(2 \cdot x\_m\right)}{c \cdot \left(x\_m \cdot \left(c \cdot s\right)\right)}}{x\_m}}{s}\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m c s)
 :precision binary64
 (let* ((t_0 (/ (/ 1.0 c) (* x_m s))))
   (if (<= x_m 6.8e-46)
     (* t_0 t_0)
     (/ (/ (/ (cos (* 2.0 x_m)) (* c (* x_m (* c s)))) x_m) s))))
x_m = fabs(x);
double code(double x_m, double c, double s) {
	double t_0 = (1.0 / c) / (x_m * s);
	double tmp;
	if (x_m <= 6.8e-46) {
		tmp = t_0 * t_0;
	} else {
		tmp = ((cos((2.0 * x_m)) / (c * (x_m * (c * s)))) / x_m) / s;
	}
	return tmp;
}
x_m = abs(x)
real(8) function code(x_m, c, s)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (1.0d0 / c) / (x_m * s)
    if (x_m <= 6.8d-46) then
        tmp = t_0 * t_0
    else
        tmp = ((cos((2.0d0 * x_m)) / (c * (x_m * (c * s)))) / x_m) / s
    end if
    code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double c, double s) {
	double t_0 = (1.0 / c) / (x_m * s);
	double tmp;
	if (x_m <= 6.8e-46) {
		tmp = t_0 * t_0;
	} else {
		tmp = ((Math.cos((2.0 * x_m)) / (c * (x_m * (c * s)))) / x_m) / s;
	}
	return tmp;
}
x_m = math.fabs(x)
def code(x_m, c, s):
	t_0 = (1.0 / c) / (x_m * s)
	tmp = 0
	if x_m <= 6.8e-46:
		tmp = t_0 * t_0
	else:
		tmp = ((math.cos((2.0 * x_m)) / (c * (x_m * (c * s)))) / x_m) / s
	return tmp
x_m = abs(x)
function code(x_m, c, s)
	t_0 = Float64(Float64(1.0 / c) / Float64(x_m * s))
	tmp = 0.0
	if (x_m <= 6.8e-46)
		tmp = Float64(t_0 * t_0);
	else
		tmp = Float64(Float64(Float64(cos(Float64(2.0 * x_m)) / Float64(c * Float64(x_m * Float64(c * s)))) / x_m) / s);
	end
	return tmp
end
x_m = abs(x);
function tmp_2 = code(x_m, c, s)
	t_0 = (1.0 / c) / (x_m * s);
	tmp = 0.0;
	if (x_m <= 6.8e-46)
		tmp = t_0 * t_0;
	else
		tmp = ((cos((2.0 * x_m)) / (c * (x_m * (c * s)))) / x_m) / s;
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, c_, s_] := Block[{t$95$0 = N[(N[(1.0 / c), $MachinePrecision] / N[(x$95$m * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$95$m, 6.8e-46], N[(t$95$0 * t$95$0), $MachinePrecision], N[(N[(N[(N[Cos[N[(2.0 * x$95$m), $MachinePrecision]], $MachinePrecision] / N[(c * N[(x$95$m * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x$95$m), $MachinePrecision] / s), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
t_0 := \frac{\frac{1}{c}}{x\_m \cdot s}\\
\mathbf{if}\;x\_m \leq 6.8 \cdot 10^{-46}:\\
\;\;\;\;t\_0 \cdot t\_0\\

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


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

    1. Initial program 64.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 52.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{c}}{x \cdot s} \cdot \color{blue}{\frac{\frac{1}{c}}{x \cdot s}} \]
    7. Applied egg-rr79.4%

      \[\leadsto \color{blue}{\frac{\frac{1}{c}}{x \cdot s} \cdot \frac{\frac{1}{c}}{x \cdot s}} \]

    if 6.79999999999999992e-46 < x

    1. Initial program 70.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 94.8% accurate, 2.6× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} t_0 := \frac{\frac{1}{c}}{x\_m \cdot s}\\ \mathbf{if}\;x\_m \leq 1.02 \cdot 10^{-20}:\\ \;\;\;\;t\_0 \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{\cos \left(2 \cdot x\_m\right)}{x\_m \cdot \left(c \cdot s\right)}}{x\_m \cdot c}}{s}\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m c s)
 :precision binary64
 (let* ((t_0 (/ (/ 1.0 c) (* x_m s))))
   (if (<= x_m 1.02e-20)
     (* t_0 t_0)
     (/ (/ (/ (cos (* 2.0 x_m)) (* x_m (* c s))) (* x_m c)) s))))
x_m = fabs(x);
double code(double x_m, double c, double s) {
	double t_0 = (1.0 / c) / (x_m * s);
	double tmp;
	if (x_m <= 1.02e-20) {
		tmp = t_0 * t_0;
	} else {
		tmp = ((cos((2.0 * x_m)) / (x_m * (c * s))) / (x_m * c)) / s;
	}
	return tmp;
}
x_m = abs(x)
real(8) function code(x_m, c, s)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (1.0d0 / c) / (x_m * s)
    if (x_m <= 1.02d-20) then
        tmp = t_0 * t_0
    else
        tmp = ((cos((2.0d0 * x_m)) / (x_m * (c * s))) / (x_m * c)) / s
    end if
    code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double c, double s) {
	double t_0 = (1.0 / c) / (x_m * s);
	double tmp;
	if (x_m <= 1.02e-20) {
		tmp = t_0 * t_0;
	} else {
		tmp = ((Math.cos((2.0 * x_m)) / (x_m * (c * s))) / (x_m * c)) / s;
	}
	return tmp;
}
x_m = math.fabs(x)
def code(x_m, c, s):
	t_0 = (1.0 / c) / (x_m * s)
	tmp = 0
	if x_m <= 1.02e-20:
		tmp = t_0 * t_0
	else:
		tmp = ((math.cos((2.0 * x_m)) / (x_m * (c * s))) / (x_m * c)) / s
	return tmp
x_m = abs(x)
function code(x_m, c, s)
	t_0 = Float64(Float64(1.0 / c) / Float64(x_m * s))
	tmp = 0.0
	if (x_m <= 1.02e-20)
		tmp = Float64(t_0 * t_0);
	else
		tmp = Float64(Float64(Float64(cos(Float64(2.0 * x_m)) / Float64(x_m * Float64(c * s))) / Float64(x_m * c)) / s);
	end
	return tmp
end
x_m = abs(x);
function tmp_2 = code(x_m, c, s)
	t_0 = (1.0 / c) / (x_m * s);
	tmp = 0.0;
	if (x_m <= 1.02e-20)
		tmp = t_0 * t_0;
	else
		tmp = ((cos((2.0 * x_m)) / (x_m * (c * s))) / (x_m * c)) / s;
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, c_, s_] := Block[{t$95$0 = N[(N[(1.0 / c), $MachinePrecision] / N[(x$95$m * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$95$m, 1.02e-20], N[(t$95$0 * t$95$0), $MachinePrecision], N[(N[(N[(N[Cos[N[(2.0 * x$95$m), $MachinePrecision]], $MachinePrecision] / N[(x$95$m * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x$95$m * c), $MachinePrecision]), $MachinePrecision] / s), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
t_0 := \frac{\frac{1}{c}}{x\_m \cdot s}\\
\mathbf{if}\;x\_m \leq 1.02 \cdot 10^{-20}:\\
\;\;\;\;t\_0 \cdot t\_0\\

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


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

    1. Initial program 64.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{c}}{x \cdot s} \cdot \frac{\frac{1}{c}}{x \cdot s}} \]

    if 1.02000000000000001e-20 < x

    1. Initial program 70.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 97.2% accurate, 2.7× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} t_0 := c \cdot \left(x\_m \cdot s\right)\\ \frac{1}{t\_0} \cdot \frac{\cos \left(2 \cdot x\_m\right)}{t\_0} \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m c s)
 :precision binary64
 (let* ((t_0 (* c (* x_m s)))) (* (/ 1.0 t_0) (/ (cos (* 2.0 x_m)) t_0))))
x_m = fabs(x);
double code(double x_m, double c, double s) {
	double t_0 = c * (x_m * s);
	return (1.0 / t_0) * (cos((2.0 * x_m)) / t_0);
}
x_m = abs(x)
real(8) function code(x_m, c, s)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: t_0
    t_0 = c * (x_m * s)
    code = (1.0d0 / t_0) * (cos((2.0d0 * x_m)) / t_0)
end function
x_m = Math.abs(x);
public static double code(double x_m, double c, double s) {
	double t_0 = c * (x_m * s);
	return (1.0 / t_0) * (Math.cos((2.0 * x_m)) / t_0);
}
x_m = math.fabs(x)
def code(x_m, c, s):
	t_0 = c * (x_m * s)
	return (1.0 / t_0) * (math.cos((2.0 * x_m)) / t_0)
x_m = abs(x)
function code(x_m, c, s)
	t_0 = Float64(c * Float64(x_m * s))
	return Float64(Float64(1.0 / t_0) * Float64(cos(Float64(2.0 * x_m)) / t_0))
end
x_m = abs(x);
function tmp = code(x_m, c, s)
	t_0 = c * (x_m * s);
	tmp = (1.0 / t_0) * (cos((2.0 * x_m)) / t_0);
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, c_, s_] := Block[{t$95$0 = N[(c * N[(x$95$m * s), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(N[Cos[N[(2.0 * x$95$m), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
t_0 := c \cdot \left(x\_m \cdot s\right)\\
\frac{1}{t\_0} \cdot \frac{\cos \left(2 \cdot x\_m\right)}{t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 66.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 93.7% accurate, 2.7× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \frac{\frac{\cos \left(2 \cdot x\_m\right)}{c}}{\left(x\_m \cdot s\right) \cdot \left(c \cdot \left(x\_m \cdot s\right)\right)} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m c s)
 :precision binary64
 (/ (/ (cos (* 2.0 x_m)) c) (* (* x_m s) (* c (* x_m s)))))
x_m = fabs(x);
double code(double x_m, double c, double s) {
	return (cos((2.0 * x_m)) / c) / ((x_m * s) * (c * (x_m * s)));
}
x_m = abs(x)
real(8) function code(x_m, c, s)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = (cos((2.0d0 * x_m)) / c) / ((x_m * s) * (c * (x_m * s)))
end function
x_m = Math.abs(x);
public static double code(double x_m, double c, double s) {
	return (Math.cos((2.0 * x_m)) / c) / ((x_m * s) * (c * (x_m * s)));
}
x_m = math.fabs(x)
def code(x_m, c, s):
	return (math.cos((2.0 * x_m)) / c) / ((x_m * s) * (c * (x_m * s)))
x_m = abs(x)
function code(x_m, c, s)
	return Float64(Float64(cos(Float64(2.0 * x_m)) / c) / Float64(Float64(x_m * s) * Float64(c * Float64(x_m * s))))
end
x_m = abs(x);
function tmp = code(x_m, c, s)
	tmp = (cos((2.0 * x_m)) / c) / ((x_m * s) * (c * (x_m * s)));
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, c_, s_] := N[(N[(N[Cos[N[(2.0 * x$95$m), $MachinePrecision]], $MachinePrecision] / c), $MachinePrecision] / N[(N[(x$95$m * s), $MachinePrecision] * N[(c * N[(x$95$m * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|

\\
\frac{\frac{\cos \left(2 \cdot x\_m\right)}{c}}{\left(x\_m \cdot s\right) \cdot \left(c \cdot \left(x\_m \cdot s\right)\right)}
\end{array}
Derivation
  1. Initial program 66.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 76.1% accurate, 17.4× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} \mathbf{if}\;s \leq 1.2 \cdot 10^{+224}:\\ \;\;\;\;\frac{1}{\left(x\_m \cdot c\right) \cdot \left(s \cdot \left(c \cdot \left(x\_m \cdot s\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(c \cdot s\right) \cdot \left(x\_m \cdot \left(x\_m \cdot \left(c \cdot s\right)\right)\right)}\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m c s)
 :precision binary64
 (if (<= s 1.2e+224)
   (/ 1.0 (* (* x_m c) (* s (* c (* x_m s)))))
   (/ 1.0 (* (* c s) (* x_m (* x_m (* c s)))))))
x_m = fabs(x);
double code(double x_m, double c, double s) {
	double tmp;
	if (s <= 1.2e+224) {
		tmp = 1.0 / ((x_m * c) * (s * (c * (x_m * s))));
	} else {
		tmp = 1.0 / ((c * s) * (x_m * (x_m * (c * s))));
	}
	return tmp;
}
x_m = abs(x)
real(8) function code(x_m, c, s)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: tmp
    if (s <= 1.2d+224) then
        tmp = 1.0d0 / ((x_m * c) * (s * (c * (x_m * s))))
    else
        tmp = 1.0d0 / ((c * s) * (x_m * (x_m * (c * s))))
    end if
    code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double c, double s) {
	double tmp;
	if (s <= 1.2e+224) {
		tmp = 1.0 / ((x_m * c) * (s * (c * (x_m * s))));
	} else {
		tmp = 1.0 / ((c * s) * (x_m * (x_m * (c * s))));
	}
	return tmp;
}
x_m = math.fabs(x)
def code(x_m, c, s):
	tmp = 0
	if s <= 1.2e+224:
		tmp = 1.0 / ((x_m * c) * (s * (c * (x_m * s))))
	else:
		tmp = 1.0 / ((c * s) * (x_m * (x_m * (c * s))))
	return tmp
x_m = abs(x)
function code(x_m, c, s)
	tmp = 0.0
	if (s <= 1.2e+224)
		tmp = Float64(1.0 / Float64(Float64(x_m * c) * Float64(s * Float64(c * Float64(x_m * s)))));
	else
		tmp = Float64(1.0 / Float64(Float64(c * s) * Float64(x_m * Float64(x_m * Float64(c * s)))));
	end
	return tmp
end
x_m = abs(x);
function tmp_2 = code(x_m, c, s)
	tmp = 0.0;
	if (s <= 1.2e+224)
		tmp = 1.0 / ((x_m * c) * (s * (c * (x_m * s))));
	else
		tmp = 1.0 / ((c * s) * (x_m * (x_m * (c * s))));
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, c_, s_] := If[LessEqual[s, 1.2e+224], N[(1.0 / N[(N[(x$95$m * c), $MachinePrecision] * N[(s * N[(c * N[(x$95$m * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(c * s), $MachinePrecision] * N[(x$95$m * N[(x$95$m * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
\mathbf{if}\;s \leq 1.2 \cdot 10^{+224}:\\
\;\;\;\;\frac{1}{\left(x\_m \cdot c\right) \cdot \left(s \cdot \left(c \cdot \left(x\_m \cdot s\right)\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if s < 1.2e224

    1. Initial program 67.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 52.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.2e224 < s

    1. Initial program 61.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 78.5% accurate, 20.9× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} t_0 := \frac{\frac{1}{c}}{x\_m \cdot s}\\ t\_0 \cdot t\_0 \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m c s)
 :precision binary64
 (let* ((t_0 (/ (/ 1.0 c) (* x_m s)))) (* t_0 t_0)))
x_m = fabs(x);
double code(double x_m, double c, double s) {
	double t_0 = (1.0 / c) / (x_m * s);
	return t_0 * t_0;
}
x_m = abs(x)
real(8) function code(x_m, c, s)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: t_0
    t_0 = (1.0d0 / c) / (x_m * s)
    code = t_0 * t_0
end function
x_m = Math.abs(x);
public static double code(double x_m, double c, double s) {
	double t_0 = (1.0 / c) / (x_m * s);
	return t_0 * t_0;
}
x_m = math.fabs(x)
def code(x_m, c, s):
	t_0 = (1.0 / c) / (x_m * s)
	return t_0 * t_0
x_m = abs(x)
function code(x_m, c, s)
	t_0 = Float64(Float64(1.0 / c) / Float64(x_m * s))
	return Float64(t_0 * t_0)
end
x_m = abs(x);
function tmp = code(x_m, c, s)
	t_0 = (1.0 / c) / (x_m * s);
	tmp = t_0 * t_0;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, c_, s_] := Block[{t$95$0 = N[(N[(1.0 / c), $MachinePrecision] / N[(x$95$m * s), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
t_0 := \frac{\frac{1}{c}}{x\_m \cdot s}\\
t\_0 \cdot t\_0
\end{array}
\end{array}
Derivation
  1. Initial program 66.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{1}{c}}{x \cdot s} \cdot \frac{\frac{1}{c}}{x \cdot s}} \]
  8. Final simplification75.1%

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

Alternative 10: 75.5% accurate, 24.1× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \frac{1}{\left(c \cdot s\right) \cdot \left(x\_m \cdot \left(c \cdot \left(x\_m \cdot s\right)\right)\right)} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m c s)
 :precision binary64
 (/ 1.0 (* (* c s) (* x_m (* c (* x_m s))))))
x_m = fabs(x);
double code(double x_m, double c, double s) {
	return 1.0 / ((c * s) * (x_m * (c * (x_m * s))));
}
x_m = abs(x)
real(8) function code(x_m, c, s)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = 1.0d0 / ((c * s) * (x_m * (c * (x_m * s))))
end function
x_m = Math.abs(x);
public static double code(double x_m, double c, double s) {
	return 1.0 / ((c * s) * (x_m * (c * (x_m * s))));
}
x_m = math.fabs(x)
def code(x_m, c, s):
	return 1.0 / ((c * s) * (x_m * (c * (x_m * s))))
x_m = abs(x)
function code(x_m, c, s)
	return Float64(1.0 / Float64(Float64(c * s) * Float64(x_m * Float64(c * Float64(x_m * s)))))
end
x_m = abs(x);
function tmp = code(x_m, c, s)
	tmp = 1.0 / ((c * s) * (x_m * (c * (x_m * s))));
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, c_, s_] := N[(1.0 / N[(N[(c * s), $MachinePrecision] * N[(x$95$m * N[(c * N[(x$95$m * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|

\\
\frac{1}{\left(c \cdot s\right) \cdot \left(x\_m \cdot \left(c \cdot \left(x\_m \cdot s\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 66.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 76.1% accurate, 24.1× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \frac{1}{\left(c \cdot s\right) \cdot \left(x\_m \cdot \left(x\_m \cdot \left(c \cdot s\right)\right)\right)} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m c s)
 :precision binary64
 (/ 1.0 (* (* c s) (* x_m (* x_m (* c s))))))
x_m = fabs(x);
double code(double x_m, double c, double s) {
	return 1.0 / ((c * s) * (x_m * (x_m * (c * s))));
}
x_m = abs(x)
real(8) function code(x_m, c, s)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = 1.0d0 / ((c * s) * (x_m * (x_m * (c * s))))
end function
x_m = Math.abs(x);
public static double code(double x_m, double c, double s) {
	return 1.0 / ((c * s) * (x_m * (x_m * (c * s))));
}
x_m = math.fabs(x)
def code(x_m, c, s):
	return 1.0 / ((c * s) * (x_m * (x_m * (c * s))))
x_m = abs(x)
function code(x_m, c, s)
	return Float64(1.0 / Float64(Float64(c * s) * Float64(x_m * Float64(x_m * Float64(c * s)))))
end
x_m = abs(x);
function tmp = code(x_m, c, s)
	tmp = 1.0 / ((c * s) * (x_m * (x_m * (c * s))));
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, c_, s_] := N[(1.0 / N[(N[(c * s), $MachinePrecision] * N[(x$95$m * N[(x$95$m * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|

\\
\frac{1}{\left(c \cdot s\right) \cdot \left(x\_m \cdot \left(x\_m \cdot \left(c \cdot s\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 66.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 76.4% accurate, 24.1× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \frac{1}{\left(x\_m \cdot s\right) \cdot \left(c \cdot \left(c \cdot \left(x\_m \cdot s\right)\right)\right)} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m c s)
 :precision binary64
 (/ 1.0 (* (* x_m s) (* c (* c (* x_m s))))))
x_m = fabs(x);
double code(double x_m, double c, double s) {
	return 1.0 / ((x_m * s) * (c * (c * (x_m * s))));
}
x_m = abs(x)
real(8) function code(x_m, c, s)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    code = 1.0d0 / ((x_m * s) * (c * (c * (x_m * s))))
end function
x_m = Math.abs(x);
public static double code(double x_m, double c, double s) {
	return 1.0 / ((x_m * s) * (c * (c * (x_m * s))));
}
x_m = math.fabs(x)
def code(x_m, c, s):
	return 1.0 / ((x_m * s) * (c * (c * (x_m * s))))
x_m = abs(x)
function code(x_m, c, s)
	return Float64(1.0 / Float64(Float64(x_m * s) * Float64(c * Float64(c * Float64(x_m * s)))))
end
x_m = abs(x);
function tmp = code(x_m, c, s)
	tmp = 1.0 / ((x_m * s) * (c * (c * (x_m * s))));
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, c_, s_] := N[(1.0 / N[(N[(x$95$m * s), $MachinePrecision] * N[(c * N[(c * N[(x$95$m * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|

\\
\frac{1}{\left(x\_m \cdot s\right) \cdot \left(c \cdot \left(c \cdot \left(x\_m \cdot s\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 66.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 78.5% accurate, 24.1× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} t_0 := c \cdot \left(x\_m \cdot s\right)\\ \frac{\frac{1}{t\_0}}{t\_0} \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m c s)
 :precision binary64
 (let* ((t_0 (* c (* x_m s)))) (/ (/ 1.0 t_0) t_0)))
x_m = fabs(x);
double code(double x_m, double c, double s) {
	double t_0 = c * (x_m * s);
	return (1.0 / t_0) / t_0;
}
x_m = abs(x)
real(8) function code(x_m, c, s)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: t_0
    t_0 = c * (x_m * s)
    code = (1.0d0 / t_0) / t_0
end function
x_m = Math.abs(x);
public static double code(double x_m, double c, double s) {
	double t_0 = c * (x_m * s);
	return (1.0 / t_0) / t_0;
}
x_m = math.fabs(x)
def code(x_m, c, s):
	t_0 = c * (x_m * s)
	return (1.0 / t_0) / t_0
x_m = abs(x)
function code(x_m, c, s)
	t_0 = Float64(c * Float64(x_m * s))
	return Float64(Float64(1.0 / t_0) / t_0)
end
x_m = abs(x);
function tmp = code(x_m, c, s)
	t_0 = c * (x_m * s);
	tmp = (1.0 / t_0) / t_0;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, c_, s_] := Block[{t$95$0 = N[(c * N[(x$95$m * s), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
t_0 := c \cdot \left(x\_m \cdot s\right)\\
\frac{\frac{1}{t\_0}}{t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 66.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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