mixedcos

Percentage Accurate: 67.9% → 97.1%
Time: 16.2s
Alternatives: 10
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 10 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.9% 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.1% accurate, 1.4× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \frac{1}{c\_m \cdot \left(x \cdot s\right)} \cdot {\left(\left(x \cdot s\right) \cdot \frac{c\_m}{\cos \left(x \cdot 2\right)}\right)}^{-1} \end{array} \]
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
 :precision binary64
 (* (/ 1.0 (* c_m (* x s))) (pow (* (* x s) (/ c_m (cos (* x 2.0)))) -1.0)))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
	return (1.0 / (c_m * (x * s))) * pow(((x * s) * (c_m / cos((x * 2.0)))), -1.0);
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s
    code = (1.0d0 / (c_m * (x * s))) * (((x * s) * (c_m / cos((x * 2.0d0)))) ** (-1.0d0))
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
	return (1.0 / (c_m * (x * s))) * Math.pow(((x * s) * (c_m / Math.cos((x * 2.0)))), -1.0);
}
c_m = math.fabs(c)
[x, c_m, s] = sort([x, c_m, s])
def code(x, c_m, s):
	return (1.0 / (c_m * (x * s))) * math.pow(((x * s) * (c_m / math.cos((x * 2.0)))), -1.0)
c_m = abs(c)
x, c_m, s = sort([x, c_m, s])
function code(x, c_m, s)
	return Float64(Float64(1.0 / Float64(c_m * Float64(x * s))) * (Float64(Float64(x * s) * Float64(c_m / cos(Float64(x * 2.0)))) ^ -1.0))
end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
	tmp = (1.0 / (c_m * (x * s))) * (((x * s) * (c_m / cos((x * 2.0)))) ^ -1.0);
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := N[(N[(1.0 / N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[(x * s), $MachinePrecision] * N[(c$95$m / N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\frac{1}{c\_m \cdot \left(x \cdot s\right)} \cdot {\left(\left(x \cdot s\right) \cdot \frac{c\_m}{\cos \left(x \cdot 2\right)}\right)}^{-1}
\end{array}
Derivation
  1. Initial program 68.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.1% accurate, 2.7× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \begin{array}{l} t_0 := c\_m \cdot \left(x \cdot s\right)\\ \frac{1}{t\_0} \cdot \frac{\cos \left(x \cdot 2\right)}{t\_0} \end{array} \end{array} \]
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
 :precision binary64
 (let* ((t_0 (* c_m (* x s)))) (* (/ 1.0 t_0) (/ (cos (* x 2.0)) t_0))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
	double t_0 = c_m * (x * s);
	return (1.0 / t_0) * (cos((x * 2.0)) / t_0);
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s
    real(8) :: t_0
    t_0 = c_m * (x * s)
    code = (1.0d0 / t_0) * (cos((x * 2.0d0)) / t_0)
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
	double t_0 = c_m * (x * s);
	return (1.0 / t_0) * (Math.cos((x * 2.0)) / t_0);
}
c_m = math.fabs(c)
[x, c_m, s] = sort([x, c_m, s])
def code(x, c_m, s):
	t_0 = c_m * (x * s)
	return (1.0 / t_0) * (math.cos((x * 2.0)) / t_0)
c_m = abs(c)
x, c_m, s = sort([x, c_m, s])
function code(x, c_m, s)
	t_0 = Float64(c_m * Float64(x * s))
	return Float64(Float64(1.0 / t_0) * Float64(cos(Float64(x * 2.0)) / t_0))
end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
	t_0 = c_m * (x * s);
	tmp = (1.0 / t_0) * (cos((x * 2.0)) / t_0);
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(c$95$m * 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}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := c\_m \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 68.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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)} \]
  7. Add Preprocessing

Alternative 3: 96.9% accurate, 2.7× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \begin{array}{l} t_0 := x \cdot \left(c\_m \cdot s\right)\\ \frac{\frac{\cos \left(x \cdot 2\right)}{t\_0}}{t\_0} \end{array} \end{array} \]
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
 :precision binary64
 (let* ((t_0 (* x (* c_m s)))) (/ (/ (cos (* x 2.0)) t_0) t_0)))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
	double t_0 = x * (c_m * s);
	return (cos((x * 2.0)) / t_0) / t_0;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s
    real(8) :: t_0
    t_0 = x * (c_m * s)
    code = (cos((x * 2.0d0)) / t_0) / t_0
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
	double t_0 = x * (c_m * s);
	return (Math.cos((x * 2.0)) / t_0) / t_0;
}
c_m = math.fabs(c)
[x, c_m, s] = sort([x, c_m, s])
def code(x, c_m, s):
	t_0 = x * (c_m * s)
	return (math.cos((x * 2.0)) / t_0) / t_0
