Next Article in Journal
Extended General Malfatti’s Problem
Next Article in Special Issue
Algorithm for Option Number Selection in Stochastic Paired Comparison Models
Previous Article in Journal
Correlation Analysis of Railway Track Alignment and Ballast Stiffness: Comparing Frequency-Based and Machine Learning Algorithms
Previous Article in Special Issue
On Implementing a Two-Step Interior Point Method for Solving Linear Programs
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Algorithms for Various Trigonometric Power Sums

School of Mathematics and Statistics, The University of Melbourne, Parkville, VIC 3010, Australia
Algorithms 2024, 17(8), 373; https://doi.org/10.3390/a17080373
Submission received: 18 June 2024 / Revised: 4 July 2024 / Accepted: 8 July 2024 / Published: 22 August 2024
(This article belongs to the Special Issue Numerical Optimization and Algorithms: 2nd Edition)

Abstract

:
In this paper, algorithms for different types of trigonometric power sums are developed and presented. Although interesting in their own right, these trigonometric power sums arise during the creation of an algorithm for the four types of twisted trigonometric power sums defined in the introduction. The primary aim in evaluating these sums is to obtain exact results in a rational form, as opposed to standard or direct evaluation, which often results in machine-dependent decimal values that can be affected by round-off errors. Moreover, since the variable, m, appearing in the denominators of the arguments of the trigonometric functions in these sums, can remain algebraic in the algorithms/codes, one can also obtain polynomial solutions in powers of m and the variable r that appears in the cosine factor accompanying the trigonometric power. The degrees of these polynomials are found to be dependent upon v, the value of the trigonometric power in the sum, which must always be specified.

1. Introduction

Over the last half-century or so, finite sums involving powers of trigonometric functions have fascinated mathematicians and physicists. Although there had been sporadic interest in these sums before that, the modern interest was sparked in 1966 when Quoniam [1] sought the solution of
k = 1 n / 2 2 2 m cos 2 m k π n + 1 = ( n + 1 ) 2 m 1 m 1 2 2 m 1 ,
where m < n + 1 , with m and n being positive integers. The problem was solved shortly afterwards by Greening et al. [2]. Later, Gardner [3] observed that the finite sum of inverse powers of cosines given by
S v , 2 ( m ) = π 2 m 2 v k = 1 m 1 cos 2 v k π 2 m ,
where both m and v are positive integers, appears in the calculation of the v-th cumulant of a certain quadratic form in m independent standardized normal variates. Although he was able to find that
lim m S v ( m ) = ζ ( 2 v ) ,
where ζ (s) is the Riemann zeta function, he asked whether it was possible to obtain a “simpler” closed form expression for S v ( m ) , for all m and v.
In solving this problem, Fisher [4,5] observed that the above sum could be expressed as
S v , 2 ( m ) = π 2 m 2 v k = 1 m 1 sin 2 v k π 2 m .
He then set about devising an ingenious generating function approach for the more general trigonometric power series given by
Q m , v ( δ ) = k = 1 m 1 sin 2 v k π + δ 2 m .
Eventually, he arrived at
S 1 , 2 ( m ) = π 2 6 1 1 m 2 and S 2 , 2 ( 2 ) = π 4 90 1 + 5 2 m 2 7 2 m 4 ,
while for large m, he found that
S v , 2 ( m ) = ζ ( 2 v ) + v 12 m 2 ζ ( 2 v 2 ) + O m 4 .
A flurry of activity on trigonometric power sums occurred in the late 1980s due to their appearance in important physical applications, such as the work of Dowker [6,7,8] which dealt with the Casimir effect and heat kernel expansion on a generalized cone, Verlinde [9], whose formula predicts the dimension of the space of conformal blocks in a chiral conformal field theory (CFT), and Zagier [10], who developed Verlinde’s results further. A decade later, studies of related sums appeared, such as by Berndt and Yeap [11] on the explicit evaluation and reciprocity theorems of specific trigonometric power sums, and Cvijović and Srivastava [12,13] on Dowker’s and related sums. It should be mentioned here that Berndt and Yeap also presented an extensive literature survey on these sums in the introduction to their paper. At the same time, other authors [14,15,16], motivated by the intrinsic fascination of these sums, derived formulas where the summand was a power of secant, as in
k = 0 m 1 sec 2 p k π m = m k = 1 2 p 1 ( 1 ) p + k p 1 + k m 2 p 1 j = k 2 p 1 2 p j + 1 .
It should be noted that when both sides of this result are evaluated separately in Mathematica (Version 14.0) [17], it is found that they agree in decimal form, although for large values of n and p, one may encounter problems with complex infinities on the left-hand side (lhs) due to the summand becoming very small.
Afterwards, Dowker [18] concentrated only on sums involving powers of cosecant with a similar argument as in the above sum, since he noted that they also occur in Rényi entropy and Dedekind sums. More recently, however, these sums have appeared in a study of the entanglement entropy in string theory [19], where the argument inside the trigonometric powers are the fractions k / m multiplied by 2 π , rather than π .
The most fascinating trigonometric power sums are those possessing inverse powers of the sine or cosine, including tangent and cotangent, because their evaluation generally involves the zeta function directly, or through related numbers such as the Bernoulli and Euler numbers. In these types of trigonometric power sums, the solution is number-theoretical in nature [10,12,13], whereas if it is a basic trigonometric power sum, i.e., possessing only even positive powers of sine or cosine, then it is combinatorial [20,21]. Nevertheless, this paper will present new developments concerning both positive and negative powers of the trigonometric function in the summand.
Specifically, this paper is concerned with developing an algorithm for evaluating general twisted trigonometric power sums, which are defined as
T v , l ± ( m , r ) k = 1 l m 1 ( ± 1 ) k cos 2 r k π l m csc 2 v k π l m .
In the above equation, r is an integer lying between 1 and m 1 , while l can equal to 1 or 2. The major difference between these sums and the other sums mentioned above is the appearance of an extra cosine factor next to the trigonometric power. That is, most of the previous studies have been concerned with the untwisted or r = 0 forms of (9), with the exception being the papers of Cvijovic and Srivastava [12,13].
As indicated earlier, Dowker was the first to find physical applications of trigonometric power sums possessing an extra cosine factor next to the trigonometric power [6,8]. The sums were later referred to as twisted Dowker sums by Cvijovic and Srivastava [12,13], when developing Dowker’s results further. Nevertheless, these twisted trigonometric power sums were concerned mainly with the non-alternating l = 1 case of (9). In keeping with these papers, we shall refer to the sums with l = 1 as the Dowker case. In addition, we shall generalize the works of these authors so that one can observe the underlying number-theoretical and combinatorial behavior emanating from the sums. Moreover, we shall study the corresponding l = 2 forms, which will be referred to as the Gardner–Fisher case following from the seminal role of these two authors in this case. Our ultimate goal, however, will be to develop general algorithms capable of yielding: (1) purely rational values for the four types of trigonometric power sums defined by (9) when m and r are specified values, and (2) polynomials in powers of m and r when both variables are algebraic.
To complete this introduction, it should be stated that trigonometric power sums are not only affected by the power and type of trigonometric function in the summand, but also by the different sequences of rationals multiplying π in the arguments of these functions. As a result, it becomes a formidable task to devise a master theorem that can cover all kinds of trigonometric power sums. Nevertheless, we shall obtain deep and meaningful results for both the Dowker and Gardner–Fisher cases. In addition, whilst polynomial expressions in powers of m and r can be obtained, the same cannot be said for the power, v, in (9). That is, the value of the trigonometric power must always be specified before the solution to a particular sum can be determined.

2. Background

Before more intricate trigonometric power sums as discussed in [21] can be considered, one needs to study the untwisted Dowker and Gardner–Fisher sums, which can be represented in a general form as
S v , l ( m ) k = 1 m 1 csc 2 v k π l m .
The untwisted Dowker sum is given by l = 1 in the above definition, while the Gardner–Fisher sum corresponds to the l = 2 case. Later in this work, we shall study more general alternating forms of the sums as given in (9), where r is an integer ranging from 1 to m 1 . It should also be mentioned here that the Gardner–Fisher sum studied in [4,5] was defined with an extra normalization factor of ( π / 2 m ) 2 v . Therefore, to make contact with the results presented in [21], the results presented here need to be multiplied by the appropriate normalization factor for each value of v.
General expressions for the two sums were obtained by employing a novel integral technique in Theorems 3.1 and 4.1 of [21]. In the case of the Gardner–Fisher sum, it was found to be given by
S v , 2 ( m ) = 1 ( 2 v 1 ) ! 2 m π 2 v n = 0 v 1 π m 2 n s ( v , n ) Γ ( 2 v 2 n ) ζ ( 2 v 2 n ) 1 1 m 2 v 2 n ,
where n v 1 and s ( v , n ) represents the n-th elementary symmetric polynomial obtained by summing over the entire sequence of quadratic powers or squares of integers from 1 2 to ( v 1 ) 2 . That is, the polynomials are given by
s ( v , n ) = 1 i 1 < i 2 < < i n < v 1 x i 1 x i 2 x i n ,
where x i 1 < x i 2 < < x i n and each x i j is equal to at least one value in the set 1 , 2 2 , 3 2 , , ( v 1 ) 2 . It was also found in [21] that
s ( v , n ) = 2 2 n ( 2 v 2 n ) 2 n c 2 v , n ,
where ( x ) k denotes the Pochhammer notation for Γ ( k + x ) / Γ ( x ) and the c ρ , n , known as the generalized cosecant numbers, represent the polynomial coefficients in ρ of the generating function for ( x csc x ) ρ . The first ten orders are displayed in Table 1, while important applications and alternative methods of evaluating them are described extensively in [21,22]. For the special case of ρ = 1 , the generalized cosecant numbers reduce to the cosecant numbers, c k , which are given by
c k = 2 1 2 1 2 k ζ ( 2 k ) π 2 k = ( 1 ) k + 1 ( 2 k ) ! 2 2 k 2 B 2 k .
In the above equation, B 2 k represent the Bernoulli numbers. The c k have the advantage of converging quickly to zero as k , whereas the Bernoulli numbers diverge.
On the other hand, the untwisted Dowker sum was found in [21] to be given by
S v , 1 ( m ) = k = 1 m 1 csc 2 v k π m = 2 ( 2 v 1 ) ! m π 2 v n = 0 v 1 2 π m 2 n × s ( v , n ) Γ ( 2 v 2 n ) ζ ( 2 v 2 n ) 1 1 m 2 v 2 n .
Thus, it is seen that both sums are similar, with the differences occurring in the powers of the summands and the factors outside the sums.
By applying the SymmetricPolynomial, Gamma, Zeta, Sum, and Table routines in Mathematica [17], we were able to derive the first 15 values of v for both sums with only a few lines of code. To accomplish this, (11) is implemented in Mathematica as
 
S2[m,v]:= (1/((2v−1)!)) (2m/Pi)(2v)Sum[(Pi/m)(2n)
SymmetricPolynomial[n,Table[k2,{k,1,v−1}]]
Gamma[2v−2n] Zeta[2(v−n)](1−1/(m(2(v−n)))), {n,0,v−1}].
 
The above line only prints out the coefficient of π 2 to the v-th power in S v , 2 . For example, setting m = 15 and v = 12 yields
 
In[1]:= S2[15, 12]
 
Out[1] = 2868438460764696861661970072338432 8303765625 ,
 
whilst putting m = 15 and v = 3 gives
 
In[2]:= S2[15, 3]
 
Out[2] = 105368576 135 .
 
For m, algebraic, the instruction prints out all the terms for the v-th power of π 2 . To obtain the coefficient in terms of a polynomial in m, one needs to wrap the instruction in the FullSimplify routine. Therefore, for v = 3 one finds that
 
In[3]:= FullSimplify[S2[m, 3]]
 
Out[3] = 8 945 71 + 42 m 2 + 21 m 4 + 8 m 6 .
 
Moreover, by typing the following instruction in Mathematica:
 
F 2 [ m , n ] : = Table [ Simplify [ S 2 [ m , v ] ] , { v , 1 , n } ] ,
 
one obtains a table of all the results of S v , 2 ( m ) for v = 1 to n or the first n values of the Gardner–Fisher sum. For example, setting n = 3 results in the following output:
 
In[4]:= F[m, 3]
 
Out[4] = 2 3 1 + m 2 , 4 45 7 + 5 m 2 + 2 m 4 , 8 945 71 + 42 m 2 + 21 m 4 + 8 m 6 .
 
The above results can be displayed as a table by wrapping F 2 [ m , n ] first inside the Partition routine and then using the Grid routine as in [21], but this is not necessary here. In addition, by wrapping it inside the Timing routine, one can obtain the amount of CPU time taken to generate the results. For example, the above results took only 0.00048 CPU seconds on a Venom Blackbook Zero laptop with 64 GB of RAM. For completeness, Table 2 displays the first ten values of S v , 2 ( m ) .
The above statements can be easily adapted to yield values of the untwisted Dowker sum. All we need to do is modify the first instruction to
 
S1[v, m]:= (2(2 v + 1)/(2 v − 1)!) Sum[(2 Pi/m)(2 n −2 v)
SymmetricPolynomial[n,Table[k 2, {k, 1, v − 1}]] Gamma[2 (v − n)] Zeta[2 (v − n)]
(1 − 1/(m(2 (v − n)))),{n, 0, v − 1}].
 
Consequently, for n = 3 , we obtain the following output:
 
In[5]:= FullSimplify[S1[3, m]]
 
Out[5]= 1 945 (−1 + m) (1 + m) (191 + 23 m2 + 2 m4),
 
which represents S 3 , 1 ( m ) .
To obtain all the results for the untwisted Dowker sum up to v, one must write the second instruction as
 
F 1 [ n , m ] : = Table [ Simplify [ S 1 [ v , m ] ] , { v , 1 , n } ] .
 
Then, by setting n = 3 in F 1 [ m , n ] and wrapping it around the Timing routine in Mathematica, one arrives at
 
In[6]:= Timing[F1[3, m]]
 
Out[6]= {0.000377, 1/3 (−1 + m2), 1/45 (−11 + 10 m2 + m4), 1/945 (−191 +
168 m2 + 21 m4 + 2 m6) }.
 
This means it took 0.000377 s to generate the first three untwisted Dowker sums on the same Venom Blackbook Zero laptop mentioned previously. Note also that there are no powers of π as in the Gardner–Fisher sum. In fact, the factor outside the results in Table 3 is equal to ζ ( 2 v ) / π 2 v .
It should be mentioned here that the results obtained above and later on are exact due to the fact that they are computed using integer arithmetic, not machine-dependent decimal numbers. This means that there is no error involved in their determination. Furthermore, if m is set to a rational value, then the numerical value will be expressed as a rational subject to the memory of the computing system which, for the laptop used in this paper, is a few terabytes. In this work, we will be frequently generating rational values for the trigonometric power sums, but when we wish to compare them with those generated by the standard instructions in Mathematica, we will need to convert them to number or decimal form. For these situations, any number of decimal places can be specified by the user, but here they will be restricted to 16 decimal places, since those evaluated by standard means are limited by the byte size for the computing machine, especially when m > 5 . Therefore, whilst it is possible to obtain much higher decimal precision from the computed values of the new results in this work, they will only be expressed to 16 decimal places in order to make a fair comparison with the machine-dependent numbers arising from the standard instructions in Mathematica.
To complete this section, it should also be mentioned that the untwisted Dowker sums can be obtained in Mathematica simply by typing in the l = 1 version of (10) as follows:
 
Sv1[v, m]:= Sum[Csc[k π /m](2 v), {k,1,m−1}].
 
With v = 6 and m = m in the instruction, Mathematica prints out
 
In[7]:= Sv1[6, m]
 
Out[7] = (1/638512875)(−92427157 + 78624000 m2 + 11507496 m4 + 1987700 m6 + 279279 m8 + 27300 m10 + 1382 m12).
 
The same approach, however, does not apply to the Gardner–Fisher case, but can be applied to the alternating version of the untwisted Dowker sum as described in the next section.

3. Alternating Sums

