Math on the fingers: let's count at least one Fourier series in the mind
- Tutorial
Do you need to read this text?
Let's check. Read the following:
A trigonometric Fourier series of a function  is a functional series of the form
where
Scary, but still I want to understand what this means?
So you under the cat. I will try not to use formulas.
Motivation
I am deeply convinced that mathematics can be approached on two levels: most people see it (they are taught it just like that) as a set of icons and rules for operations with icons, which leads to the masses of people who are injured by mathematics. And you can try to convey the meaning and ideas, not particularly focusing on the icons. Personally, I am incapable of a syntactic approach; in a chain of two formulas I will definitely lose some minus, which does not prevent me from being a mathematician quite successfully. Just in my head a graphics accelerator.
I already quoted Feynman about how he read all the equations, what he had to do:
Actually, there was a certain amount of genuine quality to my guesses. I had a scheme, which I still use today when somebody is explaining
something that I'm trying to understand: I keep making up examples. For instance, the mathematicians would come in with a terrific theorem, and they're all excited. As they're telling me the conditions of the theorem, I construct something which fits all the conditions. You know, you have a set (one ball) - disjoint (two balls). Then the balls turn colors, grow hairs, or whatever, in my head as they put more conditions on. Finally they state the theorem, which is some dumb thing about the ball which isn't true for my hairy green ball thing, so I say, "False!"
And while preparing this text, I came across a wonderful report by Henri Poincaré, who was perhaps the greatest mathematician of the late nineteenth and early twentieth centuries. He pointed out that even in such an abstract science as mathematics, intuitive concepts should be cultivated, for example, the concept of straightforwardness, although intuition should be verified by formal proofs.
His report is entitled "Du rôle de l'intuition et de la logique en mathématiques", in French you can read here , an English translation is available here . I highly recommend those interested in mathematics, read in one breath.
Update: Here lies the translation into Russian.
Unfortunately, conveying intuition is very difficult, but I will try, since the benefit of the transmitted intuition is incomparably higher than the benefit of conveying just icons.
What I rely on in this text
First of all, you need to know what a vector is, at least at the “arrow” level. Well, imagine that the arrows can be drawn in a significantly larger number of dimensions than 2 or 3. Well, and that you can store a vector in std :: vector.
Then the central concept is a scalar product.
On fingers, a scalar product can be represented as a measure of how much one vector is similar to another. That is, it is an operation that takes two vectors to the input, gives a number to the output. Data rationing is already the details, not very necessary yet. Therefore, if I have two arrows of unit length, then the scalar product is equal to one, if the arrows coincide, zero if they are orthogonal and minus one if they are opposite.
Lyrical digression
This is not just lyrics, this is an example that at first glance is not related to the topic of conversation, but in fact is its essence. If you want to understand further, understand the example. What is unclear, ask questions.
Let's take a look at the extremely practical task for a moment: I have a leisurely robot, and he must know where he is. The navigation system must be passive. I love extremely oak solutions, so I put two microphones on my robot (like a person’s ears). Then I have a beacon (actually several, but let's talk about one) that plays some (mono) sound in a loop. For example, this one:
These are just dry clicks, for simplicity we put one click per second.
The "ears" of the robot are at different distances from the lighthouse, and the sound propagates slowly, so each of the two microphones will record plus or minus the same signal, but with a slight delay, one relative to the other. I am not looking for easy ways, so I do not have laboratory conditions. Here, for example, looks like a recording in a few seconds:
Two channels by the number of ears, high noise level (music plays). The recording shows regular bursts of dry clicks, but directly looking for them in the signal is extremely difficult, sometimes the music is even louder than clicks.
How do I remove background noise? I remind you that my robot is completely leisurely. The most oak way is to record an hour of sound, then cut it into 3600 pieces in one second long (I have one click per second), and take the average between all these pieces of recording.
It will turn out something like this:
Peaks of clicks occur in each of 3600 pieces at the same place, and the rest of the noise is spread more or less evenly along the entire length, as a result, the noise leaves. By the way, I have several lighthouses, there is no synchronization between them, and there are only two ears. And that's exactly how I separate the signals from the lighthouses: one lighthouse clicks three times a second, another five, the third seven. (Very important) Cutting the same signal into pieces in 1/3, 1/5 or 1/7 of a second, I will get the signal from the right beacon!
So now I need to understand how one signal is shifted relative to another. I absolutely do not care where in the recording place I have a peak, I need a shift of one channel relative to another.
To begin, let's understand how I generally represent this signal in the memory of the machine. I am writing a regular wav with a sampling frequency of 44100Hz. The record length is one second, so I just have two arrays (vectors!) Of real numbers with 44100 elements.
We fix one vector, and the second 44100 times cyclically shift to the right. (Very important) Let's calculate 44100 scalar products and take the shift at which this scalar product is maximal. That is, it is this shift that maximizes the similarity of the two signals. Congratulations, you just found the cross-correlation function!
Update: good commentary with illustration.
Now let's count the Fourier series in the mind
The previous section is very important, but for now let's postpone it and try to count on our fingers a simple Fourier series.
As an example, let's take a simple square wave, so beloved in electronics. I draw graphics in sage .
def square_wave(t): return (sgn(sin(t))+1)/2
t = var('t')
plot(square_wave(t), (t, -10*pi, 10*pi),figsize=(10,2))
This is a simple periodic signal with a period of 2 pi. Half the time it is zero, half the time is one. Let's take the coefficients of the Fourier series (see the beginning of the article).
Zero frequency
The coefficient a0 is just the average of the signal, it is obvious that it is equal to half. How to count a1 and b1?
First frequency
And here I propose to draw one period of our signal, but this time not in the ordinary Cartesian coordinate system, but in the polar. Total, our angle goes from zero to two pi, and we get the following picture:
parametric_plot((cos(t)*square_wave(t), sin(t)*square_wave(t)), (t, 0, 2*pi))
Why in the polar system? Very simple. How are the polar coordinates of the point (r, alpha) converted to Cartesian?
x = r cos (alpha),
y = r sin (alpha).
And what do we have under the sign of the integral in the formula for a1 and b1? That's right, f sin (t) and f cos (t). It remains to integrate. How to do it in the mind? Imagine that this is not a mathematical graph, but a piece of wire. Let's find his center of gravity. Obviously, it will lie on the ordinate axis approximately in the center of our arc (in fact, at a distance of 2 / pi from the center, well that's not the point, let's call this distance A): The
coordinates of the red dot (the center of gravity of the graph) are the integrals we need (up to multiplication by a constant, well, that's not the point). By the way, can you say why this is so?
Total a1 = 0, b1 = A.
Second frequency
What about a2 and b2? Let's do a polar graph again, “winding” our regular graph around zero. The only thing that we will now reel, making two turns.
First turn:
parametric_plot((cos(2*t)*square_wave(t), sin(2*t)*square_wave(t)), (t, 0, pi))
parametric_plot((cos(2*t)*square_wave(t), sin(2*t)*square_wave(t)), (t, pi, 2*pi))
The second revolution will obviously be empty, our square signal at this moment is zero:
The center of mass of the first + second graphs is obviously at zero. Thus, a2 = 0, b2 = 0.
Third frequency
Now we wind around zero one period of our function three times, for clarity, I show three turns on separate graphs:
The first turn fills our circle completely, the second half is half, and the third is empty. If one full turn weighs one kilogram, then we have one kilogram at zero and a pound at a distance A from zero. Total, the center of gravity will be at a distance of A / 3 from zero.
a3 = 0
b3 = A / 3
Higher frequencies
What will happen with the fourth frequency? Two filled turns and two empty, center at zero. And so for all even.
What will happen with the fifth frequency? Two filled, two empty and one half-turn. Total center of gravity on the ordinate axis at a distance of A / 5 from zero.
To summarize
If we look again at how we consider the integrals, it becomes clear that between our signal (square wave) and the functions cos (nx), sin (nx) we are looking for scalar products. That is, we look how much our signal is similar to cos (nx) and how similar it is to sin (nx). Winding up a certain number of times the graph of the (periodic!) Function around zero, we extinguish all frequencies except the current one.
The polar angle of our center of gravity says how much the signal looks like the corresponding sine or how much it looks like the corresponding cosine. And the distance at which the center of gravity is located indicates the strength of their contribution to the formation of our signal.
Total, our series is f (x) = 1/2 + 2 / pi sin (x) + 2 / (3 pi) sin (3x) + 2 / (5 pi) sin (5x) + ...
Homework
1) Do you understand the connection between the robot example and the square wave?
2) How is the Fourier series related to the Fourier transform?