mixedcos

Percentage Accurate: 67.4% → 97.4%
Time: 16.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: 67.4% 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.4% accurate, 2.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(c \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 (* x (* c s)))) (/ (/ (cos (* x 2.0)) t_0) t_0)))
double code(double x, double c, double s) {
	double t_0 = x * (c * 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 = x * (c * 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 = x * (c * s);
	return (Math.cos((x * 2.0)) / t_0) / t_0;
}
def code(x, c, s):
	t_0 = x * (c * s)
	return (math.cos((x * 2.0)) / t_0) / t_0
function code(x, c, s)
	t_0 = Float64(x * Float64(c * s))
	return Float64(Float64(cos(Float64(x * 2.0)) / t_0) / t_0)
end
function tmp = code(x, c, s)
	t_0 = x * (c * s);
	tmp = (cos((x * 2.0)) / t_0) / t_0;
end
code[x_, c_, s_] := Block[{t$95$0 = N[(x * N[(c * 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 := x \cdot \left(c \cdot s\right)\\
\frac{\frac{\cos \left(x \cdot 2\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 68.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-identity68.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 94.0% accurate, 2.7× speedup?

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

\\
\frac{\frac{\cos \left(x \cdot 2\right)}{c}}{\left(x \cdot s\right) \cdot \left(c \cdot \left(x \cdot s\right)\right)}
\end{array}
Derivation
  1. Initial program 68.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-identity68.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-sqrt68.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-frac68.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\cos \left(2 \cdot x\right)}{c \cdot \left(x \cdot s\right)} \cdot \frac{1}{c \cdot \left(x \cdot s\right)}} \]
    2. associate-/r*96.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.2%

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

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

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

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

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

Alternative 3: 97.3% 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 68.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-identity68.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-sqrt68.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-frac68.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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 4: 76.5% accurate, 17.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ \mathbf{if}\;s \leq 2 \cdot 10^{+165}:\\ \;\;\;\;\frac{1}{\left(x \cdot c\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 2e+165)
     (/ 1.0 (* (* x c) (* 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 <= 2e+165) {
		tmp = 1.0 / ((x * c) * (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 <= 2d+165) then
        tmp = 1.0d0 / ((x * c) * (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 <= 2e+165) {
		tmp = 1.0 / ((x * c) * (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 <= 2e+165:
		tmp = 1.0 / ((x * c) * (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 <= 2e+165)
		tmp = Float64(1.0 / Float64(Float64(x * c) * 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 <= 2e+165)
		tmp = 1.0 / ((x * c) * (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, 2e+165], N[(1.0 / N[(N[(x * c), $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 2 \cdot 10^{+165}:\\
\;\;\;\;\frac{1}{\left(x \cdot c\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 < 1.9999999999999998e165

    1. Initial program 68.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.9999999999999998e165 < s

    1. Initial program 68.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 59.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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*93.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. *-commutative93.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*90.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-rr90.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)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification74.6%

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

Alternative 5: 78.9% accurate, 20.9× speedup?

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

\\
\frac{1}{c \cdot \left(x \cdot s\right)} \cdot \frac{\frac{\frac{1}{x}}{s}}{c}
\end{array}
Derivation
  1. Initial program 68.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-identity68.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-sqrt68.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-frac68.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 78.8% accurate, 20.9× speedup?

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

\\
\frac{\frac{1}{c}}{x \cdot s} \cdot \frac{\frac{1}{x \cdot s}}{c}
\end{array}
Derivation
  1. Initial program 68.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}} \]
    4. unpow275.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)}} \]
    5. associate-*r*75.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{1}{c}}{x \cdot s} \cdot \frac{\frac{1}{x \cdot s}}{c}} \]
  10. Final simplification76.3%

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

Alternative 7: 75.7% 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 68.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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.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-rr72.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)}} \]
  8. Final simplification72.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{{\left(c \cdot \left(x \cdot s\right)\right)}^{2}}} \]
    4. unpow275.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-rr75.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 simplification75.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: 79.0% accurate, 24.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := c \cdot \left(x \cdot s\right)\\ \frac{\frac{1}{t\_0}}{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(Float64(1.0 / 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[(N[(1.0 / 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{1}{t\_0}}{t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 68.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-identity68.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-sqrt68.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-frac68.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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