In the previous section, algorithms for both the untwisted Gardner–Fisher and Dowker sums were presented. As indicated in [21], these results formed the basis for determining more intricate trigonometric power sums, which will be discussed in later sections of this paper. For now, however, we can extend this basis by considering the alternating versions of the sums. That is, we are interested in solving
S v , l ± ( m ) k = 1 m 1 ( ± 1 ) k csc 2 v k π l m .
From here on, we shall denote S v , l ( m ) in the previous section as S v , l + ( m ) .
The solutions for l = 1 and 2 of S v , l ( m ) can be determined by modifying the derivations for l = 1 and 2 of S v , l + ( m ) , as can be seen by the following theorem.
Theorem 1. 
General solutions of S v , l ( m ) for the Dowker ( l = 1 ) and Gardner–Fisher ( l = 2 ) cases are, respectively,
S v , 1 ( m ) = 0 , m , odd , 2 2 v + 1 n = 0 v 1 ( 2 π ) 2 n 2 v ( 2 v 2 n ) 2 n s ( v , n ) 2 2 n 2 v + 1 1 m 2 v 2 n 1 ζ ( 2 v 2 n ) , m , even ,
and
S v , 2 ( m ) = 2 2 v n = 0 v 1 ( 2 π ) 2 n 2 v ( 2 v 2 n ) 2 n s ( v , n ) ( 2 m 2 v 2 n ( 2 m ) 2 v 2 n ( 1 ) m 2 2 v 2 n + ( 1 ) m 1 ) ζ ( 2 v 2 n ) .
Proof. 
In the proof of Theorem 3.1 in [21], the following result was obtained:
csc 2 v k π 2 m = 4 v m 2 π 2 Γ ( 2 v ) 0 1 ln u 1 u 2 m n = 1 v 1 m 2 π 2 ln 2 u + n 2 u k + u 2 m k d u u .
This can be generalized to csc 2 v ( k π / l m ) by replacing m with l m / 2 . Then, we have
csc 2 v k π l m = 4 v 1 l 2 m 2 π 2 Γ ( 2 v ) 0 1 ln u 1 u l m n = 1 v 1 l 2 m 2 4 π 2 ln 2 u + n 2 u k + u l m k d u u .
Multiplying the above result by ( 1 ) k and summing over k from 1 to m 1 , we obtain S v , l ( m ) , which is given by
S v , l ( m ) = 4 v 1 l 2 m 2 π 2 Γ ( 2 v ) 0 1 ln u 1 u l m n = 1 v 1 l 2 m 2 4 π 2 ln 2 u + n 2 k = 1 m 1 ( u ) k + k = 1 m 1 ( 1 ) k u l m k d u u .
The sums over k in (21) are simply the finite geometric series, which yield
1 u k = 1 m 1 ( u ) k + ( 1 ) k u l m k = 1 + ( 1 ) m u ( l 1 ) m 1 ( u ) m 1 1 + u .
In addition, from [21], the product in (21) can be expressed via Newton’s identities as
n = 1 v 1 l 2 m 2 4 π 2 ln 2 u + n 2 = n = 0 v 1 l 2 m 2 4 π 2 ln 2 u n s ( v , n ) .
By introducing (22) and (23) into (21), one is able to write the integrals over u in terms of derivative of digamma function via No. 4.271(16) in [23]. Thus, after some algebra, one arrives at
S v , l ( m ) = 2 2 v Γ ( 2 v ) n = 0 v 1 ( 2 π ) 2 n 2 v s ( v , n ) k = 1 m 1 ( ( 1 ) k ψ ( 2 v 2 n 1 ) k l m + ( 1 ) m k ψ ( 2 v 2 n 1 ) k + ( l 1 ) m l m ) ,
where s ( v , n ) is given by (12). Noting that ψ ( n ) ( x ) = ( 1 ) n + 1 n ! ζ ( n + 1 , x ) , where ζ ( n , x ) represents the Hurwitz zeta function, we can simplify (24) to
S v , l ( m ) = 2 2 v Γ ( 2 v 2 n ) Γ ( 2 v ) n = 0 v 1 ( 2 π ) 2 n 2 v s ( v , n ) k = 1 m 1 ( ( 1 ) k ζ 2 v 2 n , k l m + ( 1 ) m k ζ 2 v 2 n , k + ( l 1 ) m l m ) .
Now, we examine the l = 1 and l = 2 cases of (24) separately. For l = 1 or the Dowker case, we find that the summation over k reduces to
k = 1 m 1 ( ( 1 ) k ζ 2 v 2 n , k m + ( 1 ) m k ζ 2 v 2 n , k m ) = ( 1 + ( 1 ) m ) k = 1 m 1 ( 1 ) k ζ 2 v 2 n , k m .
This result indicates that when m is an odd integer, S v , 1 ( m ) vanishes. Hence, the trigonometric power sum will only yield non-zero solutions for even integer values of m. Thus, we arrive at
S v , 1 ( m ) = 2 2 v + 1 Γ ( 2 v 2 n ) Γ ( 2 v ) n = 0 v 1 ( 2 π ) 2 n 2 v s ( v , n ) k = 1 m 1 ( 1 ) k ζ 2 v 2 n , k m .
The sum over k can be expressed as
k = 1 m 1 ( 1 ) k ζ ( v , k / m ) = m v k = 1 m 1 ( 1 ) k j = 0 1 ( j m + k ) v .
Since m can only be an even integer, we can combine the two dimensional sum into one dimensional sums by noting that
k = 1 m 1 ( 1 ) k ζ ( v , k / m ) = m v j = 1 ( 1 ) j j v j = 1 1 ( j m ) v = 2 1 v m v m v 1 ζ ( v ) .
Introducing (29) into (25) yields the first result displayed in the theorem.
For l = 2 or the Gardner–Fisher case, the summation over k in (25) for any positive integer v becomes
k = 1 m 1 ( 1 ) k ζ v , k 2 m + ( 1 ) m + k ζ v , k + m 2 m = k m k = 1 2 m 1 ( 1 ) k ζ v , k 2 m .
By inserting the k = m term into the sum over k on the right-hand side (rhs) and subtracting it separately, one eventually arrives at
k m k = 1 2 m 1 ( 1 ) k ζ v , k 2 m = 2 m v ( 2 m ) v ( 1 ) m 2 v + ( 1 ) m 1 ζ ( v ) .
Introducing (31) into (25) gives the second result in the theorem. □
We can use the material in the previous section to create an algorithm/program of these results. First, we begin by programming the alternating sum directly. This will show that Mathematica is able to provide the polynomials in powers of m 2 for the Dowker case, but can only provide numerical values in the Gardner–Fisher case. Furthermore, we can combine both cases into one instruction as follows:
 
Sminus[v, l, m]:= Sum[(−1)k Csc[k Pi/(l m)](2 v), {k, 1, m − 1}].
 
Obviously, if one puts l = 1 , then one obtains the Dowker case, while if it equals 2, then results for the Gardner–Fisher case are printed out. Putting v = 4 , l = 1 and m = m yields
 
In[8]:= Sminus[4, 1, m]
 
Out[8] = (−319616 − 138240 m2 − 32928 m4 − 4960 m6 − 381 m8)/1814400.
 
However, if l = 2 , then the following occurs:
 
In[9]:= Sminus[4, 2, m]
 
Out[9] = k = 1 1 + m ( 1 ) k Csc k π 2 m 8 .
 
Therefore, Mathematica is unable to generate algebraic forms in the Gardner–Fisher case. In this case, only numerical values can be obtained by specifying values of m.
If we examine (17) and (18) closely, then we see that main difference, aside from a factor of 2 outside the Dowker case, is that the expressions inside the large parentheses are different. That is, the summands are identical except for the terms inside the large brackets. Consequently, we can create two different factors corresponding to the l = 1 and l = 2 cases that need to be introduced into the summand. Let us call this the summand factor, which can be specified by the following instructions:
 
Smdfctr[v, m, n, 1]:= 2 ((2(2 n − 2 v + 1) − 1) m(2 v− 2n)− 1)
 
Smdfctr[v, m, n, 2]:= (2 m(2 v − 2 n) − (2 m)(2 v − 2 n) − (−1)m
2(2 v − 2 n) + (−1)m − 1).
 
Moreover, both cases can be combined into one instruction by introducing l as a variable, which would need to be specified by the user as follows:
 
SMinus[v, m, l]:= 2(2 v) Sum[((2 π )(2 n − 2 v) Zeta[2 v − 2 n]/Pochhammer
[2 v − 2 n, 2 n]) Smdfctr[v, m, n,l] SymmetricPolynomial[n,Table[k2, {k, 1, v − 1}]],
{n, 0,v − 1}].
 
To generate the results in the same manner as in the previous section, one simply types
 
F1[n, m, l]:= Table[Simplify[SMinus[v, m, l]], {v, 1, n}].
 
If one puts n = 3 , m = m , and l = 1 in the above instruction, then Mathematica prints out
 
In[10]:= F1[3, m, 1]
 
Out[10] = {1/6 (−2 − m2), 1/360 (−88 − 40 m2 − 7 m4), (−3056 − 1344 m2 − 294 m4
− 31 m6)/15120}.
 
Thus, the first three results for the alternating version of the Dowker sum are obtained. Table 4 presents the first 10 results for the sum generated by putting n = 10 in the above instruction. Wrapping the instruction inside the Timing routine gives a CPU time of 0.030429 s using the same Venom laptop mentioned in the previous section.
To obtain the alternating version of the Gardner–Fisher sum, all one needs to do is to put l = 2 . Therefore, typing
 
In[11]:= Timing[F1[3, m, 2]],
 
yields
 
Out[11] = {0.000618, {1/6 (−1 −3 (−1)m − 2 m2), 1/90 (−11 − 45 (−1)m − 20 m2 − 14 m4),
(−191 − 945 (−1)m − 336 m2 − 294 m4 − 124 m6)/1890}}.
 
This indicates that it took 0.000618 s to produce the first three results of the alternating version of the Gardner–Fisher sum.
Table 5 displays the first ten results of the alternating version of the Gardner–Fisher sum, which took only 0.004516 s to produce. As for S v , 1 ( m ) and the non-alternating versions of both types of sum, the result yields polynomials in powers of m 2 of degree 2 v . There is, however, one interesting property of S v , 2 ( m ) that the other sums do not possess. This is that the constant in the polynomials is different when m is odd and even, and might explain why Mathematica is unable to provide the results in Table 5 as it does for Table 4. Nevertheless, all four sums yield rational values for any value of m.
To conclude this section, it should be noted that if we modify the upper limit of S v , 2 ( m ) to 2 m 1 , as will be the case in Section 5, then we find that
T v , 2 ( m , 0 ) = k = 1 2 m 1 ( 1 ) k csc 2 v k π 2 m = 2 S v , 2 ( m ) + ( 1 ) m ,
where the general definition of T v , l ± ( m , r ) appears in the introduction. In any case, we can use the results in Table 5 to obtain T v , 2 ( m , 0 ) for specific values of v. Furthermore, from (18), we arrive at
T v , 2 ( m , 0 ) = 2 2 v + 1 n = 0 v 1 ( 2 π ) 2 n 2 v ( 2 v 2 n ) 2 n s ( v , n ) ( 2 m 2 v 2 n ( 2 m ) 2 v 2 n ( 1 ) m 2 2 v 2 n + ( 1 ) m 1 ) ζ ( 2 v 2 n ) + ( 1 ) m .

4. Basic Trigonometric Power Sums

Basic trigonometric power sums are defined as finite trigonometric power sums of the form
S ( m , n ) C ( m , n ) k = 0 g ( n ) ( ± 1 ) k f ( k ) cos 2 m sin 2 m q k π n ,
where m, q and n are positive integers, g ( n ) is dependent upon n such as n 1 or even m / n , and f ( k ) is a relatively simple function of k, such as unity or cos ( k π / p ) with p, an integer. Besides the derivation of new results for interesting versions of these sums in [20], important applications were studied, such as the determination of the number of closed random walks of length 2 m with n 1 vertices. The key results of this work are
C ( m , n ) = 2 1 2 m n 2 m 1 m 1 + p = 1 m / n 2 m m p n , if   m n , 2 1 2 m n 2 m 1 m 1 , if   m < n ,
and
S ( m , n ) = 2 1 2 m n 2 m 1 m 1 + p = 1 m / n ( 1 ) p n 2 m m p n , if   m n , 2 1 2 m n 2 m 1 m 1 , if   m < n ,
where
C ( m , n ) : = k = 0 n 1 cos 2 m k π n ,
and
S ( m , n ) : = k = 0 n 1 sin 2 m k π n .
Although the second result in each case is not necessary, since it is covered by the first result, they were displayed separately (1) because of their simplicity and (2) to make contact with the results on p. 640 of [24]. There, they are given as
k = 1 n / 2 cos 2 m k π n = 2 1 2 m n 2 m m 1 2 , m < n ,
and
k = 1 n sin 2 m k π 2 n = 2 2 m n 2 m m + 1 2 , m < 2 n .
The above results can be programmed easily in Mathematica by typing the following instructions:
 
CosSum[m, n]:= Sum[Cos[k Pi/n](2 m), {k, 0, n − 1}]
 
CosSum2[m, n]:= 2(1 − 2 m) n (Binomial[2 m − 1, m − 1] +
Sum[Binomial[2 m, m − p n], {p, 1, Floor[m/n] }]).
 
If we put m = 15 and n = 17 , then Mathematica prints out
 
In[12]:= CosSum[15, 17]
 
Out[12] = 1 + 2 Cos [ π 17 ] 30 + 2 Cos 2 π 17 30 + 2 Cos 3 π 17 30 + 2 Cos 4 π 17 30 + 2 Sin π 34 30 +
2 Sin 3 π 34 30 + 2 Sin 5 π 34 30 + 2 Sin 7 π 34 30 .
 
In number form, this gives a value of 2.455895617604257. On the other hand, typing in
 
In[13]:= CosSum2[15, 17]
 
yields
 
Out[13] = 164812365/67108864.
 
The decimal value of the above result yields the same decimal value as CosSum[15, 17] except a 6 appears as the last figure, and not a 7. This means that the first result is limited by machine precision, and will not be accurate beyond 16 decimal places. Moreover, one cannot observe whether the results are rational or not, which is clearly the case when employing CosSum2.
The other basic trigonometric power sums studied in [20] were written in terms of C ( m , n ) and S ( m , n ) . Nearly all involved combinations of C ( m , n ) or S ( m , n ) with different arguments. A typical example is
k = 0 3 n 1 cos k π 3 cos 2 m ( k π 3 n ) = 3 C ( m , n / 2 ) 3 C ( m , n ) / 2 + C ( m , 3 n ) / 2 C ( m , 3 n / 2 ) ,
where n is a positive even integer. Based on the preceding material we can program this basic trigonometric power sum as
 
CosSum3[m, n]:= Sum[Cos[k Pi/3] Cos[k Pi/(3 n)](2 m), k, 0, 3 n−1]
 
CosSum4[m, n]:= 3 CosSum2[m, n/2] − 3 CosSum2[m, n]/2 + CosSum2[m, 3 n]/2 −
CosSum2[m, 3 n/2].
 
By putting m = 15 and n = 18 in both instructions, one obtains
 
In[14]:= CosSum3[15, 18]
 
Out[14] = 261261003/268435456 + Cos π 54 30 − Cos π 27 30 − 2 Cos π 18 30 − Cos 2 π 27 30 +
Cos 5 π 54 30 + 2 Cos π 9 30 + Cos 7 π 54 30 − Cos 4 π 27 30 − Cos 5 π 27 30 + Cos 11 π 54 30 +
2 Cos 2 π 9 30 + Cos 13 π 54 30 − Sin π 54 30 + Sin π 27 30 + 2 Sin π 18 30 + Sin 2 π 27 30 − Sin 11 π 54 30
2 Sin π 9 30 − Sin 7 π 54 30 + Sin 4 π 54 30 + Sin 5 π 27 30 − Sin 11 π 54 30 − 2 Sin 2 π 9 30 − Sin 13 π 54 30 .
 
In number form, this yields 0.02986178733408444. However, by applying the second form we find that
 
In[15]:= CosSum4[15, 18]
 
Out[15] = 16031925/536870912.
 
This gives the same value in number form as the above value except the last two digits are 51, not 44. Therefore, programming (35) and (36) into Mathematica yields rational values for all the basic trigonometric power sums studied in [20].
More recently, Du et al. [25] have developed basic trigonometric power sums further in two directions. The first involves the introduction of an offset in the argument of the power of the trigonometric function so that (37) and (38) are re-defined as
C α ( m , n ) : = k = 0 n 1 cos 2 m k n + α π ,
and
S α ( m , n ) : = k = 0 n 1 sin 2 m k n + α π .
Consequently, it was found that
C α ( m , n ) = 2 1 2 m n 2 m 1 m + 2 1 2 m n p = 1 m / n 2 m m p n cos 2 α p n π .
and
S α ( m , n ) = 2 1 2 m n 2 m 1 m + 2 1 2 m n p = 1 m / n ( 1 ) p n 2 m m p n cos 2 α p n π .
Here, the m < n forms have been dropped, since they are included in (44) and (45).
The above results can be checked by implementing them in Mathematica [17]. For example, (44) can be implemented via the following instructions:
 
CosSum[m, n, α ]:= Sum[Cos[(k/n + α ) π ](2 m), {k, 0, n − 1 }]
 
CosSum2[m, n, α ]:= 2(1 − 2 m) n (Binomial[2 m − 1, m − 1] +
Sum[Binomial[2 m, m − p n] Cos[2 α p n π ], {p, 1, Floor[m/n]}]).
 
Putting m = 12 , n = 15 and α = 1 / 3 in the first instruction yields
 
In[16]:= CosSum[12, 15, 1/3]
 
Out[16] = 8388609/8388608 + (−1 − 5 ) 24 /140737488355328 +
(1 − 5 ) 24 /281474976710656 + (−1 + 5 ) 24 /281474976710656 + 2 Cos[ π / 15 ] 24 +
2 Cos[(2 π ) / 15 ] 24 + 2 Sin[ π / 30 ] 24 + 2 Sin[(7 π ) / 30 ] 24 .
 
In number form, Mathematica prints out a value of 2.41770386695862. On the other hand, typing CosSum2[12,15,1/3] generates the rational value of 10140585/4194304, which yields the same decimal value except the final digit of 2 is replaced by 18.
The second direction taken in [25] deals with the introduction of a twisted cosine phase factor, e.g., cos ( 2 l k π / q ) , in the summand with the cosine power. This will become become important when we study twisted forms of Dowker-like sums in the next section. It should be mentioned that twisted basic trigonometric power sums were also studied in [20], but only in limited cases. In [25], the following result was obtained:
k = 0 q n 1 cos 2 k π q cos 2 m k π q n = 2 2 n 1 C ( m + n , q n ) + n j = 0 n 1 ( 1 ) j + 1 j + 1 2 n j 2 j × 2 2 n 2 j 2 C ( m + n j 1 , q n ) .
The above result was obtained by adapting No. I.1.10 in [24] and then multiplying by cos 2 m ( k π / q ) . By summing over k from zero to q n 1 , one finds that
k = 0 q n 1 cos 2 k π q cos 2 m k π q n = 2 2 n 1 k = 0 q n 1 cos 2 m + 2 n k π q n + n j = 0 n 1 ( 1 ) j + 1 j + 1 2 n j 2 j × 2 2 n 2 j 2 k = 0 q n 1 cos 2 m + 2 n 2 j 2 k π q n .
The sums over k on the rhs in (47) are simply versions of the basic cosine power sum given by (35). As a consequence, their introduction results in (46). However, it should be stressed that (47) is only valid for = 1 and 2.
Since C ( m , n ) was observed in [21] to yield rational values, it follows that the cosine power sum given on the lhs of (46) will also yield rational rational values. As an example, consider q = 5 , which yields
k = 0 5 n 1 cos 2 k π 5 cos 2 m k π 5 n = 2 2 n 1 C ( n + m , 5 n ) + n j = 0 n 1 ( 1 ) j + 1 j + 1 2 n j 2 j × 2 2 n 2 j 2 C ( n + m j 1 , 5 n ) .
Both the l = 1 and l = 2 results were not checked numerically in [25]. However, we can check them here, since a knowledge of how they are coded will be required in the following section.
The definition of a basic trigonometric power sum also includes those with alternating phase factors in the summands. Surprisingly, these have not been studied yet. Moreover, we shall require these sums in the next section. Therefore, the following lemma needs to be proved.
Lemma 1. 
The alternating basic sine power sum, S α , l ( m , n ) , stemming from the definition, S α , l ± ( m , n ) k = 1 n ( ± 1 ) k sin 2 m ( k + α ) π / l n , has the following solutions for α = 0 . For the Dowker case or l = 1 , we have
S 0 , 1 ( m , n ) = 0 , n , odd , ( 1 ) m 2 1 2 m j = 0 m ( 1 ) j 2 m j H 2 ( m , n , j ) 2 2 m 2 m m , n , even ,
where
H 2 ( m , n , j ) = n + 1 , exp 2 i ( m j ) π / n = 1 , ( 1 + ( 1 ) n ) / 2 , for all other values of j , m and n .
For the Gardner–Fisher case or l = 2 , the sum has the following solution:
S 0 , 2 ( m , n ) = ( 1 ) m 2 1 2 m j = 0 m ( 1 ) j 2 m j H 1 ( m , n , j ) , n , odd , ( 1 ) m 2 1 2 m j = 0 m ( 1 ) j 2 m j H 1 ( m , n , j ) 2 2 m 2 m m , n , even ,
where
H 1 ( m , n , j ) = n + 1 , exp i ( m j ) π / n = 1 , ( 1 + ( 1 ) m + n j ) / 2 , for all other values of j , m and n .
Remark 1. 
The conditions on H 1 ( m , n , j ) and H 2 ( m , n , j ) in the lemma mean that H 1 ( m , n , j ) and H 2 ( m , n , j ) are equal to n + 1 , when 2 ( m j ) / n and ( m j ) / n , respectively, are odd numbers. Consequently, we shall find that the above results can only be implemented as algorithms/programs yielding rational values.
Proof. 
To prove the Dowker case for odd values of n, we set n = 2 p + 1 , where p is a non-negative integer, and write S 0 , 1 ( m , n ) as
S 0 , 1 ( m , n ) = k = 1 p ( 1 ) k sin 2 m k π 2 p + 1 + k = p + 1 2 p 1 ( 1 ) k sin 2 m k π 2 p + 1 .
In the second sum, we replace k by 2 p + 1 k . Then, ( 1 ) k becomes ( 1 ) 2 p + 1 k or ( 1 ) k + 1 , while sin ( π k π / ( 2 p + 1 ) ) = sin ( k π / ( 2 p + 1 ) ) . Accordingly, the second sum becomes the negative of the first sum on the rhs (rhs) of (53), thereby yielding zero or the first result of (49). To prove the remaining results in the lemma, we use No. 17.4.5 of [26], which can be expressed as
sin 2 m x 2 = ( 1 ) m 2 2 m 1 j = 0 m ( 2 m ) j j ! cos ( m j ) x 1 2 2 m 2 m m .
For the Dowker case, we need to put x / 2 equal to k π / n , while for the Gardner–Fisher case, we put x = k π . Then, we multiply both sides of each resulting equation by ( 1 ) k , sum over k from zero to n and interchange the summations. Hence, for the Dowker case, we arrive at
k = 0 n ( 1 ) k sin 2 m k π n = ( 1 ) m 2 2 m 1 j = 0 m ( 1 ) j ( 2 m ) j j ! k = 0 n ( 1 ) k cos 2 ( m j ) k π n 1 2 2 m 2 m m k = 0 n ( 1 ) k ,
while for the Gardner–Fisher case, we obtain
k = 0 n ( 1 ) k sin 2 m k π 2 n = ( 1 ) m 2 2 m 1 j = 0 m ( 1 ) j ( 2 m ) j j ! k = 0 n ( 1 ) k cos ( m j ) k π n 1 2 2 m 2 m m k = 0 n ( 1 ) k .
The second sum appearing on the rhs of both (55) and (56) simply yields ( 1 + ( 1 ) n ) / 2 , which means, in turn, that it vanishes for odd values of n and gives unity when n is even. It provides the common term in the n even cases of (51) and (52).
The first sum on the rhs of either (55) or (56) can be evaluated either in Mathematica or using the formula for a geometric series. We shall define them by
H r ( m , n , j , x ) k = 0 n ( 1 ) k cos r k ( m j ) x .
This is the general form for the sum. When x is set equal to π / n shortly, the sum will be denoted as H r ( m , n , j ) . For the Dowker or l = 1 case, we require r = 2 in (57), which becomes
H 2 ( m , n , j , x ) = k = 0 n ( 1 ) k cos 2 k ( m j ) x .
The above sum can be determined using Mathematica or splitting the cosine into exponentials of imaginary arguments and applying the geometric series. In adopting the first approach, one simply types
 
