mixedcos

Percentage Accurate: 67.1% → 99.2%
Time: 16.5s
Alternatives: 14
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 14 alternatives:

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

Initial Program: 67.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ t_1 := \cos \left(2 \cdot x\right)\\ t_2 := x \cdot \left(c \cdot s\right)\\ \mathbf{if}\;\frac{t\_1}{{c}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq \infty:\\ \;\;\;\;\frac{\frac{t\_1}{t\_0}}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(\cos x, \cos x, -{\sin x}^{2}\right)}{t\_2 \cdot t\_2}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* c (* x s))) (t_1 (cos (* 2.0 x))) (t_2 (* x (* c s))))
   (if (<= (/ t_1 (* (pow c 2.0) (* x (* x (pow s 2.0))))) INFINITY)
     (/ (/ t_1 t_0) t_0)
     (/ (fma (cos x) (cos x) (- (pow (sin x) 2.0))) (* t_2 t_2)))))
double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	double t_1 = cos((2.0 * x));
	double t_2 = x * (c * s);
	double tmp;
	if ((t_1 / (pow(c, 2.0) * (x * (x * pow(s, 2.0))))) <= ((double) INFINITY)) {
		tmp = (t_1 / t_0) / t_0;
	} else {
		tmp = fma(cos(x), cos(x), -pow(sin(x), 2.0)) / (t_2 * t_2);
	}
	return tmp;
}
function code(x, c, s)
	t_0 = Float64(c * Float64(x * s))
	t_1 = cos(Float64(2.0 * x))
	t_2 = Float64(x * Float64(c * s))
	tmp = 0.0
	if (Float64(t_1 / Float64((c ^ 2.0) * Float64(x * Float64(x * (s ^ 2.0))))) <= Inf)
		tmp = Float64(Float64(t_1 / t_0) / t_0);
	else
		tmp = Float64(fma(cos(x), cos(x), Float64(-(sin(x) ^ 2.0))) / Float64(t_2 * t_2));
	end
	return tmp
end
code[x_, c_, s_] := Block[{t$95$0 = N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$1 / N[(N[Power[c, 2.0], $MachinePrecision] * N[(x * N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(t$95$1 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[Cos[x], $MachinePrecision] * N[Cos[x], $MachinePrecision] + (-N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision])), $MachinePrecision] / N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\cos x, \cos x, -{\sin x}^{2}\right)}{t\_2 \cdot t\_2}\\


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

    1. Initial program 78.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-identity78.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-sqrt78.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-frac78.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. Applied egg-rr99.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. *-commutative99.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-*l/99.4%

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

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

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

      \[\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 +inf.0 < (/.f64 (cos.f64 (*.f64 2 x)) (*.f64 (pow.f64 c 2) (*.f64 (*.f64 x (pow.f64 s 2)) x)))

    1. Initial program 0.0%

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

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

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

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

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

        \[\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. frac-2neg85.3%

        \[\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)} \]
      3. frac-2neg85.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-\color{blue}{\mathsf{fma}\left(\cos x, \cos x, -\sin x \cdot \sin x\right)}\right) \cdot -1}{\left(\left(c \cdot s\right) \cdot \left(-x\right)\right) \cdot \left(\left(c \cdot s\right) \cdot \left(-x\right)\right)} \]
      2. distribute-rgt-neg-in99.2%

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

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

      \[\leadsto \frac{\left(-\mathsf{fma}\left(\cos x, \cos x, \color{blue}{-1 \cdot {\sin x}^{2}}\right)\right) \cdot -1}{\left(\left(c \cdot s\right) \cdot \left(-x\right)\right) \cdot \left(\left(c \cdot s\right) \cdot \left(-x\right)\right)} \]
    12. Step-by-step derivation
      1. neg-mul-199.2%

        \[\leadsto \frac{\left(-\mathsf{fma}\left(\cos x, \cos x, \color{blue}{-{\sin x}^{2}}\right)\right) \cdot -1}{\left(\left(c \cdot s\right) \cdot \left(-x\right)\right) \cdot \left(\left(c \cdot s\right) \cdot \left(-x\right)\right)} \]
    13. Simplified99.2%

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

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

