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 NABNA \mid B and ABA \nmid B (A,B,NZA,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=0N1cos(2πkAB+ϕ)=Re(ejϕk=0N1ej2πkAB)=Re(ejϕ(1e2πjNAB1e2π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 NABNA \mid B and ABA \nmid B, then 1e2πjNAB=01- e^{2\pi j \frac{NA}{B}} = 0 and1e2πjAB01- e^{2\pi j \frac{A}{B}} \neq 0, thus Re(ejϕ(1e2πjNAB1e2π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 NABNA \nmid B as well as ABA \nmid B, for any ϕ\phi that satisfies:

Re(ejϕ(1e2πjNAB1e2πjAB))=0ejϕ(1e2πjNAB1e2π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π(nZ)\Delta \varphi \neq n\pi (n \in \mathbb{Z}) that makes

Re(ej(ϕ+Δϕ)(1e2πjNAB1e2π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 ABA \mid B, assume that A=nB(nZ)A = nB (n \in \mathbb{Z}),

k=0N1cos(2πkAB+ϕ)=k=0N1cos(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ωt1vsi=didtp0i=0ωt1nsinei{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 vs0v_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/sum-of-sampled-sinfunction/
Author
Zhiyang Cao
Published at
2025-06-12
License
CC BY-NC-SA 4.0