H2[m, n, j, x]:= Sum[(−1)k Cos[2 k (m − j) x], {k, 0, n }].
 
Next, one types
 
In[17]:= H2[m, n, j, x].
 
Then, one obtains the following output:
 
Out[17] = 1/2 (Cos[j x − m x] Sec[(j − m) x] + Cos[n π − j x + m x − 2 j n x + 2 m n x]
Sec[(j − m) x]).
 
Putting x = k π / n and dropping the fourth variable, since it is summed out eventually, one arrives at
H 2 m , n , j = 1 2 ( cos ( j m ) π n + cos 2 ( j m ) π + ( j m ) π n n π × sec ( j m ) π n .
There is, however, a problem with using this result in the summand, due to the fact that the secant can yield infinity. This problem can be circumvented by simplifying (59) with the aid of trigonometric identities. Thus, we find that
H 2 m , n , j = 1 2 1 + ( 1 ) n cos ( m j ) π ( 2 + 1 / n ) cos ( j m ) π / n = 1 2 1 + ( 1 ) n .
The above equation is beginning to approach the second result of (50). Unfortunately, this is not the end of the matter, as (59) cannot be valid for all values of m, n and j. If we return to (58) and put x = k π / n , then we observe that whenever 2 ( m j ) / n = ( 2 p + 1 ) , where p is a non-negative integer, H 2 ( m , n , j ) = k = 0 n 1 = n + 1 , not the result obtained from (60). As j is summed from 0 to m, this condition can be met occasionally. That is, there will be at least one value of p where H 2 ( m , n , j ) = n + 1 . Hence, we arrive at (50). If we insert (50) and the result below (56) into (55), then it becomes
k = 0 n ( 1 ) k sin 2 m k π n = ( 1 ) m 2 2 m 1 j = 0 m ( 1 ) j ( 2 m ) j j ! H 2 ( m , n , j ) 1 2 2 m + 1 2 m m 1 + ( 1 ) n .
From the reflection formula for the gamma function, one obtains
( 2 m ) j j ! = ( 1 ) j 2 m j .
Introducing the above result into (61) yields (49). In the Gardner–Fisher case given by (56), we observe that the summation over k can be represented by H 1 ( m , n , j , x ) according to (57). This, too, can be summed in Mathematica or by employing the geometric series. Thus, by typing the instruction as
 
H1[m, n, j, x]:= Sum[(−1)k Cos[k (m − j) x], {k, 0, n }],
 
followed by
 
In[18]:= H1[m, n, j, x],
 
one obtains following output:
 
Out[18] = 1/2 (−Cos[ 1 2 (−2 π + j x − m x)] Sec[ 1 2 (j − m) x] + Cos[ 1 2 (2n π − j x + m x −
2 j n x + 2 m n x)] Sec[ 1 2 (j − m) x]).
 
Putting x = k π / n in the above result yields H 1 ( m , n , j ) , which is given by
H 1 m , n , j = 1 2 ( cos ( j m 2 n ) π 2 n + cos ( j m + 2 j n 2 m n 2 n 2 ) π 2 n × sec ( j m ) π 2 n .
As in the case of H 2 ( m , n , j ) , the above result can be simplified further by the application of trigonometric identities. Therefore, after a bit of manipulation, one finds that
H 1 m , n , j = 1 2 1 + ( 1 ) m + n j .
However, (64) is not valid when ( m j ) / n = 2 p + 1 and p is a non-negative integer. Thus, H 1 ( m , n , j ) = ( n + 1 ) , and we arrive at (52). Finally, if we replace the sum over k by H 1 ( m , n , j ) and introduce (62) into (56), then we obtain (51). □
The results in Lemma 1 indicate that the values of S 0 , 1 ( m , n ) and S 0 , 2 ( m , n ) are rational. Even though they have been expressed as formulas, in reality, they represent algorithms when one wishes to determine values from them. Consequently, Mathematica modules need to be created.
As an example, let us consider the second result in (49). This basic trigonometric sum can be programmed as
 
Szero1minus[m, n]:= Sum[(−1)k Sin[k π /n](2 m), {k, 0, n}].
 
For relatively small values of n, typically less than or equal to 6, the above instruction generates rational values. For example, for m = 16 and n = 6 , Mathematica prints out
 
In[19]:= Timing[Szero1minus[16, 6]]
 
Out[19] = {0.000195, −(32881827/33554432)}.
 
However, putting m = 16 and n = 8 yields
 
In[20]:= Timing[Szero1minus1[16, 8]]
 
Out[20] = {0.00016, 32769/32768 − 2 Cos[ π /8]32 − 2 Sin[ π /8]32}.
 
In number form, this yields 0.841277837753296. Unfortunately, one cannot tell whether the value is rational or not, unless the trigonometric powers are expressed as surds as in Section 5.
To create a module that is able to calculate rational values of S 0 , 1 ( m , n ) for even integer values of n, we require a Do loop to determine each of the contributions from the summand of the second result of (49). Before entering the Do loop, we calculate the second term on the rhs first, which will be denoted as e1. To obtain the correct value of the summand, we introduce an If statement with the condition being whether exp ( ( 2 ( m j ) i π / n ) is equal to −1 or not. If it is, then H 2 ( m , n , j ) or H2 as it is denoted in the module below equals n + 1 . Otherwise, it will equal ( 1 + ( 1 ) n ) / 2 . Then, the summand, which will be denoted as e2, can be evaluated and summed with e1 to yield a new value for e1. On exiting the Do loop, the final value will become the value of S 0 , 1 ( m , n ) , which can then be printed out as in the following module:
 
Szero1minusA[m, n]:= Module[{}, e1 = −Binomial[2 m, m] (1 + (−1)n)/2(2 m +
1); Print[“The value of e1 is ”, e1];
Do[If[ Exp[2 (m − j) I π /n] == −1, H2 = (n + 1), H2 = (1 + (−1)n)/2];
e2 = (−1)(m + j) Binomial[2 m, j] H2/2(2 m − 1);
Print[“For j=”, j, “ the value of H2 is ”, H2, “ while the value of e2 is ”, e2];
e1 = e1 + e2, {j, 0, m}]; Print[“The value of Szero1minus is ”, e1]].
 
Running the module for m = 16 and n = 8 gives
 
Szero1minusA[16, 8]
The value of e1 is −(300540195/2147483648)
For j = 0 the value of H2 is 1 while the value of e2 is 1/2147483648
For j = 1 the value of H2 is 1 while the value of e2 is −(1/67108864)
For j = 2 the value of H2 is 1 while the value of e2 is 31/134217728
For j = 3 the value of H2 is 1 while the value of e2 is −(155/67108864)
For j = 4 the value of H2 is 9 while the value of e2 is 40455/268435456
For j = 5 the value of H2 is 1 while the value of e2 is −(6293/67108864)
For j = 6 the value of H2 is 1 while the value of e2 is 56637/134217728
For j = 7 the value of H2 is 1 while the value of e2 is −(105183/67108864)
For j = 8 the value of H2 is 1 while the value of e2 is 2629575/536870912
For j = 9 the value of H2 is 1 while the value of e2 is −(876525/67108864)
For j = 10 the value of H2 is 1 while the value of e2 is 4032015/134217728
For j = 11 the value of H2 is 1 while the value of e2 is −(4032015/67108864)
For j = 12 the value of H2 is 9 while the value of e2 is 254016945/268435456
For j = 13 the value of H2 is 1 while the value of e2 is −(10855425/67108864)
For j = 14 the value of H2 is 1 while the value of e2 is 29464725/134217728
For j = 15 the value of H2 is 1 while the value of e2 is −(17678835/67108864)
For j = 16 the value of H2 is 1 while the value of e2 is 300540195/1073741824
The value of Szero1minusA is 3528575/4194304.
 
Finally, the decimal value is found by typing
 
In[21]:= N[3528575/4194304, 16]
 
Out[21] = 0.8412778377532959,
 
which agrees with the previously given value. Of course, the above process can be sped up by removing the Print instruction in the Do loop. From the output, we observe also that there are two instances where H 2 ( m , n , j ) equal to n + 1 or 9, namely j = 4 and j = 12 . These values of j will change when m and n are assigned different values. Finally, if we wish to evaluate S 0 , 2 ( m , n ) , all that is required is to alter the first part of the Do loop to
 
Do[If[ Exp[(m − j) I π /n] == −1, H1 = (n + 1), H1 = (1 + (−1)(m + n − j))/2];
e2 = (−1)(m + j) Binomial[2 m, j] H1/2(2 m − 1);.
 
In fact, we can combine both modules into one module by introducing the variable, l, which is set equal to 1 or 2 corresponding to the Dowker and Gardner–Fisher cases. This can be accomplished by using the Which instruction in Mathematica in the following manner:
 
Sminuszerol[−1, l, i, m]:= Module[{H1, H2}, H1 = 0; H2 = 0;
e1 = −Binomial[2 i, i] (1 + (−1)m)/2(2 i + 1);
Which[l == 1, Do[If[ Exp[2 (i − j) I π /m] == −1, H2 = (m + 1), H2 = (1 + (−1)m)/2];
e2 = (−1)(i + j) Binomial[2 i, j] H2/2(2 i − 1); e1 = e1 + e2, {j, 0, i}],
l == 2, Do[If[ Exp[(i − j) I π /m] == −1, H1 = (m + 1), H1 = (1 + (−1)(i + m − j))/2];
e2 = (−1)(i + j) Binomial[2 i, j] H1/2(2 i − 1);
e1 = e1 + e2, {j, 0, i}]]; Print[e1]].
 
Therefore, by setting l = 1 and 2 in the above module, one obtains the values for S 0 , 1 ( i , m ) and S 0 , 2 ( i , m ) , respectively.

5. Twisted Trigonometric Power Sums

As indicated in the introduction, a twisted trigonometric power sum is one whose trigonometric power is multiplied by an extra cosine factor. Originally, this name was applied to the l = 1 case of (10) with cos ( 2 r k π / m ) inserted in the sum, and r was any integer from 1 to m 1 [6,7,12]. In actual fact, r can be much greater m, but then it must be replaced by the modulo value with respect to m, viz., mod ( r , m ) . This issue will be discussed in more detail in Section 6. Moreover, since the trigonometric power sum in (10) has l m in the denominator, we shall consider twisted trigonometric power sums where the cosine factor appears as cos ( 2 r k π / l m ) as in (9). Hence, we will be able to study both the Dowker and Gardner–Fisher cases of (9). Note, however, the upper limit is now l m 1 , whereas in the previous sections, we considered m 1 as the upper limit in both cases. Obviously, this has no effect in the Dowker case, but in the Gardner–Fisher case, it will play a role. For l = 2 , we shall be required to express the sums in (9) in terms of those appearing in previous sections. It should also be mentioned that the case of the cosine factor accompanying the basic trigonometric power has already been studied in [25].
When one considers twisted trigonometric power sums, one frequently ends up having to study other trigonometric power sums, denoted here by V v , j , l ± ( m ) , and defined as
V v , j , l ± ( m ) k = 1 l m 1 ( ± 1 ) k csc 2 v k π l m cos 2 j k π l m ,
where j ranges from 0 to r. These sums arise when the factor of cos ( 2 r k π / l m ) in a twisted trigonometric power sum is expressed as a sum in powers of cos 2 ( k π / l m ) , as will be seen later. Nevertheless, these sums are not only interesting in their own right, but are also formidable. By expressing the cosine powers in terms of power of sines via the binomial theorem, one finds that
V v , j , l ± ( m ) = i = 0 j ( 1 ) i j i k = 1 l m 1 ( ± 1 ) k sin 2 i 2 v k π l m .
For the case of j < v , the inner sum becomes a pure cosecant power sum. Consequently, it will yield polynomials in powers of m 2 with number-theoretical coefficients or coefficients expressible in terms of the Riemann zeta function. However, when j > v , there will also be sums involving basic trigonometric power sums. In particular, when i v and the summand does not alternate, the sum over k simply becomes S ( i v , m ) given by (36). On the other hand, for the alternating case, it can be expressed in terms of S 0 , l ( i v , m ) in Lemma 1. As we have seen in the previous section, such sums are combinatorial in nature. Hence the second case is more complicated than the first case. Nevertheless, both cases can be considered together in one lemma as follows.
Lemma 2. 
For j < v , the trigonometric power sum defined by (65) can be expressed as
V v , j , l ± ( m ) = i = 0 j ( 1 ) i j i n = 0 v i 1 s ( v i , n ) ( 2 v 2 i 2 n ) 2 n ζ ( 2 v 2 i 2 n ) π 2 v 2 i 2 n S f ( v i , n , ± 1 , l ) ,
where the summand factors, S f ( v i , n , ± , l ) are displayed in Table 6 for both signs in the Dowker and Gardner–Fisher cases.
For j v , V v , j , l ± ( m ) is given by
V v , j , l ± ( m ) = i = 0 v 1 ( 1 ) i j i n = 0 v i 1 s ( v i , n ) ( 2 v 2 i 2 n ) 2 n ζ ( 2 v 2 i 2 n ) π 2 v 2 i 2 n S f ( v i , n , ± 1 , l ) + l i = v + 1 j ( 1 ) i j i S 0 , l ± ( i v , m ) ( ± 1 ) m 2 ( 1 ) v 1 + ( 1 ) l j 1 v + ( 1 ) v P ( ± 1 , l ) j v ,
where S 0 , 1 + ( i v , m ) , S 0 , 2 + ( i v , m ) , S 0 , 1 ( i v , m ) and S 0 , 2 ( i v , m ) are, respectively, given by (81), (82), (49) and (51), while the various m-dependent values of P ( ± 1 , l ) are displayed in Table 7. In addition, δ l , 2 denotes the Kronecker delta, which equals unity only when l = 2 or in the Gardner–Fisher case.
Proof. 
When j < v , all the sine powers in (66) are negative. Consequently, the results of Section 2 and Section 3 can be used to evaluate V v , j , l ± . For l = 1 and the non-alternating case, we introduce (15) into (66), which gives
V v , j , 1 + ( m ) = 2 i = 0 j ( 1 ) j j i n = 0 v i 1 s ( v i , n ) ( 2 v 2 i 2 n ) 2 n ζ ( 2 v 2 i 2 n ) π 2 v 2 i 2 n m 2 v 2 i 2 n 1 .
On the other hand, for the Gardner–Fisher case, where l = 2 , we note that
k = 1 2 m 1 sin 2 i 2 v k π 2 m = 2 k = 1 m 1 sin 2 i 2 v k π 2 m + 1 .
Therefore, we can replace the sum on the rhs of (66) by 2 S v , 2 + ( m ) + 1 . Since S v , 2 + ( m ) is given by (11), we arrive at
V v , j , 2 + ( m ) = i = 0 j ( 1 ) i j i n = 0 v i 1 s ( v i , n ) ( 2 v 2 i 2 n ) 2 n ζ ( 2 v 2 i 2 n ) π 2 v 2 i 2 n m 2 v 2 i 2 n 1 2 2 v 2 i 2 n 1 ,
where the contribution from the term of unity on the rhs of (70) vanishes courtesy of the binomial theorem. When the summand alternates in sign, i.e., for V v , j , l ( m ) , we still have a purely cosecant power sum, but now the results in Section 3 apply. For the Dowker case, we introduce (17) into (66). Thus, we arrive at
V v , j , 1 ( m ) = i = 0 j ( 1 ) i j i 0 , m , odd , n = 0 v i 1 s ( v i , n ) ( 2 v 2 i 2 n ) 2 n ζ ( 2 v 2 i 2 n ) π 2 v 2 i 2 n × 2 2 n + 1 2 2 n + 2 i 2 v + 1 1 m 2 v 2 i 2 n 1 , m , even .
For V v , j , 2 ( m ) , however, we need to take note of the fact that
k = 1 2 m 1 ( 1 ) k sin 2 i 2 v k π 2 m = 2 S v i , 2 ( m ) + ( 1 ) m ,
where S v i , 2 ( m ) is defined by (16). Now, by introducing (18) into (66), one obtains
V v , j , 2 ( m ) = i = 0 j ( 1 ) i j i n = 0 v i 1 s ( v i , n ) ( 2 v 2 i 2 n ) 2 n ζ ( 2 v 2 i 2 n ) π 2 v 2 i 2 n     × ( 2 2 n + 2 2 2 v 2 i + 1 m 2 v 2 i 2 n ( 1 ) m 2 2 v 2 i + 1 + ( 1 ) m 1 2 2 n + 1 ) .
Similarly to the term of unity in the non-alternating case, the resulting sum arising from the constant of ( 1 ) m in (73) vanishes due to the binomial theorem. From these results, we see that the sums over n have a common term of s ( v i , n ) ζ ( 2 v 2 i 2 n ) / ( 2 v 2 i 2 n ) 2 n π 2 v 2 i 2 n . Hence, the sums can be expressed as this term multiplied by a summand factor, S f ( v , n , s g n , l ) , for each value of s g n in both the Dowker and Gardner–Fisher cases. By adopting this approach, we arrive at (67), where the summand factors are displayed in Table 6. These results have been obtained from (11), (15), (17) and (18), bearing in mind that, in the Gardner–Fisher cases, there is an extra factor of 2, as indicated by (70) and (73). Furthermore, since the above results for V v , j , l ± ( m ) depend on the Riemann zeta function, they are purely number-theoretical. When j v , however, the situation changes. Then, (66) becomes
V v , j , l ± ( m ) = i = 0 v 1 ( 1 ) i j i k = 1 l m 1 ( ± 1 ) k csc 2 v 2 i k π l m + ( 1 ) v j v k = 1 l m 1 ( ± 1 ) k + i = v + 1 j ( 1 ) i j i k = 1 l m 1 ( ± 1 ) k sin 2 i 2 v k π l m .
The first term on the rhs of (75) is number-theoretical as in the j < v case, except the upper limit is v 1 , not j. Consequently, the earlier results in the proof can be applied here except the summation over i has an upper limit of v 1 . The next term on the rhs is the j = v term, which has been isolated or separated to avoid any potential problem concerning the determinacy of the zeroth power of the sine in Mathematica. For l = 1 and the positive-sign or non-alternating case, the sum over k equals m 1 . However, for l = 1 and the negative-sign or alternating case, the sum over k vanishes when m is odd, but equals 1 when m is even. For the Gardner–Fisher case, the sum over k equals 2 m 1 for s g n = + 1 and 1 for s g n = 1 . We shall represent the latter sums over k for the various values of the sign and l by P ( ± 1 , l ) . Hence, the second term on the rhs of (75) can be represented by ( 1 ) v P ( ± 1 , l ) j v , where the various values of P ( ± 1 , l ) appear in Table 7.
The final term on the rhs of (75) represents a sum over basic sine power sums. It also vanishes when j = v . From the previous section, we have seen that these sums yield combinatorial results. For j close to v, the first sum on the rhs of (75) dominates. Hence, we expect that the overall results will be mainly number-theoretical in nature when j is approximately equal to v. This applies especially to the alternating Dowker case because, as we shall see, the sum over the basic sine power sums vanishes when coded as a program. For the Dowker or l = 1 case, the final term on the rhs of (66) can be expressed as
i = v + 1 j ( 1 ) i j i k = 1 m 1 ( ± 1 ) k sin 2 i 2 v k π m = i = v + 1 j ( 1 ) i j i S 0 , 1 ± ( i v , m ) .
On the other hand, in the Gardner–Fisher case, we have to split the sum over k into two separate sums, since the upper limit is 2 m 1 for V v , j , 2 ± ( m ) . In terms of S 0 , 2 ± ( i , m ) , the sum can be expressed as
k = 1 2 m 1 ( ± 1 ) k sin 2 i k π 2 m = 2 S 0 , 2 ± ( i , m ) + ( ± 1 ) m ,
which is identical to the inverse power cases given by (70) and (73). As a consequence, for the Gardner–Fisher case, the third term on the rhs of (75) becomes
i = v + 1 j ( 1 ) i j i k = 1 2 m 1 ( ± 1 ) k sin 2 i 2 v k π 2 m = 2 i = v + 1 j ( 1 ) i j i S 0 , 2 ± ( i v , m ) + i = v + 1 j ( 1 ) i j i ( ± 1 ) m .
As a result of the preceding discussion, (75) becomes
V v , j , l ± ( m ) = i = 0 v 1 ( 1 ) i j i n = 0 v 1 s ( v i , n ) ( 2 v 2 i 2 n ) 2 n ζ ( 2 v 2 i 2 n ) π 2 v 2 i 2 n S f ( v i , n , ± 1 , l ) + l i = v + 1 j ( 1 ) i j i S 0 , l ± ( i v , m ) + ( ± 1 ) m 2 1 + ( 1 ) l i = v + 1 j ( 1 ) i j i + ( 1 ) v P ( ± 1 , l ) j v .
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
i = v + 1 j ( 1 ) i j i = ( 1 ) v + 1 j 1 v .
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 v 2 n , the degree of the polynomials in m will be 2 v corresponding to n = 0 . In other words, the highest power of V v , j , l ± ( m ) is m 2 v , where s ( v i , 0 ) = 1 .
We are now in a position to consider the development of an algorithm that will evaluate V v , j , l ± ( m ) as defined by (65). Of the terms comprising V v , 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
S 0 , 1 + ( i , m ) = 2 1 2 i m p = 0 i / m ( 1 ) p m c p 2 i i p m ,
and
S 0 , 2 + ( i , m ) = 2 1 2 i m p = 0 i / 2 m c p 2 i i 2 p m 1 2 ,
where
c p = 1 / 2 , p = 0 , 1 , p 1 .
These forms are easily implemented in Mathematica. However, when the summands are alternating, i.e., for S 0 , l ( i v , 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 v , m ) = ( 1 ) l m + 1 2 2 i 2 v j = 0 i v ( 1 ) j 2 i 2 v j H 3 l ( i v , m , j ) ( 1 + ( 1 ) m ) 2 2 i 2 v + 1 2 i 2 v i v .
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 v , m , j ) and H 1 ( i v , 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 s g n equals −1. On the other hand, we can introduce another conditional statement to cover the case when the sign is equal to +1. Moreover, the l = 1 and l = 2 cases can be combined into one statement by separating the i = v term in the second term of (68) and expressing it as
l i = v + 1 j ( 1 ) i j i S 0 , l + ( i v , m ) = l i = v + 1 j ( 1 ) i j i ( 2 2 v 2 i m 2 i 2 v i v + 2 1 + 2 v 2 i m × p = 1 ( i v ) / ( l m ) ( 1 ) p l m 2 i 2 v i v p m l 1 + ( 1 ) l 4 ) .
Although the above equation is elegant from a mathematical point of view, it makes a module less readable rather than considering the l = 1 and l = 2 cases separately, which can be handled by employing a conditional If statement. Consequently, we shall create a module that will calculate the entire last term on the rhs of (75) for both the Dowker and Gardner–Fisher cases in addition to both their non-alternating ( s g n = +1) and alternating versions ( s g n = −1). Thus, we shall evaluate
U l , v , j ± ( m ) = i = v + 1 j ( 1 ) i j i k = 1 l m 1 ( ± 1 ) k sin 2 i 2 v k π l m .
The above result can be regarded as a different type of trigonometric power sum. A Mathematica module that is capable of calculating U l , v , j ± ( m ) appears below:
 
U[sgn_,l_,v_,j_,m_]:= Module[{H}, H = 0; totval = 0;
Do[e1 = 0;Which[sgn == 1&&(l == 1),
e1 = 2(1−2(i−v))m Sum[(−1)(p m) Binomial[2 (i−v),i−v−p m], {p,1,Floor[(i−v)/m]}]
+2(−2(i−v))m Binomial[2(i−v),i−v];
(sgn == 1)&&(l == 2),
e1 = 2(1−2(i−v)) m Sum[Binomial[2 (i−v),i−v−2p m],{p,1,Floor[(i−v)/(2m)]}]
+2(−2 (i−v))m Binomial[2 (i−v),i−v]−1/2,
(sgn == −1)&&(l == 1),
e1 = −Binomial[2 (i−v),i−v](1 + (−1)m)/2(2 (i−v) + 1);
Do[If[Exp[2(i−v−k)I π /m] == −1,H = (m + 1),H = (1 + (−1)m)/2];
e2 = (−1)(i−v + k) Binomial[2 (i−v),k]H/2(2(i−v)−1); e1 = e1 + e2,{k,0,(i−v)}];
(sgn == −1)&& (l == 2),
e1 = −Binomial[2 (i−v),i−v](1 + (−1)m)/2∧(2 (i−v) + 1);
Do[If[ Exp[(i−v−k)I π /m] == −1,H = (m + 1),H = (1 + (−1)(i−v + m−k))/2];
e2 = (−1)(i−v + k) Binomial[2 (i−v),k]H/2(2(i−v)−1); e1 = e1 + e2,{k,0,i−v}]];
If[l == 2,e1 = (−1)i Binomial[j,i](2 e1−(−1)m),
e1 = (−1)i Binomial[j,i] e1] e1;totval = totval + e1,{i,v + 1,j}];
Print[“For l=”,l,“, sgn=”,sgn,“, j= ”,j,“v=”,v,“ and m=”,m,“, the sum of the basic
trigonometric power sums in U v , j , l ± is equal to ”,totval]]].
 
After setting both the values of H, given by (57), and U l , v , j ± ( m ) or totval to zero initially, the code encounters a Do loop, whose purpose is to evaluate the summation over i in (86). Within the Do loop, the module encounters a Which instruction, which is required to handle all four types of basic trigonometric power sums according to the values of s g n and l. The first case in the Which instruction corresponds to the non-alternating Dowker case, where the value of S 0 , 1 ± ( i v , m ) given by e1 is calculated in accordance with the upper signed version of (76). The second case is the non-alternating Gardner–Fisher sum, where e1 is evaluated according to (82). The next two cases in the Which instruction handle both types of alternating sums. This is where H figures in the evaluation of e1. As indicated previously, both these cases require another Do loop, since H is conditional on the value of exp ( i ( 2 l ) π / m ) . After e1 has been calculated for the particular values of s g n and l, the code continues with the first Do loop by testing the upper limit of the inner sum. That is, for the l = 2 case, the code takes account of the fact that the upper limit is l m 1 as in (77). Then, each e1 is multiplied by the binomial factor of ( 1 ) i j i to give each value of the summand in the sum over i in (86). Finally, all the e1 values are summed within the first Do loop to become the current value of totval. When the Do loop has been completed, totval becomes the value of U l , v , j ± ( m ) , which is the only value printed out by the code.
Table 8 displays the values obtained from the above Mathematica module of all four cases of U l , v , j ± ( m ) , where v and j are varied for fixed values of m. All told, there are 100 values that have been evaluated using the Mathematica module. As expected, the tabulated values are rational. The values were then converted into decimal notation so that they could be checked against the values calculated by programming each basic trigonometric sum in Mathematica. For example, U 2 , v , j ( m ) or the alternating Gardner–Fisher case can also be programmed as
 
TRGSM4[v_,j_,m_]:= Sum[(−1)∧i Binomial[j,i] Sum[(−1)∧k Sin[k Pi/(2 m)]∧ (2 i−2 v),
{k,1,2m−1}],{i,v + 1,j}].
 
Obviously, in this module, the ( 1 ) k phase factor has to be removed for the non-alternating cases, while when dealing with a Dowker case sum, 2 m is replaced by m.
It was found that the decimal values of all the results in Table 8 agreed with the results obtained from the alternative modules, except for the final value in the l = 2 and s g n = 1 column. The decimal value of 4250495 / 8589934592 is 0.0004948227…, whereas TRGSM4[20,40,16] gives a value of 0.000369022… As indicated previously, a closer examination of U 2 , 20 , 40 ( 16 ) can be conducted by inserting a Print[e1] instruction before totval is evaluated in the module. This means that each term in the sum over i in (86) is now printed out. In doing so, it is found that e1 vanishes for i ranging from i = 21 to i = 36 . That is, only the last five values in the sum contribute to the value of U 2 , 20 , 40 ( 16 ) . Specifically, the last five or non-zero values in the sum are
45695 33554432 , 20995 16777216 , 61425 134217728 , 10545 134217728 , and 45695 8589934592 .
Summing these values yields the final value in Table 8 or 4250495 / 8589934592 .
On the other hand, if one examines the individual terms in the sum over i in TRGSM4[40,20,16], which is achieved by the following instruction:
 
Term[j,v,i,m]:= (−1)i Binomial[j,i] Sum[(−1) Sin[k Pi/(2 m)](2 i−2 v),
{k,1,2m−1}],
 
then one finds that the five values given above are obtained in decimal form for i ranging from 36 to 40. Thus, both Mathematica modules calculate the correct components for U 2 , 20 , 40 ( 16 ) . The problem, however, lies with the vanishing terms. These are found to be zero using the first module, but are rounded off when using TRGSM4. These round-off errors become sizeable because of the binomial factor multiplying the round-off value obtained from the sum over k in TRGSM4. Normally, round-off errors remain small due since they often oscillate in sign and remain negligible. However, when the terms from i = 21 to 35 are summed by typing the following instruction:
 
Sum[Term[40,20,i,16],{i,21,35}],
 
then Mathematica prints out a value of −0.0001258. If this value is added to 4250495 / 8589934592 , then one obtains 0.00036902 , which agrees with the value of TRGSM4[20,40,16] given above. From this study, we observe that utilizing the machine dependent approach to obtain values of U l , v , j ± ( m ) will not necessarily guarantee a correct answer, especially when the binomial factor, j i , becomes very large. Nonetheless, we see that such trigonometric power sums are rational, which is also not noticeable when utilizing the machine dependent approach.
Having produced a Mathematica module for the term involving basic trigonometric power sums or the second term in (68), we turn our attention to the last two terms in the same equation. The first of these can be handled by one instruction, such as
 
BinomTerm[sgn,j,v,m]:= sgnm (−1)(v + j) Binom[j−1,v](1 + (−1)l)/2.
 
This term only makes a contribution in the Gardner–Fisher or l = 2 case. It also changes when the summand of V v , j , l ± ( m ) alternates in sign. Nevertheless, it is rather simple to program by employing the Binomial instruction in Mathematica. On the other hand, the final term in (68) is dependent upon both l and s g n , since P ( s g n , l ) is different for all cases of V v , j , l ± ( m ) . This term can be programmed as a Mathematica module as follows:
 
PSum[sgn,l,j,v,m]:= Module[, Which[ (sgn == 1) &&(l == 1),e1 = m−1,
(sgn == 1) &&(l == 2),e1 = 2m−1,(sgn == −1) &&(l == 1), e1 = −(1 + (−1)m)/2,
(sgn == −1) &&(l == 2), e1 = −1];
PSumval = (−1)v Binomial[j,v] e1; Print[“ The value of the sum with P(sgn,l) is ”,
PSumval]].
 
From this module we see that the same conditions in the Which instruction for U[sgn, l,v,j,m] apply. Therefore, one could, perhaps, incorporate the above module into U[sgn,l,v,j,m]. However, this is hampered by the Do loop corresponding to the summation over i in (68) even though having a module with one Which instruction would result in a more elegant code. Therefore, a simpler option is to insert the module after totval has been evaluated, assign a new variable e2 to determine PSumval and then add PSumval and BinomTerm to determine totval. A code combining the modules appears below:
 
U1[sgn_,l_,v_,j_,m_]:= Module[{H}, H = 0; totval = 0;
Do[e1 = 0; Which[sgn == 1&&(l == 1),
e1 = 2(1−2(i−v))m Sum[(−1)(p m) Binomial[2 (i−v),i−v−p m], {p,1,Floor[(i−v)/m]}]
+2(−2(i−v))m Binomial[2(i−v),i−v];
(sgn == 1)&&(l == 2),
e1 = 2(1−2(i−v)) m Sum[Binomial[2 (i−v),i−v−2p m],{p,1,Floor[(i−v)/(2m)]}]
+2(−2 (i−v))m Binomial[2 (i−v),i−v]−1/2,
(sgn == −1)&&(l == 1),
e1 = −Binomial[2 (i−v),i−v](1 + (−1)m)/2(2 (i−v) + 1);
Do[If[Exp[2(i−v−k)I π /m] == −1,H = (m + 1),H = (1 + (−1)m)/2];
e2 = (−1)(i−v + k) Binomial[2 (i−v),k]H/2(2(i−v)−1); e1 = e1 + e2,{k,0,(i−v)}];
(sgn == −1)&& (l == 2),
e1 = −Binomial[2 (i−v),i−v](1 + (−1)m)/2∧(2 (i−v) + 1);
Do[If[ Exp[(i−v−k)I π /m] == −1,H = (m + 1),H = (1 + (−1)(i−v + m−k))/2];
e2 = (−1)(i−v + k) Binomial[2 (i−v),k]H/2(2(i−v)−1); e1 = e1 + e2,{k,0,i−v}]];
If[l == 2,e1 = (−1)i Binomial[j,i](2 e1−(−1)m),
e1 = (−1)i Binomial[j,i] e1] e1;totval = totval + e1,{i,v + 1,j}];
Which[(sgn == 1)&&(l == 1),e3 = m−1, (sgn == 1)&&(l == 2),e3 = 2m−1,
(sgn == −1)&&(l == 1),e3 = −(1 + (−1)m)/2, (sgn == −1)&&(l == 2),e3 = −1];
scndval = (−1) Binomial[j,v] e3;totval = totval + scndval;
totval = totval + (−1)v Binomial[j,v] Sum[(sgn)k,{k,1,lm−1}];
Print[“For l=”,l,“, sgn=”,sgn,“, j= ”,j,“v=”,v,“ and m=”,m,“, the sum of the basic
trigonometric power sums in U v , , l ± is equal to ”,totval]]].
 
This interim module is essentially the same as the previous one, except it calculates the last two terms in (68) and adds them to totval. Therefore, to produce a code that determines values of V v , j , l ± ( m ) , we only require the code to evaluate the first term on the rhs of (68) when j v . Moreover, this term is identical to the rhs of (67), except for the upper limit of the outer sum. Hence, one can use the same code to calculate (67), except for a change in the upper limit. To handle this problem, a conditional If instruction has been inserted near the beginning of the program. This instruction tests whether the upper limit of the outer sum equals j when j < v or equals v 1 for all other values of j. It then assigns a variable called upplmt to whichever case applies. Moreover, the same instructions can be used to evaluate the double sum in either case. As a result of the introduction of upplmt into the code, there needs to be another conditional If instruction or statement following the calculation of the double sum, which calculates the remaining terms in (68) for v j .
In Section 3, we introduced a summand factor to cover both the l = 1 and l = 2 cases of S v , l ( m ) . Here, we adopt this approach further by noting that the four cases of S v , l ± ( m ) all include ζ ( 2 v 2 n ) s ( v , n ) / π 2 v 2 n ( 2 v 2 n ) 2 n in their summands. Therefore, we can employ the Which instruction again to determine the appropriate summation factor for the case of V v , j , l ± ( m ) we are studying. This is achieved by implementing the following instruction:
 
Which[sgn == 1 &&(l == 1), Sfctr = 2(2n + 1) (m(2 v−2 n) −1),
sgn == 1 &&(l == 2), Sfctr = 2(2v + 1) (m(2v−2n)−1),
sgn == −1 &&(l == 1), Sfctr = 2(2n)(1 + (−1)m)(((2(2 n−2 v + 1)−1) m(2 v−2n) −1),
sgn == −1 &&(l == 2), Sfctr = (2(2n + 2)− 2(2v + 1)) m(2v−2n)− (−1)m 2(2v + 1)
+((−1)m −1)2(2n + 1)].
 
Now, we are in a position to present an algorithm for determining rational values of V v , j , l ± ( m ) by combining the preceding material into one module called Vpm[sgn,l,v,j,m]. To execute the module, one needs to input the values of s g n , l, v, j and m, although the value of m can be algebraic. The module begins by initializing the value of the trigonometric power sum given by the variable totval to zero in addition to H, which is used in evaluating the term involving the basic trigonometric power sum or the second term on the rhs of (68). Next, the summand factor for either the rhs of (67) or the first term on the rhs of (68) is determined from the input values of s g n and l. The summand factor is printed out via the first Print instruction, but this diagnostic can be commented out, if desired. In fact, there are other Print instructions in the module that can also be removed, since they only appear to observe that the module is behaving properly. Hence, only the last Print instruction, which prints out the final value of totval, needs to be retained.
Once the appropriate summand factor has been determined, the module determines whether the upper limit of the number-theoretical term is j or v 1 corresponding to j < v or j v . If it is the former value, then upplmt is set equal to j and the variable totval becomes the value of the double sum in (67). Otherwise, upplmt is set equal v 1 and totval becomes the value of the first term on the rhs of (68). It is then printed out as the current value of totval. In the first case, totval becomes the value of V v , j , l ± ( m ) . The rest of the module is discarded because of the conditional If instruction after the second Print instruction. Hence, totval becomes the final value of V v , j , l ± ( m ) , and is printed out again in the final Print instruction. However, if v j , then the module calculates the remaining terms on the rhs of (68).
As stated earlier, the second term on the rhs of (68) represents a finite sum of basic trigonometric power sums, which can be evaluated by employing the module presented for U l , v , j ± ( m ) below (32). It was also stated that this is the most difficult term to evaluate because in the case of an alternating sum H changes according to the conditions of the If instruction as it is being tested for each iteration in a Do loop. Therefore, this term is left until after the third and fourth terms on the rhs of (68) are evaluated in the module below. After the number-theoretical term has been calculated, the module evaluates the fourth term on the rhs of (68), which only contributes to the Gardner–Fisher or l = 2 trigonometric power sums. This calculation is represented by e1 in the module.
 
Vpm[sgn, l, v, j, m] := Module[{H}, H = 0; totval = 0;
Which[(sgn == 1 && l == 1), Sfctr = 2(2 n + 1) (m(2 v − 2 i − 2 n) − 1),
(sgn == 1 && l == 2), Sfctr = 2(2 v − 2 i + 1) (m(2 v −2 i − 2 n) − 1),
(sgn == −1 && l == 1), Sfctr = 2(2 n) (1 + (−1)m) ((2(2 n − 2 v + 2 i + 1)−1)
m(2 v−2 i− 2 n)− 1),
(sgn == −1 && l == 2), Sfctr = (2(2 n + 2) − 2(2 v − 2 i + 1)) m(2 v − 2 i − 2 n) −
(−1) m 2(2 v − 2 i + 1) + ((−1)m − 1) 2(2 n + 1)];
Print[“The value of the summand factor is ”, Sfctr];
If[j < v, upplmt = j, upplmt = v − 1];
totval = Expand[FullSimplify[ Sum[(−1)i Binomial[j, i] Sum[ SymmetricPolynomial[n,
Table[k2, k, 1, v − i − 1]] Zeta[2 v−2 i−2 n] Sfctr/(Pi(2 v− 2 i −2 n) Pochhammer[2 v−
2 i−2 n, 2 n]), {n, 0, v − i − 1}], {i, 0, upplmt}]]];
Print[“The current value of totval is ”, totval];
If[v < = j, If[l == 2 && j != v, e1 = −sgnm (−1)v Binomial[j−1, v], e1 = 0];
totval = totval + e1;
Print[“The value of the l = 2 extra term is ”, e1];
Which[(sgn == 1 && l == 1), e2 = m − 1, (sgn == 1 && l == 2), e2 = 2 m − 1, (sgn
== −1 && l == 1), e2 = −(1 + (−1)m)/2, (sgn == −1 && l == 2), e2 = −1];
Print[“The value of P(sgn,l) is ”, e2];
e3 = (−1)v Binomial[j, v] e2;
Print[“The value of the extra term is ”, e3];
totval = totval + e3];
If[v<j, Do[e4 = 0; Which[(sgn == 1) && (l == 1),
e4 = 2(1 −2 (i −v)) m Sum[(−1)(p m)
Binomial[2 (i −v), i−v−p m], {p, 1, Floor[(i − v)/m]}] + 2(−2 (i− v)) m Binomial[2 (i− v),
i− v], (sgn == 1) && (l ==2), e4 = 2(1 −2 (i −v)) m Sum[Binomial[2 (i−v), i−v −2 p m],
{p, 0, Floor[(i − v)/(2 m)]}] − 2(−2 (i−v)) m Binomial[2 (i− v), i− v] − 1/2, (sgn == −1)
&& (l == 1), e4 = −Binomial[2 (i−v), i−v] (1 + (−1)m)/2(2 (i−v) + 1);
Do[If[ Exp[2 (i− v− k) I Pi/m] == −1, H = (m + 1), H = (1 + (−1)m)/2]; e5 = (−1)(i−
v + k) Binomial[2 (i−v), k] H/2 (2 (i− v) − 1); e4 = e4 + e5, {k, 0, (i− v)}], (sgn == −1)
&& (l == 2), e4 = −Binomial[2 (i− v), i− v] (1 + (−1)m)/2 (2 (i− v) + 1);
Do[If[ Exp[(i − v − k) I Pi/m] == −1, H = (m + 1), H = (1 + (−1)(i− v+ m− k))/2];
e5 = (−1)(i −v+ k) Binomial[2 (i−v), k] H/2(2 (i − v) − 1); e4 = e4 + e5, {k, 0, i − v}]];
If[l == 2, e4 = (−1)i Binomial[j, i] (2 e4 + (sgn)(m)), e4 = (−1)i Binomial[j, i] e4];
Print[“The value of e4 is ”, e4];
totval = totval + e4, {i, v + 1, j}]];
Print[“The final value of the sum is ”, totval]].
 
The fourth term on the rhs of (68) is the next term that is evaluated in the module. Before this term can be evaluated, the appropriate value of P ( ± 1 , l ) given in Table 7 must be determined. Like the summand factor for the number-theoretical terms, a Which instruction is invoked, and the value is given by e2. A diagnostic Print statement that prints out the appropriate value of P ( ± , l ) follows. Then, this value is multiplied by the binomial factor to give the value of e3, which is subsequently added to totval. Finally, e4 representing the value for the sum of the basic trigonometric power sums is obtained by adapting the Mathematica module for U l , v , j ± ( m ) , and is added to totval to give the final value for V v , j , l ± ( m ) . Before this value is added to totval, the module checks whether a doubling up is required due to the fact that for l = 2 , the summation over k has an upper limit of 2 m 1 , rather than m 1 .
For the Dowker case, we introduce (17) and (49) into (77). Therefore, we observe that for m odd, V v , j , 1 ( m ) vanishes, as in (72). However, there is no need to display the result here, as we can use the algorithms for S v i ( m ) and S 0 , 1 ( i v , m ) to obtain the values of V v , j , 1 ( m ) .
Let us now examine the output generated from the above module for two examples. In the first example, we consider j = v , while in the second example, we consider j > v . That is, in both examples, we shall require the more complicated (68) rather than (67). Moreover, we shall consider the alternating or s g n = 1 forms of V v , j , l ± ( m ) , since they require the results of Lemma 1. Specifically, we shall set l = 1 or consider the Dowker case for j = v in the first example, and then set l = 2 , or consider the Gardner–Fisher case for j > v . For the first example, we do not require (49) because j is not greater than v, but in the second example, we require (50), since there will be basic trigonometric power sums for all those values between j v + 1 and j. Finally, we shall set m to a specific value, viz. 12 in the first example, while it will remain algebraic in the second example.
Below is the output generated by Vpm when j = v = 9 and m = 12 for the alternating form of the Dowker case. That is, the trigonometric power sum reduces to
V 9 , 9 , 1 ( 12 ) = k = 1 11 ( 1 ) k cos 18 k π 12 csc 18 k π 12 .
Typing Vpm[−1, 1, 9, 9, 12] into a Mathematica notebook yields
 
Vpm[−1, 1, 9, 9, 12]
The value of the summand factor is 21+2n (−1+1218−2i−2n (−1+2−17+2i+2n))
The current value of totval is − 776563028730601 19683
The value of the l = 2 extra term is 0
The value of P(sgn,l) is −1
The value of the extra term is 1
The final value of the sum is − 776563028710918 19683 .
 
In decimal form, the final value is given as
 
N 776563028710918 19683
−3.94535 × 1010.
 
By clicking on the NumberForm of this result, one can extend the decimal value to 16 places. For example,
 
NumberForm[−3.94535 × 1010, 16]
NumberForm= −3.94534892399999 × 10 10 .
 
The above output begins by displaying the value of the summand factor, which is a simplification of the j = v = 9 and m = 12 form of the third result in Table 6. Next, the value of the first term on the rhs of (68) is given. As expected, because l = 1 , the third term on the rhs of (68) does not contribute. Thus, the l = 2 term is given as zero. Then, the last term on the rhs of (68) is calculated, which requires P ( 1 , 1 ) from Table 7. Since m is even, the entire term is non-zero. In fact, it yields unity due to the fact that j = v and v is odd. Finally, the term involving basic trigonometric powers sums, viz. the second term on the rhs of (68) is evaluated. However, as j = v in the example, there is no contribution from this term.
On the other hand, one can evaluate V 9 , 9 , 1 ( 12 ) by using the standard instructions in Mathematica [17], which means expressing it as
 
Sum[(−1)k Csc[k Pi/12](18) Cos[k Pi/12](18), {k, 1, 11}].
 
The above instruction generates the following output:
 
774801614 19683 ( 1 3 ) 18 ( 1 + 3 ) 18 262144 ( 1 + 3 ) 36 262144 ( 1 + 3 ) 36 131072 .
 
Once again, the above expression can be evaluated via the N[] instruction in Mathematica as indicated below:
 
In[22]:= N 774801614 19683 ( 1 3 ) 18 ( 1 + 3 ) 18 262144 ( 1 + 3 ) 36 262144 ( 1 + 3 ) 36 131072 .
 
Out[22] = −3.94535 × 1010.
 
As before, we can extend the number of decimal places using NumberForm. Therefore, we find that
 
In[23]:= NumberForm[−3.94535 × 1010, 16]
 
Out[23] = −3.945348923999989 × 1010.
 
In this example, we observe that the standard approach yields an almost identical result to the algorithmic approach employing V v , j , l ± ( m ) which, as we have seen already, is not always the case.
Let us now consider the second example. As indicated above, this example has the same values for the arguments as the first example except that l = 2 and m remains algebraic. In this instance, the sum becomes V 9 , 12 , 2 ( m ) , which is given by
V 9 , 12 , 2 ( m ) = k = 1 2 m 1 ( 1 ) k cos 24 k π 2 m csc 18 k π 2 m .
Then, typing Vpm[−1, 2, 9, 9, m] into a Mathematica notebook generates the following output:
 
In[24]:= Vpm[−1, 2, 9, 12, m]
 
The value of the summand factor is
 
−(−1)m 219−2i+21+2n (−1+(−1)m)+(−219−2i+22+2n) m 18 2 i 2 n
 
The current value of totval is
 
14141033520614911 194896477400625 165 ( 1 ) m 51766106 m 2 328185 + 4946109824 m 4 50675625 1794850075988 m 6 40226311125 +
559016662 m 8 35083125 10363664 m 10 2338875 + 187005175216 m 12 201131555625 12646904 m 14 91216125 + 33862354 m 16 2584456875
22998766228 m 18 38979295480125
 
The value of the l = 2 extra term is 55 (−1)m
The value of P(sgn,l) is −1
The value of the extra term is 220
The value of e4 is 66 ( 1 ) m + 2 1 4 ( 1 ( 1 ) m ) + 1 2 ( 1 + ( 1 ) m )
The value of e4 is −12 ( 1 ) m + 2 3 8 ( 1 ( 1 ) m ) + 3 8 ( 1 + ( 1 ) m )
The value of e4 is ( 1 ) m + 2 5 64 1 ( 1 ) m + 5 64 1 + ( 1 ) m
The final value of the sum is
28736191507522589 194896477400625 109 ( 1 ) m + 2 5 64 1 ( 1 ) m + 5 64 1 + ( 1 ) m )
12 ( 1 ) m + 2 3 8 1 ( 1 ) m + 3 8 1 + ( 1 ) m ) +
66 ( 1 ) m + 2 1 4 1 ( 1 ) m + 1 2 1 + ( 1 ) m 51766106 m 2 328185 +
4946109824 m 4 50675625 1794850075988 m 6 40226311125 + 559016662 m 8 35083125 10363664 m 10 2338875 +
187005175216 m 12 201131555625 12646904 m 14 91216125 + 33862354 m 16 2584456875 22998766228 m 18 38979295480125 .
 
The output begins by printing out the summand factor, S f ( 9 i , n . 1 , 2 ) , for the first sum on the rhs of (68). Then, the module prints out the value of the number-theoretical term or the first term on the rhs of (68). Next the third term on the rhs of (68), which only contributes when l = 2 , is calculated and printed out. After this, the term containing P ( 1 , 2 ) is calculated and printed out followed by the value of the last term on the rhs of (68). The last term handled by the module is the sum over the basic trigonometric power sums or the second term on the rhs of (68). As expected, there are three distinct sums corresponding to j v . These combinatorial terms only affect the constant term in the polynomials derived from summing the number-theoretical terms represented by the first value of totval. Finally, all these terms are added to totval to give the value of V 9 , 12 , 2 ( m ) . From the output, we observe that the behavior of the trigonometric power sum is mainly dominated by the number-theoretical term in (68).
One can check the above result for V 9 , 12 , 2 ( m ) by setting m equal to specific values. Before this can be accomplished, one must first create a function out of the final value as follows:
 
Q[m]:= 28736191507522589/194896477400625 − 219 (−1)m + 2 ( 5 64 ( 1 ( 1 ) m ) +
5 64 ( 1 + ( 1 ) m ) ) 12 ( 1 ) m + 2 3 8 1 ( 1 ) m + 3 8 1 + ( 1 ) m +
66 ( 1 ) m + 2 1 4 ( 1 ( 1 ) m ) + 1 2 ( 1 + ( 1 ) m ) 51766106 m 2 328185 +
4946109824 m 4 50675625 1794850075988 m 6 40226311125 + 559016662 m 8 35083125 10363664 m 10 2338875 +
187005175216 m 12 201131555625 12646904 m 14 91216125 + 33862354 m 16 2584456875 22998766228 m 18 38979295480125 .
 
By putting m = 10 in the above polynomial, one finds that
 
In[25]:= Q[10]
 
Out[25] = − 294987411105763646 625 .
 
In number form or to machine precision, Mathematica prints out
 
In[26]:= NumberForm[−4.7198 × 10 14 , 16]
 
Out[26]//NumberForm = −4.719798577692218 × 10 14 .
 
On the other hand, for m equal to an odd value, say 11, one finds that Q [ 11 ] gives a value of
 
In[27]:= Q[11]
 
Out[27] = − 30011175790744604 11 .
 
In decimal form to 16 places, the above value becomes 2.7282887082495095 × 10 15 .
Since the above trigonometric power sum can be expressed as
V 9 , 12 , 2 ( m ) = k = 1 2 m 1 ( 1 ) k cos 24 k π 2 m csc 18 k π 2 m ,
it can also be expressed in terms of the standard instructions in Mathematica as
 
VSum[m]:= Sum[(−1)k Cos[k Pi/(2 m)](24) Csc[k Pi/(2 m)](18), {k, 1, 2 m − 1}].
 
Putting m = 10 in the above form for V 9 , 12 , 2 ( m ) yields
 
In[28]:= VSum[10]
1 4 + ( 1 5 ) 24 281474976710656 ( 5 / 8 5 / 8 ) 9 + ( 1 5 ) 24 281474976710656 ( 5 / 8 + 5 / 8 ) 9 +
2 5 8 5 8 12 1 + 5 18 + ( 1 + 5 ) 24 281474976710656 ( 5 / 8 + 5 / 8 ) 9 +
2 5 8 + 5 8 12 1 + 5 18 + ( 1 + 5 ) 24 281474976710656 ( 5 / 8 5 / 8 ) 9
2 cos 6 π 20 cot 18 π 20 2 cos 6 3 π 20 cot 18 3 π 20 2 sin 6 π 20 tan 18 π 20
2 sin 6 3 π 20 tan 18 3 π 20 .
 
If one asks for the number form value of the above expression to 16 decimal places, then Mathematica yields the following result:
 
In[29]:= NumberForm[−4.7198 × 10 14 , 16]
 
Out[29]//NumberForm = −4.719798577691239 × 10 14 .
 
Therefore, we obtain the same numerical value as the algorithm for V 9 , 12 , 2 ( 10 ) except for the last few decimal places, which is due to the fact that the above method has implemented far more machine precision. Moreover, if we set m = 11 in VSum, then we obtain a similar expression in products of power of trigonometric functions as displayed above, but with no algebraic terms. In this instance, the denominators of the arguments of the trigonometric functions are either 11 or 22. In number form to 16 decimal places, we find that VSum[11] equals 2.7282887082496685 × 10 15 , which equals Q[11] to 13 decimal places.
Now that we have created an algorithm for V ± ( v , j , l ) ( m ) , we can turn our attention to the creation of an algorithm for the general twisted trigonometric power sum defined in the introduction. This is accomplished in the following theorem.
Theorem 2. 
For r, an integer lying in range of [1,…, m 1 ], the general twisted trigonometric power sum, T v , l ± ( m , r ) , as defined by (9), can be expressed as a sum of various forms of the trigonometric power sum, V v , j , l ± ( m ) , given by (66) as follows:
T v , l ± ( m , r ) = 2 2 r 1 V v , r , l ± ( m ) + j = 0 r 1 C ( r , j ) V v , r j 1 , l ± ( m ) ,
where
C ( r , j ) = ( 1 ) j + 1 r j + 1 2 r j 2 j 2 2 r 2 j 2 .
Proof. 
To prove the above theorem, we require No. I.1.10 in [24] which, as mentioned previously, was used in the derivation of (46). On this occasion, however, we replace n and x by 2 r and k π / l m , respectively. Hence, we arrive at
cos 2 r k π l m = 2 2 r 1 cos 2 r k π l m + r j = 0 r 2 ( 1 ) j + 1 j + 1 2 r j 2 j 2 2 r 2 j 2 × cos 2 r 2 j 2 k π l m ,
where, without loss of generality, r is an integer lying between 1 and m 1 . For r = 0 or the untwisted case, one needs to insert an additional term of 1 / 2 into (92) as a result of No. 4.2.1.8 in [24].
If one introduces (92) into (2), then one obtains
T v , l ± ( m , r ) = 2 r 1 k = 1 l m 1 ( ± 1 ) k csc 2 v k π l m cos 2 r k π l m + j = 0 r 1 C ( r , j ) × k = 1 l m 1 ( ± 1 ) k csc 2 v k π l m cos 2 r 2 j 2 k π l m ,
where C ( r , j ) is given by (91). Now, it is readily observed that the summations over k represent different forms of (66). Therefore, by replacing the summations by the corresponding form of V v , j , l ± ( m ) , we arrive at (90). □
From (90), we see that the general twisted trigonometric power sum reduces to a finite sum involving different forms of V v , j , l ± ( m ) . Therefore, we can call the Mathematica module for V v , j , l ± ( m ) , given earlier in this section, inside another module that handles only (92). Such a module appears below:
 
Tpm[sgn, l, v, m, r]:= Module[{}, Vpm[sgn, l, v, r, m];
sumval = 2(2 r − 1) totval;
Print[“The value of the trigonometric power sum Vpm is ”, sumval];
Do[Crj = (−1)(j + 1) r Binomial[2 r − j − 2, j] 2(2 r − 2 j − 2)/(j + 1);
Print[“The value of the coefficient Crj is ”, Crj];
Vpm[sgn, l, v, r − j − 1, m]; e5 = totval Crj;
Print[“The value of e5 is ”, e5]; sumval = sumval + e5, {j, 0, r − 1}];
Print[“The value of Tpm[”, sgn,“,”, l, “,”, v, “,”, m, “,”, r“] is ”, Expand[
FullSimplify[sumval]]]].
 
For this module to yield values, one needs to specify values for all the input variable except m, which can remain algebraic.
The module begins with the evaluation of the first term on the rhs of (90). This involves the j = v form of V v , j , l ± ( m ) multiplied by 2 2 r 1 , and is set equal to the variable sumval, which will ultimately yield the value of the entire twisted trigonometric power sum. Next, the summation over j on the rhs of (90) is evaluated in a Do loop. For each value of j, the coefficient, C ( r , j ) is calculated first and printed out. Then, a call to V v , r j 1 , l ± ( m ) is made. With each call a new value of totval is calculated. In each instance, the variable is multiplied by the appropriate value of C ( r , j ) , since it is not local in the module, Vpm[sgn,l,v,j−,m]. The resulting value denoted by e5 is printed out before being added to sumval. After exiting the Do loop, the final value of sumval is printed out yielding the value of T v , l ± ( m , r ) .
Now, we confirm that the module does give correct values of T v , l ± ( m , r ) by considering a few examples. To facilitate this study, we shall remove all diagnostic Print statements or instructions in both modules. That is, we shall only maintain the output provided by the last Print instruction in Tpm[sgn, l, v, m, r]. In the first example, we shall consider twisted trigonometric power sums in the Dowker case. Specifically, we shall study
T v , 1 ± ( m , r ) = k = 1 m 1 ( ± 1 ) k cos 2 k r π m csc 2 v k π m .
In terms of standard Mathematica instructions, this sum can be expressed as
 
TSumP[m, v, r]:= Sum[Cos[2 k r Pi/m] Csc[k Pi/m](2 v), {k, 1, m − 1}].
 
The corresponding sum for the alternating case becomes TSumM[m, v, r], and has an extra phase factor of ( 1 ) k in the summand.
If we put v = 9 and r = 3 , then we find that Mathematica prints out the following result for TSumP[m,9,3]:
 
In[30]:= TSumP[m, 9, 3]
 
Out[30] = 1 38979295480125 (12964140545731 − 11467298304000 m2 − 1421455464576 m4
112614327264 m6 + 24754314312 m8 + 10826441262 m10 + 1620381180 m12 +
39314268 m14 − 12988647 m16 + 87734 m18).
 
On the other hand, if we put sgn = 1, l = 1 , v = 9 and r = 3 in the module Tpm[sgn, l, v, m, r], then Mathematica prints out
 
In[31]:= Tpm[1, 1, 9, m, 3]
 
The value of Tpm[1,1,9,m,3 ] is
 
12964140545731 38979295480125 4096 m 2 13923 7761536 m 4 212837625 116217056 m 6 40226311125 + 4456 m 8 7016625 + 13642 m 10 49116375 +
30404 m 12 731387475 + 92 m 14 91216125 3617 m 16 10854718875 + 87734 m 18 38979295480125 .
 
Both forms for T 9 , 1 + ( m , 3 ) are identical to each other, though they appear to be different due to the FullSimplify instruction being implemented in one of the algorithms.
An interesting situation occurs when 3 is replaced by r in the command for TSum. That is, typing
 
In[32]:= TSumP[m,9,r]
 
yields
 
1 194896477400625 ( 23133945892303 + 19459657728000 m 2 + 2972311034112 m 4 +
579728203680 m 6 + 103972564332 m 8 + 16038878310 m 10 + 2027485212 m 12 +
196571340 m 14 + 12988647 m 16 + 438670 m 18 116757946368000 m r +
116757946368000 r 2 89169331023360 m 2 r 2 12174292277280 m 4 r 2
2079451286640 m 6 r 2 317569790538 m 8 r 2 40050901800 m 10 r 2
3880879884 m 12 r 2 256397400 m 14 r 2 8659098 m 16 r 2 + 178338662046720 m r 3
89169331023360 r 4 + 60871461386400 m 2 r 4 + 7278079503240 m 4 r 4 +
1058565968460 m 6 r 4 + 132167975940 m 8 r 4 + 12777137100 m 10 r 4 + 843669540 m 12 r 4 +
28488600 m 14 r 4 73045753663680 m r 5 + 24348584554560 r 6 14556159006480 m 2 r 6
1481992355844 m 4 r 6 176223967920 m 6 r 6 16865820972 m 8 r 6 1111055400 m 10 r 6
37496424 m 12 r 6 + 12476707719840 m r 7 3119176929960 r 8 + 1587848952690 m 2 r 8 +
132167975940 m 4 r 8 + 12047014980 m 6 r 8 + 785674890 m 8 r 8 + 26453700 m 10 r 8
1058565968460 m r 9 + 211713193692 r 10 88111983960 m 2 r 10 5621940324 m 4 r 10
349188840 m 6 r 10 11639628 m 8 r 10 + 48061082160 m r 11 8010180360 r 12 +
2555427420 m 2 r 12 + 111105540 m 4 r 12 + 3527160 m 6 r 12 1179428040 m r 13 +
168489720 r 14 36628200 m 2 r 14 813960 m 4 r 14 + 14651280 m r 15 1831410 r 16 +
203490 m 2 r 16 71820 m r 17 + 7980 r 18 ) .
 
Therefore, we see that Mathematica is able to produce not only the polynomials of degree 2 v in m as the module Tpm[sgn, l, v, m, r] does, but also polynomials of degree 2 v in r. In fact, the polynomials are composed of terms of the form m i r j , where i and j are less than or equal to 2 v . This issue forms the basis of the next section where the integral approach in [21] is extended to T v , l ± ( m , r ) . For now, we are concerned with how the module Vpm[sgn,l,v,m,r] can be used to obtain values for the various twisted trigonometric power sums.
Before discussing an example of the Gardner–Fisher case, it should be mentioned that there is another representation of (90). Instead of using (92), one can use the intermediate form of No. I.1.10 in [24], which can be expressed as
cos 2 n x = k = 0 n ( 1 ) n k 2 n 2 k sin 2 n 2 k x cos 2 k x .
Introducing (95) into (2) yields
T v , l ± ( m , r ) = ( 1 ) r k = 1 l m 1 ( ± 1 ) k j = 0 r ( 1 ) j 2 r 2 j sin 2 r 2 j 2 v k π l m cos 2 j k π l m .
By interchanging the order of the summations, we can substitute (66), thereby obtaining
T v , l ± ( m , r ) = ( 1 ) r j = 0 r ( 1 ) j 2 r 2 j V v + j r , j , l ± ( m ) .
This can be programmed in a slightly shorter Mathematica module as follows:
 
Tpm3[sgn, l, v, m, r]:= Module[{}, e1 = 0;
Do[Vpm[sgn, l, v + j − r, j, m]; e2 = (−1)(r + j) totval Binomial[2 r, 2 j];
e1 = e1 + e2, j, 0, r];
Print[“The value of Tpm3[”,sgn,“,”,l,“,”,v,“,”,m,“,”,r,”] is ”, Expand[FullSimplify[e1]]]].
 
As expected, this module gives the same values for Tp[1,1,9,m,3] and TSum[m,9,3] presented above. Hence, we can use this form when we study the Gardner–Fisher case.
For l = 2 , we shall consider the alternating case ( s g n = 1 ) with v and r again equal to 9 and 3, respectively. If one types in Tpm[−1, 2, 9, m, 3], then Mathematica prints out
 
The final value of the sum is 23133945892303 194896477400625 ( 1 ) m
65536 m 2 328185 32459264 m 4 152026875 7418606528 m 6 40226311125 4753864 m 8 35083125 590132 m 10 7016625
8566072712 m 12 201131555625 1507144 m 14 91216125 33862354 m 16 7753370625 22998766228 m 18 38979295480125 .
 
In this case, we need to modify TSumM[v, m, r] to
 
TSumM2[v, m, r]:= Sum[(−1)k Cos[k r Pi/m] Csc[k Pi/(2 m)](2 v),
{k, 1, m − 1}].
 
If one types TSumM2[9,m,3] into Mathematica, then all that is generated is the original sum itself. That is, Mathematica is unable to generate the polynomials of degree 2 v or 18 in m as above. On the other hand, if one types in TSumM2[9,11,3], then the package prints out
 
1486025307131/177147 − Csc π 18 22 − Csc π 9 22 − Csc 2 π 9 22 − Sec [ π 18 ] 22 − Sec π 9 22
Sec 2 π 9 22 .
 
In NumberForm this gives a value of 2.283894674697865 × 10 15 compared with 2.283894674697867 × 10 15 when m is set equal to 11 in the above polynomial expression.

6. Integral Approach Revisited

The previous section was aimed at constructing an algorithm for twisted trigonometric power sums, T v , l ± ( m , r ) , by using the general results for another important trigonometric power sum, V v , j , l ± ( m ) , given in Lemma 1. Two different forms were determined, the first appearing in Theorem 2, and the second given by (97). Consequently, we obtained polynomials in m of degree 2 v , provided r was set to fixed values. These results agreed with the values obtained by programming the power sums directly in Mathematica. From the direct approach, it was found in the Gardner–Fisher case that both m and r had to be specified or set to numerical values, which meant only decimal values for the trigonometric power sum could be compared with each other, even though rational values were obtained from the new algorithm. In addition, m did not need to be specified to obtain expressions for T v , l ± ( m , r ) via the new algorithm. Surprisingly, in the Dowker case, Mathematica was not only able to provide the polynomials in m for the values of the twisted trigonometric power sums, but also combined with powers of r, when r was algebraic. This is not possible with the new algorithm since r has to be specified. Consequently, this section aims to adapt the integral approach in [21] in order to generate results possessing powers of m and r like those generated by Mathematica in the Dowker case. In doing so, we shall be able to obtain the results for the Gardner–Fisher case, where Mathematica fails. Thus, the results presented here will be more general than any of the results presented in previous sections.
Theorem 3. 
For r, a positive integer less than l m , the twisted trigonometric power sum, T v , l + ( m , r ) , as defined by (9) is given by
T v , l + ( m , r ) = 2 2 v Γ ( 2 v ) n = 0 v 1 ( 1 ) n 2 n + 2 s ( v , v n 1 ) ( l m ) 2 n + 2 B 2 n + 2 ( r / l m ) B 2 n + 2 ,
where, as before, B 2 n + 2 ( x ) represents the Bernoulli polynomial of order 2n + 2.
Proof. 
The proof begins with (20), where we assume m = l m for the time being. Multiplying this equation by cos ( 2 π k r / m ) yields
cos 2 π k r m csc 2 v k π m = 2 2 v 2 m 2 2 π 2 Γ ( 2 v ) 0 1 ln u 1 u m n = 1 v 1 m 2 4 π 2 ln 2 u + n 2 × u k + u m k e 2 i π k r / m + e 2 i π k r / m d u u .
Therefore, the summation over k becomes
T v , l ± ( m , r ) = 2 2 v 2 m 2 2 π 2 Γ ( 2 v ) 0 1 ln u 1 u m n = 1 v 1 m 2 4 π 2 ln 2 u + n 2 × k = 1 m 1 ( ± 1 ) k u k + u m k e 2 i π k r / m + e 2 i π k r / m d u u .
For the upper-signed case, one finds, by substituting m k by k in the sums with u m k and r equal to an integer, that
k = 1 m 1 u m k e ± 2 i π k r / m = k = 1 m 1 u e 2 i π r / m k .
In other words, we obtain the same sums involving u k , which means that we can multiply the sums involving u k by a factor of 2 and discard the complex conjugate terms. The upper-signed case of (100) can be expressed as
T v , l + ( m , r ) = 2 2 v 1 m 2 2 π 2 Γ ( 2 v ) n = 0 v 1 m 2 π 2 n s ( v , v n 1 ) 0 1 ln 2 n + 1 u 1 u m × k = 1 m 1 u k e 2 i π k r / m + c . c . d u u ,
where c.c. denotes the complex conjugate of the preceding sum over k. The summation over k can be easily evaluated, yielding
k = 1 m 1 u k e 2 i π k r / m = u m e 2 i π r / m u e 2 i π r / m u = u 2 u e 2 i π r / m + u m u m + 1 e 2 i π r / m 1 2 u cos ( 2 π r / m ) + u 2 .
If we introduce (103) into (102) and carry out a little algebra, then we find that
T v , l + ( m , r ) = 2 2 v 1 m 2 π 2 Γ ( 2 v ) n = 0 v 1 m 2 π 2 n s ( v , v n 1 ) 0 1 ln 2 n + 1 u 1 u m × u 2 2 u cos ( 2 π r / m ) + 1 + ( u m 1 ) 1 2 u cos ( 2 π r / m ) 1 2 u cos ( 2 π r / m ) + u 2 d u u .
Expressed in this form, one can cancel terms in the denominator. Consequently, (102) reduces to
T v , l + ( m , r ) = 2 2 v 1 m 2 π 2 Γ ( 2 v ) n = 0 v 1 m 2 π 2 n s ( v , v n 1 ) 0 1 ln 2 n + 1 u × u 1 1 u m u 1 cos ( 2 π r / m ) 1 2 u cos ( 2 π r / m ) + u 2 d u .
The integrals in (105) are divergent at the lower limit, despite the fact that the lhs or T v , j , l + ( m , r ) is finite. This means that the divergences must cancel. To observe this cancellation, we re-write (105) as follows:
T v , l + ( m , r ) = 2 2 v 1 m 2 π 2 Γ ( 2 v ) n = 0 v 1 m 2 π 2 n s ( v , v n 1 ) lim ϵ 0 + 0 1 ln 2 n + 1 u × u ϵ 1 1 u m u ϵ 1 ( 1 + u cos ( 2 π r / m ) 1 2 u cos ( 2 π r / m ) + u 2 d u .
According to No. 4.271(15) in [23], we have
0 1 u ϵ 1 ln 2 n + 1 u 1 u m d u = m 2 n 2 ψ ( 2 n + 1 ) ϵ m ,
where ψ ( n ) ( x ) represents the digamma function differentiated n times. From No. 8.363(8) in [23] and separating the k = 0 term, we find that
1 m 2 n + 2 ψ ( 2 n + 1 ) ϵ m = Γ ( 2 n + 2 ) m 2 n + 2 k = 1 1 k 2 n + 2 + m 2 n + 2 ϵ 2 n + 2 .
Thus, we observe that only one term is responsible for the divergence in the first integral.
The second integral in (105) is evaluated by using No. 4.272(3) in [23] subject to the condition that r < m / 2 . Then, we find that
0 1 ln 2 n + 1 u u ϵ 1 cos ( 2 π r / m ) 1 2 u cos ( 2 π r / m ) + u 2 d u = Γ ( 2 n + 2 ) sin ( 2 π r / m ) k = 1 sin ( 2 π k r / m ) ( k + ϵ 1 ) 2 n + 2 cos ( 2 π r / m ) k = 1 sin ( 2 π k r / m ) k 2 n + 2 .
Again, only the k = 1 term in the first summation on the rhs of (109) is divergent. As expected, this term cancels the divergent term in (108).
Now, we can take the limit as ϵ 0 + without any issues. Consequently, (106) becomes
T v , l + ( m , r ) = 2 2 v 1 m 2 π 2 Γ ( 2 v ) n = 0 v 1 m 2 π 2 n s ( v , v n 1 ) Γ ( 2 n + 2 ) m 2 n + 2 ζ ( 2 n + 2 ) + Γ ( 2 n + 2 ) sin ( 2 π r / m ) k = 1 sin ( 2 π ( k + 1 ) r / m ) k 2 n + 2 cos ( 2 π r / m ) k = 1 sin ( 2 π k r / m ) k 2 n + 2 .
Expanding the sine in the numerator of the first summation over k results in the cancellation of the second summation over k in (110). So, (110) reduces to
T v , l + ( m , r ) = 2 2 v 1 m 2 π 2 Γ ( 2 v ) n = 0 v 1 m 2 π 2 n s ( v , v n 1 ) Γ ( 2 n + 2 ) m 2 n + 2 ζ ( 2 n + 2 ) Γ ( 2 n + 2 ) k = 1 cos ( 2 π k r / m ) k 2 n + 2 .
From No. 9.622(3) in [23], we can identify the remaining summation over k in (111) as being related to the Bernoulli polynomial, B 2 n + 2 ( r / m ) . Moreover, as the divergences have been removed, we can analytically continue the result from r < m / 2 to r < m , since the summation over k is valid for these values of r. Then, we obtain
T v , l + ( m , r ) = 2 2 v 1 m 2 π 2 Γ ( 2 v ) n = 0 v 1 m 2 π 2 n s ( v , v n 1 ) Γ ( 2 n + 2 ) m 2 n + 2 ζ ( 2 n + 2 ) ( 1 ) n 2 ( 2 π ) 2 n + 2 B 2 n + 2 ( r / m ) .
From No. 9.616 in [23], we can replace the first term in the parentheses by the Bernoulli number, B 2 n + 2 , which results in (98) with l = 1 . For l = 2 or the Gardner–Fisher case, all that is required is to replace m by 2 m in (112). Thus, we end up with (98) for both cases. □
To verify (98), all we need to do is construct a code and compare it with the output from the instruction for TSumP below (94). Of course, this can only be performed in the Dowker or l = 1 case. A simple code for (98) in Mathematica is
 
Tplus[m, r, v]:= Expand[FullSimplify[(2(2 v)/Gamma[2 v])
 
Sum[(−1)n SymmetricPolynomial[v−n−1,Table[k2, {k,1,v−1}]]
 
(m(2 n + 2) BernoulliB[2n + 2,r/m] − BernoulliB[2n + 2])/(2 n + 2), {n,0,v−1}]]].
 
Note that the first argument in the SymmetricPolynomial instruction is now v n 1 instead of n. This has occurred because previously when Newton’s identities were applied to the product term inside (21) to yield (23), the ordering over n was reversed.
Let us consider an example by putting m = m , r = r and v = 4 in the above compound instruction. Then, we find that
 
In[33]:= Tplus[m, r, 4]
 
Out [ 33 ] = 2497 14175 + 16 m 2 105 + 14 m 4 675 + 8 m 6 2835 + m 8 4725 32 m r 35 + 32 r 2 35 28 m 2 r 2 45
8 m 4 r 2 135 4 m 6 r 2 45 + 56 m r 3 45 28 r 4 45 + 8 m 2 r 4 27 + 2 m 4 r 4 135 16 m r 5 45 + 16 r 6 135 4 m 2 r 6 135 +
8 m r 7 315 2 r 8 315 .
 
This is the same result obtained when one types TSumP[m,4,r] into Mathematica. Nevertheless, it should be pointed out that (98) applies to the Gardner–Fisher case ( l = 2 ), which cannot be determined by a simple Mathematica instruction as in TSumP.
On the other hand, it should be pointed out that the results for the Dowker case are more general in Mathematica, in the sense that r is not restricted to being an integer less than m. Whilst one obtains polynomial results via (98) when m and v are specified, this does not apply to TSumP[m,v,r]. For example, typing
 
In[34]:= TSumP[5, r, 4]
 
produces the following result:
 
Out[34] = cos 2 π r / 5 5 / 8 5 / 8 4 + cos 4 π r / 5 5 / 8 + 5 / 8 4 + cos 6 π r / 5 5 / 8 + 5 / 8 4 + cos 8 π r / 5 5 / 8 5 / 8 4 .
 
The above result, of course, is simply an expression totaling the individual summands in T 4 , 1 + ( 5 , r ) , and can be expressed in reduced form as
T 4 , 1 + ( 5 , r ) = 32 25 cos 2 π r 5 cos π r 5 .
An expression for the second cosine in (113) appears in Appendix I.11.5 of [24], but it is misleading. The more correct version, which appears as (3.15) in [25], is given by
cos π r 5 = ( 1 ) ( r + 2 ) / 5 5 4 + ( 1 ) r + 1 4 .
The first cosine is simply obtained by replacing r by 2 r , which gives (3.16) in [24]. In this case, the second term on the rhs of (114) equals −1/4. Introducing (114) into (112) and carrying out some algebra, one obtains
T 4 , 1 + ( 5 , r ) = 64 25 15 p ( r ) + 7 5 p + ( r ) 14 ,
where
p ± ( r ) = ( 1 ) ( 2 r + 2 ) / 5 ) ± ( 1 ) r + ( r + 2 ) / 5 ) .
Since both p ( r ) and p + ( r ) are periodic or modulo 5, T 4 , 1 + ( 5 , r ) is modulo 5. Moreover, p + ( r ) is zero for all values of r greater than zero and less than 5, where Theorem 3 applies. The modulo 5 values of r equal to zero can be handled with the results in Section 2. Consequently, the 5 -term in (115) vanishes, and the values of T 4 , 1 + ( 5 , r ) are rational, as expected. In fact, for r equal to 1, 2, 3 and 4, T 4 , 1 + ( 5 , r ) equals 1024/25, −2816/25, −2816/25 and 1024/25, respectively. The above example can be extended to other values of v and m using other results in Appendix I.11 of [24].
We now turn our attention to the alternating cases of the results in Theorem 3, which are presented in the following theorem.
Theorem 4. 
For r, a positive integer less than l m , the alternating twisted trigonometric power sum in the Dowker case, T v , 1 ( m , r ) , is given by
T v , 1 ( m , r ) = 0 , m , odd , 2 2 v Γ ( 2 v ) n = 0 v 1 ( 1 ) n 2 n + 2 s ( v , v n 1 ) ( 2 ( m / 2 ) 2 n + 2 B 2 n + 2 ( 2 r / m ) m 2 n + 2 B 2 n + 2 ( r / m ) B 2 n + 2 ) , m , even ,
while the corresponding alternating twisted trigonometric power sum in the Gardner–Fisher case is given by
T v , 2 ( m , r ) = 2 2 v Γ ( 2 v ) n = 0 v 1 ( 1 ) n 2 n + 2 s ( v , v n 1 ) ( 2 m 2 n + 2 B 2 n + 2 ( r / m ) ( 2 m ) 2 n + 2 B 2 n + 2 ( r / 2 m ) B 2 n + 2 ) .
Proof. 
The second result in the theorem will be proved first, since it will be used in the proof of the first result. As a consequence, we express T v , 2 ( m , r ) as
k = 1 2 m 1 ( 1 ) k cos k π r m csc 2 v k π 2 m = k = 1 m 1 cos k π r m csc 2 v k π 2 m + 2 k = 2 , 4 2 ( m 1 ) / 2 cos k π r m csc 2 v k π 2 m .
The first sum on the rhs of (119) is the l = 2 or Gardner–Fisher version of (98), while the second sum on the rhs of (119) can also be expressed as
k = 2 , 4 2 ( m 1 ) / 2 cos k π r m csc 2 v k π 2 m = k = 1 m 1 cos 2 k π r m csc 2 v k π m .
Hence, the second sum becomes the l = 1 or Dowker version of (98). Introducing the two versions of (98) into (119) yields (118) after some algebra.
If one assumes that m is even, then we can put m = m / 2 in T v , 2 ( m , r ) , thereby obtaining
T v , 2 ( m / 2 , r ) = k = 1 m 1 ( 1 ) k cos 2 π k r m csc 2 v k π m .
In other words, we arrive at T v , 1 ( m , r ) . Therefore, substituting m by m / 2 in (118) yields the second result in (117).
Finally, we consider the situation when m is odd. Already, we have seen that T v , 1 ( m , 0 ) vanishes as demonstrated in the proof of Theorem 1. Here, we let m = 2 N + 1 , where N is a non-negative integer, and write T v , 1 ( 2 N + 1 , r ) as
T v , 1 ( 2 N + 1 , r ) = k = 1 , 3 , 2 N 1 cos 2 π k r 2 N + 1 csc 2 v k π 2 N + 1 + k = 2 , 4 , 2 N cos 2 π k r 2 N + 1 × csc 2 v k π 2 N + 1 .
In the second sum we replace k by 2 N + 1 k . This gives
k = 2 , 4 , 2 N cos 2 π k r 2 N + 1 csc 2 v k π 2 N + 1 = k = 1 , 3 , 2 N 1 cos 2 π k r 2 N + 1 csc 2 v k π 2 N + 1 .
The above result cancels the first sum on the rhs of (122), leaving us with zero for odd values of m in the alternating twisted trigonometric power sum for the Dowker case. □
From the results in Theorems 3 and 4, it can be seen that the solutions to twisted trigonometric power sums in the Dowker case are only valid for integer values of r from zero to m 1 . However, it was mentioned at the beginning of Section 5 that, for r larger than m, solutions of twisted trigonometric power sums could be obtained for the Dowker case by assigning r to become the modulo of r with respect to m. Thus, there are m distinct values of this twisted trigonometric power sum. In other words, the twisted trigonometric power sum is cyclic over the integers.
In the Gardner–Fisher case, there are 2 m distinct values for the twisted trigonometric power sum, but the upper m values of the non-alternating version become the lowest m values of the alternating version or vice versa. To see this more clearly, let r = p m + q , where p is an integer and q = mod ( r , m ) . Introducing this value of r into (9) yields
T v , 2 ± ( m , p m + q ) = k = 1 l m 1 ( ± 1 ) k cos k π p + q m csc 2 v k π 2 m .
This equation can be simplified further, giving
T v , 2 ± ( m , p m + q ) = k = 1 l m 1 ( ± 1 ) k ( 1 ) p k cos q k π m csc 2 v k π 2 m .
Let us assume that s g n = + 1 , which means the summand has only a factor of ( 1 ) p k . Therefore, whenever p is even, T v , 2 + ( m , p m + q ) = T v , 2 + ( m , q ) , while if p is odd, then T v , 2 + ( m , p m + q ) = T v , 2 ( m , q ) . On the other hand, if s g n = 1 , we find that when p is even, T v , 2 ( m , p m + q ) = T v , 2 ( m , q ) , while for p, odd, T v , 2 ( m , p m + q ) = T v , 2 + ( m , q ) .
Following the descriptions around previous codes throughout this work, it is now a straightforward matter to combine the results in Theorems 3 and 4 into one Mathematica module/program. First, we note that the results in both theorems except the vanishing odd m result in the alternating version of the Dowker case are very similar. The main difference lies in the Bernoulli polynomial expression accompanying the symmetric polynomial term, s ( v , v n 1 ) . As we observed with the summand factor of the previous section, the Which instruction can be used to determine the appropriate Bernoulli polynomial expression, which will be called BrnTrm. Then, the Sum instruction can be utilized to sum over the symmetric polynomials multiplied by BrnTrm for the various values of n. Finally, we use the Print instruction to print out the value of the particular twisted trigonometric power sum requested in the input. An implementation of this algorithm appears below:
 