Alternative 2: 99.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ t_1 := \cos \left(2 \cdot x\right)\\ t_2 := x \cdot \left(c \cdot s\right)\\ \mathbf{if}\;\frac{t\_1}{{c}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq \infty:\\ \;\;\;\;\frac{\frac{t\_1}{t\_0}}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\cos x}^{2} - {\sin x}^{2}}{t\_2 \cdot t\_2}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* c (* x s))) (t_1 (cos (* 2.0 x))) (t_2 (* x (* c s))))
   (if (<= (/ t_1 (* (pow c 2.0) (* x (* x (pow s 2.0))))) INFINITY)
     (/ (/ t_1 t_0) t_0)
     (/ (- (pow (cos x) 2.0) (pow (sin x) 2.0)) (* t_2 t_2)))))
double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	double t_1 = cos((2.0 * x));
	double t_2 = x * (c * s);
	double tmp;
	if ((t_1 / (pow(c, 2.0) * (x * (x * pow(s, 2.0))))) <= ((double) INFINITY)) {
		tmp = (t_1 / t_0) / t_0;
	} else {
		tmp = (pow(cos(x), 2.0) - pow(sin(x), 2.0)) / (t_2 * t_2);
	}
	return tmp;
}
public static double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	double t_1 = Math.cos((2.0 * x));
	double t_2 = x * (c * s);
	double tmp;
	if ((t_1 / (Math.pow(c, 2.0) * (x * (x * Math.pow(s, 2.0))))) <= Double.POSITIVE_INFINITY) {
		tmp = (t_1 / t_0) / t_0;
	} else {
		tmp = (Math.pow(Math.cos(x), 2.0) - Math.pow(Math.sin(x), 2.0)) / (t_2 * t_2);
	}
	return tmp;
}
def code(x, c, s):
	t_0 = c * (x * s)
	t_1 = math.cos((2.0 * x))
	t_2 = x * (c * s)
	tmp = 0
	if (t_1 / (math.pow(c, 2.0) * (x * (x * math.pow(s, 2.0))))) <= math.inf:
		tmp = (t_1 / t_0) / t_0
	else:
		tmp = (math.pow(math.cos(x), 2.0) - math.pow(math.sin(x), 2.0)) / (t_2 * t_2)
	return tmp
