# Algorithms for Various Trigonometric Power Sums
## 5 Twisted Trigonometric Power Sums
As a consequence, for the Gardner-Fisher case, the third term on the rhs of (75) becomes  
\[\sum_{i=v+1}^{j}(-1)^{i}\binom{j}{i}\sum_{k=1}^{2m-1}(\pm 1)^{k} \sin^{2i-2v}\Bigl{(}\frac{k\pi}{2m}\Bigr{)}=2\sum_{i=v+1}^{j}(-1 )^{i}\binom{j}{i}S_{0,2}^{\pm}(i-v,m)\] \[V^{-}_{v,j,2}(m)=\sum_{i=0}^{j}(-1)^{i}\binom{j}{i}\sum_{n=0}^{v -i-1}\frac{s(v-i,n)}{(2v-2i-2n)_{2n}}\frac{\zeta(2v-2i-2n)}{\pi^{2v-2i-2n}}\]0  
As a result of the preceding discussion, (75) becomes  
\[V^{-}_{v,j,2}(m)=\sum_{i=0}^{j}(-1)^{i}\binom{j}{i}\sum_{n=0}^{v -i-1}\frac{s(v-i,n)}{(2v-2i-2n)_{2n}}\frac{\zeta(2v-2i-2n)}{\pi^{2v-2i-2n}}\]1 \[V^{-}_{v,j,2}(m)=\sum_{i=0}^{j}(-1)^{i}\binom{j}{i}\sum_{n=0}^{v -i-1}\frac{s(v-i,n)}{(2v-2i-2n)_{2n}}\frac{\zeta(2v-2i-2n)}{\pi^{2v-2i-2n}}\]2 \[V^{-}_{v,j,2}(m)=\sum_{i=0}^{j}(-1)^{i}\binom{j}{i}\sum_{n=0}^{v -i-1}\frac{s(v-i,n)}{(2v-2i-2n)_{2n}}\frac{\zeta(2v-2i-2n)}{\pi^{2v-2i-2n}}\]3  
The sum in the penultimate term on the rhs of (79) can be evaluated with the aid of No. 4.2.1.5 in Ref. [24]. Then, we find that  
\[V^{-}_{v,j,2}(m)=\sum_{i=0}^{j}(-1)^{i}\binom{j}{i}\sum_{n=0}^{v -i-1}\frac{s(v-i,n)}{(2v-2i-2n)_{2n}}\frac{\zeta(2v-2i-2n)}{\pi^{2v-2i-2n}}\]4  
By introducing (80) into (79), we arrive at the second result in Lemma 2. From the proof, we observe that the powers of \(m\) in the final results are governed by the summand factors. In fact, since each summand factor possesses a term with \(m^{2\upsilon-2n}\), the degree of the polynomials in \(m\) will be \(2\upsilon\) corresponding to \(n=0\). In other words, the highest power of \(V^{\pm}_{\upsilon,j,l}(m)\) is \(m^{2\upsilon}\), where \(s(v-i,0)=1\). We are now in a position to consider the development of an algorithm that will evaluate \(V^{\pm}_{\upsilon,j,l}(m)\) as defined by (65). Of the terms comprising \(V^{\pm}_{\upsilon,j,l}(m)\), the most formidable is the second term on the rhs of (68), namely the term involving the alternating basic sine power sums since, from (36), the positive sign or non-alternating case can be reduced to  
\[V^{-}_{v,j,2}(m)=\sum_{i=0}^{j}(-1)^{i}\binom{j}{i}\sum_{n=0}^{v -i-1}\frac{s(v-i,n)}{(2v-2i-2n)_{2n}}\frac{\zeta(2v-2i-2n)}{\pi^{2v-2i-2n}}\]5  
and  
\[V^{-}_{v,j,2}(m)=\sum_{i=0}^{j}(-1)^{i}\binom{j}{i}\sum_{n=0}^{v -i-1}\frac{s(v-i,n)}{(2v-2i-2n)_{2n}}\frac{\zeta(2v-2i-2n)}{\pi^{2v-2i-2n}}\]6  
where  
\[c_{p}= \begin{cases}1/2,&p=0,\\ 1,&p\geq 1.\end{cases}  \tag{83}\]  
These forms are easily implemented in Mathematica. However, when the summands are alternating, i.e., for \(S^{-}_{0,l}(i-\upsilon,m)\), we have to deal with \(H_{r}(m,n,j)\). Previously, it was shown how this function can be implemented by itself in Mathematica, but now it appears in another sum involving binomial coefficients. To simplify the problem, we combine the results appearing in Lemma 2 into one expression as  
\[S^{-}_{0,l}(i-\upsilon,m) = \Big{(}\frac{(-1)^{lm}+1}{2^{2i-2\upsilon}}\Big{)}\sum_{j=0}^{i- \upsilon}(-1)^{j}\binom{2i-2\upsilon}{j}H_{3-l}(i-\upsilon,m,j) \tag{84}\] \[- \frac{(1+(-1)^{m})}{2^{2i-2\upsilon+1}}\binom{2i-2\upsilon}{i- \upsilon}.\]  
Therefore, when \(l\!=\!1\) and \(m\) is odd, (84) vanishes as demonstrated by the top result of (49), while when \(l\!=\!2\) or \(m\) is even, the first sum contributes as demonstrated by the other results in (49) and (50) with the major difference being that \(H_{2}(i-\upsilon,m,j)\) and \(H_{1}(i-\upsilon,m,j)\) are implemented when \(l\!=\!1\) and \(l\!=\!2\), respectively. In accordance with Lemma 1, the second or final term on the rhs of (84) only contributes when \(m\) is even. When it comes to the creation of a module in Mathematica, we do not really need to implement \(H_{2}\) and \(H_{1}\). Instead, we employ a condition to evaluate \(H\), which is different according to whether \(l\!=\!1\) or \(l\!=\!2\) when the sign or \(sgn\) equals \(-1\). On the other hand, we can introduce another conditional statement to cover the case when the sign is equal to \(+1\).