Ttwstd[sgn, l, m, v, r]:= Module[{}, flg = 1;
If[1 + (−1)m == 0 | | 1 + (−1)m,flg = −1]; Which[(sgn == +1),
BrnTrm = (l m)(2 n + 2) BernoulliB[2 n + 2, r/(l m)] − BernoulliB[2 n + 2],
(sgn == −1 && l == 1 && flg > 0 ), Print[“The result below is not valid for odd
values of m.”];
BrnTrm = 2 (m/2)(2 n + 2) BernoulliB[2 n + 2, 2 r/m]− m(2 n + 2)
BernoulliB[2 n + 2, r/m] − BernoulliB[2 n + 2],
(sgn == −1 && l == 1 && 1 + (−1)m == 0 && flg < 0 ), BrnTrm = 0,
(sgn == −1 && l == 1 && 1 + (−1)m ! = 0 && flg < 0 ), BrnTrm = 2 (m/2)(2 n + 2)
BernoulliB[2 n + 2, 2 r/m] − m(2 n + 2) BernoulliB[2 n + 2, r/m]
− BernoulliB[2 n + 2],
(sgn == −1 && l == 2), BrnTrm = 2 m(2 n + 2) BernoulliB[2 n + 2,r/m]
− (2 m)(2 n + 2) BernoulliB[2 n + 2, r/(2 m)] − BernoulliB[2 n + 2] ];
e1 = (2(2 v)/Gamma[2 v]) Sum[((−1)n/(2 n + 2)) BrnTrm
SymmetricPolynomial[v−n−1, Table[k2,{k, 1, v−1}]], {n, 0, v−1}];
Print[“The value of T(”, sgn, “){”, v, “,”, l, “}(”, m, “,”, r, “)=”, Expand[e1]]].
 