function code(x, c, s)
	t_0 = Float64(c * Float64(x * s))
	t_1 = cos(Float64(2.0 * x))
	t_2 = Float64(x * Float64(c * s))
	tmp = 0.0
	if (Float64(t_1 / Float64((c ^ 2.0) * Float64(x * Float64(x * (s ^ 2.0))))) <= Inf)
		tmp = Float64(Float64(t_1 / t_0) / t_0);
	else
		tmp = Float64(Float64((cos(x) ^ 2.0) - (sin(x) ^ 2.0)) / Float64(t_2 * t_2));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	t_0 = c * (x * s);
	t_1 = cos((2.0 * x));
	t_2 = x * (c * s);
	tmp = 0.0;
	if ((t_1 / ((c ^ 2.0) * (x * (x * (s ^ 2.0))))) <= Inf)
		tmp = (t_1 / t_0) / t_0;
	else
		tmp = ((cos(x) ^ 2.0) - (sin(x) ^ 2.0)) / (t_2 * t_2);
	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[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$1 / N[(N[Power[c, 2.0], $MachinePrecision] * N[(x * N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(t$95$1 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[Power[N[Cos[x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Sin[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\frac{{\cos x}^{2} - {\sin x}^{2}}{t\_2 \cdot t\_2}\\


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

    1. Initial program 78.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-identity78.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-sqrt78.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-frac78.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. Applied egg-rr99.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. *-commutative99.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-*l/99.4%

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

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

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

      \[\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 +inf.0 < (/.f64 (cos.f64 (*.f64 2 x)) (*.f64 (pow.f64 c 2) (*.f64 (*.f64 x (pow.f64 s 2)) x)))

    1. Initial program 0.0%

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

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

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

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

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

        \[\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. frac-2neg85.3%

        \[\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)} \]
      3. frac-2neg85.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\left(-\color{blue}{\mathsf{fma}\left(\cos x, \cos x, -\sin x \cdot \sin x\right)}\right) \cdot -1}{\left(\left(c \cdot s\right) \cdot \left(-x\right)\right) \cdot \left(\left(c \cdot s\right) \cdot \left(-x\right)\right)} \]
      2. distribute-rgt-neg-in99.2%

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

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

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

        \[\leadsto \frac{\left(-\color{blue}{\left({\cos x}^{2} + -1 \cdot {\sin x}^{2}\right)}\right) \cdot -1}{\left(\left(c \cdot s\right) \cdot \left(-x\right)\right) \cdot \left(\left(c \cdot s\right) \cdot \left(-x\right)\right)} \]
      2. neg-mul-199.1%

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

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

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

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

Alternative 3: 99.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ t_1 := \cos \left(2 \cdot x\right)\\ t_2 := x \cdot \left(c \cdot s\right)\\ \mathbf{if}\;\frac{t\_1}{{c}^{2} \cdot \left(x \cdot \left(x \cdot {s}^{2}\right)\right)} \leq \infty:\\ \;\;\;\;\frac{\frac{t\_1}{t\_0}}{t\_0}\\ \mathbf{else}:\\ \;\;\;\;\frac{t\_1}{t\_2 \cdot t\_2}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* c (* x s))) (t_1 (cos (* 2.0 x))) (t_2 (* x (* c s))))
   (if (<= (/ t_1 (* (pow c 2.0) (* x (* x (pow s 2.0))))) INFINITY)
     (/ (/ t_1 t_0) t_0)
     (/ t_1 (* t_2 t_2)))))
double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	double t_1 = cos((2.0 * x));
	double t_2 = x * (c * s);
	double tmp;
	if ((t_1 / (pow(c, 2.0) * (x * (x * pow(s, 2.0))))) <= ((double) INFINITY)) {
		tmp = (t_1 / t_0) / t_0;
	} else {
		tmp = t_1 / (t_2 * t_2);
	}
	return tmp;
}
public static double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	double t_1 = Math.cos((2.0 * x));
	double t_2 = x * (c * s);
	double tmp;
	if ((t_1 / (Math.pow(c, 2.0) * (x * (x * Math.pow(s, 2.0))))) <= Double.POSITIVE_INFINITY) {
		tmp = (t_1 / t_0) / t_0;
	} else {
		tmp = t_1 / (t_2 * t_2);
	}
	return tmp;
}
def code(x, c, s):
	t_0 = c * (x * s)
	t_1 = math.cos((2.0 * x))
	t_2 = x * (c * s)
	tmp = 0
	if (t_1 / (math.pow(c, 2.0) * (x * (x * math.pow(s, 2.0))))) <= math.inf:
		tmp = (t_1 / t_0) / t_0
	else:
		tmp = t_1 / (t_2 * t_2)
	return tmp
function code(x, c, s)
	t_0 = Float64(c * Float64(x * s))
	t_1 = cos(Float64(2.0 * x))
	t_2 = Float64(x * Float64(c * s))
	tmp = 0.0
	if (Float64(t_1 / Float64((c ^ 2.0) * Float64(x * Float64(x * (s ^ 2.0))))) <= Inf)
		tmp = Float64(Float64(t_1 / t_0) / t_0);
	else
		tmp = Float64(t_1 / Float64(t_2 * t_2));
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	t_0 = c * (x * s);
	t_1 = cos((2.0 * x));
	t_2 = x * (c * s);
	tmp = 0.0;
	if ((t_1 / ((c ^ 2.0) * (x * (x * (s ^ 2.0))))) <= Inf)
		tmp = (t_1 / t_0) / t_0;
	else
		tmp = t_1 / (t_2 * t_2);
	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[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$1 / N[(N[Power[c, 2.0], $MachinePrecision] * N[(x * N[(x * N[Power[s, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(t$95$1 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(t$95$1 / N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{t\_2 \cdot t\_2}\\


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

    1. Initial program 78.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-identity78.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-sqrt78.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-frac78.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. Applied egg-rr99.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. *-commutative99.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-*l/99.4%

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

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

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

      \[\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 +inf.0 < (/.f64 (cos.f64 (*.f64 2 x)) (*.f64 (pow.f64 c 2) (*.f64 (*.f64 x (pow.f64 s 2)) x)))

    1. Initial program 0.0%

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

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

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

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

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

        \[\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. frac-2neg85.3%

        \[\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)} \]
      3. frac-2neg85.3%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 95.7% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ t_1 := \cos \left(2 \cdot x\right)\\ \mathbf{if}\;c \leq 5.2 \cdot 10^{-240}:\\ \;\;\;\;\frac{t\_1 \cdot \frac{\frac{1}{x \cdot \left(c \cdot s\right)}}{c \cdot s}}{x}\\ \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 (* 2.0 x))))
   (if (<= c 5.2e-240)
     (/ (* t_1 (/ (/ 1.0 (* x (* c s))) (* c s))) x)
     (/ (/ t_1 t_0) t_0))))
double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	double t_1 = cos((2.0 * x));
	double tmp;
	if (c <= 5.2e-240) {
		tmp = (t_1 * ((1.0 / (x * (c * s))) / (c * s))) / x;
	} 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((2.0d0 * x))
    if (c <= 5.2d-240) then
        tmp = (t_1 * ((1.0d0 / (x * (c * s))) / (c * s))) / x
    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((2.0 * x));
	double tmp;
	if (c <= 5.2e-240) {
		tmp = (t_1 * ((1.0 / (x * (c * s))) / (c * s))) / x;
	} else {
		tmp = (t_1 / t_0) / t_0;
	}
	return tmp;
}
def code(x, c, s):
	t_0 = c * (x * s)
	t_1 = math.cos((2.0 * x))
	tmp = 0
	if c <= 5.2e-240:
		tmp = (t_1 * ((1.0 / (x * (c * s))) / (c * s))) / x
	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(2.0 * x))
	tmp = 0.0
	if (c <= 5.2e-240)
		tmp = Float64(Float64(t_1 * Float64(Float64(1.0 / Float64(x * Float64(c * s))) / Float64(c * s))) / x);
	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((2.0 * x));
	tmp = 0.0;
	if (c <= 5.2e-240)
		tmp = (t_1 * ((1.0 / (x * (c * s))) / (c * s))) / x;
	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[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[c, 5.2e-240], N[(N[(t$95$1 * N[(N[(1.0 / N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $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(2 \cdot x\right)\\
\mathbf{if}\;c \leq 5.2 \cdot 10^{-240}:\\
\;\;\;\;\frac{t\_1 \cdot \frac{\frac{1}{x \cdot \left(c \cdot s\right)}}{c \cdot s}}{x}\\

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


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

    1. Initial program 64.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.19999999999999984e-240 < c

    1. Initial program 66.4%

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

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

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

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

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

        \[\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-*l/97.8%

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

        \[\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)} \]
      4. *-commutative97.9%

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

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

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

Alternative 5: 95.1% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ t_1 := \cos \left(2 \cdot x\right)\\ \mathbf{if}\;c \leq 2 \cdot 10^{-276}:\\ \;\;\;\;\frac{\frac{t\_1}{x \cdot \left(x \cdot \left(c \cdot s\right)\right)}}{c \cdot s}\\ \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 (* 2.0 x))))
   (if (<= c 2e-276)
     (/ (/ t_1 (* x (* x (* c s)))) (* c s))
     (/ (/ t_1 t_0) t_0))))
double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	double t_1 = cos((2.0 * x));
	double tmp;
	if (c <= 2e-276) {
		tmp = (t_1 / (x * (x * (c * s)))) / (c * s);
	} 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((2.0d0 * x))
    if (c <= 2d-276) then
        tmp = (t_1 / (x * (x * (c * s)))) / (c * s)
    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((2.0 * x));
	double tmp;
	if (c <= 2e-276) {
		tmp = (t_1 / (x * (x * (c * s)))) / (c * s);
	} else {
		tmp = (t_1 / t_0) / t_0;
	}
	return tmp;
}
def code(x, c, s):
	t_0 = c * (x * s)
	t_1 = math.cos((2.0 * x))
	tmp = 0
	if c <= 2e-276:
		tmp = (t_1 / (x * (x * (c * s)))) / (c * s)
	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(2.0 * x))
	tmp = 0.0
	if (c <= 2e-276)
		tmp = Float64(Float64(t_1 / Float64(x * Float64(x * Float64(c * s)))) / Float64(c * s));
	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((2.0 * x));
	tmp = 0.0;
	if (c <= 2e-276)
		tmp = (t_1 / (x * (x * (c * s)))) / (c * s);
	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[(2.0 * x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[c, 2e-276], N[(N[(t$95$1 / N[(x * N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c * s), $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(2 \cdot x\right)\\
\mathbf{if}\;c \leq 2 \cdot 10^{-276}:\\
\;\;\;\;\frac{\frac{t\_1}{x \cdot \left(x \cdot \left(c \cdot s\right)\right)}}{c \cdot s}\\

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


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

    1. Initial program 64.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-identity64.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-sqrt64.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-frac64.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. Applied egg-rr96.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. *-commutative96.1%

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

        \[\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)} \]
      3. frac-2neg96.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e-276 < c

    1. Initial program 66.3%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \cos \left(2 \cdot x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      2. add-sqr-sqrt66.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-frac66.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. Applied egg-rr97.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. *-commutative97.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-*l/97.9%

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

        \[\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)} \]
      4. *-commutative97.9%

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

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

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

Alternative 6: 93.7% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \frac{\frac{\cos \left(2 \cdot x\right)}{c}}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(x \cdot s\right)} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (/ (/ (cos (* 2.0 x)) c) (* (* c (* x s)) (* x s))))
double code(double x, double c, double s) {
	return (cos((2.0 * x)) / c) / ((c * (x * s)) * (x * s));
}
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) / ((c * (x * s)) * (x * s))
end function
public static double code(double x, double c, double s) {
	return (Math.cos((2.0 * x)) / c) / ((c * (x * s)) * (x * s));
}
def code(x, c, s):
	return (math.cos((2.0 * x)) / c) / ((c * (x * s)) * (x * s))
function code(x, c, s)
	return Float64(Float64(cos(Float64(2.0 * x)) / c) / Float64(Float64(c * Float64(x * s)) * Float64(x * s)))
end
function tmp = code(x, c, s)
	tmp = (cos((2.0 * x)) / c) / ((c * (x * s)) * (x * s));
end
code[x_, c_, s_] := N[(N[(N[Cos[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / c), $MachinePrecision] / N[(N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision] * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{\cos \left(2 \cdot x\right)}{c}}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(x \cdot s\right)}
\end{array}
Derivation
  1. Initial program 65.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-identity65.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-sqrt65.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-frac65.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. Applied egg-rr97.0%

    \[\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.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-identity97.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. associate-/r*97.0%

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

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

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

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

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

Alternative 7: 97.2% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{\frac{\cos \left(2 \cdot x\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 65.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-identity65.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-sqrt65.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-frac65.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. Applied egg-rr97.0%

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right) \cdot \frac{1}{c \cdot \left(x \cdot s\right)}}{c \cdot \left(x \cdot s\right)}} \]
    3. div-inv97.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)} \]
    4. *-commutative97.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-rr97.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)}} \]
  7. Final simplification97.0%

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

Alternative 8: 79.1% accurate, 15.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(c \cdot s\right)\\ t_1 := \frac{1}{c \cdot \left(x \cdot s\right)}\\ \mathbf{if}\;x \leq 2.6 \cdot 10^{+44}:\\ \;\;\;\;t\_1 \cdot t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-1}{t\_0}}{t\_0}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* x (* c s))) (t_1 (/ 1.0 (* c (* x s)))))
   (if (<= x 2.6e+44) (* t_1 t_1) (/ (/ -1.0 t_0) t_0))))
