437 words
2 minutes
When will the sum of samples from a trigonometric function be zero
2025-06-12

There’s an interesting feature of trigonometric functions that I came up with while dealing with the WFM of resolvers: When a trigonometric function cos⁡(Ax+φ)\cos (Ax + \varphi) is sampled BB times within x∈[0,2π)x \in [0, 2\pi) with equal time interval, the necessary and sufficient condition for the sum of NN consecutive samples to be zero is that NA∣BNA \mid B and A∤BA \nmid B (A,B,N∈ZA,B,N \in \mathbb{Z}).

It is somehow intrinsic once mentioned, but it really took me a while to prove. I guess that’s a hint for me that I should never get involved in math.


Prove:

For any φ∈[0,2π)\varphi \in [0, 2\pi):

∑k=0N−1cos⁡(2πkAB+ϕ)=Re(ejϕ∑k=0N−1ej2πkAB)=Re(ejϕ(1−e2πjNAB1−e2πjAB))\sum\limits_{k = 0}^{N - 1} {\cos \left( {\frac{{2\pi kA}}{B} + \phi } \right)} = {\mathop{\rm Re}\nolimits} \left( {{e^{j\phi }}\sum\limits_{k = 0}^{N - 1} {{e^{j\frac{{2\pi kA}}{B}}}} } \right) = {\mathop{\rm Re}\nolimits} \left( {{e^{j\phi }}\left( {\frac{{1 - {e^{2\pi j\frac{{NA}}{B}}}}}{{1 - {e^{2\pi j\frac{A}{B}}}}}} \right)} \right)

If NA∣BNA \mid B and A∤BA \nmid B, then 1−e2πjNAB=01- e^{2\pi j \frac{NA}{B}} = 0 and1−e2πjAB≠01- e^{2\pi j \frac{A}{B}} \neq 0, thus Re(ejϕ(1−e2πjNAB1−e2πjAB))≡0{\mathop{\rm Re}\nolimits} \left( {{e^{j\phi }}\left( {\frac{{1 - {e^{2\pi j\frac{{NA}}{B}}}}}{{1 - {e^{2\pi j\frac{A}{B}}}}}} \right)} \right) \equiv 0, and the sum of NN consecutive samples is always zero.

Otherwise, if NA∤BNA \nmid B as well as A∤BA \nmid B, for any ϕ\phi that satisfies:

Re(ejϕ(1−e2πjNAB1−e2πjAB))=0⇔ejϕ(1−e2πjNAB1−e2πjAB)=±j{\mathop{\rm Re}\nolimits} \left( {{e^{j\phi }}\left( {\frac{{1 - {e^{2\pi j\frac{{NA}}{B}}}}}{{1 - {e^{2\pi j\frac{A}{B}}}}}} \right)} \right) = 0 \Leftrightarrow {e^{j\phi }}\left( {\frac{{1 - {e^{2\pi j\frac{{NA}}{B}}}}}{{1 - {e^{2\pi j\frac{A}{B}}}}}} \right) = \pm j

there is always a Δφ≠nπ(n∈Z)\Delta \varphi \neq n\pi (n \in \mathbb{Z}) that makes

Re(ej(ϕ+Δϕ)(1−e2πjNAB1−e2πjAB))=Re(±jejΔϕ){{\rm{Re}}\left( {{e^{j\left( {\phi + \Delta \phi } \right)}}\left( {\frac{{1 - {e^{2\pi j\frac{{NA}}{B}}}}}{{1 - {e^{2\pi j\frac{A}{B}}}}}} \right)} \right) = {\rm{Re}}\left( { \pm j{e^{j\Delta \phi }}} \right)}

=Re(±j(cos⁡Δϕ+jsin⁡Δϕ))=±sin⁡Δϕ≠0{ = {\rm{Re}}\left( { \pm j\left( {\cos \Delta \phi + j\sin \Delta \phi } \right)} \right) = \pm \sin \Delta \phi \ne 0}

which means the sum of NN consecutive samples is determined by ϕ\phi.

If A∣BA \mid B, assume that A=nB(n∈Z)A = nB (n \in \mathbb{Z}),

∑k=0N−1cos⁡(2πkAB+ϕ)=∑k=0N−1cos⁡(2πnk+ϕ)=Ncos⁡ϕ\sum\limits_{k = 0}^{N - 1} {\cos \left( {\frac{{2\pi kA}}{B} + \phi } \right)} = \sum\limits_{k = 0}^{N - 1} {\cos \left( {2\pi nk + \phi } \right)} = N\cos \phi

which means the sum of samples equals zero only with φ=π2\varphi = \frac{\pi}{2} or φ=3π2\varphi = \frac{3\pi}{2}.

Q.E.D.


Let’s say such conclusion is somehow useful. E.g., if the induced voltage of a resolver has a constant-amplitude component of:

vs=∑i=0ωt−1vsi=didtp0∑i=0ωt−1nsinei{v_s} = \sum\limits_{i=0}^{\omega_t-1} {{v_{si}}} = \frac{{{\rm{d}}i}}{{{\rm{d}}t}}{p_0}\sum\limits_{i=0}^{\omega_t-1} {{n_{si}}{n_{ei}}}

where nsi=Nscos⁡(ωsθi)n_{si} = N_s \cos (\omega_s \theta_i), nei=Necos⁡(ωeθi)n_{ei} = N_e \cos (\omega_e \theta_i), and θi=2πiωt\theta_i = \frac{2\pi i}{\omega_t}.

What are the requirements to have vs≡0v_s \equiv 0? In this example, A=ωe±ωsA = \omega_e \pm \omega_s, B=ωtB = \omega_t and N=ωtN = \omega_t. So the necessary and sufficient condition will be ωe±ωs∤ωt\omega_e \pm \omega_s \nmid \omega_t.

When will the sum of samples from a trigonometric function be zero
http://tsaoo.github.io/resrvplot/posts/ee/sum-of-sampled-sinfunction/
Author
Zhiyang Cao
Published at
2025-06-12
License
CC BY-NC-SA 4.0