Whilst the above module largely follows in a straightforward manner from the other modules presented earlier, there is one new feature that has been inserted above. This is the variable f l g , which represents a flag that is initially set equal to 1. Its primary purpose is to determine whether m is algebraic or has been set equal to an integer. If m is algebraic, then f l g remains positive and the module continues treating m as an algebraic quantity. Whether m is algebraic or not does not affect the Gardner–Fisher forms. However, it does affect the alternating Dowker results. If one should input s g n = 1 , l = 1 and m = m , then f l g will remain greater than zero and the module will print out a statement that the result for the twisted trigonometric power sums is not valid for odd values of m. On the other hand, if m has been given an integer value, then f l g is set equal to −1 in the If statement at the beginning of the module. In this instance, the module prints out zero for the twisted trigonometric power sum if m is odd or its value for even values of m.
We now consider some examples of the above module before concluding this paper. Let us consider a relatively small value of m initially, say m = 5 . By putting s g n = + 1 , l = 2 , v = 9 and r = 2 , Ttwstd prints out
 
In[35]:= Ttwstd[+1, 2, 5, 9, 2]
 
Out[35] = The value of T(1){9,2}(5,2) = 117011644541 125
 
In[36]:= N[ (117011644541/125)]
 
Out[36] = − 9.36093 × 10 8
 