double code(double x, double c, double s) {
	double t_0 = x * (c * s);
	double t_1 = 1.0 / (c * (x * s));
	double tmp;
	if (x <= 2.6e+44) {
		tmp = t_1 * t_1;
	} else {
		tmp = (-1.0 / 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 = x * (c * s)
    t_1 = 1.0d0 / (c * (x * s))
    if (x <= 2.6d+44) then
        tmp = t_1 * t_1
    else
        tmp = ((-1.0d0) / t_0) / t_0
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double t_0 = x * (c * s);
	double t_1 = 1.0 / (c * (x * s));
	double tmp;
	if (x <= 2.6e+44) {
		tmp = t_1 * t_1;
	} else {
		tmp = (-1.0 / t_0) / t_0;
	}
	return tmp;
}
def code(x, c, s):
	t_0 = x * (c * s)
	t_1 = 1.0 / (c * (x * s))
	tmp = 0
	if x <= 2.6e+44:
		tmp = t_1 * t_1
	else:
		tmp = (-1.0 / t_0) / t_0
	return tmp
function code(x, c, s)
	t_0 = Float64(x * Float64(c * s))
	t_1 = Float64(1.0 / Float64(c * Float64(x * s)))
	tmp = 0.0
	if (x <= 2.6e+44)
		tmp = Float64(t_1 * t_1);
	else
		tmp = Float64(Float64(-1.0 / t_0) / t_0);
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	t_0 = x * (c * s);
	t_1 = 1.0 / (c * (x * s));
	tmp = 0.0;
	if (x <= 2.6e+44)
		tmp = t_1 * t_1;
	else
		tmp = (-1.0 / t_0) / t_0;
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2.6e+44], N[(t$95$1 * t$95$1), $MachinePrecision], N[(N[(-1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \left(c \cdot s\right)\\
t_1 := \frac{1}{c \cdot \left(x \cdot s\right)}\\
\mathbf{if}\;x \leq 2.6 \cdot 10^{+44}:\\
\;\;\;\;t\_1 \cdot t\_1\\

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


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

    1. Initial program 67.4%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \cos \left(2 \cdot x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      2. add-sqr-sqrt67.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-frac67.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. 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. Taylor expanded in x around 0 85.4%

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

    if 2.5999999999999999e44 < x

    1. Initial program 59.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 79.1% accurate, 15.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(c \cdot s\right)\\ \mathbf{if}\;x \leq 2.6 \cdot 10^{+44}:\\ \;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \frac{\frac{1}{c}}{x \cdot s}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-1}{t\_0}}{t\_0}\\ \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* x (* c s))))
   (if (<= x 2.6e+44)
     (* (/ 1.0 (* c (* x s))) (/ (/ 1.0 c) (* x s)))
     (/ (/ -1.0 t_0) t_0))))
