mixedcos

Percentage Accurate: 66.3% → 97.5%
Time: 15.3s
Alternatives: 9
Speedup: 24.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 66.3% accurate, 1.0× speedup?

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

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

Alternative 1: 97.5% accurate, 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 61.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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)} \]
    10. *-commutative96.0%

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

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

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

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

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

Alternative 2: 86.6% accurate, 2.6× speedup?

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

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

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


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

    1. Initial program 61.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left(c \cdot c\right) \cdot \color{blue}{\left(\left(x \cdot s\right) \cdot \left(x \cdot s\right)\right)}} \]
      10. swap-sqr82.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. unpow282.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.3000000000000001e-8 < x

    1. Initial program 62.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 91.6% accurate, 2.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1 \cdot \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)}} \]
    3. *-un-lft-identity96.9%

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

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

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

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

      \[\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)} \]
    8. *-commutative92.6%

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

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

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

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

Alternative 4: 78.4% accurate, 3.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 78.4% accurate, 20.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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)} \]
    10. *-commutative96.0%

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

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

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

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

    \[\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)}} \]
  8. Taylor expanded in x around 0 75.9%

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

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

      \[\leadsto \frac{\frac{1}{\color{blue}{\left(-\left(-c \cdot s\right)\right)} \cdot x}}{x \cdot \left(c \cdot s\right)} \]
    3. distribute-lft-neg-in76.8%

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

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

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

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

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

Alternative 7: 78.3% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 75.2% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 75.1% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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