In[37]:= NumberForm[ 9.36093 × 10 8 , 16]
 
Out[37] = −9.36093156328 × 10 8 .
 
On the other hand, if we consider the same values except set s g n = 1 , then we obtain
 
In[38]:= Ttwstd[−1, 2, 5, 9, 2]
 
Out[38] = The value of T(−1){9,2}(5,7) = 117017411709 125
 
In[39]:= N[−117017411709/125]
 
Out[39] = 9.36139 × 10 8
 
In[40]:= NumberForm[ 9.36139 × 10 8 , 16]
 
Out[40]:= 9.36139293672 × 10 8 .
 
It was mentioned above that when r = p m + q in the Gardner–Fisher case, where p is odd, the values of T v , 2 + ( m , p m + q ) equal T v , 2 ( m , q ) . If we replace r = 2 by r = 7 , in the first calculation, then we expect that calculated value will equal Ttwstd[−1,2,5,9,2]. Typing in the values of the variables, we find that:
 
In[41]:= Ttwstd[1, 2, 5, 9, 7]
 
The value of T(1){9,2}(5,7) = 117017411709 125 ,
 
which is indeed the value of T 9 , 2 ( 5 , 2 ) .
To compare the above results with a direct evaluation in Mathematica, one requires the following instruction:
 
