Hello and welcome to
the University of Southampton,
School of Mathematics
Virtual Open Day.
I’m Nick Wright.
My area is pure mathematics.
I’m also the admissions
tutor for mathematics.
So, if you apply
for a place here
and when things get a bit
more back to normal,
when you’re actually able
to come and physically visit,
I’m one of the people
who you’re very likely to see.
So, the idea
of this lecture here,
it’s a taste of some
of the mathematics that you’ll
learn here at Southampton.
Hopefully, it’ll be kind
of fun and interesting.
I’m going to talk about
the mathematics of vectors,
and how it’s applied
to the theory of sound.
Now, this connects
with all sorts
of areas of mathematics.
So, if we’re trying
to understand sound,
this relates to calculus.
It relates to
differential equations.
But it also relates
to lineal algebra,
meaning vectors and matrices
and things like that.
That’s the area that’s
going to be my focus today.
Let’s start with sound waves.
We’ve all seen a picture
of a sound wave.
We know roughly
what it looks like.
So, the horizontal axis is time.
This is a recording,
actually, of someone
playing the violin.
We’re going to measure
time in milliseconds.
So, here, we’ve actually
got five seconds,
5,000 milliseconds.
But to see the shape
of the wave,
we have to zoom in.
We have to take a very
small part of this picture
and expand it out.
So, now we’re looking
at merely two or three
milliseconds of sound,
and you can see the detail
of the wave at this point.
Mathematically, the simplest
example of sound is a sine wave.
So, this is just
a sine function.
So, we’ve got here Y
equals A sin 2 pi FT.
T is time.
F is the frequency.
So, that’s the pitch
or note of your sound.
And A is the amplitude.
So, how tall the wave is.
So, now let’s look
at some sine waves
of varying frequencies.
So, we’re going to start
with this one.
That’s a middle C.
That’s a frequency of 261.6256.
The digits go on
forever, in fact.
This next one,
that’s the A above middle C.
That’s 440 Hz.
Now, what we’ve done
here is we’ve squashed
the wave together.
We’ve increased the frequency.
So, it’s oscillating
more rapidly.
And then the third one here,
the A below middle C,
that’s 220 Hz.
Now, notice that the As are
nice round numbers.
That’s because the frequencies
of notes are really
defined relative to A…
The A above middle C
is defined to be 440 Hz,
and everything else
is done relative to that.
The two As differ
by a factor of two,
and that’s because an octave
in music is a factor of two.
And so, when you
double the frequency,
you’re going up by an octave.
When you half the frequency,
you’re going down by an octave.
It’s worth thinking about
what would it mean to go half up
or down half an octave.
Because the change
is multiplicative,
the number of frequency halfway
between 220 and 440,
that’s not going to be 330 Hz,
because if I’m going up
by a factor of 1.5,
if I do that twice,
I’ll have overshot, I’ll have
gone up by a factor of 2.25.
So, actually, the factor
which will be half an octave is
actually the A square root of 2.
Two of those
multiplied together,
giving you a whole octave.
C is actually a quarter
of an octave up from an A,
and so that’s actually
a fourth root of 2.
And if you get your calculator
out and try this, 220 Hz,
multiply that by
fourth root of 2,
you will get this
funny 261.6256 figure.
Now, the sine waves themselves,
they don’t really
sound very good.
They’re not particularly
pleasant to listen to.
So, to make it a bit
more interesting,
here’s one which combines
two sine waves.
I personally think
this one sounds a little bit
like an old 80s electric organ.
Maybe the 80s electric organ
worked precisely by combining
two sine waves together.
So, when I do this combination,
what am I really doing?
I’ve got one sine wave.
That’s the blue
one in the diagram.
And then I’m adding a sine wave
which has got two times the
frequency of the original one.
It’s going up
and down twice as fast,
but only half the amplitude.
And so, at the beginning,
where they’re both positive,
these things reinforce,
and then you start
to get cancellation.
And then when they’re
both negative, they both,
again, reinforce again.
If we want to make slightly
more interesting sounds,
we can add several
sine waves together.
So, this next one here,
this is basically
following the pattern.
I start with one frequency,
and then I add
twice the frequency.
Actually, I’m doing three times
and four times and
five times the frequency,
but at each stage
halving the amplitude.
Of course, time is
a continuous variable.
But when we plot a sound wave,
or when we store it
on the computer,
or on your phone,
or, indeed, being
a bit old fashion,
we read it off a CD, then we
can only look at a discrete,
finite set of values.
This is called sampling.
We sample the sound
wave at some very,
very large number
of times per second.
And for a CD,
for example, it’s
44,100 times per second.
We just look at the values
at those finite set of times,
and we don’t worry
about the values in between.
This process of
discrete sampling is
where the term sample
comes from in music,
meaning a recording of someone’s
song or what have you.
Now, the human ear can hear
ranges of sounds from about
20 Hz up to 22,000 Hz,
and that’s where
this 44,100 comes from.
You need a number
that’s just a little bit bigger
than twice the maximal frequency
that you’re trying to record.
So, what does all this
got to do with vectors?
Well, let’s start off
by asking ourselves
what is a vector?
What do I mean by vector?
If I had to describe
a vector to someone
who’ve never come
across the concept before,
what would I say?
Well, I might start
by drawing a picture
and basically say,
well, a vector is
some sort of arrow.
It points in
some direction here.
If I want to be
a bit more mathematical,
I might give a list
of coordinates, say 0 1,
for instance, meaning
0 component horizontally
and a vertical component of 1.
If I want to be a little
bit more conceptual,
I could talk about a vector
as being a quantity that has
magnitude and direction.
Now, there isn’t a single
right answer here.
They’re all really different
aspects of the same idea.
Now, when I describe
the magnitude, that’s easy.
It’s just 1.
And for direction,
I need to say relative
to something else.
So, for instance,
it’s 1 in the direction
of the Y axis.
And actually, the coordinates,
as we saw,
are also relative.
That’s in terms of the axes.
And I might also want
to think about measuring
the vector relative
to some different set of axes.
So, suppose I want to resolve
the vector into components
not horizontally, vertically,
but in some other direction.
Say, I take an angle
of pi by 4 to the axis.
So, I have two vectors here.
I’ve got vector U,
which goes in that direction,
and the vector V,
which goes in this direction.
They’re both pi
by 4 from the axis.
So, their coordinates are
cosine pi by 4 and sine pi by 4.
And then for V,
minus sine pi by 4
and cosine pi by 4.
You might remember
that cosine and sine of pi
by 4 are actually equal.
Both of them are just one
over the square root of 2.
Or if you’ve seen
the square root of 2 over 2,
that’s the same thing.
Now, if I want to resolve
the vector into its components,
then there’s a useful
tool I can use,
which is something
called the dot product.
You might see this
in your A-levels.
If you haven’t seen
it, don’t worry.
It’s actually really
quite simple to explain
how you do the dot product,
but also very useful.
So, if I have two vectors… Here,
I’m just taking
two-dimensional vectors.
So, one of them is PQ,
the other one is XY.
I just multiply
the first component together.
So, I have P times X,
and the same thing
with the second component,
Q times Y,
and I add them up.
So, very simple rule,
but it’s very
useful because it’s
got this interesting
geometrical interpretation.
If I take the dot product
of two vectors A and B,
what I get is the length
of A times the length of B times
the cosine of the angle
between the two of them.
Now, in particular,
suppose one of those factors
is a unit vector,
a vector with length 1.
Then, well, then I
do the dot product.
I just get the length
of the other vector times cosine
of the angle.
But now, if I think
about the right triangle
that I’ve drawn here.
So, I’ve got the U direction,
and then I’ve got
the A vector,
and then I draw a perpendicular
from the A vector
onto the U direction.
Well, the component of A
in the direction of U is
exactly A cosine theta,
the length of A cosine theta.
So, the dot product computes
the components for us.
And that’s means I can write
my original vector,
the vertical one as some number
of Us times some number of Vs.
And the number of Us
and the number of Vs
that I need is simply
given by the dot product.
So, I take the dot product
of U with my 0 1 vector,
and that means I take
0 times 1 over root 2.
That’s 0.
And then I take 1 times 1
over root 2.
That’s 1 over root 2.
So, that’s one dot product.
The other dot product actually
turns out to be the same thing
because it’s only dependant
on the second commandment
of the use of Vs,
and those are both
1 over root 2.
And so, this means I can build
my 0 1 vector as 1
over root 2 times U
plus 1 over root 2 times V. So,
now let’s get back
to sound waves and sampling.
When I sample a sound wave,
what I get is my data is
some list of numbers.
Those are supposed
to be the amplitudes
at various different,
small time intervals.
But if I have a list of numbers,
I can think of it
as being a vector.
Now, normally, you’re used
to thinking of vectors
with two or three coordinates.
Now, we’re going to have
probably thousands of them.
But at the end of the day,
the algebra behind it
is kind of similar.
Maybe we want a computer
to actually do the calculations
for us because it
can be quite long-winded,
but the ideas are
kind of the same.
Remember when we
talked about vectors,
we said that there are
different coordinate systems,
and the same thing is true
here with the samples.
So, when the sample comes to us,
it comes in one
coordinate system.
So, the first coordinate
is the first sample.
The second coordinate
is the second sample.
Basically, each coordinate
corresponds to the amplitude
at a different time.
But here’s another coordinate
system we might use.
We might try to use some sort
of coordinate system
based on frequency
so that we can split
the waves out
into their separate frequencies.
Now, our motto from thinking
about the vectors is
that dot products compute
components for us,
and the same thing
is going to be true here.
We’re going to use
dot products to compute
frequency components of a sound.
So, to be specific,
let’s look at
the sine wave again.
So, we’ve got sine of 2 pi FT.
Remember, F here
is the frequency.
Now, normally, frequency
is measured in hertz.
That means the total
number of cycles,
the total number of oscillations
that we have per second.
And T there is then
measured in seconds.
So, now T is going to…
If I have N samples taken
over one second,
then T is going to be 1
over N, 2 over N,
3 over N and so forth.
So, I’m evaluating sine
of 2 pi FT at T is 1 over N,
2 over N and so forth.
So, I’ll get this long vector
with entry Z. Now,
to make this
a little bit simpler,
I’m going to define
a new frequency, capital F,
which is little F divided by N,
and now I’m just, basically,
I’m just changing the units.
Instead of asking
about the number
of cycles per second,
I’m asking about the number
of cycles per sample.
Now, actually,
if I’ve got three
cycles per sample,
this is going to be
no use whatsoever
because sampling is going
to miss two out of three cycles.
So, the number of cycles per
sample is going to be something
or needs to be something
that’s less than one.
Really, we want several samples
per cycle rather than
several cycles per sample.
So, this F is going
to be some fraction
that’s less than 1.
The capital F. Little
F should be an integer.
That’s because we want
things to sort of match up.
If I get to the end
of my one second clip,
I want it to have completed
a full number of the sine waves.
So, little F needs
to be an integer,
and that means
that capital F can be 0,
1 over N,
2 over N and so forth,
and it can go up to a half.
The reason we can’t go
beyond a half is that
if I swap capital F between…
Say I have a number
bigger than a half,
like 0.7 in this example,
if I look at the frequency
of 0.7 and the frequency
of 1 minus, that’s 0.3.
When I take those samples,
I will get exactly
the same value.
Well, actually, I get it
with a change of sine.
This is because sine
of 2 pi N times 1 minus F,
sine of 2 pi N
actually is just 0.
We’ve made 2 pi N…
We’ve made N full cycles.
So, I’m just left with sine
of 2 pi N times minus
F.
And this picture
illustrates the problem.
If I look at the sine
with frequency 0.7,
that’s the green one,
the faster one,
and I compare it with the sine
with frequency 0.3,
but negated, it’s
turned upside down,
so it starts off by going down
and then up and so on,
when I evaluated
those discrete points,
that’s what the red lines
are indicating there,
the individual samples,
I will get exactly
the same thing from the blue
and from the green.
So, if I have this higher
frequency green wave,
and I just look
at those discrete points,
it looks like I’ve just got
this lower frequency blue one.
And so, that’s why
our capital F had better
not be any more than a half.
And actually, going back to
what we were saying earlier.
The human ear can hear
up to 22,000 Hz,
and so our sampling rate
needs to be double that,
because if I’m
sampling 22,000 Hz,
but I’m sampling
44,000 times per second,
then that gives me the value
of capital F equals a half,
which is the biggest
we’re allowing it to be.
So, as a variant on this,
we might replace
the sine function
with the cosine function.
But actually,
this gives us a sound
that really kind of
sounds the same to us
because what we’re doing
here is… The cosine function,
the sine function,
you just get from one
to the other by shifting
them a little bit.
All I’m doing is
I’m shifting the start time
by one quarter of the period.
So, 1 over 4F here.
Of course, I can shift
by any number from 1
up to capital N here.
And so, at first sight,
it looks like I’ve got
N different vectors,
all with the same frequency.
But actually, I only need
to think about the sine vector
and the cosine vector,
and I can build all
the other ones from that.
So, that uses one of
these trig identities that you
probably don’t really remember,
but trust me
this is the formula.
Sine of A plus B is
sine A cos B plus cos
A sine B.
I’ve written it as cos B sine A
instead of the other way
around just because of
how I’m going to use it.
So, looking at my vector here,
I’ve got, say,
sine of… Let’s take
the third coordinate here.
I’ve got sine of 2 pi times 3F
plus 2 pi times F.
And then the formula says
I can write that as cosine
of 2 pi F times sine
of 2 pi times 3F,
and then plus the same thing
but with the As
and Bs switched around.
And notice that all
the way through this,
I’m going to get a cosine 2 pi
F term plus a sine 2 pi F term,
and then I’m going to get
varying terms of sine 2 pi 3F
and cosine 2 pi 3F and so forth.
So, putting this all together,
this one vector,
which is I shifted
my start time by one,
I can write that
as the sine vector
that I had times some scalar,
which is given by this cosine,
plus the cosine vector
times some scalar,
which is the sine.
So, again, this is a case
of taking vectors and resolving
them into components.
We have this vector,
which was I took the sine wave
and I shifted it by one.
Now, what I see is
I can resolve it
into two components,
a sine component,
and a cosine component.
And of course,
I could shift by two or three
or four and so on.
All that’s going to do is
change those coefficients
that I put at the front
of these two vectors.
Fourier theory is the idea that
any time you have
something that’s periodic,
that repeats, it can be built
out of sines and cosines.
Now, the fact
that you can do this
for absolutely anything
that repeats is really
a remarkable fact.
So, in terms of vectors,
what we’re saying is
that absolutely any vector
that you can write down,
can be built out of sines and
cosines of various frequencies.
So, to do this,
we’re going to use
the dot product.
For that, remember we wanted
to have unit length vectors.
So, what we’re going to do is
we’re going to take the sine
and cosines and rescale them
to make them unit length.
Turns out the factor we need
is the square root of 2 over N.
That’s another of
these trig identities.
I’ll call it an exercise
and leave you to work
that out yourself
if you’re really keen.
The hint is you use
the double angle formula.
So, to summarise,
how many vectors have we got?
We said that there are
actually N over 2 plus
1 possible frequencies,
ranging from 0 up to a half.
So, N over 2 would range,
say, from 1 over
and up to a half,
but we got 0 thrown
in there as well.
So, that’s an extra one.
And for each
of those frequencies,
I got two vectors,
the cosine one
and the sine one.
So, in total,
that’s N plus 2 vectors.
That’s actually more
than we need
because we’ve only
got N coordinates.
But actually, turns
out exactly two of those vectors
we’ve written down are 0.
If I take the
frequency F to be 0,
and I put that into the sine,
I’m just evaluating
sine of 0 repeatedly.
That’s 0.
On the other hand,
if I take the frequency F
to be a half,
it’s fine in the cosine one.
But in the sine one,
again, I’m going to get 0.
I have sine of 2
pi N times a half.
That just means I’m evaluating
sine of pi times N.
And of course, again,
those are all the 0 points
of the sine function.
So, that gives me
exactly N vectors now,
once I throw those two away,
and that’s exactly
the number of vectors I
need to build any other vector.
Now that we’ve learnt how it is
that we can decompose one
of these sound waves
into its component frequency,
in terms of sines and cosines,
let’s look at an example.
First example we’re going
to look at is the square wave.
Now, a square wave is
a very simple wave.
It just alternates
between some positive value
and the same thing
but negated in this kind
of square shape.
What we have here
is a square wave
with frequency 440 Hz.
Remember, that’s the A
above middle C.
And to decompose it into
the component sines and cosines,
what we need to do is to compute
a bunch of dot products,
the dot products
of each of these sines
and each of these cosines.
So, for the cosines,
we can work out what
that is fairly easily.
What we see is
that… Remember the rule
for the dot product, each term,
each sample in our square
wave vector is multiplied
against the corresponding sample
in the cosine vector,
and then we add all of those up.
But in the square wave,
the terms we’re multiplying
by are basically either
plus 1 or minus 1,
up to some rescaling.
And so, what I’ve done here
is I’ve drawn the cosine
that we’re trying
to take a product with,
but I’ve drawn it alternately
in red and blue.
So, blue indicates
where the cosine
is multiplied by plus 1,
and red where it’s
multiplied by minus 1.
And you see the blue section
at the beginning
and the red section at the end
basically look the same,
apart from their colour.
Of course, one is reversed
from the other one.
But when we add
these terms together,
when we add the red term
and the blue term,
we’re going to get 0
because the red term
is multiplied by minus
1 and the blue term
is multiplied by plus 1.
So, the dot product is 0.
It’s going to total 0.
And if I have a cosine
with higher frequency,
so here it’s oscillating
twice as fast, we’re going
to get the same answer.
We’re going to get 0 again.
Now, for the sines,
it’s a little bit
more complicated.
Remember actually
we’ve got to look
at 22,000 different frequencies
if we’re sampling at 44,000 Hz.
So, in principle,
we’ve got 22,000
terms to compute.
Of course, we
can reduce it down.
We can simplify this.
But just to save time,
we’re going to put it
into the computer,
and the computer
will tell us the answer.
Here it is.
Again, for most
of the sine terms,
the dot product
is again going to be 0,
but we just see spikes
at a certain discrete
set of frequencies.
Now, what are those frequencies?
Well, the first
of those frequencies is 440 Hz.
That was the frequency
of our square wave.
And then the next one is
not two but three times that.
Okay, so we have here
three times 440 Hz.
And then the next one
is not 4 but 5 times
that 440 Hz frequency.
So, we get basically
that original base frequency,
but then multiplied by 1, 3,
5, 7, all the odd multiples,
and those are
where we get the spikes.
Our next example,
some musical instruments.
For each one,
I’ve sampled a single note
and then looped it
to give us something
that we can Fourier transform.
We have a violin, a cello,
and a French horn.
Here are pictures
of the sound waves.
In no particular order,
we’ve got a French horn,
we’ve got a cello,
we’ve got a violin.
Your challenge is to try
and work out which is which.
Now, it’s not so obvious just
looking at the sound waves.
If I moved
the frequency analysis,
on the other hand,
now the differences become
rather more striking.
So, what I’ve done here,
I’ve not separated out
the sines and cosines.
I’ve just shown
the total amplitude
for each given frequency.
So, combining the sine
and cosine terms together here.
The first thing we noticed is
that, much like we have
with the square wave,
this is the first frequency
that we see,
and then we get various
multiples for that frequency.
That’s really the
characteristic of something
like a musical instrument.
That is the frequency
that you hear
of that instrument,
whether it’s an A
or a C or what have you.
Now, the other thing
that we notice is
that the middle instrument, the
second one there, is definitely
kind of an odd one out.
It’s rather different
to the other two.
By the time I’ve got the first
two frequencies of this… So,
the first frequency
has this amplitude,
and then the second frequency
has that amplitude.
But once I’ve got those two,
that’s actually more
or less the whole way.
All the other frequencies
have very low amplitude.
So, that definitely looks
like the odd one out,
and sure enough, yes,
that one really is
the French horn.
Now, what about the first
and the third?
That’s the cello and the violin.
Which one is which?
Well, again,
there are similarities
and there are differences.
If I look at that first one,
the frequencies jump
up and down,
up and down a little bit.
There’s no particular
spike there.
Whereas, in the last one,
a bit like the French horn,
there is this big spike
on that second frequency.
So, that’s perhaps
a key difference
between these two instruments
in terms of their sound.
The other thing that you
probably noticed is that
when I compare
the one at the top
and the one at the bottom,
actually, the spikes
are much closer together
at the one at the bottom.
In fact,
we’re getting essentially
twice as many spikes.
And that means
that our lowest frequency
that we have here is
definitely a little bit lower.
So, we have violin,
we have French horn,
and we have cello.
Here’s another application
of Fourier theory.
The clip you just heard is
a recording of Lewis Hamilton’s
engine from the Brazilian
Grand Prix last year.
At the time,
Lewis is running in third place.
He’s chasing down Pierre Gasly,
who’s currently in second
in the Toro Rosso.
Now, we hear
that Lewis is accelerating,
but what else can we tell
from analysing the sound here?
Well, I’m not going
to take the whole sound.
I’m just going to
take the end of it,
when the revs are
at their highest,
and I’m going to loop
that to give us something
that we can Fourier transform.
So, here’s the sound
that we’re actually
going to transform.
What we’re going to do is work
out its decomposition in terms
of sines and cosines.
More precisely,
the computer is going to work
that out for us.
So, here are the graphs.
The first one,
the blue graph,
that’s basically telling
you the amplitude
for each of the cosines.
The cosines are multiplied
by those numbers indicated
in the blue graph.
They may be positive
or negative because we can,
of course, negate the cosine.
Similarly, the sines are
multiplied by the frequencies
that we see in red there.
Now, what’s noticeable is
that both the sines
and the cosines have
a big spike there at 660 Hz.
So, what does that tell us?
Well, the engine, obviously,
a large part of the noise
from the engine is the firing
of the cylinders.
So, this big spike
at 660 Hz,
that’s telling us how regularly,
how frequently the
cylinders are firing.
Now, Formula One
engines are V6s.
That means the engine
has six cylinders.
So, if the cylinders are firing
660 times per second,
that means each individual
cylinder is firing
110 times a second,
giving us 660 as the total.
A very, very small amount
of information about
how engines work here.
These engines are
what are called four-stroke.
That means that it takes
four movements of the piston,
that’s in and out,
in and out again,
for each firing of the cylinder.
The first movement is
where the fuel is drawn into
the cylinder and compressed,
and then the second movement
is actually the ignition,
followed by the exhaust gasses.
So, all in all,
what that tells you is that
if each cylinder is firing
110 times per second,
the engine has a full revolution
220 times per second.
Well, RPM means revs per minute.
So, we just have to multiply
that by a factor of 60 to find
out what the RPM is
for the engine.
So, that tells
us that, actually,
Lewis Hamilton’s engine at
the top end of the revs
is currently running at
13,200 revolutions per minute.
Now, that’s kind of interesting.
In particular,
it would be interesting
to Pierre Gasly to know this
because that probably
means Lewis has turned
the engine up a little bit.
Formula One engines,
they don’t usually run
at their maximum revs
because they need to save
the engines for future races.
The engines have to last
a certain period of time.
And so, a typical race
RPM might be, say, 12,000.
The fact that Lewis has turned
it up to 13,000 plus indicates
that they are actually
really pushing hard to try
and catch Gasly.
Now, of course,
the fact that I
can do this means
that Formula One teams
can do this as well,
and indeed sound analysis of …
This is a very basic example.
They, of course, use much
more advance techniques,
looking at many
of the frequencies,
not just this one big spike.
But these ideas
of sound analysis are used
in Formula One to monitor
what the opposing
teams are doing.
Thank you for listening.
I hope it’s been
interesting and inspiring.
If you do have any questions
about our programmes
or you want to know more,
please do get in touch.
