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.

- even(x) - returns true if x is even, false otherwise.
- odd(x) - returns true if x is odd, false otherwise.
- power(x, a) - returns x
^{a}.

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 (-π, π).

Enjoy!

*To receive updates, subscribe now!*
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-_-.

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

Keep up the great work!

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.

DeleteOf 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!