double code(double x, double c, double s) {
	double t_0 = x * (c * s);
	double tmp;
	if (x <= 2.6e+44) {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s));
	} else {
		tmp = (-1.0 / 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) :: tmp
    t_0 = x * (c * s)
    if (x <= 2.6d+44) then
        tmp = (1.0d0 / (c * (x * s))) * ((1.0d0 / c) / (x * s))
    else
        tmp = ((-1.0d0) / t_0) / t_0
    end if
    code = tmp
end function
public static double code(double x, double c, double s) {
	double t_0 = x * (c * s);
	double tmp;
	if (x <= 2.6e+44) {
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s));
	} else {
		tmp = (-1.0 / t_0) / t_0;
	}
	return tmp;
}
def code(x, c, s):
	t_0 = x * (c * s)
	tmp = 0
	if x <= 2.6e+44:
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s))
	else:
		tmp = (-1.0 / t_0) / t_0
	return tmp
function code(x, c, s)
	t_0 = Float64(x * Float64(c * s))
	tmp = 0.0
	if (x <= 2.6e+44)
		tmp = Float64(Float64(1.0 / Float64(c * Float64(x * s))) * Float64(Float64(1.0 / c) / Float64(x * s)));
	else
		tmp = Float64(Float64(-1.0 / t_0) / t_0);
	end
	return tmp
