mixedcos

Percentage Accurate: 66.3% → 97.5%
Time: 12.5s
Alternatives: 9
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 9 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.3% accurate, 1.0× speedup?

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

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

Alternative 1: 97.5% accurate, 1.5× speedup?

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

\\
\cos \left(x \cdot 2\right) \cdot {\left(x \cdot \left(s \cdot c\right)\right)}^{-2}
\end{array}
Derivation
  1. Initial program 61.7%

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

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

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

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

      \[\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-pow146.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-eval46.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. pow146.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. *-commutative46.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*43.6%

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

      \[\leadsto \frac{1}{c \cdot \sqrt{{s}^{2} \cdot \color{blue}{{x}^{2}}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    11. pow-prod-down46.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-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-rr97.2%

    \[\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. *-commutative97.2%

      \[\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*97.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 96.3% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(x \cdot 2\right)\\ t_1 := c \cdot \left(x \cdot s\right)\\ \mathbf{if}\;x \leq 1.5 \cdot 10^{+91}:\\ \;\;\;\;\frac{\frac{t\_0}{t\_1}}{t\_1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{t\_0}{x}}{c}}{s \cdot \left(x \cdot \left(s \cdot c\right)\right)}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (cos (* x 2.0))) (t_1 (* c (* x s))))
   (if (<= x 1.5e+91)
     (/ (/ t_0 t_1) t_1)
     (/ (/ (/ t_0 x) c) (* s (* x (* s c)))))))
double code(double x, double c, double s) {
	double t_0 = cos((x * 2.0));
	double t_1 = c * (x * s);
	double tmp;
	if (x <= 1.5e+91) {
		tmp = (t_0 / t_1) / t_1;
	} else {
		tmp = ((t_0 / x) / c) / (s * (x * (s * c)));
	}
	return tmp;
}
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = cos((x * 2.0d0))
    t_1 = c * (x * s)
    if (x <= 1.5d+91) then
        tmp = (t_0 / t_1) / t_1
    else
        tmp = ((t_0 / x) / c) / (s * (x * (s * c)))
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double t_0 = Math.cos((x * 2.0));
	double t_1 = c * (x * s);
	double tmp;
	if (x <= 1.5e+91) {
		tmp = (t_0 / t_1) / t_1;
	} else {
		tmp = ((t_0 / x) / c) / (s * (x * (s * c)));
	}
	return tmp;
}
def code(x, c, s):
	t_0 = math.cos((x * 2.0))
	t_1 = c * (x * s)
	tmp = 0
	if x <= 1.5e+91:
		tmp = (t_0 / t_1) / t_1
	else:
		tmp = ((t_0 / x) / c) / (s * (x * (s * c)))
	return tmp