TSum[sgn, l, m, v, r]:= Sum[sgn k Cos[2 k r Pi/(l m)] Csc[k Pi/(l m)](2 v),
{k, 1, l m − 1}].
 
Since m is relatively small in this case, we can expect to obtain a solution in terms of powers of 5 as occurred earlier when evaluating the non-alternating Dowker case directly. Typing in
 
In[42]:= TSum[1, 2, 5, 9, 7]
 
Out[42] = −1 + 1 5 2 ( 5 / 8 5 / 8 ) 9 + 1 + 5 2 ( 5 / 8 + 5 / 8 ) 9 + 1 2 ( 1 + 5 ) 18 ( 1 + 5 ) +
1 2 ( 1 5 ) ( 1 + 5 ) 18 ,
 
while for s g n = 1 , one finds
 
In[43]:= TSum[−1, 2, 5, 9, 7]
 
Out[43] = 1 + 1 5 2 ( 5 / 8 5 / 8 ) 9 + 1 + 5 2 ( 5 / 8 + 5 / 8 ) 9 1 2 ( 1 + 5 ) 18 ( 1 + 5 )
1 2 ( 1 5 ) ( 1 + 5 ) 18 .
 
As expected, the terms in powers of 5 cancel and we are left with the rational values given above for the two types of Gardner–Fisher twisted trigonometric power sums.
Let us now consider the alternating Dowker case. First, we shall let m remain algebraic. For v = 9 and r = 7 , we obtain
 
Ttwstd[−1, 1, m, 9, 7]
 
The result below is not valid for odd values of m.
 
The value of T(−1){9,1}(m,7)=
 
2503953954305731 38979295480125 + 2048 m 2 51 33163664 m 4 3378375 29761296203 m 6 4469590125 + 151231981 m 8 67359600
 
1394041799 m 10 5388768000 + 24715156621 m 12 1872351936000 12392983 m 14 43110144000 + 321692363 m 16 152437469184000
 
5749691557 m 18 2554547108585472000 .
 
With the same input values, TSum yields
 
In[44]:= TSum[−1, 1, m, 9, 7]
 
Out[44] = (164099126349380386816 + 102582597615353856000 m2
25076595103059935232 m4 − 17009755041717485568 m6 + 5735325325405777920 m8
660845938604656896 m10 + 33720173366174592 m12 − 734362169827104 m14 +
5390920619154 m16 − 5749691557 m18)/2554547108585472000.
 
This result is identical to the corresponding result immediately above it, since subtracting the results from each other yields zero. Because both forms are in a different format, this implies the methods used to determine them are also different.
If we set m = 5 , then we find that Ttwstd prints out
 
Ttwstd[−1, 1, 5, 9, 2]
 
The value of T(−1){9,1}(5,2) = 0,
 
while if m = 6 , then the module prints out
 
In[45]:= Ttwstd[−1, 1, 6, 9, 2]
 
The value of T(−1){9,1}(6,2) = − 5160022813 19683 .
 
On the other hand, putting m = 5 and m = 6 in TSum[−1,1,m,9,2], one obtains zero and −5160022813/19683, respectively, confirming the results generated by Ttwstd.

7. Conclusions

This paper has been concerned with developing algorithms aimed at evaluating rational values and polynomials in powers of m and r for the general twisted trigonometric power sum, T v , l ± ( m , r ) , as defined by (9). In the process, we have encountered other interesting trigonometric power sums for which algorithms were also developed. It is hoped that the material in this work in conjunction with the results in [21] can be used to study more complicated trigonometric power sums in the future. Although the descriptions of the codes or algorithms have been converted into Mathematica modules here, it should be possible to create alternative programs using other software packages such as Maple and MatLab.

Funding

This research has received no external funding.

Data Availability Statement

There are no external databases where the results in this work can be analyzed.

Acknowledgments

The author thanks Carlos M. da Fonseca and M. Lawrence Glasser for their encouragement of this work and also for their earlier contributions on trigonometric power sums without which this work would not have been possible.

Conflicts of Interest

The author declares no conflict of interest.

