Earlier this year Grant Sanderson, creator of the YouTube channel 3blue1brown, posted a video explaining how Fourier series approximate periodic functions using sums of sines and cosines. In the video and its companion, Grant animates sets of vectors that rotate on circular orbits and, when summed together, reproduce a range of images defined by closed curves.

Consider, for example, the boundary of GitHub’s logo:

Let γ:[0,1]R2 be the closed curve in R2 defining the logo’s boundary. Suppose there is an integer n such that γ(t)=k=nnγk(t) for some set of circular orbits γn,,γn:[0,1]R2 and for all times t[0,1]. (Negative and positive subscripts correspond to clockwise and anti-clockwise orbits. Both may be necessary to reconstruct γ.) Each orbit γk has time t position defined by the vector γk(t)=[rkcos(2πkt+θk)rksin(2πkt+θk)] for some radius rk, angular speed 2πk rad/s and initial phase θk. Consequently, the curves x,y:[0,1]R defining the horizontal and vertical components of γ must satisfy the system x(t)=k=nnrkcos(2πkt+θk)y(t)=k=nnrksin(2πkt+θk) of identities. Let z:[0,1]C be the curve with z(t)=x(t)+iy(t) for all t[0,1]. Euler’s formula gives z(t)=k=nnrk(cos(2πkt+θk)+isin(2πkt+θk))=k=nnrkexp(2πikt+iθk)=k=nnckexp(2πikt), where each Fourier coefficient ck=rkexp(iθk) has modulus |ck|=rk and (principal) argument Arg(ck)=θk. Now, notice that 01z(t)exp(2πikt)dt=01(j=nncjexp(2πijt))exp(2πikt)dt=01ckdt+jkcj01exp(2πi(jk)t)dt=ck for each k because 01exp(2πi(jk)t)dt=0 for all integers jk by the 2πi-periodicity of the complex exponential function. Thus ck=01z(t)exp(2πikt)dt, which can be calculated using Riemann sums given sample points along the component curves x and y. Doing this calculation for each k, and computing the corresponding moduli rn,,rn and arguments θn,,θn, provides enough information to generate the animation below.