function code(x, c, s)
	t_0 = cos(Float64(x * 2.0))
	t_1 = Float64(c * Float64(x * s))
	tmp = 0.0
	if (x <= 1.5e+91)
		tmp = Float64(Float64(t_0 / t_1) / t_1);
	else
		tmp = Float64(Float64(Float64(t_0 / x) / c) / Float64(s * Float64(x * Float64(s * c))));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	t_0 = cos((x * 2.0));
	t_1 = c * (x * s);
	tmp = 0.0;
	if (x <= 1.5e+91)
		tmp = (t_0 / t_1) / t_1;
	else
		tmp = ((t_0 / x) / c) / (s * (x * (s * c)));
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := Block[{t$95$0 = N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.5e+91], N[(N[(t$95$0 / t$95$1), $MachinePrecision] / t$95$1), $MachinePrecision], N[(N[(N[(t$95$0 / x), $MachinePrecision] / c), $MachinePrecision] / N[(s * N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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


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

    1. Initial program 62.0%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity62.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-sqrt62.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-frac62.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-prod62.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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. *-commutative97.1%

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

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

    if 1.50000000000000003e91 < x

    1. Initial program 60.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-identity60.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-sqrt60.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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*97.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 95.9% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
t_1 := \cos \left(x \cdot 2\right)\\
\mathbf{if}\;c \leq 8 \cdot 10^{-236}:\\
\;\;\;\;\frac{\frac{t\_1}{x}}{\left(s \cdot c\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < 8.0000000000000004e-236

    1. Initial program 61.1%

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

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

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

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

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

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

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

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

        \[\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*28.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. unpow228.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-down28.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-pow145.3%

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

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

        \[\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. *-commutative45.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.0000000000000004e-236 < c

    1. Initial program 62.2%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity62.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-sqrt62.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-frac62.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-prod62.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-pow162.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-eval62.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. pow162.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. *-commutative62.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*58.6%

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

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

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

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

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

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

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

      \[\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/99.0%

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

        \[\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. *-commutative99.0%

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

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

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

Alternative 4: 85.3% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 5.8 \cdot 10^{-10}:\\ \;\;\;\;\frac{\frac{1}{c}}{\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cos \left(x \cdot 2\right)}{x}}{\left(s \cdot c\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (if (<= x 5.8e-10)
   (/ (/ 1.0 c) (* (* x s) (* c (* x s))))
   (/ (/ (cos (* x 2.0)) x) (* (* s c) (* x (* s c))))))
double code(double x, double c, double s) {
	double tmp;
	if (x <= 5.8e-10) {
		tmp = (1.0 / c) / ((x * s) * (c * (x * s)));
	} else {
		tmp = (cos((x * 2.0)) / x) / ((s * c) * (x * (s * c)));
	}
	return tmp;
}
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: tmp
    if (x <= 5.8d-10) then
        tmp = (1.0d0 / c) / ((x * s) * (c * (x * s)))
    else
        tmp = (cos((x * 2.0d0)) / x) / ((s * c) * (x * (s * c)))
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double tmp;
	if (x <= 5.8e-10) {
		tmp = (1.0 / c) / ((x * s) * (c * (x * s)));
	} else {
		tmp = (Math.cos((x * 2.0)) / x) / ((s * c) * (x * (s * c)));
	}
	return tmp;
}
def code(x, c, s):
	tmp = 0
	if x <= 5.8e-10:
		tmp = (1.0 / c) / ((x * s) * (c * (x * s)))
	else:
		tmp = (math.cos((x * 2.0)) / x) / ((s * c) * (x * (s * c)))
	return tmp
function code(x, c, s)
	tmp = 0.0
	if (x <= 5.8e-10)
		tmp = Float64(Float64(1.0 / c) / Float64(Float64(x * s) * Float64(c * Float64(x * s))));
	else
		tmp = Float64(Float64(cos(Float64(x * 2.0)) / x) / Float64(Float64(s * c) * Float64(x * Float64(s * c))));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (x <= 5.8e-10)
		tmp = (1.0 / c) / ((x * s) * (c * (x * s)));
	else
		tmp = (cos((x * 2.0)) / x) / ((s * c) * (x * (s * c)));
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := If[LessEqual[x, 5.8e-10], N[(N[(1.0 / c), $MachinePrecision] / N[(N[(x * s), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision] / N[(N[(s * c), $MachinePrecision] * N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.8 \cdot 10^{-10}:\\
\;\;\;\;\frac{\frac{1}{c}}{\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}\\

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


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

    1. Initial program 61.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-identity61.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-sqrt61.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-frac61.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-prod61.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-pow144.3%

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

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

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

        \[\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*41.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. unpow241.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-down44.3%

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

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

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

        \[\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. *-commutative44.8%

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

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

        \[\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*97.0%

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

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

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

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

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

    if 5.79999999999999962e-10 < x

    1. Initial program 62.2%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity62.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-sqrt62.3%

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

        \[\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-prod62.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-pow151.1%

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

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

        \[\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. *-commutative51.1%

        \[\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*49.4%

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

        \[\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-down51.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-pow153.9%

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

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

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

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

      \[\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. *-commutative98.2%

        \[\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*98.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 85.2% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 3.5 \cdot 10^{-10}:\\ \;\;\;\;\frac{\frac{1}{c}}{\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(\left(s \cdot c\right) \cdot \left(x \cdot \left(s \cdot c\right)\right)\right)}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (if (<= x 3.5e-10)
   (/ (/ 1.0 c) (* (* x s) (* c (* x s))))
   (/ (cos (* x 2.0)) (* x (* (* s c) (* x (* s c)))))))
double code(double x, double c, double s) {
	double tmp;
	if (x <= 3.5e-10) {
		tmp = (1.0 / c) / ((x * s) * (c * (x * s)));
	} else {
		tmp = cos((x * 2.0)) / (x * ((s * c) * (x * (s * c))));
	}
	return tmp;
}
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: tmp
    if (x <= 3.5d-10) then
        tmp = (1.0d0 / c) / ((x * s) * (c * (x * s)))
    else
        tmp = cos((x * 2.0d0)) / (x * ((s * c) * (x * (s * c))))
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double tmp;
	if (x <= 3.5e-10) {
		tmp = (1.0 / c) / ((x * s) * (c * (x * s)));
	} else {
		tmp = Math.cos((x * 2.0)) / (x * ((s * c) * (x * (s * c))));
	}
	return tmp;
}
def code(x, c, s):
	tmp = 0
	if x <= 3.5e-10:
		tmp = (1.0 / c) / ((x * s) * (c * (x * s)))
	else:
		tmp = math.cos((x * 2.0)) / (x * ((s * c) * (x * (s * c))))
	return tmp
function code(x, c, s)
	tmp = 0.0
	if (x <= 3.5e-10)
		tmp = Float64(Float64(1.0 / c) / Float64(Float64(x * s) * Float64(c * Float64(x * s))));
	else
		tmp = Float64(cos(Float64(x * 2.0)) / Float64(x * Float64(Float64(s * c) * Float64(x * Float64(s * c)))));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	tmp = 0.0;
	if (x <= 3.5e-10)
		tmp = (1.0 / c) / ((x * s) * (c * (x * s)));
	else
		tmp = cos((x * 2.0)) / (x * ((s * c) * (x * (s * c))));
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := If[LessEqual[x, 3.5e-10], N[(N[(1.0 / c), $MachinePrecision] / N[(N[(x * s), $MachinePrecision] * N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / N[(x * N[(N[(s * c), $MachinePrecision] * N[(x * N[(s * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5 \cdot 10^{-10}:\\
\;\;\;\;\frac{\frac{1}{c}}{\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}\\

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


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

    1. Initial program 61.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-identity61.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-sqrt61.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-frac61.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-prod61.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-pow144.3%

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

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

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

        \[\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*41.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. unpow241.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-down44.3%

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

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

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

        \[\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. *-commutative44.8%

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

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

        \[\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*97.0%

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

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

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

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

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

    if 3.4999999999999998e-10 < x

    1. Initial program 62.2%

      \[\frac{\cos \left(2 \cdot x\right)}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity62.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-sqrt62.3%

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

        \[\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-prod62.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-pow151.1%

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

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

        \[\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. *-commutative51.1%

        \[\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*49.4%

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

        \[\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-down51.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-pow153.9%

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

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

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

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

      \[\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. *-commutative98.2%

        \[\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*98.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 97.4% accurate, 2.7× speedup?

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

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

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

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

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

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

      \[\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-pow146.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-eval46.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. pow146.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. *-commutative46.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*43.6%

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

      \[\leadsto \frac{1}{c \cdot \sqrt{{s}^{2} \cdot \color{blue}{{x}^{2}}}} \cdot \frac{\cos \left(2 \cdot x\right)}{\sqrt{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)}} \]
    11. pow-prod-down46.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-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-rr97.2%

    \[\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. *-commutative97.2%

      \[\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*97.3%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 78.4% accurate, 3.0× speedup?

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

\\
{\left(c \cdot \left(x \cdot s\right)\right)}^{-2}
\end{array}
Derivation
  1. Initial program 61.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot {\left(x \cdot s\right)}^{2}} \]
    9. unpow263.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-sqr76.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. unpow276.5%

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

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

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

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

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

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

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

Alternative 8: 78.4% accurate, 20.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot {\left(x \cdot s\right)}^{2}} \]
    9. unpow263.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-sqr76.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. unpow276.5%

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

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

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

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

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

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

      \[\leadsto {\left(c \cdot \left(x \cdot s\right)\right)}^{\color{blue}{\left(-1 + -1\right)}} \]
    5. pow-prod-up76.7%

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

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

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

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

Alternative 9: 78.3% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\left(c \cdot c\right)} \cdot {\left(x \cdot s\right)}^{2}} \]
    9. unpow263.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-sqr76.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. unpow276.5%

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

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

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

      \[\leadsto \frac{1}{{\left(c \cdot \color{blue}{\left(x \cdot s\right)}\right)}^{2}} \]
    2. pow276.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)}} \]
  7. Applied egg-rr76.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)}} \]
  8. Add Preprocessing

Reproduce

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