end
function tmp_2 = code(x, c, s)
	t_0 = x * (c * s);
	tmp = 0.0;
	if (x <= 2.6e+44)
		tmp = (1.0 / (c * (x * s))) * ((1.0 / c) / (x * s));
	else
		tmp = (-1.0 / t_0) / t_0;
	end
	tmp_2 = tmp;
end
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(c * s), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2.6e+44], N[(N[(1.0 / N[(c * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / c), $MachinePrecision] / N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \left(c \cdot s\right)\\
\mathbf{if}\;x \leq 2.6 \cdot 10^{+44}:\\
\;\;\;\;\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \frac{\frac{1}{c}}{x \cdot s}\\

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


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

    1. Initial program 67.4%

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

        \[\leadsto \frac{\color{blue}{1 \cdot \cos \left(2 \cdot x\right)}}{{c}^{2} \cdot \left(\left(x \cdot {s}^{2}\right) \cdot x\right)} \]
      2. add-sqr-sqrt67.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-frac67.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. 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. Taylor expanded in x around 0 85.4%

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

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

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

    if 2.5999999999999999e44 < x

    1. Initial program 59.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 76.1% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 76.8% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 76.9% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 77.1% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{1}{c}}{x \cdot s} \cdot \frac{\frac{1}{c}}{x \cdot s}} \]
  8. Step-by-step derivation
    1. associate-/l/79.5%

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

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

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

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

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

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

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

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

Alternative 14: 79.0% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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