mixedcos

Percentage Accurate: 66.9% → 97.4%
Time: 13.6s
Alternatives: 9
Speedup: 24.1×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 9 alternatives:

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

Initial Program: 66.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.4% accurate, 2.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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)}} \]
    11. unpow297.4%

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

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

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

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

      \[\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)}} \]
    3. *-un-lft-identity97.4%

      \[\leadsto \frac{\color{blue}{1 \cdot \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. times-frac97.4%

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

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

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

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

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

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

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

Alternative 2: 86.0% accurate, 2.6× speedup?

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

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

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


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

    1. Initial program 65.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\cos \left(x \cdot -2\right)}{{c}^{2}}}{\color{blue}{{s}^{2} \cdot {x}^{2}}} \]
    3. Simplified58.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 53.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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)}}} \]
      12. metadata-eval83.8%

        \[\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}}} \]
      13. pow183.8%

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

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

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

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

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

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

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

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

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

    if 5.0999999999999997e-14 < x

    1. Initial program 67.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 86.3% accurate, 2.6× speedup?

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

\\
\begin{array}{l}
t_0 := c \cdot \left(x \cdot s\right)\\
\mathbf{if}\;x \leq 3 \cdot 10^{-25}:\\
\;\;\;\;{t\_0}^{-2}\\

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


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

    1. Initial program 64.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.9999999999999998e-25 < x

    1. Initial program 68.1%

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

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

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

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

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

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

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

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

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

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

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

        \[\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)}} \]
      11. unpow298.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 97.4% accurate, 2.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 \color{blue}{\left(x \cdot 2\right)}}{c \cdot \left(x \cdot s\right)}}{c \cdot \left(x \cdot s\right)} \]
    6. *-commutative97.4%

      \[\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)} \]
    7. associate-*l*95.9%

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

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

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

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

Alternative 5: 78.5% 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 65.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{\left(c \cdot \left(s \cdot x\right)\right)}^{-2}} \]
  12. Final simplification78.0%

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

Alternative 6: 78.3% accurate, 20.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 78.3% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 \color{blue}{\left(x \cdot 2\right)}}{c \cdot \left(x \cdot s\right)}}{c \cdot \left(x \cdot s\right)} \]
    6. *-commutative97.4%

      \[\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)} \]
    7. associate-*l*95.9%

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

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

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

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

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

Alternative 8: 78.2% accurate, 24.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 75.6% 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 65.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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