References

  1. Quoniam, J.M. Problem E1937. Am. Math. Mon. 1966, 73, 1122. [Google Scholar]
  2. Greening, M.G.; Carlitz, L.; Gootkind, D.; Hoffman, S.; Reich, S.; Scheinok, P.; Quoniam, J.M. A trigonometric summation—Solution to Problem E1937. Am. Math. Mon. 1968, 75, 405–406. [Google Scholar]
  3. Gardner, L.A., Jr. Sum of inverse powers of cosines. Siam Rev. 1969, 11, 1621. [Google Scholar] [CrossRef]
  4. Fisher, M.E. Sum of inverse powers of cosines (L.A. Gardner, Jr.). Siam Rev. 1971, 13, 116–119. [Google Scholar] [CrossRef]
  5. Klamkin, M.S. (Ed.) Problems in Applied Mathematics—Selections from SIAM Review; SIAM: Philadelphia, PA, USA, 1990; pp. 157–160. [Google Scholar]
  6. Dowker, J.S. Casimir effect around a cone. Phys. Rev. D 1987, 36, 3095–3101. [Google Scholar] [CrossRef] [PubMed]
  7. Dowker, J.S. Heat kernel expansion on a generalized cone. J. Math. Phys. 1989, 30, 770–773. [Google Scholar] [CrossRef]
  8. Dowker, J.S. On Verlinde’s formula for the dimensions of vector bundles on moduli spaces. J. Phys. A Math. Gen. 1992, 25, 2641–2648. [Google Scholar] [CrossRef]
  9. Verlinde, E. Fusion rules and modular transformations in 2D conformal field theory. Nucl. Phys. B 1988, 300, 360–376. [Google Scholar] [CrossRef]
  10. Zagier, D. Elementary aspects of the Verlinde formula and of the Harder-Narasimhan-Bott formula. Israel Math. Conf. Proc. 1996, 9, 445–462. [Google Scholar]
  11. Berndt, B.C.; Yeap, B.P. Explicit evaluations and reciprocity theorems for finite trigonometric sums. Adv. Appl. Math. 2002, 29, 358–385. [Google Scholar] [CrossRef]
  12. Cvijovic, D.; Srivastava, H.M. Closed-form summation of Dowker and related sums. J. Math. Phys. 2007, 48, 043507. [Google Scholar] [CrossRef]
  13. Cvijovic, D.; Srivastava, H.M. Closed-form summations of Dowker’s and related trigonometric sums. J. Phys. A Math. Theor. 2012, 45, 1–10. [Google Scholar] [CrossRef]
  14. Chu, W.; Marini, A. Partial fractions and trigonometric identities. Adv. Appl. Math. 1999, 23, 115–175. [Google Scholar] [CrossRef]
  15. Chu, W. Summations on trigonometric functions. Appl. Math. Comput. 2003, 141, 161–176. [Google Scholar] [CrossRef]
  16. Wang, X.; Zheng, D.Y. Summation formulae on trigonometric functions. J. Math. Anal. Appl. 2007, 335, 1020–1037. [Google Scholar] [CrossRef]
  17. Wolfram, S. Mathematica-A System for Doing Mathematics by Computer; Addison-Wesley: Reading, PA, USA, 1992. [Google Scholar]
  18. Dowker, J.S. On sums of powers of cosecs. arXiv 2015, arXiv:1507.01848. [Google Scholar]
  19. He, S.; Numasawa, T.; Takayanagi, T.; Watanabe, K. Notes on entanglement entropy in string theory. J. High Energy Phys. 2015, 106, 1–17. [Google Scholar] [CrossRef]
  20. da Fonseca, C.M.; Glasser, M.L.; Kowalenko, V. Basic trigonometric power sums with applications. Ramanujan J. 2017, 42, 401–428. [Google Scholar] [CrossRef]
  21. da Fonseca, C.M.; Glasser, M.L.; Kowalenko, V. Generalized Cosecant Numbers and Trigonometric Inverse Power Series. Appl. Anal. Discrete Math. 2018, 12, 70–109. [Google Scholar]
  22. Kowalenko, V. Alternative Formulations of the Generalized Cosecant and Secant Numbers. Integers 2021, 21, A1. [Google Scholar]
  23. Gradshteyn, I.S.; Ryzhik, I.M.; Jeffrey, A. (Eds.) Table of Integrals, Series, and Products, 5th ed.; Academic Press, Inc.: Boston, DC, USA, 1994. [Google Scholar]
  24. Prudnikov, A.P.; Brychkov, Y.A.; Marichev, O.I. Integrals and Series: Vol. I Elementary Functions; Gordon & Breach: New York, NY, USA, 2003. [Google Scholar]
  25. Du, Z.; da Fonseca, C.M.; Kowalenko, V. Further Developments of Basic Trigonometric Power Sums. Rev. Real Acad. Cienc. Exactas Fis. Nat. Ser. A-Mat 2023, 117, 112. [Google Scholar] [CrossRef]
  26. Hansen, E.R. A Table of Series and Products; Prentice-Hall, Inc.: Englewood Hills, OH, USA, 1975. [Google Scholar]
Table 1. Generalized cosecant numbers c ρ , n up to n = 10 .
Table 1. Generalized cosecant numbers c ρ , n up to n = 10 .
n c ρ , n
01
1 1 3 ! ρ
2 2 6 ! 2 ρ + 5 ρ 2
3 8 9 ! 16 ρ + 42 ρ 2 + 35 ρ 3
4 2 3 × 10 ! 144 ρ + 404 ρ 2 + 420 ρ 3 + 175 ρ 4
5 4 3 × 12 ! 768 ρ + 2288 ρ 2 + 2684 ρ 3 + 1540 ρ 4 + 385 ρ 5
6 2 9 × 15 ! 1061376 ρ + 3327594 ρ 2 + 4252248 ρ 3 + 2862860 ρ 4 + 1051050 ρ 5 + 175175 ρ 6
7 1 27 × 15 ! ( 552960 ρ + 1810176 ρ 2 + 2471456 ρ 3 + 1849848 ρ 4 + 820820 ρ 5 + 210210 ρ 6
+ 25025 ρ 7 )
8 2 45 × 18 ! ( 200005632 ρ + 679395072 ρ 2 + 978649472 ρ 3 + 792548432 ρ 4 + 397517120 ρ 5
+ 125925800 ρ 6 + 23823800 ρ 7 + 2127125 ρ 8 )
9 4 81 × 21 ! ( 129369047040 ρ + 453757851648 ρ 2 + 683526873856 ρ 3 + 589153364352 ρ 4
+ 323159810064 ρ 5 + 117327450240 ρ 6 + 27973905960 ρ 7 + 4073869800 ρ 8 + 282907625 ρ 9 )
10 2 6075 × 22 ! ( 38930128699392 ρ + 140441050828800 ρ 2 + 219792161825280 ρ 3 + 199416835425280 ρ 4
+ 117302530691808 ρ 5 + 47005085727600 ρ 6 + 12995644662000 ρ 7 + 2422012593000 ρ 8
+ 280078548750 ρ 9 + 15559919375 ρ 10 )
Table 2. Values of S v , 2 ( m ) for v up to and including 10.
Table 2. Values of S v , 2 ( m ) for v up to and including 10.
v S v , 2 ( m )
1 2 3 ( m 2 1 )
2 4 45 ( 2 m 4 + 5 m 2 7 )
3 8 945 ( 8 m 6 + 21 m 4 + 42 m 2 71 )
4 16 14175 ( 24 m 8 + 80 m 6 + 147 m 4 + 270 m 2 521 )
5 32 93555 ( 32 m 10 + 132 m 8 + 286 m 6 + 451 m 4 + 792 m 2 1693 )
6 64 638512875 ( 44224 m 12 + 218400 m 10 + 558558 m 8 + 993850 m 6 + 1438437 m 4 + 2457000 m 2
5710468 )
7 128 273648375 ( 3840 m 14 + 22112 m 12 + 65520 m 10 + 133419 m 8 + 211640 m 6 + 289926 m 4
+ 486000 m 2 1212457 )
8 256 488462349375 ( 1388928 m 16 + 9139200 m 14 + 30824128 m 12 + 71073600 m 10 + 126249123 m 8
+ 185684200 m 6 + 244813158 m 4 + 404838000 m 2 1074010337 )
9 512 194896477400625 ( 112299520 m 18 + 831273408 m 16 + 3145141440 m 14 + 8109940848 m 12
+ 16038878310 m 10 + 25993141083 m 8 + 36233012730 m 6 + 46442359908 m 4
+ 76014288000 m 2 212920335247 )
10 1024 32157918771103125 ( 3754834944 m 20 + 30882368000 m 18 + 129540106080 m 16
+ 369483576000 m 14 + 806213290740 m 12 + 1435972970250 m 10 + 2178408236235 m 8
+ 2917253715750 m 6 + 3659175925020 m 4 + 5941116720000 m 2 17471801743019 )
Table 3. Values of S v , 1 ( m ) for v up to and including 10.
Table 3. Values of S v , 1 ( m ) for v up to and including 10.
v S v , 1 ( m )
1 1 3 ( m 2 1 )
2 1 45 ( m 4 + 10 m 2 11 )
3 1 945 ( 2 m 6 + 21 m 4 + 168 m 2 191 )
4 1 14175 ( 3 m 8 + 40 m 6 + 294 m 4 + 21600 m 2 2497 )
5 1 93555 ( 2 m 10 + 33 m 8 + 286 m 6 + 1804 m 4 + 12672 m 2 14797 )
6 1 638512875 ( 1382 m 12 + 27300 m 10 + 279279 m 8 + 1987700 m 6 + 11507496 m 4 + 78624000 m 2
92427157 )
7 1 273648375 ( 60 m 14 + 1382 m 12 + 16380 m 10 + 133419 m 8 + 846560 m 6 + 4638816 m 4
+ 31104000 m 2 36740617 )
8 1 488462349375 ( 10851 m 16 + 285600 m 14 + 3853016 m 12 + 35536800 m 10 + 252498246 m 8
+ 1485473600 m 6 + 7834021056 m 4 + 51819264000 m 2 61430943169 )
9 1 194896477400625 ( 438760 m 18 + 12988647 m 16 + 196571340 m 14 + 2027485212 m 12
+ 16038878310 m 10 + 103972564332 m 8 + 579728203680 m 6 + 2972311034112 m 2
+ 19459657728000 m 2 23133945892303 )
10 1 32157918771103125 ( 7333662 m 20 + 241268500 m 18 + 4048128315 m 16 + 46185447000 m 14
+ 403106645370 m 12 + 2871945940500 m 10 + 17427265889880 m 8 + 93352118904000 m 6
+ 468374518402560 m 4 + 3041851760640000 m 2 3624331198599787 )
Table 4. Values of S v , 1 ( m ) for v up to and including 10.
Table 4. Values of S v , 1 ( m ) for v up to and including 10.
v S v , 1 ( m )
1 1 6 ( m 2 + 2 )
2 1 360 ( 7 m 4 + 40 m 2 + 88 )
3 1 15120 ( 31 m 6 + 294 m 4 + 1344 m 2 + 3056 )
4 1 1814400 ( 381 m 8 + 4960 m 6 + 32928 m 4 + 138240 m 2 + 319616 )
5 1 23950080 ( 511 m 10 + 8382 m 8 + 70928 m 6 + 404096 m 4 + 1622016 m 2 + 3788032 )
6 1 653837184000 ( 1414477 m 12 + 27900600 m 10 + 283747464 m 8 + 1971798400 m 6
+ 10310716416 m 4 + 40255488000 m 2 + 94645408768 )
7 1 560431872000 ( 122865 m 14 + 2828954 m 12 + 33480720 m 10 + 271107408 m 8
+ 1679575040 m 6 + 8312758272 m 4 + 31850496000 m 2 + 75244783616 )
8 1 16005934264320000 ( 355554717 m 16 + 9357398400 m 14 + 126193980032 m 12
+ 751392960304896000 m 10 + 4532762148894228480 m 8 + 23706957299908608000 m 6
+ 107433873533105602560 m 4 + 398701593970606080000 m 2 + 950096677725742563328 )
9 1 12772735542927360000 ( 28748457785 m 18 + 851197992498 m 16 + 12880926767520 m 14
+ 132808391326848 m 12 + 1049070952500480 m 10 + 6760712023123968 m 8
+ 36805784195235840 m 6 + 170444203940118528 m 4 + 637654064431104000 m 2
+ 1516106277997969408 )
10 1 8430005458332057600000 ( 1922471824497 m 20 + 63246607127000 m 18 + 1061160163980840 m 16
+ 12105759884064000 m 14 + 105620390793265920 m 12 + 751392960304896000 m 10
+ 4532762148894228480 m 8 + 23706957299908608000 m 6 + 107433873533105602560 m 4
+ 398701593970606080000 m 2 + 950096677725742563328 )
Table 5. Values of S v , 2 ( m ) for v up to and including 10.
Table 5. Values of S v , 2 ( m ) for v up to and including 10.
v S v , 2 ( m )
1 1 6 ( 2 m 2 + 1 + ( 1 ) m 3 )
2 1 90 ( 14 m 4 + 20 m 2 + 11 + ( 1 ) m 45 )
3 1 1890 ( 124 m 6 + 294 m 4 + 336 m 2 + 191 + ( 1 ) m 945 )
4 1 28350 ( 762 m 8 + 2480 m 6 + 4116 m 4 + 4320 m 2 + 2497 + ( 1 ) m 14175 )
5 1 187110 ( 2044 m 10 + 8382 m 8 + 17732 m 6 + 25256 m 4 + 25344 m 2 + + 14797 + ( 1 ) m 555 )
6 1 1277025750 ( 5657908 m 12 + 27900600 m 10 + 70936866 m 8 + 123237400 m 6 + 161104944 m 4
+ 157248000 m 2 + 94645408768 + ( 1 ) m 638512875
7 1 547296750 ( 982920 m 14 + 5657908 m 12 + 16740360 m 10 + 33888426 m 8 + 52486720 m 6
+ 64943424 m 4 + 62208000 m 2 + 36740617 + ( 1 ) m 273648375 )
8 1 976924698750 ( 711109434 m 16 + 4678699200 m 14 + 15774247504 m 12 + 36318609600 m 10
+ 64134554484 m 8 + 92099363200 m 6 + 109676294784 m 4 + 103638528000 m 2
+ 61430943169 + ( 1 ) m 488462349375 )
9 1 389792954801250 ( 114993831140 m 18 + 851197992498 m 16 + 3220231691880 m 14
+ 8300524457928 m 12 + 16391733632820 m 10 + 26409031340328 m 8 + 35943148628160 m 6
+ 41612354477568 m 4 + 38919315456000 m 2 + 23133945892303 + ( 1 ) m 194896477400625 )
10 1 64315837542206250 ( 7689887297988 m 20 + 63246607127000 m 18 + 265290040995210 m 16
+ 756609992754000 m 14 + 1650318606144780 m 12 + 2935128751191000 m 10
+ 4426525536029520 m 8 + 5787831372048000 m 6 + 6557243257635840 m 4
+ 6083703521280000 m 2 + 16399688681447 + ( 1 ) m 145510944665625 )
Table 6. Summand factors for the inverse powers of sine in V v , j , l ± ( m ) .
Table 6. Summand factors for the inverse powers of sine in V v , j , l ± ( m ) .
sgnl S f ( v , n , s g n , l )
11 2 2 n + 1 ( m 2 v 2 n 1 )
12 2 2 v + 1 ( m 2 v 2 n 1 )
1 1 2 2 n ( 2 2 n 2 v + 1 1 ) m 2 v 2 n 1 1 + ( 1 ) m
1 2 ( 2 2 n + 2 2 2 v + 1 ) m 2 v 2 n ( 1 ) m 2 2 v + 1 + ( ( 1 ) m 1 ) 2 2 n + 1
Table 7. Factors P ( ± 1 , l ) in the j = v term of V v , j , l ± ( m ) .
Table 7. Factors P ( ± 1 , l ) in the j = v term of V v , j , l ± ( m ) .
sgnl P ( s g n , l )
11 m 1
12 2 m 1
1 1 1 , m even 0 , m odd
1 2 1
Table 8. Values of the Four Basic Trigonometric Power Sums, U l , v , j s g n ( m ) , for various values of v, j and m.
Table 8. Values of the Four Basic Trigonometric Power Sums, U l , v , j s g n ( m ) , for various values of v, j and m.
vj l = 1 l = 2 l = 1 l = 2
s g n ++
29 422343 8192 223545 2048 0 24747 4096
612 1598103 2048 1620819 1024 0 5679 256
m = 3 915 6744267 2048 6798747 1024 0 3045 64
1219 248613615 8192 125215101 2048 0 1810587 4096
1530 70980258098522691 536870912 36217263345658047 134217728 0 1454268592793403 268435456
315 5103981565 4194304 5130885535 2097152 0 13451985 1048576
510 183225 512 91615 128 0 5 256
m = 5 1020 139679654025 524288 139710446585 262144 0 1924535 16384
2030 14318455371625 524288 14318864559225 262144 0 25574225 16384
2540 11226079196963413825 268435456 11226967864447527165 134217728 0 222166871028335 33554432
413 5074887 2048 20299565 4096 40919 2048 17 4096
816 30295991 1024 121183965 2048 53191 1024 1 2048
m = 8 1119 145793675 1024 583174701 2048 131707 1024 1 2048
1430 1530284095489007 4194304 24484565631151767 33554432 5626959414511 4194304 20103327655 33554432
1835 85397153404618323 8388608 1366354983263679667 67108864 221267848529747 8388608 528789786499 67108864
514 154581141 16384 154581141 8192 1653 2048 0
716 746494545 16384 746494545 8192 2967 2048 0
m = 12 1220 2751221655 8192 2751221655 4096 765 1024 0
1425 1743775392027 131072 1743775392027 65536 34909329 262144 0
1632 1123494714551097135 536870912 1123494714561502359 268435456 3006142168365 33554432 1300653 33554432
613 1099943 128 1099943 64 00
917 213188525 2048 213188525 1024 1 2048 0
m = 16 1120 2802276035 4096 2802276035 2048 31 4096 0
1526 963117586951 32768 963117586951 16384 22755 32768 0
2040 2753540784550831440045 4294967296 11014163138203330010675 8589934592 1989694564057805 4294967296 4250495 8589934592
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Kowalenko, V. Algorithms for Various Trigonometric Power Sums. Algorithms 2024, 17, 373. https://doi.org/10.3390/a17080373

AMA Style

Kowalenko V. Algorithms for Various Trigonometric Power Sums. Algorithms. 2024; 17(8):373. https://doi.org/10.3390/a17080373

Chicago/Turabian Style

Kowalenko, Victor. 2024. "Algorithms for Various Trigonometric Power Sums" Algorithms 17, no. 8: 373. https://doi.org/10.3390/a17080373

APA Style

Kowalenko, V. (2024). Algorithms for Various Trigonometric Power Sums. Algorithms, 17(8), 373. https://doi.org/10.3390/a17080373

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop