Tuesday, April 15, 2014

Fourier Series Grapher

Here's a simple JavaScript + HTML program I wrote. It will graph a given number of terms of a Fourier series. To graph a Fourier series, type the appropriate expressions into the text fields and click "Update." The text fields support JavaScript, so you can write a whole function in there if you need to.

I also added some functions.
  1. even(x) - returns true if x is even, false otherwise.
  2. odd(x) - returns true if x is odd, false otherwise.
  3. power(x, a) - returns xa.
Some examples of input to try:
  • odd(k)?(2/k):0
  • even(k)?(4/k/PI):0
  • odd(k)?(4/(k+PI)/k):0
The default Fourier series is equal to sin(2.5x) on (-π, π).


To receive updates, subscribe now!


  1. You're awesome! I'm teaching myself JavaScript along with HTML, JQuery, and CSS and your blog is very inspiring! I saw your program, "DRAW", on KhanAcademy and it was so cool! How did you learn how to make such great programs? I don't even know where to start-_-.

    Oh! And I'm a self-taught pianist as well*thanks to suzuki piano book, hehe*

    Keep up the great work!

    1. Thanks for commenting! I started by learning BASIC (mostly from the documentation), and after that JavaScript came easily. I just had to learn the syntax and some object-oriented programming concepts.

      Of course, math is indispensable in programming. Looking at other programmers' source code can help with technique and structure, and practice helps a lot too.

      Usually I come up with an idea for a program first, and then I figure out how to write it. If I don't know how, I research it. It can take a while, but when I'm done I know a lot more about it than I did when I started.

      Good luck with programming!