concept Fourier series in category python

This is an excerpt from Manning's book Math for Programmers: 3D graphics, machine learning, and simulations with Python MEAP V11.
Our last goal will be to decompose a function representing any sound wave into a sum of (pure) musical notes and their corresponding volumes, which make up the sound wave (figure 13.4). Such a decomposition into a sum is called a Fourier series (pronounced FOR-ee-yay). Once we’ve found the sound waves making up a Fourier series, we can play them together and get the original sound.
Figure 13.4: Decomposing a sound wave function into a combination of simpler ones using a Fourier series
![]()
Mathematically, finding a Fourier series means writing a function as a sum or, more specifically, a linear combination of sine and cosine functions. This procedure and its variants are among the most important algorithms of all time. Methods similar to the ones we’ll cover are used in common applications like MP3 compression, as well as in more grandiose ones like the recent Nobel prize-winning detection of gravitational waves.
We already saw that a Fourier series with these coefficients is a solid approximation of the square wave graph. Let’s conclude this section by looking at two example functions we haven’t seen before and plotting the Fourier series alongside the original functions to show that the approximation works.