User Input - Fourier Approximation

Welcome to the User Input - Fourier Series Generator!

Now, you can draw your own function, and the generator will create a Fourier series to approximate it. It's a fun and interactive way to understand how Fourier series can approximate any periodic function.

How to Use the User Input - Fourier Series Generator:

  1. Start by drawing your desired function on the canvas slowly. The canvas records points based on their x-coordinate, so it's important to draw slowly for smooth functions.
  2. For more interesting shapes, try drawing quickly and taking multiple passes across the canvas.
  3. If you make a mistake or want to change your drawing, click the 'Clear' button and start again.
  4. Once you're happy with your drawing, input the number of harmonics you want to include in the Fourier series in the "Number of Harmonics" field, then click the 'Generate' button. Your Fourier series will be created and displayed in the main chart.
  5. Every time you change the number of harmonics, the main chart will update to show the new approximation of your drawing by the Fourier series.
  6. In some cases, if the Fourier series approximation does not load, clear the canvas and try again (sorry in advance).
  7. Enjoy exploring and feel free to create new drawings and generate their Fourier series as many times as you like!

Create your own Fourier series by drawing on the canvas!

An Explanation from OpenAI's ChatGPT

If you've been exploring this tool, you might have noticed something strange. Once the 'Number of Harmonics' (which determines the number of terms in our Fourier series approximation) surpasses 150, the approximation starts looking worse, not better. You might think, "The more terms we use, the closer the approximation should be, right?" Here's why that isn't always the case.

When we're turning a complex wave (like a picture or a song) into a bunch of numbers, we have to decide how many numbers to use. This process is like taking a picture of a scene. The more photos we take, the clearer the final image will be. The 'rate' at which we take these photos is like our sampling rate.

But, there's a catch. If we try to represent something that's changing very rapidly, we need to take pictures very quickly to capture those changes. If we don't, weird effects start to happen. Imagine trying to take a photo of a spinning fan with a slow camera - the fan might appear to be still or even spinning backwards! This is called 'aliasing.'

In our case, we're trying to draw a complicated shape with a series of simple waves (sine and cosine waves). We add these waves together to create our shape. The more waves we use (the higher the 'n' value), the closer our approximation will be. But if we try to use more waves than half the total number of data points we have (this is known as the Nyquist frequency), we run into the aliasing problem.

This is why, when 'n' reaches half the total number of points, our approximation actually starts to look worse. We're trying to represent changes that are too rapid for the amount of data we have. To solve this, we would need more data points, like taking more photos to accurately capture a rapidly spinning fan.