c_m = abs(c)
x, c_m, s = sort([x, c_m, s])
function code(x, c_m, s)
	t_0 = Float64(x * Float64(c_m * s))
	return Float64(Float64(cos(Float64(x * 2.0)) / t_0) / t_0)
end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
	t_0 = x * (c_m * s);
	tmp = (cos((x * 2.0)) / t_0) / t_0;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(x * N[(c$95$m * s), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := x \cdot \left(c\_m \cdot s\right)\\
\frac{\frac{\cos \left(x \cdot 2\right)}{t\_0}}{t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 68.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{\cos \left(x \cdot 2\right)}{x \cdot \left(s \cdot c\right)}}{x \cdot \left(s \cdot c\right)}} \]
  8. 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)} \]
  9. Add Preprocessing

Alternative 4: 94.2% accurate, 2.7× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \frac{\frac{\cos \left(x \cdot 2\right)}{c\_m}}{\left(x \cdot s\right) \cdot \left(c\_m \cdot \left(x \cdot s\right)\right)} \end{array} \]
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
 :precision binary64
 (/ (/ (cos (* x 2.0)) c_m) (* (* x s) (* c_m (* x s)))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
	return (cos((x * 2.0)) / c_m) / ((x * s) * (c_m * (x * s)));
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s
    code = (cos((x * 2.0d0)) / c_m) / ((x * s) * (c_m * (x * s)))
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
	return (Math.cos((x * 2.0)) / c_m) / ((x * s) * (c_m * (x * s)));
}
c_m = math.fabs(c)
[x, c_m, s] = sort([x, c_m, s])
def code(x, c_m, s):
	return (math.cos((x * 2.0)) / c_m) / ((x * s) * (c_m * (x * s)))
c_m = abs(c)
x, c_m, s = sort([x, c_m, s])
function code(x, c_m, s)
	return Float64(Float64(cos(Float64(x * 2.0)) / c_m) / Float64(Float64(x * s) * Float64(c_m * Float64(x * s))))
end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
	tmp = (cos((x * 2.0)) / c_m) / ((x * s) * (c_m * (x * s)));
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := N[(N[(N[Cos[N[(x * 2.0), $MachinePrecision]], $MachinePrecision] / c$95$m), $MachinePrecision] / N[(N[(x * s), $MachinePrecision] * N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\frac{\frac{\cos \left(x \cdot 2\right)}{c\_m}}{\left(x \cdot s\right) \cdot \left(c\_m \cdot \left(x \cdot s\right)\right)}
\end{array}
Derivation
  1. Initial program 68.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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)}} \]
  10. Final simplification94.9%

    \[\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)} \]
  11. Add Preprocessing

Alternative 5: 79.6% accurate, 3.0× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ {\left(c\_m \cdot \left(x \cdot s\right)\right)}^{-2} \end{array} \]
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s) :precision binary64 (pow (* c_m (* x s)) -2.0))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
	return pow((c_m * (x * s)), -2.0);
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s
    code = (c_m * (x * s)) ** (-2.0d0)
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
	return Math.pow((c_m * (x * s)), -2.0);
}
c_m = math.fabs(c)
[x, c_m, s] = sort([x, c_m, s])
def code(x, c_m, s):
	return math.pow((c_m * (x * s)), -2.0)
c_m = abs(c)
x, c_m, s = sort([x, c_m, s])
function code(x, c_m, s)
	return Float64(c_m * Float64(x * s)) ^ -2.0
end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
	tmp = (c_m * (x * s)) ^ -2.0;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := N[Power[N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision], -2.0], $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
{\left(c\_m \cdot \left(x \cdot s\right)\right)}^{-2}
\end{array}
Derivation
  1. Initial program 68.5%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{\cos \left(x \cdot -2\right)}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 56.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(x \cdot \left(s \cdot c\right)\right)}^{-1}} \cdot \frac{1}{x \cdot \left(s \cdot c\right)} \]
    14. unpow-178.8%

      \[\leadsto {\left(x \cdot \left(s \cdot c\right)\right)}^{-1} \cdot \color{blue}{{\left(x \cdot \left(s \cdot c\right)\right)}^{-1}} \]
    15. pow-sqr78.8%

      \[\leadsto \color{blue}{{\left(x \cdot \left(s \cdot c\right)\right)}^{\left(2 \cdot -1\right)}} \]
    16. metadata-eval78.8%

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

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

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

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

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

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

