$\int sin2(x)dx\; >\; 0$

The integral of the square of the sine function is always positive. This makes sense sort of by definition, because anything squared is always positive, so the negative parts of the sine curve become positive when squared. To illustrate this graphically, I'll show the integral of the sine function:

followed by the integral of the sine squared:

So the integral of the sine times itself is always greater than 0.

Now, the key: the integral of the sine times a sine with a different frequency over an entire period is always equal to 0. Let's slow down and read that one more time, since it's hard to say in a small number of words. The integral of two sine functions with different periods is always 0. To take a specific example, let the second sine function be sin(3x), or one with 3 times the frequency like the green curve here:

The statement I'm making can be expressed symbolically,

$\int sin(x)*sin(3x)dx\; =\; 0$ (integrated over a full period)

How about graphically? Well, here is a plot of sin(x)*sin(3x), and if you look, the green regions are equal in area to the yellow regions, for a total integral of 0.

How about if I show another example, with a sine of four times the frequency.

$\int sin(x)*sin(4x)dx\; =\; 0$ (integrated over a full period)

Again, the areas of the green and yellow regions are equal, and the total integral is 0. Now I haven't proven this is true for all frequencies, but it can be done rigorously (or rigourously); I suppose you might have to take my word on it, but it clearly works for the two examples given.

There's one more theorem that I need to state before finally explaining Fourier analysis, although I hope it won't be too difficult to understand. This is an associative statement, that the integral of the sum of two functions (any functions, let's just call them f(x) and g(x); for example, they could be sin(x) and sin(3x)) is equal to the sum of the integrals done separately:

$\int \; (f(x)\; +\; g(x)\; )dx\; =\; \int \; f(x)dx\; +\; \int \; g(x)dx$

Let me know if that is not clear, because I'm so excited about the punch line, I'm inclined to skip past some of this stuff.

# Finally...

To recap, so far we know the following things:

1. Any periodic shape can be expressed as the sum of sine functions with different frequencies.

2. The integral of a curve is the area under the curve.

3. The integral of a sine times itself is greater than 0.

4. The integral of a sine times a sine with a different frequency is equal to 0.

5. The integral of a sum of functions is equal to the sum of the integrals done independently.

Who can guess what the next step is?

Suppose I have an unknown function (like the A chord from the November post).

By Rule 1, I know that this function can be expressed as the sum of many sine curves of different frequencies. Now, suppose I want to understand what the signal actually is - I want to break it down into the frequencies that went into its construction.

What if I multiplied the unknown function by a sine curve of a given frequency that I know and integrated the result over an entire period? From Rule 4 above, if the frequency I control does not match one of the frequencies that make up the unknown function, the integral will be 0. But if I do find a match, all of a sudden, the integral is positive (by Rule 3) and I've identified one of the component frequencies in my unknown function!

Now, I scan my known frequency over all frequencies, and at the end of the scan, I've found all of the elements that went into making the unknown signal, producing a plot like this:

In this graph, I'm basically plotting the value I get when I integrate the product of the A chord function times a sine with a frequency given by the value on the x-axis. In most situations, I get 0, but when I find a match, the integral (or "power") is positive and I see a spike!

Isn't this exciting? And I'm being completely serious here, none of the vaguely self-mocking tone you might find elsewhere in this blog - I find Fourier analysis completely awesome and elegant and beautiful. Simply using mathematical formalism, we can completely deconstruct a complicated and unknown signal into its individual constituents and understand exactly what is going on. It's stuff like this that makes me love physics and math. If I didn't quite manage to get the beauty and simplicity across in the last few posts, let me know and I'll do what I can to fix it.

Nice post!. I always wondered how they decomposed frequencies using Fourier analysis.

ReplyDeleteGoing back and thinking about it i see how it all comes together...

ReplyDeleteYou use statement 1 to show that any signal is a composition of sine curves.

You use statement 2 just as a corollary to show what and integral is and what you are looking for.

You use statement 5 to show that you can isolate single sine curves from the others and find those integrals.

From statement 4 you can say if you multiply your signal by a specific sine curve and get 0 for the integral across the interval then that specific curve IS NOT part of your original signal.

From statement 5 you can say if you multiply your signal by a specific sine curve and get a vaule other than 0 for the integral across the interval then that specific curve IS part of your original signal.

I belive that is correct....

What then explains the amplitude of your spikes? If your frequencies determine the existance of a spike does the amplitude determine how much of the signal that frequency makes up?

Fourier analysis is AWESOME. What is NOT awesome is that non-eng/sci Yale undergrads think I am strange when I want to say, talk about how Fourier analysis is cool. *sigh*

ReplyDeleteKeep up the great blogging.

Sam Jackson, TC'11

This was fantastic. Thanks!

ReplyDeleteReally good explanation of Fourier.

ReplyDeleteWould you like to do some practical thing using this?

I am doing one of that but having some difficulties to understand some part. would you like to join me then mail me at shiva.vaghela@gmail.com.

I will explain practical thing using Fourier and we will make it physible!! what you think?

Hey Hugh! I read your fourier posts too and share your fascination with fourier analysis. :)

ReplyDeleteI'm afraid I have an inquisitive comment, though. My apologies! I hate being the showstopper. >_<

For that A-chord, you didn't actually construct the time-domain signal and its frequency-domain counterpart from live data, did you?

I'm running an experiment as part of my engineering master thesis (computer science), and developed an application that records audio data and performs the fourier transform in real-time from an electric guitar connected to the computer's microphone line-in, and the resulting frequency spectrum is, unfortunately, NOT that simple. :(

If it were, we would have polyphonic guitar detectors flooding the market for tuners worldwide as we speak.

You see, the harmonies of each vibrating string get mixed up with the fundamental frequencies we are actually interested in. Take the open E-string, using standard tuning. If you pluck it, we'd like to ideally be seeing a single spike at E2 = 82.41Hz. But the open E-string, like all strings, has its second harmonic at the 12th fret, i.e. the overtone at 164.81. This isn't the biggest problem since that frequency also evaluates to an E (it's just E3). But worse yet, the string's 3rd harmonic is at the 7th fret, and this note is, unfortunately, not another E. It's a B3 = 246.94Hz. It continues like that, but one's detection scheme might not pick up further harmonics depending on the detection threshold.

The problem presented here is that Fourier analysis does indeed decompose a signal into all of its constituent frequencues, but if the signal is coming from a guitar, then the frequencies might not be the ones you think you played...

To comment on this, feel free to either reply here or email me at s042314@student.dtu.dk

Hey Anonymous,

ReplyDeleteNo, you're right, I did cheat. I just took the theoretical frequencies for the notes in the A chord, added some noise, and plotted them by hand (although I did then run the fake signal through the fourier transform). If you want to send me what a guitar chord like that actually looks like, I would be happy to post it.

Thanks for reading and pulling the curtain aside,

Hugh

Oh, I'm sorry about leaving my name out of my previous post. That was unintended. :)

ReplyDeleteI'd love to help you out, but I'm afraid I have been unable to find an email address to mail the images to anywhere on the site. If you can post one here I'd be very grateful. Alternatively, simply send a dummy-mail to the address I posted above, and I'll reply to that.

Christian H. Pedersen

Hi Christian,

ReplyDeleteMy email is walter.lippincott@gmail.com, sorry for the delay in responding.

Hugh

Christian - see http://www.youtube.com/watch?v=mGYedBMmmzY

ReplyDeleteHugh - thanks for this it is sooo helpful. :)

I came across your post last weekend when I was thinking about making a prototype "Hero" that used a real instrument as the controller via a microphone. I figured, I would share the results here as they may be relevant.

ReplyDeleteIn my case the instrument was an accordion. There is still some noise, but even with a simple "peak detection" (and choosing the closest notes) seemed to work:

http://www.youtube.com/watch?v=dm4Kv_-Sen0

I uploaded the prototype, although I haven't tested it on other machines.

http://www.neilbirkbeck.com/?p=1895

Just came across your blog, and it has been very helpful with my research. In my mathematical research class, my project is Fourier analysis on music recognition to be able to input music and have the computer output sheet music. If you have any advice on certain steps I should take, or anything with Fourier really, if you could email me at carlyn62591@yahoo.com it would be greatly appreciated. Thanks,

ReplyDeleteCarlyn

I came across your post last weekend when I was thinking about making a prototype "Hero" that used a real instrument as the controller via a microphone. I figured, I would share the results here as they may be relevant

ReplyDeleteswtor goldtor creditscheap swtor creditsswtor creditsbuy swtor creditsswtor credits for saleFor Diablo 3 players, one of the most attractive things for the game in recent days must be the patch 1.0.7 on PTR server. Although it is just available on PTR, you can enjoy these great changes before final Diablo 3 patch comes out. Compared with playing in PvE, playing in PvP mode really needs amounts of Diablo 3 gold as well as Diablo 3 items as you may be greatly damaged even killed with PvE items for PvP mode. Need to buy Diablo 3 gold or Diablo 3 items online? CheapDiablo will never let you down. Today I would share a post about Barbarian items stats in patch 1.0.7 PvP which is tested in PTR server!

ReplyDeletetags:

buy diablo3 gold,cheap diablo3 gold,cheapest diablo gold,diablo 3 gold cheapThe CheapDiablo Team

Thanks. I always enjoy reading your posts - they are always humorous and intelligent.I am a china tour lover,You can learn more:

ReplyDeleteChina tourism|China travel service|China travel