mixedcos

Percentage Accurate: 66.8% → 97.0%
Time: 13.6s
Alternatives: 9
Speedup: 24.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 66.8% accurate, 1.0× speedup?

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

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

Alternative 1: 97.0% accurate, 2.7× speedup?

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

\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{1}{t\_0} \cdot \frac{\cos \left(x \cdot 2\right)}{t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 64.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-identity64.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-sqrt64.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-frac64.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-rr98.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. Final simplification98.8%

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

Alternative 2: 86.6% accurate, 2.6× speedup?

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

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

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


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

    1. Initial program 63.8%

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

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

        \[\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-frac63.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.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. *-commutative99.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. associate-*l/99.1%

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

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

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

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

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

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

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

    if 4.8000000000000002e-11 < x

    1. Initial program 65.8%

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

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

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

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

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

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

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

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

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

      \[\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. Step-by-step derivation
      1. div-inv98.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 94.0% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \frac{\frac{\cos \left(x \cdot 2\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 (* x 2.0)) c) (* (* c (* x s)) (* x s))))
double code(double x, double c, double s) {
	return (cos((x * 2.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 = (cos((x * 2.0d0)) / c) / ((c * (x * s)) * (x * s))
end function
public static double code(double x, double c, double s) {
	return (Math.cos((x * 2.0)) / c) / ((c * (x * s)) * (x * s));
}
def code(x, c, s):
	return (math.cos((x * 2.0)) / c) / ((c * (x * s)) * (x * s))
function code(x, c, s)
	return Float64(Float64(cos(Float64(x * 2.0)) / c) / Float64(Float64(c * Float64(x * s)) * Float64(x * s)))
end
function tmp = code(x, c, s)
	tmp = (cos((x * 2.0)) / c) / ((c * (x * s)) * (x * s));
end
code[x_, c_, s_] := N[(N[(N[Cos[N[(x * 2.0), $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(x \cdot 2\right)}{c}}{\left(c \cdot \left(x \cdot s\right)\right) \cdot \left(x \cdot s\right)}
\end{array}
Derivation
  1. Initial program 64.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-identity64.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-sqrt64.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-frac64.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-rr98.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. *-commutative98.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-/r*98.8%

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

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

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

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

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

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

Alternative 4: 97.0% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ \frac{\frac{\cos \left(x \cdot 2\right)}{t\_0}}{t\_0} \end{array} \end{array} \]
(FPCore (x c s)
 :precision binary64
 (let* ((t_0 (* c (* x s)))) (/ (/ (cos (* x 2.0)) t_0) t_0)))
double code(double x, double c, double s) {
	double t_0 = c * (x * s);
	return (cos((x * 2.0)) / t_0) / t_0;
}
real(8) function code(x, c, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c
    real(8), intent (in) :: s
    real(8) :: t_0
    t_0 = c * (x * s)
    code = (cos((x * 2.0d0)) / 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((x * 2.0)) / t_0) / t_0;
}
def code(x, c, s):
	t_0 = c * (x * s)
	return (math.cos((x * 2.0)) / t_0) / t_0
function code(x, c, s)
	t_0 = Float64(c * Float64(x * s))
	return Float64(Float64(cos(Float64(x * 2.0)) / t_0) / t_0)
end
function tmp = code(x, c, s)
	t_0 = c * (x * s);
	tmp = (cos((x * 2.0)) / 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[(x * 2.0), $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(x \cdot 2\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 64.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-identity64.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-sqrt64.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-frac64.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-rr98.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. *-commutative98.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/98.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-inv98.8%

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

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

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

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

Alternative 5: 73.9% accurate, 17.4× speedup?

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

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

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


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

    1. Initial program 63.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.99999999999999983e-214 < x

    1. Initial program 65.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{{\left(c \cdot \left(s \cdot x\right)\right)}^{2}}} \]
    6. Step-by-step derivation
      1. unpow271.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*71.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. *-commutative71.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*71.1%

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

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

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

Alternative 6: 75.9% accurate, 17.4× speedup?

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

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

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


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

    1. Initial program 65.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.2e212 < s

    1. Initial program 56.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 52.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 75.3% 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 64.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. Taylor expanded in x around 0 51.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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 8: 77.9% accurate, 24.1× speedup?

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

\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 64.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. Taylor expanded in x around 0 51.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 78.1% accurate, 24.1× speedup?

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

\\
\frac{\frac{\frac{1}{c}}{x \cdot s}}{c \cdot \left(x \cdot s\right)}
\end{array}
Derivation
  1. Initial program 64.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-identity64.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-sqrt64.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-frac64.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-rr98.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. *-commutative98.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/98.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-inv98.8%

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

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

    \[\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. Taylor expanded in x around 0 77.2%

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

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

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

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

Reproduce

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