Alternative 6: 79.5% accurate, 20.9× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \begin{array}{l} t_0 := \frac{1}{c\_m \cdot \left(x \cdot s\right)}\\ t\_0 \cdot t\_0 \end{array} \end{array} \]
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
 :precision binary64
 (let* ((t_0 (/ 1.0 (* c_m (* x s))))) (* t_0 t_0)))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
	double t_0 = 1.0 / (c_m * (x * s));
	return t_0 * t_0;
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s
    real(8) :: t_0
    t_0 = 1.0d0 / (c_m * (x * s))
    code = t_0 * t_0
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
	double t_0 = 1.0 / (c_m * (x * s));
	return t_0 * t_0;
}
c_m = math.fabs(c)
[x, c_m, s] = sort([x, c_m, s])
def code(x, c_m, s):
	t_0 = 1.0 / (c_m * (x * s))
	return t_0 * t_0
c_m = abs(c)
x, c_m, s = sort([x, c_m, s])
function code(x, c_m, s)
	t_0 = Float64(1.0 / Float64(c_m * Float64(x * s)))
	return Float64(t_0 * t_0)
end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
	t_0 = 1.0 / (c_m * (x * s));
	tmp = t_0 * t_0;
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(1.0 / N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(t$95$0 * t$95$0), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := \frac{1}{c\_m \cdot \left(x \cdot s\right)}\\
t\_0 \cdot t\_0
\end{array}
\end{array}
Derivation
  1. Initial program 68.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 79.6% accurate, 22.4× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \frac{\frac{-1}{c\_m \cdot \left(x \cdot s\right)}}{c\_m \cdot \left(x \cdot \left(-s\right)\right)} \end{array} \]
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
 :precision binary64
 (/ (/ -1.0 (* c_m (* x s))) (* c_m (* x (- s)))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
	return (-1.0 / (c_m * (x * s))) / (c_m * (x * -s));
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s
    code = ((-1.0d0) / (c_m * (x * s))) / (c_m * (x * -s))
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
	return (-1.0 / (c_m * (x * s))) / (c_m * (x * -s));
}
c_m = math.fabs(c)
[x, c_m, s] = sort([x, c_m, s])
def code(x, c_m, s):
	return (-1.0 / (c_m * (x * s))) / (c_m * (x * -s))
c_m = abs(c)
x, c_m, s = sort([x, c_m, s])
function code(x, c_m, s)
	return Float64(Float64(-1.0 / Float64(c_m * Float64(x * s))) / Float64(c_m * Float64(x * Float64(-s))))
end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
	tmp = (-1.0 / (c_m * (x * s))) / (c_m * (x * -s));
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := N[(N[(-1.0 / N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c$95$m * N[(x * (-s)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\frac{\frac{-1}{c\_m \cdot \left(x \cdot s\right)}}{c\_m \cdot \left(x \cdot \left(-s\right)\right)}
\end{array}
Derivation
  1. Initial program 68.5%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{\cos \left(x \cdot -2\right)}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 56.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-\frac{1}{\left(c \cdot x\right) \cdot s}}{-c \cdot \left(s \cdot x\right)}} \]
    9. distribute-neg-frac78.4%

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

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

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

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

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

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

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

Alternative 8: 78.5% accurate, 24.1× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \frac{\frac{1}{c\_m}}{\left(x \cdot s\right) \cdot \left(c\_m \cdot \left(x \cdot s\right)\right)} \end{array} \]
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
 :precision binary64
 (/ (/ 1.0 c_m) (* (* x s) (* c_m (* x s)))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
	return (1.0 / c_m) / ((x * s) * (c_m * (x * s)));
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s
    code = (1.0d0 / c_m) / ((x * s) * (c_m * (x * s)))
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
	return (1.0 / c_m) / ((x * s) * (c_m * (x * s)));
}
c_m = math.fabs(c)
[x, c_m, s] = sort([x, c_m, s])
def code(x, c_m, s):
	return (1.0 / c_m) / ((x * s) * (c_m * (x * s)))
c_m = abs(c)
x, c_m, s = sort([x, c_m, s])
function code(x, c_m, s)
	return Float64(Float64(1.0 / c_m) / Float64(Float64(x * s) * Float64(c_m * Float64(x * s))))
end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
	tmp = (1.0 / c_m) / ((x * s) * (c_m * (x * s)));
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := N[(N[(1.0 / c$95$m), $MachinePrecision] / N[(N[(x * s), $MachinePrecision] * N[(c$95$m * N[(x * s), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\frac{\frac{1}{c\_m}}{\left(x \cdot s\right) \cdot \left(c\_m \cdot \left(x \cdot s\right)\right)}
\end{array}
Derivation
  1. Initial program 68.5%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{\cos \left(x \cdot -2\right)}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 56.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 78.4% accurate, 24.1× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \begin{array}{l} t_0 := x \cdot \left(c\_m \cdot s\right)\\ \frac{1}{t\_0 \cdot t\_0} \end{array} \end{array} \]
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
 :precision binary64
 (let* ((t_0 (* x (* c_m s)))) (/ 1.0 (* t_0 t_0))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
	double t_0 = x * (c_m * s);
	return 1.0 / (t_0 * t_0);
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s
    real(8) :: t_0
    t_0 = x * (c_m * s)
    code = 1.0d0 / (t_0 * t_0)
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
	double t_0 = x * (c_m * s);
	return 1.0 / (t_0 * t_0);
}
c_m = math.fabs(c)
[x, c_m, s] = sort([x, c_m, s])
def code(x, c_m, s):
	t_0 = x * (c_m * s)
	return 1.0 / (t_0 * t_0)
c_m = abs(c)
x, c_m, s = sort([x, c_m, s])
function code(x, c_m, s)
	t_0 = Float64(x * Float64(c_m * s))
	return Float64(1.0 / Float64(t_0 * t_0))
end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
	t_0 = x * (c_m * s);
	tmp = 1.0 / (t_0 * t_0);
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := Block[{t$95$0 = N[(x * N[(c$95$m * s), $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\begin{array}{l}
t_0 := x \cdot \left(c\_m \cdot s\right)\\
\frac{1}{t\_0 \cdot t\_0}
\end{array}
\end{array}
Derivation
  1. Initial program 68.5%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{\cos \left(x \cdot -2\right)}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 56.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 76.1% accurate, 24.1× speedup?

\[\begin{array}{l} c_m = \left|c\right| \\ [x, c_m, s] = \mathsf{sort}([x, c_m, s])\\ \\ \frac{1}{c\_m \cdot \left(s \cdot \left(\left(x \cdot s\right) \cdot \left(c\_m \cdot x\right)\right)\right)} \end{array} \]
c_m = (fabs.f64 c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
(FPCore (x c_m s)
 :precision binary64
 (/ 1.0 (* c_m (* s (* (* x s) (* c_m x))))))
c_m = fabs(c);
assert(x < c_m && c_m < s);
double code(double x, double c_m, double s) {
	return 1.0 / (c_m * (s * ((x * s) * (c_m * x))));
}
c_m = abs(c)
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
real(8) function code(x, c_m, s)
    real(8), intent (in) :: x
    real(8), intent (in) :: c_m
    real(8), intent (in) :: s
    code = 1.0d0 / (c_m * (s * ((x * s) * (c_m * x))))
end function
c_m = Math.abs(c);
assert x < c_m && c_m < s;
public static double code(double x, double c_m, double s) {
	return 1.0 / (c_m * (s * ((x * s) * (c_m * x))));
}
c_m = math.fabs(c)
[x, c_m, s] = sort([x, c_m, s])
def code(x, c_m, s):
	return 1.0 / (c_m * (s * ((x * s) * (c_m * x))))
c_m = abs(c)
x, c_m, s = sort([x, c_m, s])
function code(x, c_m, s)
	return Float64(1.0 / Float64(c_m * Float64(s * Float64(Float64(x * s) * Float64(c_m * x)))))
end
c_m = abs(c);
x, c_m, s = num2cell(sort([x, c_m, s])){:}
function tmp = code(x, c_m, s)
	tmp = 1.0 / (c_m * (s * ((x * s) * (c_m * x))));
end
c_m = N[Abs[c], $MachinePrecision]
NOTE: x, c_m, and s should be sorted in increasing order before calling this function.
code[x_, c$95$m_, s_] := N[(1.0 / N[(c$95$m * N[(s * N[(N[(x * s), $MachinePrecision] * N[(c$95$m * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
c_m = \left|c\right|
\\
[x, c_m, s] = \mathsf{sort}([x, c_m, s])\\
\\
\frac{1}{c\_m \cdot \left(s \cdot \left(\left(x \cdot s\right) \cdot \left(c\_m \cdot x\right)\right)\right)}
\end{array}
Derivation
  1. Initial program 68.5%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{\cos \left(x \cdot -2\right)}{{c}^{2}}}{{s}^{2} \cdot {x}^{2}}} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 56.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{c \cdot \frac{x \cdot s}{\frac{\frac{\frac{1}{x}}{c}}{s}}}} \]
    2. associate-/r/76.8%

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

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

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

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

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

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

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

Reproduce

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