part the dark side of mathematics

26
Notes about the Dark Side of the Mathematical Force by Mikhail Konnik 100 200 300 400 500 600 700 800 900 1000 Figure 1: The beauty of a (seemingly) boring function  f (x) = x x + c. an obligatory tribute to the Star Wars - the best science ction ever made

Upload: mvkonnik

Post on 09-Jan-2016

11 views

Category:

Documents


0 download

DESCRIPTION

Notes about high school mathematics (unfinished)

TRANSCRIPT

Page 1: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 126

Notes about

the Dark Side

of the Mathematical Forcelowast

by Mikhail Konnik

100 200 300 400 500 600 700 800 900 1000

Figure 1 The beauty of a (seemingly) boring function f (x) = xx + c

lowastan obligatory tribute to the Star Wars - the best science fiction ever made

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 226

Abstract

These notes are about high school mathematics what it really means and how it can be turnedinto something fun and useful Over the years Irsquove been collecting neat examples interestingproofs and small programs that illustrate mathematical concepts so this is not a watered-downldquomath for liferdquo kind of text there are proofs and derivations so the reader is invited to workon them On the other hand these are not obscure textbook-type examples either - theseexamples are taken from real-world applications of mathematics in physics engineering andeven biology This is because the author is actually a researcher in optical engineering and nota pure mathematician

The contents of typical textbooks is usually not a problem - the very way how the math-

ematics is being taught is the problem The very way how mathematics is usually taughtleaves students with a feel that math is something useless distant and unnecessary

Imagine that the music theory is compulsory for high school courses which means that youhave to become really good at reading and manipulating musical score on a paper To pass thefirst music course you need to be able to draw the treble and bass clefs in exactly the rightposition and know how to draw the whole half quarter and eighth notes you have to knowwhich positions in the sheet correspond to which musical notes and so on Yet the teacher willnever allow you to sing a note or play an instrument

As a result a student will know everything about music theory What for Well it is a usefulskill you know Would you say a student who excels in this practice is good at music Hardlythe student is likely to hate music to the rest of his life

But this is precisely what high school students are subjected to in math class We force them

to memorise the precise details of solving algebraic equations and polynomial inequalities Werequire them to be adept at simplifying fractions involving radicals drawing accurate sketchesof ellipses and hyperbola from their equations and writing out the steps of a geometric proof insuch pedantic detail that would make a grown mathematician cry

So when a freshman high school student tells me that he was always good at math it translatesto ldquoI was very good at following obscure steps to manipulate mysterious symbols without anyreal understanding of what I was doingrdquo

Mathematics is not about numbers or formulas - it is about models of a real-world processesIt is in a way a purified form of a real-world The simplest way to say it is that mathematics isabout recognising and reasoning about patterns These patterns can come from anywhereshapes numbers relationships at a party physical systems tournaments card games The ideais not just to dump mathematics on students but to bring mathematics to life and show how itworks through applications in physics engineering and programming so math will not be just a

bunch of formulas but a powerful toolbox for solving real world problems

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 326

Chapter 1

Trigonometry

Trigonometry deals with the set of functions that allow us to work with angles calculate the

properties of triangular and model waves of any nature It also allows us to break wine glasseswithout touching them unearth signals buried in noise efficiently compress music and imagescontrol flames transmit and receive information determine our geographical coordinates and alot more

11 Brief introduction

Letrsquos make a plot of two trigonometric functions y = sin(x) and y = cos(x) by substitutingnumbers into them - like in Figure 11 for x isin [0 7]

0 1 2 3 4 5 6 7minus1

minus08

minus06

minus04

minus02

0

02

04

06

08

1

cossin

Figure 11 The cosine and sine functions plotted on a range of numbers from 0 to 7

That is we just made two columns of numbers x and y and in the X column we put numbersfrom 0 to 7 with step 01 - either by hand or (better) writing a program in MATLAB or Octave

1

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 426

That is we just put x = 0 01 02 all the way to 69 and finally 7 Each of the number in theX column we substituted into cos(x) and sin(x) giving us corresponding values of the functionswhich we put into Y column Then we plot numbers in X against numbers in Y

12 Why do we need trigonometric functions

These obscure mathematical functions look completely detached from real world and ultimatelyuseless But letrsquos take a closer look at say a smartphone and try to find some applications of trigonometric functions cos(x) and sin(x) there

1 when you speak you produce soundwaves (human vocal cord changes the air pressure)that are sensed by a microphone and converted into electric signals for transmission

2 what you say during the call is send to a cell-tower as a radiowave

3 various communication networks like WiFi and Bluetooth use electro-magnetic waves

too4 whenever you want to know where are you on the map you use the GPS (global positioning

system) or cell tower triangulation method to determine your location

5 when you look at the screen you see lightwaves and the image on the screen is formedby turning their angle (light polarisation angle)

6 the images themselves say from the camera are compressed to reduce size and occupyless space using trigonometric transforms (Discrete Cosine Transform)

7 when you donrsquot want to be disturbed you can put the smart-phone in vibration modewhich produces vibration waves

It seems like our smartphones are packed with waves of different origin Letrsquos see if those

waves have anything to do with that boring trigonometry

121 Sound waves and the cosine function

What do soundwaves and cosine functions have in common To answer this question letrsquos writea simple program that can generate a tone A tone has its pitch (also called frequency) andvolume (loudness or amplitude)

Sound frequency When you record the tone on a computer you see a waveform - this is justthe levels of sound proportional to air pressure made by the sound For example we can record asound tone with 400 Hz frequency (that is the soundwave will do 400 turns per second) and plotit Figure 12 The plot of a soundwave looks just like the cosine function on Figure 11 except

for the amplitude (volume or difference between the maximum and the minimum) and pitch (orfrequency) We can go further and record a tone with 800 Hz - twice the pitch compared to 400Hz and compare them both

Not surprisingly the tone has twice the pitch so it makes two times more turns per secondLetrsquos generalise this example and compare cos(x) with cos(2lowastx) - this is exactly what we did inthe example above with two soundwaves of 400Hz and 800Hz frequencies Plugging the numbersin a calculator is very tedious and plotting many points on a paper is even more so - but we canask a computer to do this job If we use a mathematical programming language like Octave andwrite a simple program like this

2

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 526

2 4 6 8 10

x 10minus3

Figure 12 The tone of 400 Hz (blue) and 800 Hz (green)

x = 0017

y = cos(x)

y2 = cos(2x)

figure plot(xyxy2)

legend(cos(x) cos(2x) Location SouthEast)

which means that

1 x = 0017 generate the row of numbers from 0 to 7 with a step of 01

2 y = cos(x) substitute numbers from x into cos(x) function to get row of cosine values y

3 y2 = cos(2x) substitute numbers from x into cos(2lowastx) to get row of cosine values withdouble frequency (2x) in y

4 figure plot(xyxy2) to plot y and y2 values on a plot like the one in Figure 13

If we compare plots in Figure 12 and Figure 13 we discover that they are very similar- in fact the trigonometric functions y = cos(x) and y = cos(2lowastx) are describing the soundwavesof two pitches 400 Hz and 800 Hz (single and double frequency)

Takeaway trigonometric function cos(x) is a very good model of a soundwave(that is a pure tone) doubling the frequency of the tone (from 400 to 800 Hz) in ourexample) can be well described by doubling the variable inside the cosine functionfrom y = cos(x) to y = cos(2 lowast x) In fact it does not matter if this is a sound wavea light wave or a wave on the surface of a pond - the cosine function will model themas well just change the frequency and amplitude accordingly

But you may notice that the values on a vertical axis in Figure 12 and Figure 13 are verydifferent - this brings us to the notion of amplitude

3

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 626

0 1 2 3 4 5 6 7minus1

minus08

minus06

minus04

minus02

0

02

04

06

08

1

cos(x)

cos(2x)

Figure 13 The plot of y = cos(x) and y = cos(2 lowast x) where x are from 0 to 7

Sound volume (or amplitude) Every time your listen to the music you use that little knobcalled ldquoVolumerdquo to make the song louder or quieter Your music player changes the amplitude of the soundwaves - yes those cosine waves above If we make another plot of two cosine functionsy = cos(x) and y = 2 lowast cos(x) we can see from Fig 14 that those plots are just scaled versionsof one another

0 1 2 3 4 5 6 7minus2

minus15

minus1

minus05

0

05

1

15

2

Figure 14 The plot of y = cos(x) and y = 2 lowast cos(x) where x are from 0 to 7

4

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 726

This brings us to a more general model of a wave

y = A lowast cos(F lowast x)

where A stands for amplitude - a constant that controls the scale of the function (volume of a soundwave) and F stands for f requency - a constant that controls how many complete turnsthe function does (pitch or a tone of a soundwave) The cosine function cos(x) is a idealisedmodel of a wave with unit amplitude and unit frequency and this is why it returns the valuesfrom -1 to 1

By now you should see that you cannot just take the number N out of brackets in cos(N lowastx)and put it in front of the function - you cannot convert the frequency into volume this easilyThe conversion is a bit more complicated and we will see it in trigonometric identities below

5

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 826

13 Trigonometric identities derivation and meaning

As we have already seen we can think of trigonometric functions as models of waves that can bedescribed as y = A lowast cos(F lowast x) Here A stands for amplitude F stands for f requency and x isa running variable (time for example) But apart from generating pure tones cosine and sinusfunctions do not take us very far - we need to know the relationships between them if we want touse trigonometry for something useful Relationships between trigonometric functions are morecomplex than just adding numbers and there are formulas that describe those relationships

But there is no need to memorise all the formulas once you understand few basic trigono-metric identities how the really work you will be able to easily derive the rest of the formulas

131 Sum of squares

One of the most useful identity is a sum of cosine and sine squares

sin2(x) + cos2(x) = 1 (11)

If you look at Figure 18 you will notice that when a cos 2(x) has its Y -value at 05 so doesthe sin2(x) If you add them together the result will be equal 1 Moreover all other points onthe plot for cos2(x) and sin2(x) will give 1 in sum when one of the functions is at valley anotherhas a peak at 1 and so on Therefore the sum of squares sin2(x) + cos2(x) always equals 1

minus5 minus4 minus3 minus2 minus1 0 1 2 3 4 50

02

04

06

08

1

12

14

cos2(x)

sin2(x)

cos2(x) + sin

2(x)=1

Figure 18 The plot of sin2

(x) + cos2

(x) = 1

The computer program for MATLAB or Octave programming languages that makes this plot is

x = minus50015

figure plot(xcos(x)ˆ2xsin(x)ˆ2x cos(x) 2 + sin(x) 2 )

legend(cosˆ2(x) sinˆ2(x) cosˆ2(x) + sin 2(x)=1

Location SouthEast)

9

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 926

Proof of Sum of squares formula

Figure 19 A geometric proof for identitysin2(x) + cos2(x) = 1

This identity can be also derived without any plotsusing only geometry Recall that the trigonometric

functions are connected with a circle of unit radiush = 1 as shown in Figure 19

Take any point on a circle of unit radius h =1 and put a vertical line down - this gives us atriangle with right angle 90 with sides a and band hypotenuse h = 1

Pythagorean theorem tells us that a2 + b2 = h2

in the right triangle and all we need is to expressthe sides in terms of cosine and sinus of an anglex We know that sin(x) = opposite

hypotenuse = a

h and

cos(x) = adjacenthypotenuse = b

h

Since h = 1 we have a2+b2 = 1 and sin(x) = a1

and cos x = b1 Substituting it back we get

sin2(x) + cos2(x) = 1 just like in Equation 11

132 Sum and difference of angles for sin(x) and cos(x)

As you may have guessed cosine wave of sum of frequencies is not just a sum of cosine wavesthat is the expression cos(x + y) = cos(x)+cos(y) is wrong and the actual expression is a bitmore complicated

cos(x plusmn y) = cos x cos y ∓ sin x sin y (12)

sin(x plusmn y) = sin x cos y plusmn cos x sin y (13)

The expressions above are very important since once you understood and memorised themyou can derive pretty much any other expression for sine and cosine functions Youcan make a plot (like in Figure 110) and compare for example cos(x + 2x) and cos x cos(2x)minussin x sin(2x) to make sure that the expression from Equation 12 is true

The program code that can plot Figure 110 in MATLAB or Octave programming languageis quite simple

y cos 3x = cos(3x)

y sin x = sin(x)

y cos x = cos(x)

y sin 2x = sin(2x)

y cos 2x = cos(2

x)

figure plot(x y cos xy c o s 2 x minus y s i n x y s i n 2 x

x y c o s x y c os 2 x x y s i n xy s i n 2 x )

legend(cos(3x) cos(x)cos(2x) sin(x)sin(2x)Location SouthEast)

Both equations 13 and 12 are so important that they deserve a formal proof 1

1There are many ways to prove those identities like using complex exponentials The proof here is Smiley Land Smiley D rdquoGeometry of Addition and Subtraction Formulasrdquo

10

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1026

0 1 2 3 4 5 6 7minus1

minus08

minus06

minus04

minus02

0

02

04

06

08

1

cos(3x)

cos(x)cos(2x)

sin(x)sin(2x)

Figure 110 The plot of cos(x + 2x) and cos x cos(2x) minus sin x sin(2x) for comparison If yousubtract the plot with sin x sin(2x) from cos x cos(2x) you will get cos(3x)

Proof for sin(α plusmn β )

Figure 111 Illustration for theproof of sin(α + β ) = sin α cos β +cos α sin β

Letrsquos take the right triangle ABC in Figure 111 such thatAK = 1 (unit length) For the proof we will need sin(α) =AC AB

so we need to express those sides in terms of cosine andsine

From ABC (α + β ) + γ = 90 there4 γ = 90 minus (α + β )From AKC angAKC + γ = 90 there4 angAKC = (α +

β ) since γ = 90 minus (α + β )Now we express side AC sin(α + β ) = AC

1 there4 AC =

sin(α + β )From ANK we are looking for expressions of sides

AN and NKcos β = AN

1 there4 AN = cos β Remember that we choose

AK to be of unit length - exactly for this Now find NKsin β = NK

1 there4 N K = sin β

From NBK we need to find NB that we need forthe proof of the formula (from Figure 111 you can see that

NB+AN = AB that we are looking for)tan α = NK

NB there4 NB = NK

tanα = sinβtanα = sinβ cosα

sinα We haveeverything we need by now and we turn back to our maintriangle ABC

Finally from ABC sin α = AC AB

= AC NB+AN

=sin(α+β)

cosβ+ sinβ cosαsinα

From this expression we need sin(α + β )

which is

11

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1126

sin(α + β ) = sin α

983080cos β +

sin β cos α

sin α

983081= sin α cos β + cos α sin β

This concludes the proof Formula for sin(αminusβ ) can be obtained simply substituting minusβ into the formula above which

gives Equation 13

Proof for cos(α plusmn β )

Figure 112 Illustration for the proof of cos(α + β ) = cos α cos β minussin α sin β

The proof is very similar to the previous one exceptwe put the angle β to the angKAC The side AK is stillof unit length as seen in Figure 112 For this proofwe will need tan(α) = AC

BC so we need to express those

sides in terms of cosine and sineFrom ABC (α+β )+γ = 90 there4 γ = 90minus(α+β )From ANK angNKA + γ = 90 there4 angN KA =

(α + β )Now we express the side NK cos(α + β ) = NK

1 there4

N K = cos(α + β ) Remember that we choose AK to beof unit length - exactly for this

From NBK sin α = NK BK

there4 BK = cos(α+β)sinα

From AKC we need to express the sides AC andKC in terms of trigonometric functions As before no-tice that AK is unit length that is AK = 1

cos β = AC 1

there4 AC = cos β

sin β = KC 1

there4 KC = sin β

Finally from ABC tan α = sinαcosα = AC

BC =

AC BK +KC = cosβ

cos(α+β)

sinα +sinβ

and all we need is to express

cos(α + β ) that we are looking for

sin α

cos α =

cos β sin α

cos(α + β ) + sin β sin α

from where

cos(α + β ) = cos α cos β minus sin α sin β

This concludes the proof

Formula for cos(α minus β ) can be obtained by simply substituting minusβ into the formula abovewhich gives Equation 12

Now since we have proven the formulas for sum and difference for cosine and sinefunctions we will get nearly all other formulas - again you donrsquot have to memorisethem mechanically since you can (relatively) simply derive them

133 Double-angle formulae

As before keep in mind that cosine and sine functions describe a wave thus cos(2x) is a waveof double frequency compared to a simple wave cos(x) The relationship between a wave of double and unit frequency is

12

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1226

sin2x = 2 sin x cos x (14)

You can simply derive the expression in Equation 14 using Equation 13 and the following

trick sin(2x) = sin(x + x) So sin 2x = sin x lowast cos x + sin x lowast cos x = 2 sin x cos x Derivationof the double-angle formula for cosine is similar just use Equation 12 and the same trickcos(2x) = cos(x + x)

cos2x = cos x lowast cos x minus sin x lowast sin x = cos2 x minus sin2 x = 2 cos2 x minus 1 = 1 minus 2sin2 x (15)

Why do we need the double-angle formula

An illustrative example this time comes from optics there are optical crystals that can double thefrequency of a lightwave such as lithium niobate (LN) or potassium titanyl phosphate (KTP)That is you can convert a light of a infra-red laser (with wavelength of 11microm that is easy toget) into a green laser light (wavelength 055microm) Most laser pointers that produce green light

use these frequency-doubling crystals

Figure 113 Doubling the lightwave frequency converting from cos(x) to cos(2x) in optics

134 Sum-to-Product Formulas

We already know by now that sine and cosine functions are models of waves and we cannot just sum them like cos x + cosy = cos(x + y) The following expressions will allow us to convertsum and difference of trigonometry functions into products

sin x plusmn sin y = 2 sin

983080x plusmn y

2

983081cos

983080x ∓ y

2

983081 (16)

cos x + cos y = 2 cos

983080x + y

2

983081cos

983080x minus y

2

983081 (17)

cos x minus cos y = minus2sin983080x + y

2983081

sin983080x minus y

2983081

(18)

These formulas can be derived using the expressions for double angles in Equation 14 andEquation 15 Letrsquos do it for sin(x)+sin(y) In this proof we take the right part of Equation 16and try to show that it is equivalent to the left part Use Equation 14 to get

2sin

983080x + y

2

983081cos

983080x minus y

2

983081= 2 lowast

1048616sin

x

2 cos

y

2 + cos

x

2 sin

y

2

1048617lowast1048616

cos x

2 cos

y

2 + sin

x

2 sin

y

2

1048617=

13

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1326

Here we just used the Equation 13 and Equation 12 Open the brackets and multiply theseitems to get

= 2 lowast1048616

sin x2

cos2 y2

cos x2

+ sin2 x2

cos y2

sin y2

+ sin y2

cos2 x2

cos y2

+ sin2 y2

cos x2

sin x2

1048617=

Take a closer look at item 1 and 4 - we can group them like this cos x2 sin x2 (sin2 y

2 +cos2 y2 )

Notice that the sum inside brackets equals 1 as we already know from sin2(x)+cos2(x) = 1 (seeEquation 11) The items 2 and 3 in the expression above can be grouped similarly so we get

= 2 lowast1048616

cos y

2 sin

y

2 + sin

x

2 cos

x

2

1048617=

Now open the brackets and look closely on each item for instance 2 cos y2 sin y2 looks similar

to Equation 14 Therefore 2 cos y2

sin y2

= sin(2 lowast y2

) = sin y and therefore

= 2 lowast 1048616cos y

2

sin y

2

+ sin x

2

cos x

21048617 = sin y + sin x

which is exactly the Equation 16 and concludes our proof

Why do we need sum-to-product formulas

These sum-to-product formulas are really special because your own brain does this all the time sounds that you hear with both ears are summed and processed by the brain so you can determinefor example where does the sound came from You can actually trick your own brain into findinga sum of two cosine waves (soundwaves) and hear binaural beats For example if a frequencyof 100 Hz is presented to your left ear and a frequency of 105 Hz is presented to your rightear your brain ldquohearsrdquo a third frequency pulsing at 5 Hz the exact difference between the twofrequencies Some binaural beat frequencies were found to be useful in auditory stimulation toenhance brain functioning

We can use the formula of sum-to-product to find the expression for sum of two sound waveswith frequency f 1 and f 2

cos(2πf 1t) + cos(2πf 2t) = 2 cos

9830802π

(f 1 + f 2)

2 t

983081cos

9830802π

(f 1 minus f 2)

2 t

983081

where t is a variable for time If the two sound frequencies are close (a difference f 1 minus f 2of about twenty hertz) the frequency of the sound wave is often too slow to be perceived as apitch Instead the sound wave is perceived as a periodic variation (beat) of the volume whichis described by the expression above We can see it in Figure 114

The program below (runs in MATLAB and GNUOctave) generates two sound waves (astereo sound) with two pure tones of frequencies f 1 = 500Hz and f 2 = 500 + 30 = 530Hz Thenthe sound is played for 4 seconds

Amplitude=10

duration=4 seconds

Frequency=500

Frequency diff= 30 frequency difference for beat

Freq sampling=10000 sampling frequency

values=01Freq samplingduration

left=Amplitudecos(2pi Frequencyvalues)

14

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1426

002 004 006 008 01 012

Figure 114 The sum (blue) of two cosine waves compared to a single wave (green) The functionplotted is yk = cos(2π lowast 500xk) + cos(2π lowast 530xk)

right = Amplitudecos(2pi (Frequency+Frequency diff)values)

stereosnd = [left right] combining two sounds at a stereo

soundsc(stereosnd Freq sampling) play the sound

You should use headphones to listen to this sound Put one earpiece in your ear and youwill hear a pure tone Then move the second earpiece slowly to your other ear - and instead of two separate tone you are going to hear a sound beat since the frequencies (or tones) differ

slightly (only by 30 Hz) Keep in mind that those two tones do not mix - they are in the left andright earpieces That is the tones do not interfere physically but are summed by the brainThis effect is related to the brainrsquos ability to locate sounds in three dimensions

See your own brain already knows and does the trigonometry and all this mathe-matical expressions just bring the trigonometric expressions to you in a convenient form

135 Product-to-sum formula

Letrsquos derive the reverse formulas which allow us to convert the product of two waves into thesum (or difference) of separate waves

2cos x cos y = cos(x minus y) + cos(x + y) (19)

2sin x sin y = cos(x minus y) minus cos(x + y) (110)

2sin x cos y = sin(x + y) + sin(x minus y) (111)

2cos x sin y = sin(x + y) minus sin(x minus y) (112)

These formulas can be used for transmitting the information via radiowaves as we will seeshortly The derivation of this formulas is very simple all you need is to use Equations 13and 12 For example the formula 2 cos x cos y = cos(x minus y) + cos(x + y) can be derived as sumof the two equations below

15

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1526

cos(x + y) = cos x cos y minus sin x sin y+cos(x minus y) = cos x cos y + sin x sin y

where sin x sin y are gone and therefore we get cos(x + y)+cos(xminus y) = 2 cos x cos y exactlyas in Equation 19 Other formulas can be derived in a similar way

Why do we need these Product-to-sum formulas

The product-to-sum trigonometric formulas can be used to transmit and receive informationEver wondered what are those FM and AM acronyms stand for They stand for AmplitudeModulation and Frequency Modulation respectively - these are the methods of transmittingmusic on a radio and we are going to use trigonometry for this

First we need a carrier wave - we are going to modify it with the input signal (our music) totransmit music using radiowaves The carrier wave is usually of a much higher frequency thanthe input signal which helps us to detect the actual signal Letrsquos take a carrier wave C (t) of

frequency F c and amplitude A given by

C (t) = A lowast cos(2πF ct)

which is a function of time t We are going to modify (or as engineers say modulate ) thiscarrier wave C (t) with a music but for simplicity letrsquos say we want to transmit just a pure toneS (t) This signal S (t) represent the modulation soundwave of a frequency F m (which must be amuch lower frequency than F c)

S (t) = M lowast cos(2πF mt)

where M is the amplitude of the modulation Letrsquos agree that M lt 1 so that (1+ S (t)) is alwayspositive Amplitude modulation occurs when the carrier wave C (t) is multiplied by (1 + S (t))

y(t) = [1 + S (t)] lowast C (t) = [1 + M lowast cos(2πF mt)] lowast A lowast cos(2πF ct) (113)

Using the Equation 19 the resulting signal (as a function of time) y(t) can be shown to be

y(t) = A lowast cos(2πF ct) + AM 2

[cos(2π(F c + F m)t) + cos(2π(F c minus F m)t)]

The modulated radiowave is shown in Figure 115 and the program for this demonstrationis provided below

A = 2 amplitude

duration=4 in seconds

Freq sampling = 10000

values=01Freq samplingduration

Carrier Frequency=1000

C t =Acos(2pi Carrier Frequencyvalues)

M = 01 modulation coefficient

Signal Frequency = 120

S t = Mcos(2piSignal Frequencyvalues)

y t = ( 1+ S t )C t

figure plot(values y t ) this is to plot a beat

16

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1626

0005 001 0015 002 0025 003 0035 004 0045 005

Figure 115 The Amplitude Modulation in action we have a carrier wave of 1000 Hz frequencywhich is modulated (modified) with a tone of 120 Hz using Equation 113 Notice the change inthe amplitude on the plot

136 The power of Trigonometry meet the Discrete Cosine Transform

Many textbooks mention the applications of trigonometry like determining the height of a build-ing if you know the distance to it and the angle to the rooftop or some equally boringexoticexamples Here we are going to see a real-world application of cosine functions which is reallyuseful for sound analysis and compression - the Discrete Cosine Transform (DCT)

Be not afraid of this fancy name it simply means that we are going to use Cosine function toTransform or decompose our sound signal on pure tones (cosine functions of various frequencies)The word Discrete simply means that the values of our signal are sampled with some fixed-stepinterval - for example we measure a value of our signal every 01 seconds

Using DCT we are going to mathematically de-compose our signal into pure tones (or cosinewaves) and calculate how many cosine waves of this particular frequency do we have in thesignal This is extremely useful for analysis of the signal for example you can reduce the noisein signal by simply zeroing out the unwanted frequencies and transforming the signal back

There are many applications of DCT that we use every day without even knowing it

signal analysis by decomposing the signal on the pure cosine waves we can see what arethe main waves in the signal This way you can analyse for example stock market pricesto find any recurring periodical fluctuations of prices (and predict when it happens next)

audio compression MP3 format uses a variety of DCT algorithm to determine which soundfrequencies to keep and which to throw away compressing the song without noticeable lossin quality

images compression JPEG format also compresses the images using DCT-like algorithmto reduce the size of the image by throwing away unnecessary details

17

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1726

Example of frequency analysis using Discrete Cosine Transform

Letrsquos go back to our previous example and take it one step further we combine a soundwave of frequency F 1 = 400 Hz and amplitude A = 1 with a soundwave of frequency F 2 = 800 Hz and

amplitude A = 2

yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) (114)

were indexes with the letter k in yk and xk simply mean the row number in the table with yand x Thatrsquos where the word discrete comes into play our computers can work with discretenumbers and all we need is to take enough samples of a function (cosine in this case) close toeach other to describe the signal

In the program code below we take L = 1000 samples for our signal from Equation 114 andwe take samples of our signal close to each other - say once every t = 14000th of a second Here4000 is our sampling frequency - this is how often we evaluate our function in Equation 114 Wetook F sampling = 4000 arbitrary - any number larger than 800 will be fine

1 Fs = 4000 Sampling frequency

2 T = 1Fs Sample time

3 L = 1000 Length of signal counts

4 x k = (1L)T Time count

56 Sum of a 400 Hz wave and a 800 Hz wave

7 y k = cos(2pi400x k) + 2cos(2pi800x k)

89 Now add some random noise to the sum of waves

10 y k n oisy = y k + 2randn(size(x k ))

1112 figure plot(Fsx k(1200)y k(1200))

13 title(Original signal (sum of two waves)) xlabel(time (milliseconds))

1415 figure plot(Fsx k(1200)y k noisy(1200))

16 title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

That is take L = 1000 numbers (line 3) and generate xk values (line 4) to be plugged intoEquation 114 (line 7) The plot of the signal can be seen in Figure 116(a)

The Discrete Cosine Transform Now the main part we are going to transform (decompose)our sound signal into pure tones (cosine waves of different frequencies) using the Discrete CosineTransform (DCT)

Dk =

N minus1991761n=0

yn cos

983131π

N

983080n +

1

2

983081k

983133 for every frequency k = 0 N minus 1 (115)

Now what does this formula2 actually mean

the signN minus1sumn=0

means ldquosumming elements with subscript n from n = 0 to n = N minus 1

N is the length of the signal y - in our case the signal has 1000 values (a row in a tablewith 1000 cells)

2This formula does not include a normalisation term to account for the number of samples - Irsquom skipping itto simplify the discussion

18

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1826

0 20 40 60 80 100 120 140 160 180 200minus2

minus15

minus1

minus05

0

05

1

15

2

25

3Original signal (sum of two waves)

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

40

X 400Y 2127

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 800Y 3618

(b)

Figure 116 Clean noiseless signal (a) The plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk)(b) the wave frequencies (Discrete Cosine Transform) in the noiseless signal you can see 400 Hzand 800 Hz peaks

yn we take from Equation 114

and we do this for every frequency k from 0 to N minus 1 At the end we get a row of numbersDk that tells us how many cosine waves with frequency 0 1 2 all the way up to frequency N minus1do we have in our signal The program code (MATLAB or Octave) for the DCT formula inEquation 115 is quite simple3

function D = my dct(y)

N = length(y) N rows do we have in the signal yD = zeros(N1) D stores the DCT transform of the signal y

for k = 01Nminus1 for every frequency k = 0 to Nminus1 with step 1

for n = 01Nminus1 for every row value of signal y do this

D(k+1) = D(k+1) + y(n+1)cos(piN (n + 12)k)

end the line above literary implements the DCT formula

end

There is no need to program the DCT formula in MATLAB and Octave it can be calledusing dct(Y) command to transform the signal stored in the variable Y

Now if we now plot the numbers in the variable Dk versus frequencies of a cosine wave (kfrom 0 to N-1) we will see the picture like the one in Fig 116(b) Notice two peaks at 400 and800 Hz - these peaks correspond to the cosine waves in our signal described by Equation 114

yk = cos(2 lowast pi lowast 400 lowast xk) + 2 lowast cos(2 lowast pi lowast 800 lowast xk)This is exactly what we expect after all our soundwave contains only 400 Hz and 800 Hz

cosine waves and those peaks of DCT indicate thisNow imagine that our soundwave was recorded with a bad microphone we have a lot of

noise in the recording If you look at Figure 117(a) there is so much noise that you donrsquot evensee the waves But if you use the DCT to decompose the noised signal and again make the plot

3The code is not efficient and it will take a lot of time for long signals However it is a simple word-for-wordimplementation of the DCT mathematical formula and serves its illustrative purpose

19

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1926

of its result you will be able to see those peaks (that correspond to soundwaves buried undernoise) in Figure 117(b)

0 20 40 60 80 100 120 140 160 180 200minus6

minus4

minus2

0

2

4

6

8

Signal Corrupted with Random Noise

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

X 800Y 3367

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 400Y 1858

(b)

Figure 117 Noised signal (a) the plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) with lotsof noise added (b) the wave frequencies (Discrete Cosine Transform) in the signal you can see400 Hz and 800 Hz peaks

This is the real power of trigonometric functions we can decompose even a very noisysignal and still see what are the cosine waves (that use pure tones) that make it And not justto look at the plot but also clean up the signal we can just zero-out the small numbers in theDCT variable Dk to clean up the noise and transform the signal back to its original state - andnoise is (almost) gone

The MATLAB (or Octave) code for this example is below

Fs = 4000 Sampling frequency

T = 1Fs Sample time

L = 1000 Length of signal counts

x k = (1L)T Time count

Sum of a 400 Hz wave and a 800 Hz wave

y k = cos(2pi400x k) + 2cos(2pi800x k)

Now add some random noise to the sum of waves

y k n oisy = y k + 2randn(size(x k )) Sinusoids plus noise

figure plot(Fsx k(1200)y k(1200))

title(Original signal (sum of two waves)) xlabel(time (milliseconds))

figure plot(Fsx k(1200)y k noisy(1200))

title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

How many cosine waves of different frequencies we have in the signal

D k dct clean signal = dct(y kL)

D k dct noisy signal = dct(y k noisyL)

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

20

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 2: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 226

Abstract

These notes are about high school mathematics what it really means and how it can be turnedinto something fun and useful Over the years Irsquove been collecting neat examples interestingproofs and small programs that illustrate mathematical concepts so this is not a watered-downldquomath for liferdquo kind of text there are proofs and derivations so the reader is invited to workon them On the other hand these are not obscure textbook-type examples either - theseexamples are taken from real-world applications of mathematics in physics engineering andeven biology This is because the author is actually a researcher in optical engineering and nota pure mathematician

The contents of typical textbooks is usually not a problem - the very way how the math-

ematics is being taught is the problem The very way how mathematics is usually taughtleaves students with a feel that math is something useless distant and unnecessary

Imagine that the music theory is compulsory for high school courses which means that youhave to become really good at reading and manipulating musical score on a paper To pass thefirst music course you need to be able to draw the treble and bass clefs in exactly the rightposition and know how to draw the whole half quarter and eighth notes you have to knowwhich positions in the sheet correspond to which musical notes and so on Yet the teacher willnever allow you to sing a note or play an instrument

As a result a student will know everything about music theory What for Well it is a usefulskill you know Would you say a student who excels in this practice is good at music Hardlythe student is likely to hate music to the rest of his life

But this is precisely what high school students are subjected to in math class We force them

to memorise the precise details of solving algebraic equations and polynomial inequalities Werequire them to be adept at simplifying fractions involving radicals drawing accurate sketchesof ellipses and hyperbola from their equations and writing out the steps of a geometric proof insuch pedantic detail that would make a grown mathematician cry

So when a freshman high school student tells me that he was always good at math it translatesto ldquoI was very good at following obscure steps to manipulate mysterious symbols without anyreal understanding of what I was doingrdquo

Mathematics is not about numbers or formulas - it is about models of a real-world processesIt is in a way a purified form of a real-world The simplest way to say it is that mathematics isabout recognising and reasoning about patterns These patterns can come from anywhereshapes numbers relationships at a party physical systems tournaments card games The ideais not just to dump mathematics on students but to bring mathematics to life and show how itworks through applications in physics engineering and programming so math will not be just a

bunch of formulas but a powerful toolbox for solving real world problems

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 326

Chapter 1

Trigonometry

Trigonometry deals with the set of functions that allow us to work with angles calculate the

properties of triangular and model waves of any nature It also allows us to break wine glasseswithout touching them unearth signals buried in noise efficiently compress music and imagescontrol flames transmit and receive information determine our geographical coordinates and alot more

11 Brief introduction

Letrsquos make a plot of two trigonometric functions y = sin(x) and y = cos(x) by substitutingnumbers into them - like in Figure 11 for x isin [0 7]

0 1 2 3 4 5 6 7minus1

minus08

minus06

minus04

minus02

0

02

04

06

08

1

cossin

Figure 11 The cosine and sine functions plotted on a range of numbers from 0 to 7

That is we just made two columns of numbers x and y and in the X column we put numbersfrom 0 to 7 with step 01 - either by hand or (better) writing a program in MATLAB or Octave

1

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 426

That is we just put x = 0 01 02 all the way to 69 and finally 7 Each of the number in theX column we substituted into cos(x) and sin(x) giving us corresponding values of the functionswhich we put into Y column Then we plot numbers in X against numbers in Y

12 Why do we need trigonometric functions

These obscure mathematical functions look completely detached from real world and ultimatelyuseless But letrsquos take a closer look at say a smartphone and try to find some applications of trigonometric functions cos(x) and sin(x) there

1 when you speak you produce soundwaves (human vocal cord changes the air pressure)that are sensed by a microphone and converted into electric signals for transmission

2 what you say during the call is send to a cell-tower as a radiowave

3 various communication networks like WiFi and Bluetooth use electro-magnetic waves

too4 whenever you want to know where are you on the map you use the GPS (global positioning

system) or cell tower triangulation method to determine your location

5 when you look at the screen you see lightwaves and the image on the screen is formedby turning their angle (light polarisation angle)

6 the images themselves say from the camera are compressed to reduce size and occupyless space using trigonometric transforms (Discrete Cosine Transform)

7 when you donrsquot want to be disturbed you can put the smart-phone in vibration modewhich produces vibration waves

It seems like our smartphones are packed with waves of different origin Letrsquos see if those

waves have anything to do with that boring trigonometry

121 Sound waves and the cosine function

What do soundwaves and cosine functions have in common To answer this question letrsquos writea simple program that can generate a tone A tone has its pitch (also called frequency) andvolume (loudness or amplitude)

Sound frequency When you record the tone on a computer you see a waveform - this is justthe levels of sound proportional to air pressure made by the sound For example we can record asound tone with 400 Hz frequency (that is the soundwave will do 400 turns per second) and plotit Figure 12 The plot of a soundwave looks just like the cosine function on Figure 11 except

for the amplitude (volume or difference between the maximum and the minimum) and pitch (orfrequency) We can go further and record a tone with 800 Hz - twice the pitch compared to 400Hz and compare them both

Not surprisingly the tone has twice the pitch so it makes two times more turns per secondLetrsquos generalise this example and compare cos(x) with cos(2lowastx) - this is exactly what we did inthe example above with two soundwaves of 400Hz and 800Hz frequencies Plugging the numbersin a calculator is very tedious and plotting many points on a paper is even more so - but we canask a computer to do this job If we use a mathematical programming language like Octave andwrite a simple program like this

2

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 526

2 4 6 8 10

x 10minus3

Figure 12 The tone of 400 Hz (blue) and 800 Hz (green)

x = 0017

y = cos(x)

y2 = cos(2x)

figure plot(xyxy2)

legend(cos(x) cos(2x) Location SouthEast)

which means that

1 x = 0017 generate the row of numbers from 0 to 7 with a step of 01

2 y = cos(x) substitute numbers from x into cos(x) function to get row of cosine values y

3 y2 = cos(2x) substitute numbers from x into cos(2lowastx) to get row of cosine values withdouble frequency (2x) in y

4 figure plot(xyxy2) to plot y and y2 values on a plot like the one in Figure 13

If we compare plots in Figure 12 and Figure 13 we discover that they are very similar- in fact the trigonometric functions y = cos(x) and y = cos(2lowastx) are describing the soundwavesof two pitches 400 Hz and 800 Hz (single and double frequency)

Takeaway trigonometric function cos(x) is a very good model of a soundwave(that is a pure tone) doubling the frequency of the tone (from 400 to 800 Hz) in ourexample) can be well described by doubling the variable inside the cosine functionfrom y = cos(x) to y = cos(2 lowast x) In fact it does not matter if this is a sound wavea light wave or a wave on the surface of a pond - the cosine function will model themas well just change the frequency and amplitude accordingly

But you may notice that the values on a vertical axis in Figure 12 and Figure 13 are verydifferent - this brings us to the notion of amplitude

3

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 626

0 1 2 3 4 5 6 7minus1

minus08

minus06

minus04

minus02

0

02

04

06

08

1

cos(x)

cos(2x)

Figure 13 The plot of y = cos(x) and y = cos(2 lowast x) where x are from 0 to 7

Sound volume (or amplitude) Every time your listen to the music you use that little knobcalled ldquoVolumerdquo to make the song louder or quieter Your music player changes the amplitude of the soundwaves - yes those cosine waves above If we make another plot of two cosine functionsy = cos(x) and y = 2 lowast cos(x) we can see from Fig 14 that those plots are just scaled versionsof one another

0 1 2 3 4 5 6 7minus2

minus15

minus1

minus05

0

05

1

15

2

Figure 14 The plot of y = cos(x) and y = 2 lowast cos(x) where x are from 0 to 7

4

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 726

This brings us to a more general model of a wave

y = A lowast cos(F lowast x)

where A stands for amplitude - a constant that controls the scale of the function (volume of a soundwave) and F stands for f requency - a constant that controls how many complete turnsthe function does (pitch or a tone of a soundwave) The cosine function cos(x) is a idealisedmodel of a wave with unit amplitude and unit frequency and this is why it returns the valuesfrom -1 to 1

By now you should see that you cannot just take the number N out of brackets in cos(N lowastx)and put it in front of the function - you cannot convert the frequency into volume this easilyThe conversion is a bit more complicated and we will see it in trigonometric identities below

5

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 826

13 Trigonometric identities derivation and meaning

As we have already seen we can think of trigonometric functions as models of waves that can bedescribed as y = A lowast cos(F lowast x) Here A stands for amplitude F stands for f requency and x isa running variable (time for example) But apart from generating pure tones cosine and sinusfunctions do not take us very far - we need to know the relationships between them if we want touse trigonometry for something useful Relationships between trigonometric functions are morecomplex than just adding numbers and there are formulas that describe those relationships

But there is no need to memorise all the formulas once you understand few basic trigono-metric identities how the really work you will be able to easily derive the rest of the formulas

131 Sum of squares

One of the most useful identity is a sum of cosine and sine squares

sin2(x) + cos2(x) = 1 (11)

If you look at Figure 18 you will notice that when a cos 2(x) has its Y -value at 05 so doesthe sin2(x) If you add them together the result will be equal 1 Moreover all other points onthe plot for cos2(x) and sin2(x) will give 1 in sum when one of the functions is at valley anotherhas a peak at 1 and so on Therefore the sum of squares sin2(x) + cos2(x) always equals 1

minus5 minus4 minus3 minus2 minus1 0 1 2 3 4 50

02

04

06

08

1

12

14

cos2(x)

sin2(x)

cos2(x) + sin

2(x)=1

Figure 18 The plot of sin2

(x) + cos2

(x) = 1

The computer program for MATLAB or Octave programming languages that makes this plot is

x = minus50015

figure plot(xcos(x)ˆ2xsin(x)ˆ2x cos(x) 2 + sin(x) 2 )

legend(cosˆ2(x) sinˆ2(x) cosˆ2(x) + sin 2(x)=1

Location SouthEast)

9

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 926

Proof of Sum of squares formula

Figure 19 A geometric proof for identitysin2(x) + cos2(x) = 1

This identity can be also derived without any plotsusing only geometry Recall that the trigonometric

functions are connected with a circle of unit radiush = 1 as shown in Figure 19

Take any point on a circle of unit radius h =1 and put a vertical line down - this gives us atriangle with right angle 90 with sides a and band hypotenuse h = 1

Pythagorean theorem tells us that a2 + b2 = h2

in the right triangle and all we need is to expressthe sides in terms of cosine and sinus of an anglex We know that sin(x) = opposite

hypotenuse = a

h and

cos(x) = adjacenthypotenuse = b

h

Since h = 1 we have a2+b2 = 1 and sin(x) = a1

and cos x = b1 Substituting it back we get

sin2(x) + cos2(x) = 1 just like in Equation 11

132 Sum and difference of angles for sin(x) and cos(x)

As you may have guessed cosine wave of sum of frequencies is not just a sum of cosine wavesthat is the expression cos(x + y) = cos(x)+cos(y) is wrong and the actual expression is a bitmore complicated

cos(x plusmn y) = cos x cos y ∓ sin x sin y (12)

sin(x plusmn y) = sin x cos y plusmn cos x sin y (13)

The expressions above are very important since once you understood and memorised themyou can derive pretty much any other expression for sine and cosine functions Youcan make a plot (like in Figure 110) and compare for example cos(x + 2x) and cos x cos(2x)minussin x sin(2x) to make sure that the expression from Equation 12 is true

The program code that can plot Figure 110 in MATLAB or Octave programming languageis quite simple

y cos 3x = cos(3x)

y sin x = sin(x)

y cos x = cos(x)

y sin 2x = sin(2x)

y cos 2x = cos(2

x)

figure plot(x y cos xy c o s 2 x minus y s i n x y s i n 2 x

x y c o s x y c os 2 x x y s i n xy s i n 2 x )

legend(cos(3x) cos(x)cos(2x) sin(x)sin(2x)Location SouthEast)

Both equations 13 and 12 are so important that they deserve a formal proof 1

1There are many ways to prove those identities like using complex exponentials The proof here is Smiley Land Smiley D rdquoGeometry of Addition and Subtraction Formulasrdquo

10

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1026

0 1 2 3 4 5 6 7minus1

minus08

minus06

minus04

minus02

0

02

04

06

08

1

cos(3x)

cos(x)cos(2x)

sin(x)sin(2x)

Figure 110 The plot of cos(x + 2x) and cos x cos(2x) minus sin x sin(2x) for comparison If yousubtract the plot with sin x sin(2x) from cos x cos(2x) you will get cos(3x)

Proof for sin(α plusmn β )

Figure 111 Illustration for theproof of sin(α + β ) = sin α cos β +cos α sin β

Letrsquos take the right triangle ABC in Figure 111 such thatAK = 1 (unit length) For the proof we will need sin(α) =AC AB

so we need to express those sides in terms of cosine andsine

From ABC (α + β ) + γ = 90 there4 γ = 90 minus (α + β )From AKC angAKC + γ = 90 there4 angAKC = (α +

β ) since γ = 90 minus (α + β )Now we express side AC sin(α + β ) = AC

1 there4 AC =

sin(α + β )From ANK we are looking for expressions of sides

AN and NKcos β = AN

1 there4 AN = cos β Remember that we choose

AK to be of unit length - exactly for this Now find NKsin β = NK

1 there4 N K = sin β

From NBK we need to find NB that we need forthe proof of the formula (from Figure 111 you can see that

NB+AN = AB that we are looking for)tan α = NK

NB there4 NB = NK

tanα = sinβtanα = sinβ cosα

sinα We haveeverything we need by now and we turn back to our maintriangle ABC

Finally from ABC sin α = AC AB

= AC NB+AN

=sin(α+β)

cosβ+ sinβ cosαsinα

From this expression we need sin(α + β )

which is

11

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1126

sin(α + β ) = sin α

983080cos β +

sin β cos α

sin α

983081= sin α cos β + cos α sin β

This concludes the proof Formula for sin(αminusβ ) can be obtained simply substituting minusβ into the formula above which

gives Equation 13

Proof for cos(α plusmn β )

Figure 112 Illustration for the proof of cos(α + β ) = cos α cos β minussin α sin β

The proof is very similar to the previous one exceptwe put the angle β to the angKAC The side AK is stillof unit length as seen in Figure 112 For this proofwe will need tan(α) = AC

BC so we need to express those

sides in terms of cosine and sineFrom ABC (α+β )+γ = 90 there4 γ = 90minus(α+β )From ANK angNKA + γ = 90 there4 angN KA =

(α + β )Now we express the side NK cos(α + β ) = NK

1 there4

N K = cos(α + β ) Remember that we choose AK to beof unit length - exactly for this

From NBK sin α = NK BK

there4 BK = cos(α+β)sinα

From AKC we need to express the sides AC andKC in terms of trigonometric functions As before no-tice that AK is unit length that is AK = 1

cos β = AC 1

there4 AC = cos β

sin β = KC 1

there4 KC = sin β

Finally from ABC tan α = sinαcosα = AC

BC =

AC BK +KC = cosβ

cos(α+β)

sinα +sinβ

and all we need is to express

cos(α + β ) that we are looking for

sin α

cos α =

cos β sin α

cos(α + β ) + sin β sin α

from where

cos(α + β ) = cos α cos β minus sin α sin β

This concludes the proof

Formula for cos(α minus β ) can be obtained by simply substituting minusβ into the formula abovewhich gives Equation 12

Now since we have proven the formulas for sum and difference for cosine and sinefunctions we will get nearly all other formulas - again you donrsquot have to memorisethem mechanically since you can (relatively) simply derive them

133 Double-angle formulae

As before keep in mind that cosine and sine functions describe a wave thus cos(2x) is a waveof double frequency compared to a simple wave cos(x) The relationship between a wave of double and unit frequency is

12

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1226

sin2x = 2 sin x cos x (14)

You can simply derive the expression in Equation 14 using Equation 13 and the following

trick sin(2x) = sin(x + x) So sin 2x = sin x lowast cos x + sin x lowast cos x = 2 sin x cos x Derivationof the double-angle formula for cosine is similar just use Equation 12 and the same trickcos(2x) = cos(x + x)

cos2x = cos x lowast cos x minus sin x lowast sin x = cos2 x minus sin2 x = 2 cos2 x minus 1 = 1 minus 2sin2 x (15)

Why do we need the double-angle formula

An illustrative example this time comes from optics there are optical crystals that can double thefrequency of a lightwave such as lithium niobate (LN) or potassium titanyl phosphate (KTP)That is you can convert a light of a infra-red laser (with wavelength of 11microm that is easy toget) into a green laser light (wavelength 055microm) Most laser pointers that produce green light

use these frequency-doubling crystals

Figure 113 Doubling the lightwave frequency converting from cos(x) to cos(2x) in optics

134 Sum-to-Product Formulas

We already know by now that sine and cosine functions are models of waves and we cannot just sum them like cos x + cosy = cos(x + y) The following expressions will allow us to convertsum and difference of trigonometry functions into products

sin x plusmn sin y = 2 sin

983080x plusmn y

2

983081cos

983080x ∓ y

2

983081 (16)

cos x + cos y = 2 cos

983080x + y

2

983081cos

983080x minus y

2

983081 (17)

cos x minus cos y = minus2sin983080x + y

2983081

sin983080x minus y

2983081

(18)

These formulas can be derived using the expressions for double angles in Equation 14 andEquation 15 Letrsquos do it for sin(x)+sin(y) In this proof we take the right part of Equation 16and try to show that it is equivalent to the left part Use Equation 14 to get

2sin

983080x + y

2

983081cos

983080x minus y

2

983081= 2 lowast

1048616sin

x

2 cos

y

2 + cos

x

2 sin

y

2

1048617lowast1048616

cos x

2 cos

y

2 + sin

x

2 sin

y

2

1048617=

13

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1326

Here we just used the Equation 13 and Equation 12 Open the brackets and multiply theseitems to get

= 2 lowast1048616

sin x2

cos2 y2

cos x2

+ sin2 x2

cos y2

sin y2

+ sin y2

cos2 x2

cos y2

+ sin2 y2

cos x2

sin x2

1048617=

Take a closer look at item 1 and 4 - we can group them like this cos x2 sin x2 (sin2 y

2 +cos2 y2 )

Notice that the sum inside brackets equals 1 as we already know from sin2(x)+cos2(x) = 1 (seeEquation 11) The items 2 and 3 in the expression above can be grouped similarly so we get

= 2 lowast1048616

cos y

2 sin

y

2 + sin

x

2 cos

x

2

1048617=

Now open the brackets and look closely on each item for instance 2 cos y2 sin y2 looks similar

to Equation 14 Therefore 2 cos y2

sin y2

= sin(2 lowast y2

) = sin y and therefore

= 2 lowast 1048616cos y

2

sin y

2

+ sin x

2

cos x

21048617 = sin y + sin x

which is exactly the Equation 16 and concludes our proof

Why do we need sum-to-product formulas

These sum-to-product formulas are really special because your own brain does this all the time sounds that you hear with both ears are summed and processed by the brain so you can determinefor example where does the sound came from You can actually trick your own brain into findinga sum of two cosine waves (soundwaves) and hear binaural beats For example if a frequencyof 100 Hz is presented to your left ear and a frequency of 105 Hz is presented to your rightear your brain ldquohearsrdquo a third frequency pulsing at 5 Hz the exact difference between the twofrequencies Some binaural beat frequencies were found to be useful in auditory stimulation toenhance brain functioning

We can use the formula of sum-to-product to find the expression for sum of two sound waveswith frequency f 1 and f 2

cos(2πf 1t) + cos(2πf 2t) = 2 cos

9830802π

(f 1 + f 2)

2 t

983081cos

9830802π

(f 1 minus f 2)

2 t

983081

where t is a variable for time If the two sound frequencies are close (a difference f 1 minus f 2of about twenty hertz) the frequency of the sound wave is often too slow to be perceived as apitch Instead the sound wave is perceived as a periodic variation (beat) of the volume whichis described by the expression above We can see it in Figure 114

The program below (runs in MATLAB and GNUOctave) generates two sound waves (astereo sound) with two pure tones of frequencies f 1 = 500Hz and f 2 = 500 + 30 = 530Hz Thenthe sound is played for 4 seconds

Amplitude=10

duration=4 seconds

Frequency=500

Frequency diff= 30 frequency difference for beat

Freq sampling=10000 sampling frequency

values=01Freq samplingduration

left=Amplitudecos(2pi Frequencyvalues)

14

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1426

002 004 006 008 01 012

Figure 114 The sum (blue) of two cosine waves compared to a single wave (green) The functionplotted is yk = cos(2π lowast 500xk) + cos(2π lowast 530xk)

right = Amplitudecos(2pi (Frequency+Frequency diff)values)

stereosnd = [left right] combining two sounds at a stereo

soundsc(stereosnd Freq sampling) play the sound

You should use headphones to listen to this sound Put one earpiece in your ear and youwill hear a pure tone Then move the second earpiece slowly to your other ear - and instead of two separate tone you are going to hear a sound beat since the frequencies (or tones) differ

slightly (only by 30 Hz) Keep in mind that those two tones do not mix - they are in the left andright earpieces That is the tones do not interfere physically but are summed by the brainThis effect is related to the brainrsquos ability to locate sounds in three dimensions

See your own brain already knows and does the trigonometry and all this mathe-matical expressions just bring the trigonometric expressions to you in a convenient form

135 Product-to-sum formula

Letrsquos derive the reverse formulas which allow us to convert the product of two waves into thesum (or difference) of separate waves

2cos x cos y = cos(x minus y) + cos(x + y) (19)

2sin x sin y = cos(x minus y) minus cos(x + y) (110)

2sin x cos y = sin(x + y) + sin(x minus y) (111)

2cos x sin y = sin(x + y) minus sin(x minus y) (112)

These formulas can be used for transmitting the information via radiowaves as we will seeshortly The derivation of this formulas is very simple all you need is to use Equations 13and 12 For example the formula 2 cos x cos y = cos(x minus y) + cos(x + y) can be derived as sumof the two equations below

15

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1526

cos(x + y) = cos x cos y minus sin x sin y+cos(x minus y) = cos x cos y + sin x sin y

where sin x sin y are gone and therefore we get cos(x + y)+cos(xminus y) = 2 cos x cos y exactlyas in Equation 19 Other formulas can be derived in a similar way

Why do we need these Product-to-sum formulas

The product-to-sum trigonometric formulas can be used to transmit and receive informationEver wondered what are those FM and AM acronyms stand for They stand for AmplitudeModulation and Frequency Modulation respectively - these are the methods of transmittingmusic on a radio and we are going to use trigonometry for this

First we need a carrier wave - we are going to modify it with the input signal (our music) totransmit music using radiowaves The carrier wave is usually of a much higher frequency thanthe input signal which helps us to detect the actual signal Letrsquos take a carrier wave C (t) of

frequency F c and amplitude A given by

C (t) = A lowast cos(2πF ct)

which is a function of time t We are going to modify (or as engineers say modulate ) thiscarrier wave C (t) with a music but for simplicity letrsquos say we want to transmit just a pure toneS (t) This signal S (t) represent the modulation soundwave of a frequency F m (which must be amuch lower frequency than F c)

S (t) = M lowast cos(2πF mt)

where M is the amplitude of the modulation Letrsquos agree that M lt 1 so that (1+ S (t)) is alwayspositive Amplitude modulation occurs when the carrier wave C (t) is multiplied by (1 + S (t))

y(t) = [1 + S (t)] lowast C (t) = [1 + M lowast cos(2πF mt)] lowast A lowast cos(2πF ct) (113)

Using the Equation 19 the resulting signal (as a function of time) y(t) can be shown to be

y(t) = A lowast cos(2πF ct) + AM 2

[cos(2π(F c + F m)t) + cos(2π(F c minus F m)t)]

The modulated radiowave is shown in Figure 115 and the program for this demonstrationis provided below

A = 2 amplitude

duration=4 in seconds

Freq sampling = 10000

values=01Freq samplingduration

Carrier Frequency=1000

C t =Acos(2pi Carrier Frequencyvalues)

M = 01 modulation coefficient

Signal Frequency = 120

S t = Mcos(2piSignal Frequencyvalues)

y t = ( 1+ S t )C t

figure plot(values y t ) this is to plot a beat

16

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1626

0005 001 0015 002 0025 003 0035 004 0045 005

Figure 115 The Amplitude Modulation in action we have a carrier wave of 1000 Hz frequencywhich is modulated (modified) with a tone of 120 Hz using Equation 113 Notice the change inthe amplitude on the plot

136 The power of Trigonometry meet the Discrete Cosine Transform

Many textbooks mention the applications of trigonometry like determining the height of a build-ing if you know the distance to it and the angle to the rooftop or some equally boringexoticexamples Here we are going to see a real-world application of cosine functions which is reallyuseful for sound analysis and compression - the Discrete Cosine Transform (DCT)

Be not afraid of this fancy name it simply means that we are going to use Cosine function toTransform or decompose our sound signal on pure tones (cosine functions of various frequencies)The word Discrete simply means that the values of our signal are sampled with some fixed-stepinterval - for example we measure a value of our signal every 01 seconds

Using DCT we are going to mathematically de-compose our signal into pure tones (or cosinewaves) and calculate how many cosine waves of this particular frequency do we have in thesignal This is extremely useful for analysis of the signal for example you can reduce the noisein signal by simply zeroing out the unwanted frequencies and transforming the signal back

There are many applications of DCT that we use every day without even knowing it

signal analysis by decomposing the signal on the pure cosine waves we can see what arethe main waves in the signal This way you can analyse for example stock market pricesto find any recurring periodical fluctuations of prices (and predict when it happens next)

audio compression MP3 format uses a variety of DCT algorithm to determine which soundfrequencies to keep and which to throw away compressing the song without noticeable lossin quality

images compression JPEG format also compresses the images using DCT-like algorithmto reduce the size of the image by throwing away unnecessary details

17

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1726

Example of frequency analysis using Discrete Cosine Transform

Letrsquos go back to our previous example and take it one step further we combine a soundwave of frequency F 1 = 400 Hz and amplitude A = 1 with a soundwave of frequency F 2 = 800 Hz and

amplitude A = 2

yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) (114)

were indexes with the letter k in yk and xk simply mean the row number in the table with yand x Thatrsquos where the word discrete comes into play our computers can work with discretenumbers and all we need is to take enough samples of a function (cosine in this case) close toeach other to describe the signal

In the program code below we take L = 1000 samples for our signal from Equation 114 andwe take samples of our signal close to each other - say once every t = 14000th of a second Here4000 is our sampling frequency - this is how often we evaluate our function in Equation 114 Wetook F sampling = 4000 arbitrary - any number larger than 800 will be fine

1 Fs = 4000 Sampling frequency

2 T = 1Fs Sample time

3 L = 1000 Length of signal counts

4 x k = (1L)T Time count

56 Sum of a 400 Hz wave and a 800 Hz wave

7 y k = cos(2pi400x k) + 2cos(2pi800x k)

89 Now add some random noise to the sum of waves

10 y k n oisy = y k + 2randn(size(x k ))

1112 figure plot(Fsx k(1200)y k(1200))

13 title(Original signal (sum of two waves)) xlabel(time (milliseconds))

1415 figure plot(Fsx k(1200)y k noisy(1200))

16 title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

That is take L = 1000 numbers (line 3) and generate xk values (line 4) to be plugged intoEquation 114 (line 7) The plot of the signal can be seen in Figure 116(a)

The Discrete Cosine Transform Now the main part we are going to transform (decompose)our sound signal into pure tones (cosine waves of different frequencies) using the Discrete CosineTransform (DCT)

Dk =

N minus1991761n=0

yn cos

983131π

N

983080n +

1

2

983081k

983133 for every frequency k = 0 N minus 1 (115)

Now what does this formula2 actually mean

the signN minus1sumn=0

means ldquosumming elements with subscript n from n = 0 to n = N minus 1

N is the length of the signal y - in our case the signal has 1000 values (a row in a tablewith 1000 cells)

2This formula does not include a normalisation term to account for the number of samples - Irsquom skipping itto simplify the discussion

18

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1826

0 20 40 60 80 100 120 140 160 180 200minus2

minus15

minus1

minus05

0

05

1

15

2

25

3Original signal (sum of two waves)

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

40

X 400Y 2127

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 800Y 3618

(b)

Figure 116 Clean noiseless signal (a) The plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk)(b) the wave frequencies (Discrete Cosine Transform) in the noiseless signal you can see 400 Hzand 800 Hz peaks

yn we take from Equation 114

and we do this for every frequency k from 0 to N minus 1 At the end we get a row of numbersDk that tells us how many cosine waves with frequency 0 1 2 all the way up to frequency N minus1do we have in our signal The program code (MATLAB or Octave) for the DCT formula inEquation 115 is quite simple3

function D = my dct(y)

N = length(y) N rows do we have in the signal yD = zeros(N1) D stores the DCT transform of the signal y

for k = 01Nminus1 for every frequency k = 0 to Nminus1 with step 1

for n = 01Nminus1 for every row value of signal y do this

D(k+1) = D(k+1) + y(n+1)cos(piN (n + 12)k)

end the line above literary implements the DCT formula

end

There is no need to program the DCT formula in MATLAB and Octave it can be calledusing dct(Y) command to transform the signal stored in the variable Y

Now if we now plot the numbers in the variable Dk versus frequencies of a cosine wave (kfrom 0 to N-1) we will see the picture like the one in Fig 116(b) Notice two peaks at 400 and800 Hz - these peaks correspond to the cosine waves in our signal described by Equation 114

yk = cos(2 lowast pi lowast 400 lowast xk) + 2 lowast cos(2 lowast pi lowast 800 lowast xk)This is exactly what we expect after all our soundwave contains only 400 Hz and 800 Hz

cosine waves and those peaks of DCT indicate thisNow imagine that our soundwave was recorded with a bad microphone we have a lot of

noise in the recording If you look at Figure 117(a) there is so much noise that you donrsquot evensee the waves But if you use the DCT to decompose the noised signal and again make the plot

3The code is not efficient and it will take a lot of time for long signals However it is a simple word-for-wordimplementation of the DCT mathematical formula and serves its illustrative purpose

19

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1926

of its result you will be able to see those peaks (that correspond to soundwaves buried undernoise) in Figure 117(b)

0 20 40 60 80 100 120 140 160 180 200minus6

minus4

minus2

0

2

4

6

8

Signal Corrupted with Random Noise

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

X 800Y 3367

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 400Y 1858

(b)

Figure 117 Noised signal (a) the plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) with lotsof noise added (b) the wave frequencies (Discrete Cosine Transform) in the signal you can see400 Hz and 800 Hz peaks

This is the real power of trigonometric functions we can decompose even a very noisysignal and still see what are the cosine waves (that use pure tones) that make it And not justto look at the plot but also clean up the signal we can just zero-out the small numbers in theDCT variable Dk to clean up the noise and transform the signal back to its original state - andnoise is (almost) gone

The MATLAB (or Octave) code for this example is below

Fs = 4000 Sampling frequency

T = 1Fs Sample time

L = 1000 Length of signal counts

x k = (1L)T Time count

Sum of a 400 Hz wave and a 800 Hz wave

y k = cos(2pi400x k) + 2cos(2pi800x k)

Now add some random noise to the sum of waves

y k n oisy = y k + 2randn(size(x k )) Sinusoids plus noise

figure plot(Fsx k(1200)y k(1200))

title(Original signal (sum of two waves)) xlabel(time (milliseconds))

figure plot(Fsx k(1200)y k noisy(1200))

title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

How many cosine waves of different frequencies we have in the signal

D k dct clean signal = dct(y kL)

D k dct noisy signal = dct(y k noisyL)

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

20

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 3: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 326

Chapter 1

Trigonometry

Trigonometry deals with the set of functions that allow us to work with angles calculate the

properties of triangular and model waves of any nature It also allows us to break wine glasseswithout touching them unearth signals buried in noise efficiently compress music and imagescontrol flames transmit and receive information determine our geographical coordinates and alot more

11 Brief introduction

Letrsquos make a plot of two trigonometric functions y = sin(x) and y = cos(x) by substitutingnumbers into them - like in Figure 11 for x isin [0 7]

0 1 2 3 4 5 6 7minus1

minus08

minus06

minus04

minus02

0

02

04

06

08

1

cossin

Figure 11 The cosine and sine functions plotted on a range of numbers from 0 to 7

That is we just made two columns of numbers x and y and in the X column we put numbersfrom 0 to 7 with step 01 - either by hand or (better) writing a program in MATLAB or Octave

1

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 426

That is we just put x = 0 01 02 all the way to 69 and finally 7 Each of the number in theX column we substituted into cos(x) and sin(x) giving us corresponding values of the functionswhich we put into Y column Then we plot numbers in X against numbers in Y

12 Why do we need trigonometric functions

These obscure mathematical functions look completely detached from real world and ultimatelyuseless But letrsquos take a closer look at say a smartphone and try to find some applications of trigonometric functions cos(x) and sin(x) there

1 when you speak you produce soundwaves (human vocal cord changes the air pressure)that are sensed by a microphone and converted into electric signals for transmission

2 what you say during the call is send to a cell-tower as a radiowave

3 various communication networks like WiFi and Bluetooth use electro-magnetic waves

too4 whenever you want to know where are you on the map you use the GPS (global positioning

system) or cell tower triangulation method to determine your location

5 when you look at the screen you see lightwaves and the image on the screen is formedby turning their angle (light polarisation angle)

6 the images themselves say from the camera are compressed to reduce size and occupyless space using trigonometric transforms (Discrete Cosine Transform)

7 when you donrsquot want to be disturbed you can put the smart-phone in vibration modewhich produces vibration waves

It seems like our smartphones are packed with waves of different origin Letrsquos see if those

waves have anything to do with that boring trigonometry

121 Sound waves and the cosine function

What do soundwaves and cosine functions have in common To answer this question letrsquos writea simple program that can generate a tone A tone has its pitch (also called frequency) andvolume (loudness or amplitude)

Sound frequency When you record the tone on a computer you see a waveform - this is justthe levels of sound proportional to air pressure made by the sound For example we can record asound tone with 400 Hz frequency (that is the soundwave will do 400 turns per second) and plotit Figure 12 The plot of a soundwave looks just like the cosine function on Figure 11 except

for the amplitude (volume or difference between the maximum and the minimum) and pitch (orfrequency) We can go further and record a tone with 800 Hz - twice the pitch compared to 400Hz and compare them both

Not surprisingly the tone has twice the pitch so it makes two times more turns per secondLetrsquos generalise this example and compare cos(x) with cos(2lowastx) - this is exactly what we did inthe example above with two soundwaves of 400Hz and 800Hz frequencies Plugging the numbersin a calculator is very tedious and plotting many points on a paper is even more so - but we canask a computer to do this job If we use a mathematical programming language like Octave andwrite a simple program like this

2

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 526

2 4 6 8 10

x 10minus3

Figure 12 The tone of 400 Hz (blue) and 800 Hz (green)

x = 0017

y = cos(x)

y2 = cos(2x)

figure plot(xyxy2)

legend(cos(x) cos(2x) Location SouthEast)

which means that

1 x = 0017 generate the row of numbers from 0 to 7 with a step of 01

2 y = cos(x) substitute numbers from x into cos(x) function to get row of cosine values y

3 y2 = cos(2x) substitute numbers from x into cos(2lowastx) to get row of cosine values withdouble frequency (2x) in y

4 figure plot(xyxy2) to plot y and y2 values on a plot like the one in Figure 13

If we compare plots in Figure 12 and Figure 13 we discover that they are very similar- in fact the trigonometric functions y = cos(x) and y = cos(2lowastx) are describing the soundwavesof two pitches 400 Hz and 800 Hz (single and double frequency)

Takeaway trigonometric function cos(x) is a very good model of a soundwave(that is a pure tone) doubling the frequency of the tone (from 400 to 800 Hz) in ourexample) can be well described by doubling the variable inside the cosine functionfrom y = cos(x) to y = cos(2 lowast x) In fact it does not matter if this is a sound wavea light wave or a wave on the surface of a pond - the cosine function will model themas well just change the frequency and amplitude accordingly

But you may notice that the values on a vertical axis in Figure 12 and Figure 13 are verydifferent - this brings us to the notion of amplitude

3

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 626

0 1 2 3 4 5 6 7minus1

minus08

minus06

minus04

minus02

0

02

04

06

08

1

cos(x)

cos(2x)

Figure 13 The plot of y = cos(x) and y = cos(2 lowast x) where x are from 0 to 7

Sound volume (or amplitude) Every time your listen to the music you use that little knobcalled ldquoVolumerdquo to make the song louder or quieter Your music player changes the amplitude of the soundwaves - yes those cosine waves above If we make another plot of two cosine functionsy = cos(x) and y = 2 lowast cos(x) we can see from Fig 14 that those plots are just scaled versionsof one another

0 1 2 3 4 5 6 7minus2

minus15

minus1

minus05

0

05

1

15

2

Figure 14 The plot of y = cos(x) and y = 2 lowast cos(x) where x are from 0 to 7

4

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 726

This brings us to a more general model of a wave

y = A lowast cos(F lowast x)

where A stands for amplitude - a constant that controls the scale of the function (volume of a soundwave) and F stands for f requency - a constant that controls how many complete turnsthe function does (pitch or a tone of a soundwave) The cosine function cos(x) is a idealisedmodel of a wave with unit amplitude and unit frequency and this is why it returns the valuesfrom -1 to 1

By now you should see that you cannot just take the number N out of brackets in cos(N lowastx)and put it in front of the function - you cannot convert the frequency into volume this easilyThe conversion is a bit more complicated and we will see it in trigonometric identities below

5

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 826

13 Trigonometric identities derivation and meaning

As we have already seen we can think of trigonometric functions as models of waves that can bedescribed as y = A lowast cos(F lowast x) Here A stands for amplitude F stands for f requency and x isa running variable (time for example) But apart from generating pure tones cosine and sinusfunctions do not take us very far - we need to know the relationships between them if we want touse trigonometry for something useful Relationships between trigonometric functions are morecomplex than just adding numbers and there are formulas that describe those relationships

But there is no need to memorise all the formulas once you understand few basic trigono-metric identities how the really work you will be able to easily derive the rest of the formulas

131 Sum of squares

One of the most useful identity is a sum of cosine and sine squares

sin2(x) + cos2(x) = 1 (11)

If you look at Figure 18 you will notice that when a cos 2(x) has its Y -value at 05 so doesthe sin2(x) If you add them together the result will be equal 1 Moreover all other points onthe plot for cos2(x) and sin2(x) will give 1 in sum when one of the functions is at valley anotherhas a peak at 1 and so on Therefore the sum of squares sin2(x) + cos2(x) always equals 1

minus5 minus4 minus3 minus2 minus1 0 1 2 3 4 50

02

04

06

08

1

12

14

cos2(x)

sin2(x)

cos2(x) + sin

2(x)=1

Figure 18 The plot of sin2

(x) + cos2

(x) = 1

The computer program for MATLAB or Octave programming languages that makes this plot is

x = minus50015

figure plot(xcos(x)ˆ2xsin(x)ˆ2x cos(x) 2 + sin(x) 2 )

legend(cosˆ2(x) sinˆ2(x) cosˆ2(x) + sin 2(x)=1

Location SouthEast)

9

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 926

Proof of Sum of squares formula

Figure 19 A geometric proof for identitysin2(x) + cos2(x) = 1

This identity can be also derived without any plotsusing only geometry Recall that the trigonometric

functions are connected with a circle of unit radiush = 1 as shown in Figure 19

Take any point on a circle of unit radius h =1 and put a vertical line down - this gives us atriangle with right angle 90 with sides a and band hypotenuse h = 1

Pythagorean theorem tells us that a2 + b2 = h2

in the right triangle and all we need is to expressthe sides in terms of cosine and sinus of an anglex We know that sin(x) = opposite

hypotenuse = a

h and

cos(x) = adjacenthypotenuse = b

h

Since h = 1 we have a2+b2 = 1 and sin(x) = a1

and cos x = b1 Substituting it back we get

sin2(x) + cos2(x) = 1 just like in Equation 11

132 Sum and difference of angles for sin(x) and cos(x)

As you may have guessed cosine wave of sum of frequencies is not just a sum of cosine wavesthat is the expression cos(x + y) = cos(x)+cos(y) is wrong and the actual expression is a bitmore complicated

cos(x plusmn y) = cos x cos y ∓ sin x sin y (12)

sin(x plusmn y) = sin x cos y plusmn cos x sin y (13)

The expressions above are very important since once you understood and memorised themyou can derive pretty much any other expression for sine and cosine functions Youcan make a plot (like in Figure 110) and compare for example cos(x + 2x) and cos x cos(2x)minussin x sin(2x) to make sure that the expression from Equation 12 is true

The program code that can plot Figure 110 in MATLAB or Octave programming languageis quite simple

y cos 3x = cos(3x)

y sin x = sin(x)

y cos x = cos(x)

y sin 2x = sin(2x)

y cos 2x = cos(2

x)

figure plot(x y cos xy c o s 2 x minus y s i n x y s i n 2 x

x y c o s x y c os 2 x x y s i n xy s i n 2 x )

legend(cos(3x) cos(x)cos(2x) sin(x)sin(2x)Location SouthEast)

Both equations 13 and 12 are so important that they deserve a formal proof 1

1There are many ways to prove those identities like using complex exponentials The proof here is Smiley Land Smiley D rdquoGeometry of Addition and Subtraction Formulasrdquo

10

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1026

0 1 2 3 4 5 6 7minus1

minus08

minus06

minus04

minus02

0

02

04

06

08

1

cos(3x)

cos(x)cos(2x)

sin(x)sin(2x)

Figure 110 The plot of cos(x + 2x) and cos x cos(2x) minus sin x sin(2x) for comparison If yousubtract the plot with sin x sin(2x) from cos x cos(2x) you will get cos(3x)

Proof for sin(α plusmn β )

Figure 111 Illustration for theproof of sin(α + β ) = sin α cos β +cos α sin β

Letrsquos take the right triangle ABC in Figure 111 such thatAK = 1 (unit length) For the proof we will need sin(α) =AC AB

so we need to express those sides in terms of cosine andsine

From ABC (α + β ) + γ = 90 there4 γ = 90 minus (α + β )From AKC angAKC + γ = 90 there4 angAKC = (α +

β ) since γ = 90 minus (α + β )Now we express side AC sin(α + β ) = AC

1 there4 AC =

sin(α + β )From ANK we are looking for expressions of sides

AN and NKcos β = AN

1 there4 AN = cos β Remember that we choose

AK to be of unit length - exactly for this Now find NKsin β = NK

1 there4 N K = sin β

From NBK we need to find NB that we need forthe proof of the formula (from Figure 111 you can see that

NB+AN = AB that we are looking for)tan α = NK

NB there4 NB = NK

tanα = sinβtanα = sinβ cosα

sinα We haveeverything we need by now and we turn back to our maintriangle ABC

Finally from ABC sin α = AC AB

= AC NB+AN

=sin(α+β)

cosβ+ sinβ cosαsinα

From this expression we need sin(α + β )

which is

11

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1126

sin(α + β ) = sin α

983080cos β +

sin β cos α

sin α

983081= sin α cos β + cos α sin β

This concludes the proof Formula for sin(αminusβ ) can be obtained simply substituting minusβ into the formula above which

gives Equation 13

Proof for cos(α plusmn β )

Figure 112 Illustration for the proof of cos(α + β ) = cos α cos β minussin α sin β

The proof is very similar to the previous one exceptwe put the angle β to the angKAC The side AK is stillof unit length as seen in Figure 112 For this proofwe will need tan(α) = AC

BC so we need to express those

sides in terms of cosine and sineFrom ABC (α+β )+γ = 90 there4 γ = 90minus(α+β )From ANK angNKA + γ = 90 there4 angN KA =

(α + β )Now we express the side NK cos(α + β ) = NK

1 there4

N K = cos(α + β ) Remember that we choose AK to beof unit length - exactly for this

From NBK sin α = NK BK

there4 BK = cos(α+β)sinα

From AKC we need to express the sides AC andKC in terms of trigonometric functions As before no-tice that AK is unit length that is AK = 1

cos β = AC 1

there4 AC = cos β

sin β = KC 1

there4 KC = sin β

Finally from ABC tan α = sinαcosα = AC

BC =

AC BK +KC = cosβ

cos(α+β)

sinα +sinβ

and all we need is to express

cos(α + β ) that we are looking for

sin α

cos α =

cos β sin α

cos(α + β ) + sin β sin α

from where

cos(α + β ) = cos α cos β minus sin α sin β

This concludes the proof

Formula for cos(α minus β ) can be obtained by simply substituting minusβ into the formula abovewhich gives Equation 12

Now since we have proven the formulas for sum and difference for cosine and sinefunctions we will get nearly all other formulas - again you donrsquot have to memorisethem mechanically since you can (relatively) simply derive them

133 Double-angle formulae

As before keep in mind that cosine and sine functions describe a wave thus cos(2x) is a waveof double frequency compared to a simple wave cos(x) The relationship between a wave of double and unit frequency is

12

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1226

sin2x = 2 sin x cos x (14)

You can simply derive the expression in Equation 14 using Equation 13 and the following

trick sin(2x) = sin(x + x) So sin 2x = sin x lowast cos x + sin x lowast cos x = 2 sin x cos x Derivationof the double-angle formula for cosine is similar just use Equation 12 and the same trickcos(2x) = cos(x + x)

cos2x = cos x lowast cos x minus sin x lowast sin x = cos2 x minus sin2 x = 2 cos2 x minus 1 = 1 minus 2sin2 x (15)

Why do we need the double-angle formula

An illustrative example this time comes from optics there are optical crystals that can double thefrequency of a lightwave such as lithium niobate (LN) or potassium titanyl phosphate (KTP)That is you can convert a light of a infra-red laser (with wavelength of 11microm that is easy toget) into a green laser light (wavelength 055microm) Most laser pointers that produce green light

use these frequency-doubling crystals

Figure 113 Doubling the lightwave frequency converting from cos(x) to cos(2x) in optics

134 Sum-to-Product Formulas

We already know by now that sine and cosine functions are models of waves and we cannot just sum them like cos x + cosy = cos(x + y) The following expressions will allow us to convertsum and difference of trigonometry functions into products

sin x plusmn sin y = 2 sin

983080x plusmn y

2

983081cos

983080x ∓ y

2

983081 (16)

cos x + cos y = 2 cos

983080x + y

2

983081cos

983080x minus y

2

983081 (17)

cos x minus cos y = minus2sin983080x + y

2983081

sin983080x minus y

2983081

(18)

These formulas can be derived using the expressions for double angles in Equation 14 andEquation 15 Letrsquos do it for sin(x)+sin(y) In this proof we take the right part of Equation 16and try to show that it is equivalent to the left part Use Equation 14 to get

2sin

983080x + y

2

983081cos

983080x minus y

2

983081= 2 lowast

1048616sin

x

2 cos

y

2 + cos

x

2 sin

y

2

1048617lowast1048616

cos x

2 cos

y

2 + sin

x

2 sin

y

2

1048617=

13

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1326

Here we just used the Equation 13 and Equation 12 Open the brackets and multiply theseitems to get

= 2 lowast1048616

sin x2

cos2 y2

cos x2

+ sin2 x2

cos y2

sin y2

+ sin y2

cos2 x2

cos y2

+ sin2 y2

cos x2

sin x2

1048617=

Take a closer look at item 1 and 4 - we can group them like this cos x2 sin x2 (sin2 y

2 +cos2 y2 )

Notice that the sum inside brackets equals 1 as we already know from sin2(x)+cos2(x) = 1 (seeEquation 11) The items 2 and 3 in the expression above can be grouped similarly so we get

= 2 lowast1048616

cos y

2 sin

y

2 + sin

x

2 cos

x

2

1048617=

Now open the brackets and look closely on each item for instance 2 cos y2 sin y2 looks similar

to Equation 14 Therefore 2 cos y2

sin y2

= sin(2 lowast y2

) = sin y and therefore

= 2 lowast 1048616cos y

2

sin y

2

+ sin x

2

cos x

21048617 = sin y + sin x

which is exactly the Equation 16 and concludes our proof

Why do we need sum-to-product formulas

These sum-to-product formulas are really special because your own brain does this all the time sounds that you hear with both ears are summed and processed by the brain so you can determinefor example where does the sound came from You can actually trick your own brain into findinga sum of two cosine waves (soundwaves) and hear binaural beats For example if a frequencyof 100 Hz is presented to your left ear and a frequency of 105 Hz is presented to your rightear your brain ldquohearsrdquo a third frequency pulsing at 5 Hz the exact difference between the twofrequencies Some binaural beat frequencies were found to be useful in auditory stimulation toenhance brain functioning

We can use the formula of sum-to-product to find the expression for sum of two sound waveswith frequency f 1 and f 2

cos(2πf 1t) + cos(2πf 2t) = 2 cos

9830802π

(f 1 + f 2)

2 t

983081cos

9830802π

(f 1 minus f 2)

2 t

983081

where t is a variable for time If the two sound frequencies are close (a difference f 1 minus f 2of about twenty hertz) the frequency of the sound wave is often too slow to be perceived as apitch Instead the sound wave is perceived as a periodic variation (beat) of the volume whichis described by the expression above We can see it in Figure 114

The program below (runs in MATLAB and GNUOctave) generates two sound waves (astereo sound) with two pure tones of frequencies f 1 = 500Hz and f 2 = 500 + 30 = 530Hz Thenthe sound is played for 4 seconds

Amplitude=10

duration=4 seconds

Frequency=500

Frequency diff= 30 frequency difference for beat

Freq sampling=10000 sampling frequency

values=01Freq samplingduration

left=Amplitudecos(2pi Frequencyvalues)

14

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1426

002 004 006 008 01 012

Figure 114 The sum (blue) of two cosine waves compared to a single wave (green) The functionplotted is yk = cos(2π lowast 500xk) + cos(2π lowast 530xk)

right = Amplitudecos(2pi (Frequency+Frequency diff)values)

stereosnd = [left right] combining two sounds at a stereo

soundsc(stereosnd Freq sampling) play the sound

You should use headphones to listen to this sound Put one earpiece in your ear and youwill hear a pure tone Then move the second earpiece slowly to your other ear - and instead of two separate tone you are going to hear a sound beat since the frequencies (or tones) differ

slightly (only by 30 Hz) Keep in mind that those two tones do not mix - they are in the left andright earpieces That is the tones do not interfere physically but are summed by the brainThis effect is related to the brainrsquos ability to locate sounds in three dimensions

See your own brain already knows and does the trigonometry and all this mathe-matical expressions just bring the trigonometric expressions to you in a convenient form

135 Product-to-sum formula

Letrsquos derive the reverse formulas which allow us to convert the product of two waves into thesum (or difference) of separate waves

2cos x cos y = cos(x minus y) + cos(x + y) (19)

2sin x sin y = cos(x minus y) minus cos(x + y) (110)

2sin x cos y = sin(x + y) + sin(x minus y) (111)

2cos x sin y = sin(x + y) minus sin(x minus y) (112)

These formulas can be used for transmitting the information via radiowaves as we will seeshortly The derivation of this formulas is very simple all you need is to use Equations 13and 12 For example the formula 2 cos x cos y = cos(x minus y) + cos(x + y) can be derived as sumof the two equations below

15

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1526

cos(x + y) = cos x cos y minus sin x sin y+cos(x minus y) = cos x cos y + sin x sin y

where sin x sin y are gone and therefore we get cos(x + y)+cos(xminus y) = 2 cos x cos y exactlyas in Equation 19 Other formulas can be derived in a similar way

Why do we need these Product-to-sum formulas

The product-to-sum trigonometric formulas can be used to transmit and receive informationEver wondered what are those FM and AM acronyms stand for They stand for AmplitudeModulation and Frequency Modulation respectively - these are the methods of transmittingmusic on a radio and we are going to use trigonometry for this

First we need a carrier wave - we are going to modify it with the input signal (our music) totransmit music using radiowaves The carrier wave is usually of a much higher frequency thanthe input signal which helps us to detect the actual signal Letrsquos take a carrier wave C (t) of

frequency F c and amplitude A given by

C (t) = A lowast cos(2πF ct)

which is a function of time t We are going to modify (or as engineers say modulate ) thiscarrier wave C (t) with a music but for simplicity letrsquos say we want to transmit just a pure toneS (t) This signal S (t) represent the modulation soundwave of a frequency F m (which must be amuch lower frequency than F c)

S (t) = M lowast cos(2πF mt)

where M is the amplitude of the modulation Letrsquos agree that M lt 1 so that (1+ S (t)) is alwayspositive Amplitude modulation occurs when the carrier wave C (t) is multiplied by (1 + S (t))

y(t) = [1 + S (t)] lowast C (t) = [1 + M lowast cos(2πF mt)] lowast A lowast cos(2πF ct) (113)

Using the Equation 19 the resulting signal (as a function of time) y(t) can be shown to be

y(t) = A lowast cos(2πF ct) + AM 2

[cos(2π(F c + F m)t) + cos(2π(F c minus F m)t)]

The modulated radiowave is shown in Figure 115 and the program for this demonstrationis provided below

A = 2 amplitude

duration=4 in seconds

Freq sampling = 10000

values=01Freq samplingduration

Carrier Frequency=1000

C t =Acos(2pi Carrier Frequencyvalues)

M = 01 modulation coefficient

Signal Frequency = 120

S t = Mcos(2piSignal Frequencyvalues)

y t = ( 1+ S t )C t

figure plot(values y t ) this is to plot a beat

16

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1626

0005 001 0015 002 0025 003 0035 004 0045 005

Figure 115 The Amplitude Modulation in action we have a carrier wave of 1000 Hz frequencywhich is modulated (modified) with a tone of 120 Hz using Equation 113 Notice the change inthe amplitude on the plot

136 The power of Trigonometry meet the Discrete Cosine Transform

Many textbooks mention the applications of trigonometry like determining the height of a build-ing if you know the distance to it and the angle to the rooftop or some equally boringexoticexamples Here we are going to see a real-world application of cosine functions which is reallyuseful for sound analysis and compression - the Discrete Cosine Transform (DCT)

Be not afraid of this fancy name it simply means that we are going to use Cosine function toTransform or decompose our sound signal on pure tones (cosine functions of various frequencies)The word Discrete simply means that the values of our signal are sampled with some fixed-stepinterval - for example we measure a value of our signal every 01 seconds

Using DCT we are going to mathematically de-compose our signal into pure tones (or cosinewaves) and calculate how many cosine waves of this particular frequency do we have in thesignal This is extremely useful for analysis of the signal for example you can reduce the noisein signal by simply zeroing out the unwanted frequencies and transforming the signal back

There are many applications of DCT that we use every day without even knowing it

signal analysis by decomposing the signal on the pure cosine waves we can see what arethe main waves in the signal This way you can analyse for example stock market pricesto find any recurring periodical fluctuations of prices (and predict when it happens next)

audio compression MP3 format uses a variety of DCT algorithm to determine which soundfrequencies to keep and which to throw away compressing the song without noticeable lossin quality

images compression JPEG format also compresses the images using DCT-like algorithmto reduce the size of the image by throwing away unnecessary details

17

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1726

Example of frequency analysis using Discrete Cosine Transform

Letrsquos go back to our previous example and take it one step further we combine a soundwave of frequency F 1 = 400 Hz and amplitude A = 1 with a soundwave of frequency F 2 = 800 Hz and

amplitude A = 2

yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) (114)

were indexes with the letter k in yk and xk simply mean the row number in the table with yand x Thatrsquos where the word discrete comes into play our computers can work with discretenumbers and all we need is to take enough samples of a function (cosine in this case) close toeach other to describe the signal

In the program code below we take L = 1000 samples for our signal from Equation 114 andwe take samples of our signal close to each other - say once every t = 14000th of a second Here4000 is our sampling frequency - this is how often we evaluate our function in Equation 114 Wetook F sampling = 4000 arbitrary - any number larger than 800 will be fine

1 Fs = 4000 Sampling frequency

2 T = 1Fs Sample time

3 L = 1000 Length of signal counts

4 x k = (1L)T Time count

56 Sum of a 400 Hz wave and a 800 Hz wave

7 y k = cos(2pi400x k) + 2cos(2pi800x k)

89 Now add some random noise to the sum of waves

10 y k n oisy = y k + 2randn(size(x k ))

1112 figure plot(Fsx k(1200)y k(1200))

13 title(Original signal (sum of two waves)) xlabel(time (milliseconds))

1415 figure plot(Fsx k(1200)y k noisy(1200))

16 title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

That is take L = 1000 numbers (line 3) and generate xk values (line 4) to be plugged intoEquation 114 (line 7) The plot of the signal can be seen in Figure 116(a)

The Discrete Cosine Transform Now the main part we are going to transform (decompose)our sound signal into pure tones (cosine waves of different frequencies) using the Discrete CosineTransform (DCT)

Dk =

N minus1991761n=0

yn cos

983131π

N

983080n +

1

2

983081k

983133 for every frequency k = 0 N minus 1 (115)

Now what does this formula2 actually mean

the signN minus1sumn=0

means ldquosumming elements with subscript n from n = 0 to n = N minus 1

N is the length of the signal y - in our case the signal has 1000 values (a row in a tablewith 1000 cells)

2This formula does not include a normalisation term to account for the number of samples - Irsquom skipping itto simplify the discussion

18

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1826

0 20 40 60 80 100 120 140 160 180 200minus2

minus15

minus1

minus05

0

05

1

15

2

25

3Original signal (sum of two waves)

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

40

X 400Y 2127

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 800Y 3618

(b)

Figure 116 Clean noiseless signal (a) The plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk)(b) the wave frequencies (Discrete Cosine Transform) in the noiseless signal you can see 400 Hzand 800 Hz peaks

yn we take from Equation 114

and we do this for every frequency k from 0 to N minus 1 At the end we get a row of numbersDk that tells us how many cosine waves with frequency 0 1 2 all the way up to frequency N minus1do we have in our signal The program code (MATLAB or Octave) for the DCT formula inEquation 115 is quite simple3

function D = my dct(y)

N = length(y) N rows do we have in the signal yD = zeros(N1) D stores the DCT transform of the signal y

for k = 01Nminus1 for every frequency k = 0 to Nminus1 with step 1

for n = 01Nminus1 for every row value of signal y do this

D(k+1) = D(k+1) + y(n+1)cos(piN (n + 12)k)

end the line above literary implements the DCT formula

end

There is no need to program the DCT formula in MATLAB and Octave it can be calledusing dct(Y) command to transform the signal stored in the variable Y

Now if we now plot the numbers in the variable Dk versus frequencies of a cosine wave (kfrom 0 to N-1) we will see the picture like the one in Fig 116(b) Notice two peaks at 400 and800 Hz - these peaks correspond to the cosine waves in our signal described by Equation 114

yk = cos(2 lowast pi lowast 400 lowast xk) + 2 lowast cos(2 lowast pi lowast 800 lowast xk)This is exactly what we expect after all our soundwave contains only 400 Hz and 800 Hz

cosine waves and those peaks of DCT indicate thisNow imagine that our soundwave was recorded with a bad microphone we have a lot of

noise in the recording If you look at Figure 117(a) there is so much noise that you donrsquot evensee the waves But if you use the DCT to decompose the noised signal and again make the plot

3The code is not efficient and it will take a lot of time for long signals However it is a simple word-for-wordimplementation of the DCT mathematical formula and serves its illustrative purpose

19

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1926

of its result you will be able to see those peaks (that correspond to soundwaves buried undernoise) in Figure 117(b)

0 20 40 60 80 100 120 140 160 180 200minus6

minus4

minus2

0

2

4

6

8

Signal Corrupted with Random Noise

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

X 800Y 3367

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 400Y 1858

(b)

Figure 117 Noised signal (a) the plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) with lotsof noise added (b) the wave frequencies (Discrete Cosine Transform) in the signal you can see400 Hz and 800 Hz peaks

This is the real power of trigonometric functions we can decompose even a very noisysignal and still see what are the cosine waves (that use pure tones) that make it And not justto look at the plot but also clean up the signal we can just zero-out the small numbers in theDCT variable Dk to clean up the noise and transform the signal back to its original state - andnoise is (almost) gone

The MATLAB (or Octave) code for this example is below

Fs = 4000 Sampling frequency

T = 1Fs Sample time

L = 1000 Length of signal counts

x k = (1L)T Time count

Sum of a 400 Hz wave and a 800 Hz wave

y k = cos(2pi400x k) + 2cos(2pi800x k)

Now add some random noise to the sum of waves

y k n oisy = y k + 2randn(size(x k )) Sinusoids plus noise

figure plot(Fsx k(1200)y k(1200))

title(Original signal (sum of two waves)) xlabel(time (milliseconds))

figure plot(Fsx k(1200)y k noisy(1200))

title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

How many cosine waves of different frequencies we have in the signal

D k dct clean signal = dct(y kL)

D k dct noisy signal = dct(y k noisyL)

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

20

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 4: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 426

That is we just put x = 0 01 02 all the way to 69 and finally 7 Each of the number in theX column we substituted into cos(x) and sin(x) giving us corresponding values of the functionswhich we put into Y column Then we plot numbers in X against numbers in Y

12 Why do we need trigonometric functions

These obscure mathematical functions look completely detached from real world and ultimatelyuseless But letrsquos take a closer look at say a smartphone and try to find some applications of trigonometric functions cos(x) and sin(x) there

1 when you speak you produce soundwaves (human vocal cord changes the air pressure)that are sensed by a microphone and converted into electric signals for transmission

2 what you say during the call is send to a cell-tower as a radiowave

3 various communication networks like WiFi and Bluetooth use electro-magnetic waves

too4 whenever you want to know where are you on the map you use the GPS (global positioning

system) or cell tower triangulation method to determine your location

5 when you look at the screen you see lightwaves and the image on the screen is formedby turning their angle (light polarisation angle)

6 the images themselves say from the camera are compressed to reduce size and occupyless space using trigonometric transforms (Discrete Cosine Transform)

7 when you donrsquot want to be disturbed you can put the smart-phone in vibration modewhich produces vibration waves

It seems like our smartphones are packed with waves of different origin Letrsquos see if those

waves have anything to do with that boring trigonometry

121 Sound waves and the cosine function

What do soundwaves and cosine functions have in common To answer this question letrsquos writea simple program that can generate a tone A tone has its pitch (also called frequency) andvolume (loudness or amplitude)

Sound frequency When you record the tone on a computer you see a waveform - this is justthe levels of sound proportional to air pressure made by the sound For example we can record asound tone with 400 Hz frequency (that is the soundwave will do 400 turns per second) and plotit Figure 12 The plot of a soundwave looks just like the cosine function on Figure 11 except

for the amplitude (volume or difference between the maximum and the minimum) and pitch (orfrequency) We can go further and record a tone with 800 Hz - twice the pitch compared to 400Hz and compare them both

Not surprisingly the tone has twice the pitch so it makes two times more turns per secondLetrsquos generalise this example and compare cos(x) with cos(2lowastx) - this is exactly what we did inthe example above with two soundwaves of 400Hz and 800Hz frequencies Plugging the numbersin a calculator is very tedious and plotting many points on a paper is even more so - but we canask a computer to do this job If we use a mathematical programming language like Octave andwrite a simple program like this

2

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 526

2 4 6 8 10

x 10minus3

Figure 12 The tone of 400 Hz (blue) and 800 Hz (green)

x = 0017

y = cos(x)

y2 = cos(2x)

figure plot(xyxy2)

legend(cos(x) cos(2x) Location SouthEast)

which means that

1 x = 0017 generate the row of numbers from 0 to 7 with a step of 01

2 y = cos(x) substitute numbers from x into cos(x) function to get row of cosine values y

3 y2 = cos(2x) substitute numbers from x into cos(2lowastx) to get row of cosine values withdouble frequency (2x) in y

4 figure plot(xyxy2) to plot y and y2 values on a plot like the one in Figure 13

If we compare plots in Figure 12 and Figure 13 we discover that they are very similar- in fact the trigonometric functions y = cos(x) and y = cos(2lowastx) are describing the soundwavesof two pitches 400 Hz and 800 Hz (single and double frequency)

Takeaway trigonometric function cos(x) is a very good model of a soundwave(that is a pure tone) doubling the frequency of the tone (from 400 to 800 Hz) in ourexample) can be well described by doubling the variable inside the cosine functionfrom y = cos(x) to y = cos(2 lowast x) In fact it does not matter if this is a sound wavea light wave or a wave on the surface of a pond - the cosine function will model themas well just change the frequency and amplitude accordingly

But you may notice that the values on a vertical axis in Figure 12 and Figure 13 are verydifferent - this brings us to the notion of amplitude

3

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 626

0 1 2 3 4 5 6 7minus1

minus08

minus06

minus04

minus02

0

02

04

06

08

1

cos(x)

cos(2x)

Figure 13 The plot of y = cos(x) and y = cos(2 lowast x) where x are from 0 to 7

Sound volume (or amplitude) Every time your listen to the music you use that little knobcalled ldquoVolumerdquo to make the song louder or quieter Your music player changes the amplitude of the soundwaves - yes those cosine waves above If we make another plot of two cosine functionsy = cos(x) and y = 2 lowast cos(x) we can see from Fig 14 that those plots are just scaled versionsof one another

0 1 2 3 4 5 6 7minus2

minus15

minus1

minus05

0

05

1

15

2

Figure 14 The plot of y = cos(x) and y = 2 lowast cos(x) where x are from 0 to 7

4

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 726

This brings us to a more general model of a wave

y = A lowast cos(F lowast x)

where A stands for amplitude - a constant that controls the scale of the function (volume of a soundwave) and F stands for f requency - a constant that controls how many complete turnsthe function does (pitch or a tone of a soundwave) The cosine function cos(x) is a idealisedmodel of a wave with unit amplitude and unit frequency and this is why it returns the valuesfrom -1 to 1

By now you should see that you cannot just take the number N out of brackets in cos(N lowastx)and put it in front of the function - you cannot convert the frequency into volume this easilyThe conversion is a bit more complicated and we will see it in trigonometric identities below

5

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 826

13 Trigonometric identities derivation and meaning

As we have already seen we can think of trigonometric functions as models of waves that can bedescribed as y = A lowast cos(F lowast x) Here A stands for amplitude F stands for f requency and x isa running variable (time for example) But apart from generating pure tones cosine and sinusfunctions do not take us very far - we need to know the relationships between them if we want touse trigonometry for something useful Relationships between trigonometric functions are morecomplex than just adding numbers and there are formulas that describe those relationships

But there is no need to memorise all the formulas once you understand few basic trigono-metric identities how the really work you will be able to easily derive the rest of the formulas

131 Sum of squares

One of the most useful identity is a sum of cosine and sine squares

sin2(x) + cos2(x) = 1 (11)

If you look at Figure 18 you will notice that when a cos 2(x) has its Y -value at 05 so doesthe sin2(x) If you add them together the result will be equal 1 Moreover all other points onthe plot for cos2(x) and sin2(x) will give 1 in sum when one of the functions is at valley anotherhas a peak at 1 and so on Therefore the sum of squares sin2(x) + cos2(x) always equals 1

minus5 minus4 minus3 minus2 minus1 0 1 2 3 4 50

02

04

06

08

1

12

14

cos2(x)

sin2(x)

cos2(x) + sin

2(x)=1

Figure 18 The plot of sin2

(x) + cos2

(x) = 1

The computer program for MATLAB or Octave programming languages that makes this plot is

x = minus50015

figure plot(xcos(x)ˆ2xsin(x)ˆ2x cos(x) 2 + sin(x) 2 )

legend(cosˆ2(x) sinˆ2(x) cosˆ2(x) + sin 2(x)=1

Location SouthEast)

9

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 926

Proof of Sum of squares formula

Figure 19 A geometric proof for identitysin2(x) + cos2(x) = 1

This identity can be also derived without any plotsusing only geometry Recall that the trigonometric

functions are connected with a circle of unit radiush = 1 as shown in Figure 19

Take any point on a circle of unit radius h =1 and put a vertical line down - this gives us atriangle with right angle 90 with sides a and band hypotenuse h = 1

Pythagorean theorem tells us that a2 + b2 = h2

in the right triangle and all we need is to expressthe sides in terms of cosine and sinus of an anglex We know that sin(x) = opposite

hypotenuse = a

h and

cos(x) = adjacenthypotenuse = b

h

Since h = 1 we have a2+b2 = 1 and sin(x) = a1

and cos x = b1 Substituting it back we get

sin2(x) + cos2(x) = 1 just like in Equation 11

132 Sum and difference of angles for sin(x) and cos(x)

As you may have guessed cosine wave of sum of frequencies is not just a sum of cosine wavesthat is the expression cos(x + y) = cos(x)+cos(y) is wrong and the actual expression is a bitmore complicated

cos(x plusmn y) = cos x cos y ∓ sin x sin y (12)

sin(x plusmn y) = sin x cos y plusmn cos x sin y (13)

The expressions above are very important since once you understood and memorised themyou can derive pretty much any other expression for sine and cosine functions Youcan make a plot (like in Figure 110) and compare for example cos(x + 2x) and cos x cos(2x)minussin x sin(2x) to make sure that the expression from Equation 12 is true

The program code that can plot Figure 110 in MATLAB or Octave programming languageis quite simple

y cos 3x = cos(3x)

y sin x = sin(x)

y cos x = cos(x)

y sin 2x = sin(2x)

y cos 2x = cos(2

x)

figure plot(x y cos xy c o s 2 x minus y s i n x y s i n 2 x

x y c o s x y c os 2 x x y s i n xy s i n 2 x )

legend(cos(3x) cos(x)cos(2x) sin(x)sin(2x)Location SouthEast)

Both equations 13 and 12 are so important that they deserve a formal proof 1

1There are many ways to prove those identities like using complex exponentials The proof here is Smiley Land Smiley D rdquoGeometry of Addition and Subtraction Formulasrdquo

10

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1026

0 1 2 3 4 5 6 7minus1

minus08

minus06

minus04

minus02

0

02

04

06

08

1

cos(3x)

cos(x)cos(2x)

sin(x)sin(2x)

Figure 110 The plot of cos(x + 2x) and cos x cos(2x) minus sin x sin(2x) for comparison If yousubtract the plot with sin x sin(2x) from cos x cos(2x) you will get cos(3x)

Proof for sin(α plusmn β )

Figure 111 Illustration for theproof of sin(α + β ) = sin α cos β +cos α sin β

Letrsquos take the right triangle ABC in Figure 111 such thatAK = 1 (unit length) For the proof we will need sin(α) =AC AB

so we need to express those sides in terms of cosine andsine

From ABC (α + β ) + γ = 90 there4 γ = 90 minus (α + β )From AKC angAKC + γ = 90 there4 angAKC = (α +

β ) since γ = 90 minus (α + β )Now we express side AC sin(α + β ) = AC

1 there4 AC =

sin(α + β )From ANK we are looking for expressions of sides

AN and NKcos β = AN

1 there4 AN = cos β Remember that we choose

AK to be of unit length - exactly for this Now find NKsin β = NK

1 there4 N K = sin β

From NBK we need to find NB that we need forthe proof of the formula (from Figure 111 you can see that

NB+AN = AB that we are looking for)tan α = NK

NB there4 NB = NK

tanα = sinβtanα = sinβ cosα

sinα We haveeverything we need by now and we turn back to our maintriangle ABC

Finally from ABC sin α = AC AB

= AC NB+AN

=sin(α+β)

cosβ+ sinβ cosαsinα

From this expression we need sin(α + β )

which is

11

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1126

sin(α + β ) = sin α

983080cos β +

sin β cos α

sin α

983081= sin α cos β + cos α sin β

This concludes the proof Formula for sin(αminusβ ) can be obtained simply substituting minusβ into the formula above which

gives Equation 13

Proof for cos(α plusmn β )

Figure 112 Illustration for the proof of cos(α + β ) = cos α cos β minussin α sin β

The proof is very similar to the previous one exceptwe put the angle β to the angKAC The side AK is stillof unit length as seen in Figure 112 For this proofwe will need tan(α) = AC

BC so we need to express those

sides in terms of cosine and sineFrom ABC (α+β )+γ = 90 there4 γ = 90minus(α+β )From ANK angNKA + γ = 90 there4 angN KA =

(α + β )Now we express the side NK cos(α + β ) = NK

1 there4

N K = cos(α + β ) Remember that we choose AK to beof unit length - exactly for this

From NBK sin α = NK BK

there4 BK = cos(α+β)sinα

From AKC we need to express the sides AC andKC in terms of trigonometric functions As before no-tice that AK is unit length that is AK = 1

cos β = AC 1

there4 AC = cos β

sin β = KC 1

there4 KC = sin β

Finally from ABC tan α = sinαcosα = AC

BC =

AC BK +KC = cosβ

cos(α+β)

sinα +sinβ

and all we need is to express

cos(α + β ) that we are looking for

sin α

cos α =

cos β sin α

cos(α + β ) + sin β sin α

from where

cos(α + β ) = cos α cos β minus sin α sin β

This concludes the proof

Formula for cos(α minus β ) can be obtained by simply substituting minusβ into the formula abovewhich gives Equation 12

Now since we have proven the formulas for sum and difference for cosine and sinefunctions we will get nearly all other formulas - again you donrsquot have to memorisethem mechanically since you can (relatively) simply derive them

133 Double-angle formulae

As before keep in mind that cosine and sine functions describe a wave thus cos(2x) is a waveof double frequency compared to a simple wave cos(x) The relationship between a wave of double and unit frequency is

12

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1226

sin2x = 2 sin x cos x (14)

You can simply derive the expression in Equation 14 using Equation 13 and the following

trick sin(2x) = sin(x + x) So sin 2x = sin x lowast cos x + sin x lowast cos x = 2 sin x cos x Derivationof the double-angle formula for cosine is similar just use Equation 12 and the same trickcos(2x) = cos(x + x)

cos2x = cos x lowast cos x minus sin x lowast sin x = cos2 x minus sin2 x = 2 cos2 x minus 1 = 1 minus 2sin2 x (15)

Why do we need the double-angle formula

An illustrative example this time comes from optics there are optical crystals that can double thefrequency of a lightwave such as lithium niobate (LN) or potassium titanyl phosphate (KTP)That is you can convert a light of a infra-red laser (with wavelength of 11microm that is easy toget) into a green laser light (wavelength 055microm) Most laser pointers that produce green light

use these frequency-doubling crystals

Figure 113 Doubling the lightwave frequency converting from cos(x) to cos(2x) in optics

134 Sum-to-Product Formulas

We already know by now that sine and cosine functions are models of waves and we cannot just sum them like cos x + cosy = cos(x + y) The following expressions will allow us to convertsum and difference of trigonometry functions into products

sin x plusmn sin y = 2 sin

983080x plusmn y

2

983081cos

983080x ∓ y

2

983081 (16)

cos x + cos y = 2 cos

983080x + y

2

983081cos

983080x minus y

2

983081 (17)

cos x minus cos y = minus2sin983080x + y

2983081

sin983080x minus y

2983081

(18)

These formulas can be derived using the expressions for double angles in Equation 14 andEquation 15 Letrsquos do it for sin(x)+sin(y) In this proof we take the right part of Equation 16and try to show that it is equivalent to the left part Use Equation 14 to get

2sin

983080x + y

2

983081cos

983080x minus y

2

983081= 2 lowast

1048616sin

x

2 cos

y

2 + cos

x

2 sin

y

2

1048617lowast1048616

cos x

2 cos

y

2 + sin

x

2 sin

y

2

1048617=

13

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1326

Here we just used the Equation 13 and Equation 12 Open the brackets and multiply theseitems to get

= 2 lowast1048616

sin x2

cos2 y2

cos x2

+ sin2 x2

cos y2

sin y2

+ sin y2

cos2 x2

cos y2

+ sin2 y2

cos x2

sin x2

1048617=

Take a closer look at item 1 and 4 - we can group them like this cos x2 sin x2 (sin2 y

2 +cos2 y2 )

Notice that the sum inside brackets equals 1 as we already know from sin2(x)+cos2(x) = 1 (seeEquation 11) The items 2 and 3 in the expression above can be grouped similarly so we get

= 2 lowast1048616

cos y

2 sin

y

2 + sin

x

2 cos

x

2

1048617=

Now open the brackets and look closely on each item for instance 2 cos y2 sin y2 looks similar

to Equation 14 Therefore 2 cos y2

sin y2

= sin(2 lowast y2

) = sin y and therefore

= 2 lowast 1048616cos y

2

sin y

2

+ sin x

2

cos x

21048617 = sin y + sin x

which is exactly the Equation 16 and concludes our proof

Why do we need sum-to-product formulas

These sum-to-product formulas are really special because your own brain does this all the time sounds that you hear with both ears are summed and processed by the brain so you can determinefor example where does the sound came from You can actually trick your own brain into findinga sum of two cosine waves (soundwaves) and hear binaural beats For example if a frequencyof 100 Hz is presented to your left ear and a frequency of 105 Hz is presented to your rightear your brain ldquohearsrdquo a third frequency pulsing at 5 Hz the exact difference between the twofrequencies Some binaural beat frequencies were found to be useful in auditory stimulation toenhance brain functioning

We can use the formula of sum-to-product to find the expression for sum of two sound waveswith frequency f 1 and f 2

cos(2πf 1t) + cos(2πf 2t) = 2 cos

9830802π

(f 1 + f 2)

2 t

983081cos

9830802π

(f 1 minus f 2)

2 t

983081

where t is a variable for time If the two sound frequencies are close (a difference f 1 minus f 2of about twenty hertz) the frequency of the sound wave is often too slow to be perceived as apitch Instead the sound wave is perceived as a periodic variation (beat) of the volume whichis described by the expression above We can see it in Figure 114

The program below (runs in MATLAB and GNUOctave) generates two sound waves (astereo sound) with two pure tones of frequencies f 1 = 500Hz and f 2 = 500 + 30 = 530Hz Thenthe sound is played for 4 seconds

Amplitude=10

duration=4 seconds

Frequency=500

Frequency diff= 30 frequency difference for beat

Freq sampling=10000 sampling frequency

values=01Freq samplingduration

left=Amplitudecos(2pi Frequencyvalues)

14

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1426

002 004 006 008 01 012

Figure 114 The sum (blue) of two cosine waves compared to a single wave (green) The functionplotted is yk = cos(2π lowast 500xk) + cos(2π lowast 530xk)

right = Amplitudecos(2pi (Frequency+Frequency diff)values)

stereosnd = [left right] combining two sounds at a stereo

soundsc(stereosnd Freq sampling) play the sound

You should use headphones to listen to this sound Put one earpiece in your ear and youwill hear a pure tone Then move the second earpiece slowly to your other ear - and instead of two separate tone you are going to hear a sound beat since the frequencies (or tones) differ

slightly (only by 30 Hz) Keep in mind that those two tones do not mix - they are in the left andright earpieces That is the tones do not interfere physically but are summed by the brainThis effect is related to the brainrsquos ability to locate sounds in three dimensions

See your own brain already knows and does the trigonometry and all this mathe-matical expressions just bring the trigonometric expressions to you in a convenient form

135 Product-to-sum formula

Letrsquos derive the reverse formulas which allow us to convert the product of two waves into thesum (or difference) of separate waves

2cos x cos y = cos(x minus y) + cos(x + y) (19)

2sin x sin y = cos(x minus y) minus cos(x + y) (110)

2sin x cos y = sin(x + y) + sin(x minus y) (111)

2cos x sin y = sin(x + y) minus sin(x minus y) (112)

These formulas can be used for transmitting the information via radiowaves as we will seeshortly The derivation of this formulas is very simple all you need is to use Equations 13and 12 For example the formula 2 cos x cos y = cos(x minus y) + cos(x + y) can be derived as sumof the two equations below

15

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1526

cos(x + y) = cos x cos y minus sin x sin y+cos(x minus y) = cos x cos y + sin x sin y

where sin x sin y are gone and therefore we get cos(x + y)+cos(xminus y) = 2 cos x cos y exactlyas in Equation 19 Other formulas can be derived in a similar way

Why do we need these Product-to-sum formulas

The product-to-sum trigonometric formulas can be used to transmit and receive informationEver wondered what are those FM and AM acronyms stand for They stand for AmplitudeModulation and Frequency Modulation respectively - these are the methods of transmittingmusic on a radio and we are going to use trigonometry for this

First we need a carrier wave - we are going to modify it with the input signal (our music) totransmit music using radiowaves The carrier wave is usually of a much higher frequency thanthe input signal which helps us to detect the actual signal Letrsquos take a carrier wave C (t) of

frequency F c and amplitude A given by

C (t) = A lowast cos(2πF ct)

which is a function of time t We are going to modify (or as engineers say modulate ) thiscarrier wave C (t) with a music but for simplicity letrsquos say we want to transmit just a pure toneS (t) This signal S (t) represent the modulation soundwave of a frequency F m (which must be amuch lower frequency than F c)

S (t) = M lowast cos(2πF mt)

where M is the amplitude of the modulation Letrsquos agree that M lt 1 so that (1+ S (t)) is alwayspositive Amplitude modulation occurs when the carrier wave C (t) is multiplied by (1 + S (t))

y(t) = [1 + S (t)] lowast C (t) = [1 + M lowast cos(2πF mt)] lowast A lowast cos(2πF ct) (113)

Using the Equation 19 the resulting signal (as a function of time) y(t) can be shown to be

y(t) = A lowast cos(2πF ct) + AM 2

[cos(2π(F c + F m)t) + cos(2π(F c minus F m)t)]

The modulated radiowave is shown in Figure 115 and the program for this demonstrationis provided below

A = 2 amplitude

duration=4 in seconds

Freq sampling = 10000

values=01Freq samplingduration

Carrier Frequency=1000

C t =Acos(2pi Carrier Frequencyvalues)

M = 01 modulation coefficient

Signal Frequency = 120

S t = Mcos(2piSignal Frequencyvalues)

y t = ( 1+ S t )C t

figure plot(values y t ) this is to plot a beat

16

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1626

0005 001 0015 002 0025 003 0035 004 0045 005

Figure 115 The Amplitude Modulation in action we have a carrier wave of 1000 Hz frequencywhich is modulated (modified) with a tone of 120 Hz using Equation 113 Notice the change inthe amplitude on the plot

136 The power of Trigonometry meet the Discrete Cosine Transform

Many textbooks mention the applications of trigonometry like determining the height of a build-ing if you know the distance to it and the angle to the rooftop or some equally boringexoticexamples Here we are going to see a real-world application of cosine functions which is reallyuseful for sound analysis and compression - the Discrete Cosine Transform (DCT)

Be not afraid of this fancy name it simply means that we are going to use Cosine function toTransform or decompose our sound signal on pure tones (cosine functions of various frequencies)The word Discrete simply means that the values of our signal are sampled with some fixed-stepinterval - for example we measure a value of our signal every 01 seconds

Using DCT we are going to mathematically de-compose our signal into pure tones (or cosinewaves) and calculate how many cosine waves of this particular frequency do we have in thesignal This is extremely useful for analysis of the signal for example you can reduce the noisein signal by simply zeroing out the unwanted frequencies and transforming the signal back

There are many applications of DCT that we use every day without even knowing it

signal analysis by decomposing the signal on the pure cosine waves we can see what arethe main waves in the signal This way you can analyse for example stock market pricesto find any recurring periodical fluctuations of prices (and predict when it happens next)

audio compression MP3 format uses a variety of DCT algorithm to determine which soundfrequencies to keep and which to throw away compressing the song without noticeable lossin quality

images compression JPEG format also compresses the images using DCT-like algorithmto reduce the size of the image by throwing away unnecessary details

17

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1726

Example of frequency analysis using Discrete Cosine Transform

Letrsquos go back to our previous example and take it one step further we combine a soundwave of frequency F 1 = 400 Hz and amplitude A = 1 with a soundwave of frequency F 2 = 800 Hz and

amplitude A = 2

yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) (114)

were indexes with the letter k in yk and xk simply mean the row number in the table with yand x Thatrsquos where the word discrete comes into play our computers can work with discretenumbers and all we need is to take enough samples of a function (cosine in this case) close toeach other to describe the signal

In the program code below we take L = 1000 samples for our signal from Equation 114 andwe take samples of our signal close to each other - say once every t = 14000th of a second Here4000 is our sampling frequency - this is how often we evaluate our function in Equation 114 Wetook F sampling = 4000 arbitrary - any number larger than 800 will be fine

1 Fs = 4000 Sampling frequency

2 T = 1Fs Sample time

3 L = 1000 Length of signal counts

4 x k = (1L)T Time count

56 Sum of a 400 Hz wave and a 800 Hz wave

7 y k = cos(2pi400x k) + 2cos(2pi800x k)

89 Now add some random noise to the sum of waves

10 y k n oisy = y k + 2randn(size(x k ))

1112 figure plot(Fsx k(1200)y k(1200))

13 title(Original signal (sum of two waves)) xlabel(time (milliseconds))

1415 figure plot(Fsx k(1200)y k noisy(1200))

16 title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

That is take L = 1000 numbers (line 3) and generate xk values (line 4) to be plugged intoEquation 114 (line 7) The plot of the signal can be seen in Figure 116(a)

The Discrete Cosine Transform Now the main part we are going to transform (decompose)our sound signal into pure tones (cosine waves of different frequencies) using the Discrete CosineTransform (DCT)

Dk =

N minus1991761n=0

yn cos

983131π

N

983080n +

1

2

983081k

983133 for every frequency k = 0 N minus 1 (115)

Now what does this formula2 actually mean

the signN minus1sumn=0

means ldquosumming elements with subscript n from n = 0 to n = N minus 1

N is the length of the signal y - in our case the signal has 1000 values (a row in a tablewith 1000 cells)

2This formula does not include a normalisation term to account for the number of samples - Irsquom skipping itto simplify the discussion

18

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1826

0 20 40 60 80 100 120 140 160 180 200minus2

minus15

minus1

minus05

0

05

1

15

2

25

3Original signal (sum of two waves)

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

40

X 400Y 2127

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 800Y 3618

(b)

Figure 116 Clean noiseless signal (a) The plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk)(b) the wave frequencies (Discrete Cosine Transform) in the noiseless signal you can see 400 Hzand 800 Hz peaks

yn we take from Equation 114

and we do this for every frequency k from 0 to N minus 1 At the end we get a row of numbersDk that tells us how many cosine waves with frequency 0 1 2 all the way up to frequency N minus1do we have in our signal The program code (MATLAB or Octave) for the DCT formula inEquation 115 is quite simple3

function D = my dct(y)

N = length(y) N rows do we have in the signal yD = zeros(N1) D stores the DCT transform of the signal y

for k = 01Nminus1 for every frequency k = 0 to Nminus1 with step 1

for n = 01Nminus1 for every row value of signal y do this

D(k+1) = D(k+1) + y(n+1)cos(piN (n + 12)k)

end the line above literary implements the DCT formula

end

There is no need to program the DCT formula in MATLAB and Octave it can be calledusing dct(Y) command to transform the signal stored in the variable Y

Now if we now plot the numbers in the variable Dk versus frequencies of a cosine wave (kfrom 0 to N-1) we will see the picture like the one in Fig 116(b) Notice two peaks at 400 and800 Hz - these peaks correspond to the cosine waves in our signal described by Equation 114

yk = cos(2 lowast pi lowast 400 lowast xk) + 2 lowast cos(2 lowast pi lowast 800 lowast xk)This is exactly what we expect after all our soundwave contains only 400 Hz and 800 Hz

cosine waves and those peaks of DCT indicate thisNow imagine that our soundwave was recorded with a bad microphone we have a lot of

noise in the recording If you look at Figure 117(a) there is so much noise that you donrsquot evensee the waves But if you use the DCT to decompose the noised signal and again make the plot

3The code is not efficient and it will take a lot of time for long signals However it is a simple word-for-wordimplementation of the DCT mathematical formula and serves its illustrative purpose

19

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1926

of its result you will be able to see those peaks (that correspond to soundwaves buried undernoise) in Figure 117(b)

0 20 40 60 80 100 120 140 160 180 200minus6

minus4

minus2

0

2

4

6

8

Signal Corrupted with Random Noise

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

X 800Y 3367

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 400Y 1858

(b)

Figure 117 Noised signal (a) the plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) with lotsof noise added (b) the wave frequencies (Discrete Cosine Transform) in the signal you can see400 Hz and 800 Hz peaks

This is the real power of trigonometric functions we can decompose even a very noisysignal and still see what are the cosine waves (that use pure tones) that make it And not justto look at the plot but also clean up the signal we can just zero-out the small numbers in theDCT variable Dk to clean up the noise and transform the signal back to its original state - andnoise is (almost) gone

The MATLAB (or Octave) code for this example is below

Fs = 4000 Sampling frequency

T = 1Fs Sample time

L = 1000 Length of signal counts

x k = (1L)T Time count

Sum of a 400 Hz wave and a 800 Hz wave

y k = cos(2pi400x k) + 2cos(2pi800x k)

Now add some random noise to the sum of waves

y k n oisy = y k + 2randn(size(x k )) Sinusoids plus noise

figure plot(Fsx k(1200)y k(1200))

title(Original signal (sum of two waves)) xlabel(time (milliseconds))

figure plot(Fsx k(1200)y k noisy(1200))

title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

How many cosine waves of different frequencies we have in the signal

D k dct clean signal = dct(y kL)

D k dct noisy signal = dct(y k noisyL)

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

20

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 5: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 526

2 4 6 8 10

x 10minus3

Figure 12 The tone of 400 Hz (blue) and 800 Hz (green)

x = 0017

y = cos(x)

y2 = cos(2x)

figure plot(xyxy2)

legend(cos(x) cos(2x) Location SouthEast)

which means that

1 x = 0017 generate the row of numbers from 0 to 7 with a step of 01

2 y = cos(x) substitute numbers from x into cos(x) function to get row of cosine values y

3 y2 = cos(2x) substitute numbers from x into cos(2lowastx) to get row of cosine values withdouble frequency (2x) in y

4 figure plot(xyxy2) to plot y and y2 values on a plot like the one in Figure 13

If we compare plots in Figure 12 and Figure 13 we discover that they are very similar- in fact the trigonometric functions y = cos(x) and y = cos(2lowastx) are describing the soundwavesof two pitches 400 Hz and 800 Hz (single and double frequency)

Takeaway trigonometric function cos(x) is a very good model of a soundwave(that is a pure tone) doubling the frequency of the tone (from 400 to 800 Hz) in ourexample) can be well described by doubling the variable inside the cosine functionfrom y = cos(x) to y = cos(2 lowast x) In fact it does not matter if this is a sound wavea light wave or a wave on the surface of a pond - the cosine function will model themas well just change the frequency and amplitude accordingly

But you may notice that the values on a vertical axis in Figure 12 and Figure 13 are verydifferent - this brings us to the notion of amplitude

3

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 626

0 1 2 3 4 5 6 7minus1

minus08

minus06

minus04

minus02

0

02

04

06

08

1

cos(x)

cos(2x)

Figure 13 The plot of y = cos(x) and y = cos(2 lowast x) where x are from 0 to 7

Sound volume (or amplitude) Every time your listen to the music you use that little knobcalled ldquoVolumerdquo to make the song louder or quieter Your music player changes the amplitude of the soundwaves - yes those cosine waves above If we make another plot of two cosine functionsy = cos(x) and y = 2 lowast cos(x) we can see from Fig 14 that those plots are just scaled versionsof one another

0 1 2 3 4 5 6 7minus2

minus15

minus1

minus05

0

05

1

15

2

Figure 14 The plot of y = cos(x) and y = 2 lowast cos(x) where x are from 0 to 7

4

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 726

This brings us to a more general model of a wave

y = A lowast cos(F lowast x)

where A stands for amplitude - a constant that controls the scale of the function (volume of a soundwave) and F stands for f requency - a constant that controls how many complete turnsthe function does (pitch or a tone of a soundwave) The cosine function cos(x) is a idealisedmodel of a wave with unit amplitude and unit frequency and this is why it returns the valuesfrom -1 to 1

By now you should see that you cannot just take the number N out of brackets in cos(N lowastx)and put it in front of the function - you cannot convert the frequency into volume this easilyThe conversion is a bit more complicated and we will see it in trigonometric identities below

5

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 826

13 Trigonometric identities derivation and meaning

As we have already seen we can think of trigonometric functions as models of waves that can bedescribed as y = A lowast cos(F lowast x) Here A stands for amplitude F stands for f requency and x isa running variable (time for example) But apart from generating pure tones cosine and sinusfunctions do not take us very far - we need to know the relationships between them if we want touse trigonometry for something useful Relationships between trigonometric functions are morecomplex than just adding numbers and there are formulas that describe those relationships

But there is no need to memorise all the formulas once you understand few basic trigono-metric identities how the really work you will be able to easily derive the rest of the formulas

131 Sum of squares

One of the most useful identity is a sum of cosine and sine squares

sin2(x) + cos2(x) = 1 (11)

If you look at Figure 18 you will notice that when a cos 2(x) has its Y -value at 05 so doesthe sin2(x) If you add them together the result will be equal 1 Moreover all other points onthe plot for cos2(x) and sin2(x) will give 1 in sum when one of the functions is at valley anotherhas a peak at 1 and so on Therefore the sum of squares sin2(x) + cos2(x) always equals 1

minus5 minus4 minus3 minus2 minus1 0 1 2 3 4 50

02

04

06

08

1

12

14

cos2(x)

sin2(x)

cos2(x) + sin

2(x)=1

Figure 18 The plot of sin2

(x) + cos2

(x) = 1

The computer program for MATLAB or Octave programming languages that makes this plot is

x = minus50015

figure plot(xcos(x)ˆ2xsin(x)ˆ2x cos(x) 2 + sin(x) 2 )

legend(cosˆ2(x) sinˆ2(x) cosˆ2(x) + sin 2(x)=1

Location SouthEast)

9

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 926

Proof of Sum of squares formula

Figure 19 A geometric proof for identitysin2(x) + cos2(x) = 1

This identity can be also derived without any plotsusing only geometry Recall that the trigonometric

functions are connected with a circle of unit radiush = 1 as shown in Figure 19

Take any point on a circle of unit radius h =1 and put a vertical line down - this gives us atriangle with right angle 90 with sides a and band hypotenuse h = 1

Pythagorean theorem tells us that a2 + b2 = h2

in the right triangle and all we need is to expressthe sides in terms of cosine and sinus of an anglex We know that sin(x) = opposite

hypotenuse = a

h and

cos(x) = adjacenthypotenuse = b

h

Since h = 1 we have a2+b2 = 1 and sin(x) = a1

and cos x = b1 Substituting it back we get

sin2(x) + cos2(x) = 1 just like in Equation 11

132 Sum and difference of angles for sin(x) and cos(x)

As you may have guessed cosine wave of sum of frequencies is not just a sum of cosine wavesthat is the expression cos(x + y) = cos(x)+cos(y) is wrong and the actual expression is a bitmore complicated

cos(x plusmn y) = cos x cos y ∓ sin x sin y (12)

sin(x plusmn y) = sin x cos y plusmn cos x sin y (13)

The expressions above are very important since once you understood and memorised themyou can derive pretty much any other expression for sine and cosine functions Youcan make a plot (like in Figure 110) and compare for example cos(x + 2x) and cos x cos(2x)minussin x sin(2x) to make sure that the expression from Equation 12 is true

The program code that can plot Figure 110 in MATLAB or Octave programming languageis quite simple

y cos 3x = cos(3x)

y sin x = sin(x)

y cos x = cos(x)

y sin 2x = sin(2x)

y cos 2x = cos(2

x)

figure plot(x y cos xy c o s 2 x minus y s i n x y s i n 2 x

x y c o s x y c os 2 x x y s i n xy s i n 2 x )

legend(cos(3x) cos(x)cos(2x) sin(x)sin(2x)Location SouthEast)

Both equations 13 and 12 are so important that they deserve a formal proof 1

1There are many ways to prove those identities like using complex exponentials The proof here is Smiley Land Smiley D rdquoGeometry of Addition and Subtraction Formulasrdquo

10

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1026

0 1 2 3 4 5 6 7minus1

minus08

minus06

minus04

minus02

0

02

04

06

08

1

cos(3x)

cos(x)cos(2x)

sin(x)sin(2x)

Figure 110 The plot of cos(x + 2x) and cos x cos(2x) minus sin x sin(2x) for comparison If yousubtract the plot with sin x sin(2x) from cos x cos(2x) you will get cos(3x)

Proof for sin(α plusmn β )

Figure 111 Illustration for theproof of sin(α + β ) = sin α cos β +cos α sin β

Letrsquos take the right triangle ABC in Figure 111 such thatAK = 1 (unit length) For the proof we will need sin(α) =AC AB

so we need to express those sides in terms of cosine andsine

From ABC (α + β ) + γ = 90 there4 γ = 90 minus (α + β )From AKC angAKC + γ = 90 there4 angAKC = (α +

β ) since γ = 90 minus (α + β )Now we express side AC sin(α + β ) = AC

1 there4 AC =

sin(α + β )From ANK we are looking for expressions of sides

AN and NKcos β = AN

1 there4 AN = cos β Remember that we choose

AK to be of unit length - exactly for this Now find NKsin β = NK

1 there4 N K = sin β

From NBK we need to find NB that we need forthe proof of the formula (from Figure 111 you can see that

NB+AN = AB that we are looking for)tan α = NK

NB there4 NB = NK

tanα = sinβtanα = sinβ cosα

sinα We haveeverything we need by now and we turn back to our maintriangle ABC

Finally from ABC sin α = AC AB

= AC NB+AN

=sin(α+β)

cosβ+ sinβ cosαsinα

From this expression we need sin(α + β )

which is

11

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1126

sin(α + β ) = sin α

983080cos β +

sin β cos α

sin α

983081= sin α cos β + cos α sin β

This concludes the proof Formula for sin(αminusβ ) can be obtained simply substituting minusβ into the formula above which

gives Equation 13

Proof for cos(α plusmn β )

Figure 112 Illustration for the proof of cos(α + β ) = cos α cos β minussin α sin β

The proof is very similar to the previous one exceptwe put the angle β to the angKAC The side AK is stillof unit length as seen in Figure 112 For this proofwe will need tan(α) = AC

BC so we need to express those

sides in terms of cosine and sineFrom ABC (α+β )+γ = 90 there4 γ = 90minus(α+β )From ANK angNKA + γ = 90 there4 angN KA =

(α + β )Now we express the side NK cos(α + β ) = NK

1 there4

N K = cos(α + β ) Remember that we choose AK to beof unit length - exactly for this

From NBK sin α = NK BK

there4 BK = cos(α+β)sinα

From AKC we need to express the sides AC andKC in terms of trigonometric functions As before no-tice that AK is unit length that is AK = 1

cos β = AC 1

there4 AC = cos β

sin β = KC 1

there4 KC = sin β

Finally from ABC tan α = sinαcosα = AC

BC =

AC BK +KC = cosβ

cos(α+β)

sinα +sinβ

and all we need is to express

cos(α + β ) that we are looking for

sin α

cos α =

cos β sin α

cos(α + β ) + sin β sin α

from where

cos(α + β ) = cos α cos β minus sin α sin β

This concludes the proof

Formula for cos(α minus β ) can be obtained by simply substituting minusβ into the formula abovewhich gives Equation 12

Now since we have proven the formulas for sum and difference for cosine and sinefunctions we will get nearly all other formulas - again you donrsquot have to memorisethem mechanically since you can (relatively) simply derive them

133 Double-angle formulae

As before keep in mind that cosine and sine functions describe a wave thus cos(2x) is a waveof double frequency compared to a simple wave cos(x) The relationship between a wave of double and unit frequency is

12

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1226

sin2x = 2 sin x cos x (14)

You can simply derive the expression in Equation 14 using Equation 13 and the following

trick sin(2x) = sin(x + x) So sin 2x = sin x lowast cos x + sin x lowast cos x = 2 sin x cos x Derivationof the double-angle formula for cosine is similar just use Equation 12 and the same trickcos(2x) = cos(x + x)

cos2x = cos x lowast cos x minus sin x lowast sin x = cos2 x minus sin2 x = 2 cos2 x minus 1 = 1 minus 2sin2 x (15)

Why do we need the double-angle formula

An illustrative example this time comes from optics there are optical crystals that can double thefrequency of a lightwave such as lithium niobate (LN) or potassium titanyl phosphate (KTP)That is you can convert a light of a infra-red laser (with wavelength of 11microm that is easy toget) into a green laser light (wavelength 055microm) Most laser pointers that produce green light

use these frequency-doubling crystals

Figure 113 Doubling the lightwave frequency converting from cos(x) to cos(2x) in optics

134 Sum-to-Product Formulas

We already know by now that sine and cosine functions are models of waves and we cannot just sum them like cos x + cosy = cos(x + y) The following expressions will allow us to convertsum and difference of trigonometry functions into products

sin x plusmn sin y = 2 sin

983080x plusmn y

2

983081cos

983080x ∓ y

2

983081 (16)

cos x + cos y = 2 cos

983080x + y

2

983081cos

983080x minus y

2

983081 (17)

cos x minus cos y = minus2sin983080x + y

2983081

sin983080x minus y

2983081

(18)

These formulas can be derived using the expressions for double angles in Equation 14 andEquation 15 Letrsquos do it for sin(x)+sin(y) In this proof we take the right part of Equation 16and try to show that it is equivalent to the left part Use Equation 14 to get

2sin

983080x + y

2

983081cos

983080x minus y

2

983081= 2 lowast

1048616sin

x

2 cos

y

2 + cos

x

2 sin

y

2

1048617lowast1048616

cos x

2 cos

y

2 + sin

x

2 sin

y

2

1048617=

13

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1326

Here we just used the Equation 13 and Equation 12 Open the brackets and multiply theseitems to get

= 2 lowast1048616

sin x2

cos2 y2

cos x2

+ sin2 x2

cos y2

sin y2

+ sin y2

cos2 x2

cos y2

+ sin2 y2

cos x2

sin x2

1048617=

Take a closer look at item 1 and 4 - we can group them like this cos x2 sin x2 (sin2 y

2 +cos2 y2 )

Notice that the sum inside brackets equals 1 as we already know from sin2(x)+cos2(x) = 1 (seeEquation 11) The items 2 and 3 in the expression above can be grouped similarly so we get

= 2 lowast1048616

cos y

2 sin

y

2 + sin

x

2 cos

x

2

1048617=

Now open the brackets and look closely on each item for instance 2 cos y2 sin y2 looks similar

to Equation 14 Therefore 2 cos y2

sin y2

= sin(2 lowast y2

) = sin y and therefore

= 2 lowast 1048616cos y

2

sin y

2

+ sin x

2

cos x

21048617 = sin y + sin x

which is exactly the Equation 16 and concludes our proof

Why do we need sum-to-product formulas

These sum-to-product formulas are really special because your own brain does this all the time sounds that you hear with both ears are summed and processed by the brain so you can determinefor example where does the sound came from You can actually trick your own brain into findinga sum of two cosine waves (soundwaves) and hear binaural beats For example if a frequencyof 100 Hz is presented to your left ear and a frequency of 105 Hz is presented to your rightear your brain ldquohearsrdquo a third frequency pulsing at 5 Hz the exact difference between the twofrequencies Some binaural beat frequencies were found to be useful in auditory stimulation toenhance brain functioning

We can use the formula of sum-to-product to find the expression for sum of two sound waveswith frequency f 1 and f 2

cos(2πf 1t) + cos(2πf 2t) = 2 cos

9830802π

(f 1 + f 2)

2 t

983081cos

9830802π

(f 1 minus f 2)

2 t

983081

where t is a variable for time If the two sound frequencies are close (a difference f 1 minus f 2of about twenty hertz) the frequency of the sound wave is often too slow to be perceived as apitch Instead the sound wave is perceived as a periodic variation (beat) of the volume whichis described by the expression above We can see it in Figure 114

The program below (runs in MATLAB and GNUOctave) generates two sound waves (astereo sound) with two pure tones of frequencies f 1 = 500Hz and f 2 = 500 + 30 = 530Hz Thenthe sound is played for 4 seconds

Amplitude=10

duration=4 seconds

Frequency=500

Frequency diff= 30 frequency difference for beat

Freq sampling=10000 sampling frequency

values=01Freq samplingduration

left=Amplitudecos(2pi Frequencyvalues)

14

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1426

002 004 006 008 01 012

Figure 114 The sum (blue) of two cosine waves compared to a single wave (green) The functionplotted is yk = cos(2π lowast 500xk) + cos(2π lowast 530xk)

right = Amplitudecos(2pi (Frequency+Frequency diff)values)

stereosnd = [left right] combining two sounds at a stereo

soundsc(stereosnd Freq sampling) play the sound

You should use headphones to listen to this sound Put one earpiece in your ear and youwill hear a pure tone Then move the second earpiece slowly to your other ear - and instead of two separate tone you are going to hear a sound beat since the frequencies (or tones) differ

slightly (only by 30 Hz) Keep in mind that those two tones do not mix - they are in the left andright earpieces That is the tones do not interfere physically but are summed by the brainThis effect is related to the brainrsquos ability to locate sounds in three dimensions

See your own brain already knows and does the trigonometry and all this mathe-matical expressions just bring the trigonometric expressions to you in a convenient form

135 Product-to-sum formula

Letrsquos derive the reverse formulas which allow us to convert the product of two waves into thesum (or difference) of separate waves

2cos x cos y = cos(x minus y) + cos(x + y) (19)

2sin x sin y = cos(x minus y) minus cos(x + y) (110)

2sin x cos y = sin(x + y) + sin(x minus y) (111)

2cos x sin y = sin(x + y) minus sin(x minus y) (112)

These formulas can be used for transmitting the information via radiowaves as we will seeshortly The derivation of this formulas is very simple all you need is to use Equations 13and 12 For example the formula 2 cos x cos y = cos(x minus y) + cos(x + y) can be derived as sumof the two equations below

15

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1526

cos(x + y) = cos x cos y minus sin x sin y+cos(x minus y) = cos x cos y + sin x sin y

where sin x sin y are gone and therefore we get cos(x + y)+cos(xminus y) = 2 cos x cos y exactlyas in Equation 19 Other formulas can be derived in a similar way

Why do we need these Product-to-sum formulas

The product-to-sum trigonometric formulas can be used to transmit and receive informationEver wondered what are those FM and AM acronyms stand for They stand for AmplitudeModulation and Frequency Modulation respectively - these are the methods of transmittingmusic on a radio and we are going to use trigonometry for this

First we need a carrier wave - we are going to modify it with the input signal (our music) totransmit music using radiowaves The carrier wave is usually of a much higher frequency thanthe input signal which helps us to detect the actual signal Letrsquos take a carrier wave C (t) of

frequency F c and amplitude A given by

C (t) = A lowast cos(2πF ct)

which is a function of time t We are going to modify (or as engineers say modulate ) thiscarrier wave C (t) with a music but for simplicity letrsquos say we want to transmit just a pure toneS (t) This signal S (t) represent the modulation soundwave of a frequency F m (which must be amuch lower frequency than F c)

S (t) = M lowast cos(2πF mt)

where M is the amplitude of the modulation Letrsquos agree that M lt 1 so that (1+ S (t)) is alwayspositive Amplitude modulation occurs when the carrier wave C (t) is multiplied by (1 + S (t))

y(t) = [1 + S (t)] lowast C (t) = [1 + M lowast cos(2πF mt)] lowast A lowast cos(2πF ct) (113)

Using the Equation 19 the resulting signal (as a function of time) y(t) can be shown to be

y(t) = A lowast cos(2πF ct) + AM 2

[cos(2π(F c + F m)t) + cos(2π(F c minus F m)t)]

The modulated radiowave is shown in Figure 115 and the program for this demonstrationis provided below

A = 2 amplitude

duration=4 in seconds

Freq sampling = 10000

values=01Freq samplingduration

Carrier Frequency=1000

C t =Acos(2pi Carrier Frequencyvalues)

M = 01 modulation coefficient

Signal Frequency = 120

S t = Mcos(2piSignal Frequencyvalues)

y t = ( 1+ S t )C t

figure plot(values y t ) this is to plot a beat

16

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1626

0005 001 0015 002 0025 003 0035 004 0045 005

Figure 115 The Amplitude Modulation in action we have a carrier wave of 1000 Hz frequencywhich is modulated (modified) with a tone of 120 Hz using Equation 113 Notice the change inthe amplitude on the plot

136 The power of Trigonometry meet the Discrete Cosine Transform

Many textbooks mention the applications of trigonometry like determining the height of a build-ing if you know the distance to it and the angle to the rooftop or some equally boringexoticexamples Here we are going to see a real-world application of cosine functions which is reallyuseful for sound analysis and compression - the Discrete Cosine Transform (DCT)

Be not afraid of this fancy name it simply means that we are going to use Cosine function toTransform or decompose our sound signal on pure tones (cosine functions of various frequencies)The word Discrete simply means that the values of our signal are sampled with some fixed-stepinterval - for example we measure a value of our signal every 01 seconds

Using DCT we are going to mathematically de-compose our signal into pure tones (or cosinewaves) and calculate how many cosine waves of this particular frequency do we have in thesignal This is extremely useful for analysis of the signal for example you can reduce the noisein signal by simply zeroing out the unwanted frequencies and transforming the signal back

There are many applications of DCT that we use every day without even knowing it

signal analysis by decomposing the signal on the pure cosine waves we can see what arethe main waves in the signal This way you can analyse for example stock market pricesto find any recurring periodical fluctuations of prices (and predict when it happens next)

audio compression MP3 format uses a variety of DCT algorithm to determine which soundfrequencies to keep and which to throw away compressing the song without noticeable lossin quality

images compression JPEG format also compresses the images using DCT-like algorithmto reduce the size of the image by throwing away unnecessary details

17

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1726

Example of frequency analysis using Discrete Cosine Transform

Letrsquos go back to our previous example and take it one step further we combine a soundwave of frequency F 1 = 400 Hz and amplitude A = 1 with a soundwave of frequency F 2 = 800 Hz and

amplitude A = 2

yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) (114)

were indexes with the letter k in yk and xk simply mean the row number in the table with yand x Thatrsquos where the word discrete comes into play our computers can work with discretenumbers and all we need is to take enough samples of a function (cosine in this case) close toeach other to describe the signal

In the program code below we take L = 1000 samples for our signal from Equation 114 andwe take samples of our signal close to each other - say once every t = 14000th of a second Here4000 is our sampling frequency - this is how often we evaluate our function in Equation 114 Wetook F sampling = 4000 arbitrary - any number larger than 800 will be fine

1 Fs = 4000 Sampling frequency

2 T = 1Fs Sample time

3 L = 1000 Length of signal counts

4 x k = (1L)T Time count

56 Sum of a 400 Hz wave and a 800 Hz wave

7 y k = cos(2pi400x k) + 2cos(2pi800x k)

89 Now add some random noise to the sum of waves

10 y k n oisy = y k + 2randn(size(x k ))

1112 figure plot(Fsx k(1200)y k(1200))

13 title(Original signal (sum of two waves)) xlabel(time (milliseconds))

1415 figure plot(Fsx k(1200)y k noisy(1200))

16 title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

That is take L = 1000 numbers (line 3) and generate xk values (line 4) to be plugged intoEquation 114 (line 7) The plot of the signal can be seen in Figure 116(a)

The Discrete Cosine Transform Now the main part we are going to transform (decompose)our sound signal into pure tones (cosine waves of different frequencies) using the Discrete CosineTransform (DCT)

Dk =

N minus1991761n=0

yn cos

983131π

N

983080n +

1

2

983081k

983133 for every frequency k = 0 N minus 1 (115)

Now what does this formula2 actually mean

the signN minus1sumn=0

means ldquosumming elements with subscript n from n = 0 to n = N minus 1

N is the length of the signal y - in our case the signal has 1000 values (a row in a tablewith 1000 cells)

2This formula does not include a normalisation term to account for the number of samples - Irsquom skipping itto simplify the discussion

18

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1826

0 20 40 60 80 100 120 140 160 180 200minus2

minus15

minus1

minus05

0

05

1

15

2

25

3Original signal (sum of two waves)

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

40

X 400Y 2127

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 800Y 3618

(b)

Figure 116 Clean noiseless signal (a) The plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk)(b) the wave frequencies (Discrete Cosine Transform) in the noiseless signal you can see 400 Hzand 800 Hz peaks

yn we take from Equation 114

and we do this for every frequency k from 0 to N minus 1 At the end we get a row of numbersDk that tells us how many cosine waves with frequency 0 1 2 all the way up to frequency N minus1do we have in our signal The program code (MATLAB or Octave) for the DCT formula inEquation 115 is quite simple3

function D = my dct(y)

N = length(y) N rows do we have in the signal yD = zeros(N1) D stores the DCT transform of the signal y

for k = 01Nminus1 for every frequency k = 0 to Nminus1 with step 1

for n = 01Nminus1 for every row value of signal y do this

D(k+1) = D(k+1) + y(n+1)cos(piN (n + 12)k)

end the line above literary implements the DCT formula

end

There is no need to program the DCT formula in MATLAB and Octave it can be calledusing dct(Y) command to transform the signal stored in the variable Y

Now if we now plot the numbers in the variable Dk versus frequencies of a cosine wave (kfrom 0 to N-1) we will see the picture like the one in Fig 116(b) Notice two peaks at 400 and800 Hz - these peaks correspond to the cosine waves in our signal described by Equation 114

yk = cos(2 lowast pi lowast 400 lowast xk) + 2 lowast cos(2 lowast pi lowast 800 lowast xk)This is exactly what we expect after all our soundwave contains only 400 Hz and 800 Hz

cosine waves and those peaks of DCT indicate thisNow imagine that our soundwave was recorded with a bad microphone we have a lot of

noise in the recording If you look at Figure 117(a) there is so much noise that you donrsquot evensee the waves But if you use the DCT to decompose the noised signal and again make the plot

3The code is not efficient and it will take a lot of time for long signals However it is a simple word-for-wordimplementation of the DCT mathematical formula and serves its illustrative purpose

19

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1926

of its result you will be able to see those peaks (that correspond to soundwaves buried undernoise) in Figure 117(b)

0 20 40 60 80 100 120 140 160 180 200minus6

minus4

minus2

0

2

4

6

8

Signal Corrupted with Random Noise

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

X 800Y 3367

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 400Y 1858

(b)

Figure 117 Noised signal (a) the plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) with lotsof noise added (b) the wave frequencies (Discrete Cosine Transform) in the signal you can see400 Hz and 800 Hz peaks

This is the real power of trigonometric functions we can decompose even a very noisysignal and still see what are the cosine waves (that use pure tones) that make it And not justto look at the plot but also clean up the signal we can just zero-out the small numbers in theDCT variable Dk to clean up the noise and transform the signal back to its original state - andnoise is (almost) gone

The MATLAB (or Octave) code for this example is below

Fs = 4000 Sampling frequency

T = 1Fs Sample time

L = 1000 Length of signal counts

x k = (1L)T Time count

Sum of a 400 Hz wave and a 800 Hz wave

y k = cos(2pi400x k) + 2cos(2pi800x k)

Now add some random noise to the sum of waves

y k n oisy = y k + 2randn(size(x k )) Sinusoids plus noise

figure plot(Fsx k(1200)y k(1200))

title(Original signal (sum of two waves)) xlabel(time (milliseconds))

figure plot(Fsx k(1200)y k noisy(1200))

title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

How many cosine waves of different frequencies we have in the signal

D k dct clean signal = dct(y kL)

D k dct noisy signal = dct(y k noisyL)

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

20

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 6: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 626

0 1 2 3 4 5 6 7minus1

minus08

minus06

minus04

minus02

0

02

04

06

08

1

cos(x)

cos(2x)

Figure 13 The plot of y = cos(x) and y = cos(2 lowast x) where x are from 0 to 7

Sound volume (or amplitude) Every time your listen to the music you use that little knobcalled ldquoVolumerdquo to make the song louder or quieter Your music player changes the amplitude of the soundwaves - yes those cosine waves above If we make another plot of two cosine functionsy = cos(x) and y = 2 lowast cos(x) we can see from Fig 14 that those plots are just scaled versionsof one another

0 1 2 3 4 5 6 7minus2

minus15

minus1

minus05

0

05

1

15

2

Figure 14 The plot of y = cos(x) and y = 2 lowast cos(x) where x are from 0 to 7

4

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 726

This brings us to a more general model of a wave

y = A lowast cos(F lowast x)

where A stands for amplitude - a constant that controls the scale of the function (volume of a soundwave) and F stands for f requency - a constant that controls how many complete turnsthe function does (pitch or a tone of a soundwave) The cosine function cos(x) is a idealisedmodel of a wave with unit amplitude and unit frequency and this is why it returns the valuesfrom -1 to 1

By now you should see that you cannot just take the number N out of brackets in cos(N lowastx)and put it in front of the function - you cannot convert the frequency into volume this easilyThe conversion is a bit more complicated and we will see it in trigonometric identities below

5

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 826

13 Trigonometric identities derivation and meaning

As we have already seen we can think of trigonometric functions as models of waves that can bedescribed as y = A lowast cos(F lowast x) Here A stands for amplitude F stands for f requency and x isa running variable (time for example) But apart from generating pure tones cosine and sinusfunctions do not take us very far - we need to know the relationships between them if we want touse trigonometry for something useful Relationships between trigonometric functions are morecomplex than just adding numbers and there are formulas that describe those relationships

But there is no need to memorise all the formulas once you understand few basic trigono-metric identities how the really work you will be able to easily derive the rest of the formulas

131 Sum of squares

One of the most useful identity is a sum of cosine and sine squares

sin2(x) + cos2(x) = 1 (11)

If you look at Figure 18 you will notice that when a cos 2(x) has its Y -value at 05 so doesthe sin2(x) If you add them together the result will be equal 1 Moreover all other points onthe plot for cos2(x) and sin2(x) will give 1 in sum when one of the functions is at valley anotherhas a peak at 1 and so on Therefore the sum of squares sin2(x) + cos2(x) always equals 1

minus5 minus4 minus3 minus2 minus1 0 1 2 3 4 50

02

04

06

08

1

12

14

cos2(x)

sin2(x)

cos2(x) + sin

2(x)=1

Figure 18 The plot of sin2

(x) + cos2

(x) = 1

The computer program for MATLAB or Octave programming languages that makes this plot is

x = minus50015

figure plot(xcos(x)ˆ2xsin(x)ˆ2x cos(x) 2 + sin(x) 2 )

legend(cosˆ2(x) sinˆ2(x) cosˆ2(x) + sin 2(x)=1

Location SouthEast)

9

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 926

Proof of Sum of squares formula

Figure 19 A geometric proof for identitysin2(x) + cos2(x) = 1

This identity can be also derived without any plotsusing only geometry Recall that the trigonometric

functions are connected with a circle of unit radiush = 1 as shown in Figure 19

Take any point on a circle of unit radius h =1 and put a vertical line down - this gives us atriangle with right angle 90 with sides a and band hypotenuse h = 1

Pythagorean theorem tells us that a2 + b2 = h2

in the right triangle and all we need is to expressthe sides in terms of cosine and sinus of an anglex We know that sin(x) = opposite

hypotenuse = a

h and

cos(x) = adjacenthypotenuse = b

h

Since h = 1 we have a2+b2 = 1 and sin(x) = a1

and cos x = b1 Substituting it back we get

sin2(x) + cos2(x) = 1 just like in Equation 11

132 Sum and difference of angles for sin(x) and cos(x)

As you may have guessed cosine wave of sum of frequencies is not just a sum of cosine wavesthat is the expression cos(x + y) = cos(x)+cos(y) is wrong and the actual expression is a bitmore complicated

cos(x plusmn y) = cos x cos y ∓ sin x sin y (12)

sin(x plusmn y) = sin x cos y plusmn cos x sin y (13)

The expressions above are very important since once you understood and memorised themyou can derive pretty much any other expression for sine and cosine functions Youcan make a plot (like in Figure 110) and compare for example cos(x + 2x) and cos x cos(2x)minussin x sin(2x) to make sure that the expression from Equation 12 is true

The program code that can plot Figure 110 in MATLAB or Octave programming languageis quite simple

y cos 3x = cos(3x)

y sin x = sin(x)

y cos x = cos(x)

y sin 2x = sin(2x)

y cos 2x = cos(2

x)

figure plot(x y cos xy c o s 2 x minus y s i n x y s i n 2 x

x y c o s x y c os 2 x x y s i n xy s i n 2 x )

legend(cos(3x) cos(x)cos(2x) sin(x)sin(2x)Location SouthEast)

Both equations 13 and 12 are so important that they deserve a formal proof 1

1There are many ways to prove those identities like using complex exponentials The proof here is Smiley Land Smiley D rdquoGeometry of Addition and Subtraction Formulasrdquo

10

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1026

0 1 2 3 4 5 6 7minus1

minus08

minus06

minus04

minus02

0

02

04

06

08

1

cos(3x)

cos(x)cos(2x)

sin(x)sin(2x)

Figure 110 The plot of cos(x + 2x) and cos x cos(2x) minus sin x sin(2x) for comparison If yousubtract the plot with sin x sin(2x) from cos x cos(2x) you will get cos(3x)

Proof for sin(α plusmn β )

Figure 111 Illustration for theproof of sin(α + β ) = sin α cos β +cos α sin β

Letrsquos take the right triangle ABC in Figure 111 such thatAK = 1 (unit length) For the proof we will need sin(α) =AC AB

so we need to express those sides in terms of cosine andsine

From ABC (α + β ) + γ = 90 there4 γ = 90 minus (α + β )From AKC angAKC + γ = 90 there4 angAKC = (α +

β ) since γ = 90 minus (α + β )Now we express side AC sin(α + β ) = AC

1 there4 AC =

sin(α + β )From ANK we are looking for expressions of sides

AN and NKcos β = AN

1 there4 AN = cos β Remember that we choose

AK to be of unit length - exactly for this Now find NKsin β = NK

1 there4 N K = sin β

From NBK we need to find NB that we need forthe proof of the formula (from Figure 111 you can see that

NB+AN = AB that we are looking for)tan α = NK

NB there4 NB = NK

tanα = sinβtanα = sinβ cosα

sinα We haveeverything we need by now and we turn back to our maintriangle ABC

Finally from ABC sin α = AC AB

= AC NB+AN

=sin(α+β)

cosβ+ sinβ cosαsinα

From this expression we need sin(α + β )

which is

11

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1126

sin(α + β ) = sin α

983080cos β +

sin β cos α

sin α

983081= sin α cos β + cos α sin β

This concludes the proof Formula for sin(αminusβ ) can be obtained simply substituting minusβ into the formula above which

gives Equation 13

Proof for cos(α plusmn β )

Figure 112 Illustration for the proof of cos(α + β ) = cos α cos β minussin α sin β

The proof is very similar to the previous one exceptwe put the angle β to the angKAC The side AK is stillof unit length as seen in Figure 112 For this proofwe will need tan(α) = AC

BC so we need to express those

sides in terms of cosine and sineFrom ABC (α+β )+γ = 90 there4 γ = 90minus(α+β )From ANK angNKA + γ = 90 there4 angN KA =

(α + β )Now we express the side NK cos(α + β ) = NK

1 there4

N K = cos(α + β ) Remember that we choose AK to beof unit length - exactly for this

From NBK sin α = NK BK

there4 BK = cos(α+β)sinα

From AKC we need to express the sides AC andKC in terms of trigonometric functions As before no-tice that AK is unit length that is AK = 1

cos β = AC 1

there4 AC = cos β

sin β = KC 1

there4 KC = sin β

Finally from ABC tan α = sinαcosα = AC

BC =

AC BK +KC = cosβ

cos(α+β)

sinα +sinβ

and all we need is to express

cos(α + β ) that we are looking for

sin α

cos α =

cos β sin α

cos(α + β ) + sin β sin α

from where

cos(α + β ) = cos α cos β minus sin α sin β

This concludes the proof

Formula for cos(α minus β ) can be obtained by simply substituting minusβ into the formula abovewhich gives Equation 12

Now since we have proven the formulas for sum and difference for cosine and sinefunctions we will get nearly all other formulas - again you donrsquot have to memorisethem mechanically since you can (relatively) simply derive them

133 Double-angle formulae

As before keep in mind that cosine and sine functions describe a wave thus cos(2x) is a waveof double frequency compared to a simple wave cos(x) The relationship between a wave of double and unit frequency is

12

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1226

sin2x = 2 sin x cos x (14)

You can simply derive the expression in Equation 14 using Equation 13 and the following

trick sin(2x) = sin(x + x) So sin 2x = sin x lowast cos x + sin x lowast cos x = 2 sin x cos x Derivationof the double-angle formula for cosine is similar just use Equation 12 and the same trickcos(2x) = cos(x + x)

cos2x = cos x lowast cos x minus sin x lowast sin x = cos2 x minus sin2 x = 2 cos2 x minus 1 = 1 minus 2sin2 x (15)

Why do we need the double-angle formula

An illustrative example this time comes from optics there are optical crystals that can double thefrequency of a lightwave such as lithium niobate (LN) or potassium titanyl phosphate (KTP)That is you can convert a light of a infra-red laser (with wavelength of 11microm that is easy toget) into a green laser light (wavelength 055microm) Most laser pointers that produce green light

use these frequency-doubling crystals

Figure 113 Doubling the lightwave frequency converting from cos(x) to cos(2x) in optics

134 Sum-to-Product Formulas

We already know by now that sine and cosine functions are models of waves and we cannot just sum them like cos x + cosy = cos(x + y) The following expressions will allow us to convertsum and difference of trigonometry functions into products

sin x plusmn sin y = 2 sin

983080x plusmn y

2

983081cos

983080x ∓ y

2

983081 (16)

cos x + cos y = 2 cos

983080x + y

2

983081cos

983080x minus y

2

983081 (17)

cos x minus cos y = minus2sin983080x + y

2983081

sin983080x minus y

2983081

(18)

These formulas can be derived using the expressions for double angles in Equation 14 andEquation 15 Letrsquos do it for sin(x)+sin(y) In this proof we take the right part of Equation 16and try to show that it is equivalent to the left part Use Equation 14 to get

2sin

983080x + y

2

983081cos

983080x minus y

2

983081= 2 lowast

1048616sin

x

2 cos

y

2 + cos

x

2 sin

y

2

1048617lowast1048616

cos x

2 cos

y

2 + sin

x

2 sin

y

2

1048617=

13

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1326

Here we just used the Equation 13 and Equation 12 Open the brackets and multiply theseitems to get

= 2 lowast1048616

sin x2

cos2 y2

cos x2

+ sin2 x2

cos y2

sin y2

+ sin y2

cos2 x2

cos y2

+ sin2 y2

cos x2

sin x2

1048617=

Take a closer look at item 1 and 4 - we can group them like this cos x2 sin x2 (sin2 y

2 +cos2 y2 )

Notice that the sum inside brackets equals 1 as we already know from sin2(x)+cos2(x) = 1 (seeEquation 11) The items 2 and 3 in the expression above can be grouped similarly so we get

= 2 lowast1048616

cos y

2 sin

y

2 + sin

x

2 cos

x

2

1048617=

Now open the brackets and look closely on each item for instance 2 cos y2 sin y2 looks similar

to Equation 14 Therefore 2 cos y2

sin y2

= sin(2 lowast y2

) = sin y and therefore

= 2 lowast 1048616cos y

2

sin y

2

+ sin x

2

cos x

21048617 = sin y + sin x

which is exactly the Equation 16 and concludes our proof

Why do we need sum-to-product formulas

These sum-to-product formulas are really special because your own brain does this all the time sounds that you hear with both ears are summed and processed by the brain so you can determinefor example where does the sound came from You can actually trick your own brain into findinga sum of two cosine waves (soundwaves) and hear binaural beats For example if a frequencyof 100 Hz is presented to your left ear and a frequency of 105 Hz is presented to your rightear your brain ldquohearsrdquo a third frequency pulsing at 5 Hz the exact difference between the twofrequencies Some binaural beat frequencies were found to be useful in auditory stimulation toenhance brain functioning

We can use the formula of sum-to-product to find the expression for sum of two sound waveswith frequency f 1 and f 2

cos(2πf 1t) + cos(2πf 2t) = 2 cos

9830802π

(f 1 + f 2)

2 t

983081cos

9830802π

(f 1 minus f 2)

2 t

983081

where t is a variable for time If the two sound frequencies are close (a difference f 1 minus f 2of about twenty hertz) the frequency of the sound wave is often too slow to be perceived as apitch Instead the sound wave is perceived as a periodic variation (beat) of the volume whichis described by the expression above We can see it in Figure 114

The program below (runs in MATLAB and GNUOctave) generates two sound waves (astereo sound) with two pure tones of frequencies f 1 = 500Hz and f 2 = 500 + 30 = 530Hz Thenthe sound is played for 4 seconds

Amplitude=10

duration=4 seconds

Frequency=500

Frequency diff= 30 frequency difference for beat

Freq sampling=10000 sampling frequency

values=01Freq samplingduration

left=Amplitudecos(2pi Frequencyvalues)

14

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1426

002 004 006 008 01 012

Figure 114 The sum (blue) of two cosine waves compared to a single wave (green) The functionplotted is yk = cos(2π lowast 500xk) + cos(2π lowast 530xk)

right = Amplitudecos(2pi (Frequency+Frequency diff)values)

stereosnd = [left right] combining two sounds at a stereo

soundsc(stereosnd Freq sampling) play the sound

You should use headphones to listen to this sound Put one earpiece in your ear and youwill hear a pure tone Then move the second earpiece slowly to your other ear - and instead of two separate tone you are going to hear a sound beat since the frequencies (or tones) differ

slightly (only by 30 Hz) Keep in mind that those two tones do not mix - they are in the left andright earpieces That is the tones do not interfere physically but are summed by the brainThis effect is related to the brainrsquos ability to locate sounds in three dimensions

See your own brain already knows and does the trigonometry and all this mathe-matical expressions just bring the trigonometric expressions to you in a convenient form

135 Product-to-sum formula

Letrsquos derive the reverse formulas which allow us to convert the product of two waves into thesum (or difference) of separate waves

2cos x cos y = cos(x minus y) + cos(x + y) (19)

2sin x sin y = cos(x minus y) minus cos(x + y) (110)

2sin x cos y = sin(x + y) + sin(x minus y) (111)

2cos x sin y = sin(x + y) minus sin(x minus y) (112)

These formulas can be used for transmitting the information via radiowaves as we will seeshortly The derivation of this formulas is very simple all you need is to use Equations 13and 12 For example the formula 2 cos x cos y = cos(x minus y) + cos(x + y) can be derived as sumof the two equations below

15

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1526

cos(x + y) = cos x cos y minus sin x sin y+cos(x minus y) = cos x cos y + sin x sin y

where sin x sin y are gone and therefore we get cos(x + y)+cos(xminus y) = 2 cos x cos y exactlyas in Equation 19 Other formulas can be derived in a similar way

Why do we need these Product-to-sum formulas

The product-to-sum trigonometric formulas can be used to transmit and receive informationEver wondered what are those FM and AM acronyms stand for They stand for AmplitudeModulation and Frequency Modulation respectively - these are the methods of transmittingmusic on a radio and we are going to use trigonometry for this

First we need a carrier wave - we are going to modify it with the input signal (our music) totransmit music using radiowaves The carrier wave is usually of a much higher frequency thanthe input signal which helps us to detect the actual signal Letrsquos take a carrier wave C (t) of

frequency F c and amplitude A given by

C (t) = A lowast cos(2πF ct)

which is a function of time t We are going to modify (or as engineers say modulate ) thiscarrier wave C (t) with a music but for simplicity letrsquos say we want to transmit just a pure toneS (t) This signal S (t) represent the modulation soundwave of a frequency F m (which must be amuch lower frequency than F c)

S (t) = M lowast cos(2πF mt)

where M is the amplitude of the modulation Letrsquos agree that M lt 1 so that (1+ S (t)) is alwayspositive Amplitude modulation occurs when the carrier wave C (t) is multiplied by (1 + S (t))

y(t) = [1 + S (t)] lowast C (t) = [1 + M lowast cos(2πF mt)] lowast A lowast cos(2πF ct) (113)

Using the Equation 19 the resulting signal (as a function of time) y(t) can be shown to be

y(t) = A lowast cos(2πF ct) + AM 2

[cos(2π(F c + F m)t) + cos(2π(F c minus F m)t)]

The modulated radiowave is shown in Figure 115 and the program for this demonstrationis provided below

A = 2 amplitude

duration=4 in seconds

Freq sampling = 10000

values=01Freq samplingduration

Carrier Frequency=1000

C t =Acos(2pi Carrier Frequencyvalues)

M = 01 modulation coefficient

Signal Frequency = 120

S t = Mcos(2piSignal Frequencyvalues)

y t = ( 1+ S t )C t

figure plot(values y t ) this is to plot a beat

16

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1626

0005 001 0015 002 0025 003 0035 004 0045 005

Figure 115 The Amplitude Modulation in action we have a carrier wave of 1000 Hz frequencywhich is modulated (modified) with a tone of 120 Hz using Equation 113 Notice the change inthe amplitude on the plot

136 The power of Trigonometry meet the Discrete Cosine Transform

Many textbooks mention the applications of trigonometry like determining the height of a build-ing if you know the distance to it and the angle to the rooftop or some equally boringexoticexamples Here we are going to see a real-world application of cosine functions which is reallyuseful for sound analysis and compression - the Discrete Cosine Transform (DCT)

Be not afraid of this fancy name it simply means that we are going to use Cosine function toTransform or decompose our sound signal on pure tones (cosine functions of various frequencies)The word Discrete simply means that the values of our signal are sampled with some fixed-stepinterval - for example we measure a value of our signal every 01 seconds

Using DCT we are going to mathematically de-compose our signal into pure tones (or cosinewaves) and calculate how many cosine waves of this particular frequency do we have in thesignal This is extremely useful for analysis of the signal for example you can reduce the noisein signal by simply zeroing out the unwanted frequencies and transforming the signal back

There are many applications of DCT that we use every day without even knowing it

signal analysis by decomposing the signal on the pure cosine waves we can see what arethe main waves in the signal This way you can analyse for example stock market pricesto find any recurring periodical fluctuations of prices (and predict when it happens next)

audio compression MP3 format uses a variety of DCT algorithm to determine which soundfrequencies to keep and which to throw away compressing the song without noticeable lossin quality

images compression JPEG format also compresses the images using DCT-like algorithmto reduce the size of the image by throwing away unnecessary details

17

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1726

Example of frequency analysis using Discrete Cosine Transform

Letrsquos go back to our previous example and take it one step further we combine a soundwave of frequency F 1 = 400 Hz and amplitude A = 1 with a soundwave of frequency F 2 = 800 Hz and

amplitude A = 2

yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) (114)

were indexes with the letter k in yk and xk simply mean the row number in the table with yand x Thatrsquos where the word discrete comes into play our computers can work with discretenumbers and all we need is to take enough samples of a function (cosine in this case) close toeach other to describe the signal

In the program code below we take L = 1000 samples for our signal from Equation 114 andwe take samples of our signal close to each other - say once every t = 14000th of a second Here4000 is our sampling frequency - this is how often we evaluate our function in Equation 114 Wetook F sampling = 4000 arbitrary - any number larger than 800 will be fine

1 Fs = 4000 Sampling frequency

2 T = 1Fs Sample time

3 L = 1000 Length of signal counts

4 x k = (1L)T Time count

56 Sum of a 400 Hz wave and a 800 Hz wave

7 y k = cos(2pi400x k) + 2cos(2pi800x k)

89 Now add some random noise to the sum of waves

10 y k n oisy = y k + 2randn(size(x k ))

1112 figure plot(Fsx k(1200)y k(1200))

13 title(Original signal (sum of two waves)) xlabel(time (milliseconds))

1415 figure plot(Fsx k(1200)y k noisy(1200))

16 title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

That is take L = 1000 numbers (line 3) and generate xk values (line 4) to be plugged intoEquation 114 (line 7) The plot of the signal can be seen in Figure 116(a)

The Discrete Cosine Transform Now the main part we are going to transform (decompose)our sound signal into pure tones (cosine waves of different frequencies) using the Discrete CosineTransform (DCT)

Dk =

N minus1991761n=0

yn cos

983131π

N

983080n +

1

2

983081k

983133 for every frequency k = 0 N minus 1 (115)

Now what does this formula2 actually mean

the signN minus1sumn=0

means ldquosumming elements with subscript n from n = 0 to n = N minus 1

N is the length of the signal y - in our case the signal has 1000 values (a row in a tablewith 1000 cells)

2This formula does not include a normalisation term to account for the number of samples - Irsquom skipping itto simplify the discussion

18

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1826

0 20 40 60 80 100 120 140 160 180 200minus2

minus15

minus1

minus05

0

05

1

15

2

25

3Original signal (sum of two waves)

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

40

X 400Y 2127

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 800Y 3618

(b)

Figure 116 Clean noiseless signal (a) The plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk)(b) the wave frequencies (Discrete Cosine Transform) in the noiseless signal you can see 400 Hzand 800 Hz peaks

yn we take from Equation 114

and we do this for every frequency k from 0 to N minus 1 At the end we get a row of numbersDk that tells us how many cosine waves with frequency 0 1 2 all the way up to frequency N minus1do we have in our signal The program code (MATLAB or Octave) for the DCT formula inEquation 115 is quite simple3

function D = my dct(y)

N = length(y) N rows do we have in the signal yD = zeros(N1) D stores the DCT transform of the signal y

for k = 01Nminus1 for every frequency k = 0 to Nminus1 with step 1

for n = 01Nminus1 for every row value of signal y do this

D(k+1) = D(k+1) + y(n+1)cos(piN (n + 12)k)

end the line above literary implements the DCT formula

end

There is no need to program the DCT formula in MATLAB and Octave it can be calledusing dct(Y) command to transform the signal stored in the variable Y

Now if we now plot the numbers in the variable Dk versus frequencies of a cosine wave (kfrom 0 to N-1) we will see the picture like the one in Fig 116(b) Notice two peaks at 400 and800 Hz - these peaks correspond to the cosine waves in our signal described by Equation 114

yk = cos(2 lowast pi lowast 400 lowast xk) + 2 lowast cos(2 lowast pi lowast 800 lowast xk)This is exactly what we expect after all our soundwave contains only 400 Hz and 800 Hz

cosine waves and those peaks of DCT indicate thisNow imagine that our soundwave was recorded with a bad microphone we have a lot of

noise in the recording If you look at Figure 117(a) there is so much noise that you donrsquot evensee the waves But if you use the DCT to decompose the noised signal and again make the plot

3The code is not efficient and it will take a lot of time for long signals However it is a simple word-for-wordimplementation of the DCT mathematical formula and serves its illustrative purpose

19

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1926

of its result you will be able to see those peaks (that correspond to soundwaves buried undernoise) in Figure 117(b)

0 20 40 60 80 100 120 140 160 180 200minus6

minus4

minus2

0

2

4

6

8

Signal Corrupted with Random Noise

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

X 800Y 3367

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 400Y 1858

(b)

Figure 117 Noised signal (a) the plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) with lotsof noise added (b) the wave frequencies (Discrete Cosine Transform) in the signal you can see400 Hz and 800 Hz peaks

This is the real power of trigonometric functions we can decompose even a very noisysignal and still see what are the cosine waves (that use pure tones) that make it And not justto look at the plot but also clean up the signal we can just zero-out the small numbers in theDCT variable Dk to clean up the noise and transform the signal back to its original state - andnoise is (almost) gone

The MATLAB (or Octave) code for this example is below

Fs = 4000 Sampling frequency

T = 1Fs Sample time

L = 1000 Length of signal counts

x k = (1L)T Time count

Sum of a 400 Hz wave and a 800 Hz wave

y k = cos(2pi400x k) + 2cos(2pi800x k)

Now add some random noise to the sum of waves

y k n oisy = y k + 2randn(size(x k )) Sinusoids plus noise

figure plot(Fsx k(1200)y k(1200))

title(Original signal (sum of two waves)) xlabel(time (milliseconds))

figure plot(Fsx k(1200)y k noisy(1200))

title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

How many cosine waves of different frequencies we have in the signal

D k dct clean signal = dct(y kL)

D k dct noisy signal = dct(y k noisyL)

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

20

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 7: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 726

This brings us to a more general model of a wave

y = A lowast cos(F lowast x)

where A stands for amplitude - a constant that controls the scale of the function (volume of a soundwave) and F stands for f requency - a constant that controls how many complete turnsthe function does (pitch or a tone of a soundwave) The cosine function cos(x) is a idealisedmodel of a wave with unit amplitude and unit frequency and this is why it returns the valuesfrom -1 to 1

By now you should see that you cannot just take the number N out of brackets in cos(N lowastx)and put it in front of the function - you cannot convert the frequency into volume this easilyThe conversion is a bit more complicated and we will see it in trigonometric identities below

5

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 826

13 Trigonometric identities derivation and meaning

As we have already seen we can think of trigonometric functions as models of waves that can bedescribed as y = A lowast cos(F lowast x) Here A stands for amplitude F stands for f requency and x isa running variable (time for example) But apart from generating pure tones cosine and sinusfunctions do not take us very far - we need to know the relationships between them if we want touse trigonometry for something useful Relationships between trigonometric functions are morecomplex than just adding numbers and there are formulas that describe those relationships

But there is no need to memorise all the formulas once you understand few basic trigono-metric identities how the really work you will be able to easily derive the rest of the formulas

131 Sum of squares

One of the most useful identity is a sum of cosine and sine squares

sin2(x) + cos2(x) = 1 (11)

If you look at Figure 18 you will notice that when a cos 2(x) has its Y -value at 05 so doesthe sin2(x) If you add them together the result will be equal 1 Moreover all other points onthe plot for cos2(x) and sin2(x) will give 1 in sum when one of the functions is at valley anotherhas a peak at 1 and so on Therefore the sum of squares sin2(x) + cos2(x) always equals 1

minus5 minus4 minus3 minus2 minus1 0 1 2 3 4 50

02

04

06

08

1

12

14

cos2(x)

sin2(x)

cos2(x) + sin

2(x)=1

Figure 18 The plot of sin2

(x) + cos2

(x) = 1

The computer program for MATLAB or Octave programming languages that makes this plot is

x = minus50015

figure plot(xcos(x)ˆ2xsin(x)ˆ2x cos(x) 2 + sin(x) 2 )

legend(cosˆ2(x) sinˆ2(x) cosˆ2(x) + sin 2(x)=1

Location SouthEast)

9

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 926

Proof of Sum of squares formula

Figure 19 A geometric proof for identitysin2(x) + cos2(x) = 1

This identity can be also derived without any plotsusing only geometry Recall that the trigonometric

functions are connected with a circle of unit radiush = 1 as shown in Figure 19

Take any point on a circle of unit radius h =1 and put a vertical line down - this gives us atriangle with right angle 90 with sides a and band hypotenuse h = 1

Pythagorean theorem tells us that a2 + b2 = h2

in the right triangle and all we need is to expressthe sides in terms of cosine and sinus of an anglex We know that sin(x) = opposite

hypotenuse = a

h and

cos(x) = adjacenthypotenuse = b

h

Since h = 1 we have a2+b2 = 1 and sin(x) = a1

and cos x = b1 Substituting it back we get

sin2(x) + cos2(x) = 1 just like in Equation 11

132 Sum and difference of angles for sin(x) and cos(x)

As you may have guessed cosine wave of sum of frequencies is not just a sum of cosine wavesthat is the expression cos(x + y) = cos(x)+cos(y) is wrong and the actual expression is a bitmore complicated

cos(x plusmn y) = cos x cos y ∓ sin x sin y (12)

sin(x plusmn y) = sin x cos y plusmn cos x sin y (13)

The expressions above are very important since once you understood and memorised themyou can derive pretty much any other expression for sine and cosine functions Youcan make a plot (like in Figure 110) and compare for example cos(x + 2x) and cos x cos(2x)minussin x sin(2x) to make sure that the expression from Equation 12 is true

The program code that can plot Figure 110 in MATLAB or Octave programming languageis quite simple

y cos 3x = cos(3x)

y sin x = sin(x)

y cos x = cos(x)

y sin 2x = sin(2x)

y cos 2x = cos(2

x)

figure plot(x y cos xy c o s 2 x minus y s i n x y s i n 2 x

x y c o s x y c os 2 x x y s i n xy s i n 2 x )

legend(cos(3x) cos(x)cos(2x) sin(x)sin(2x)Location SouthEast)

Both equations 13 and 12 are so important that they deserve a formal proof 1

1There are many ways to prove those identities like using complex exponentials The proof here is Smiley Land Smiley D rdquoGeometry of Addition and Subtraction Formulasrdquo

10

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1026

0 1 2 3 4 5 6 7minus1

minus08

minus06

minus04

minus02

0

02

04

06

08

1

cos(3x)

cos(x)cos(2x)

sin(x)sin(2x)

Figure 110 The plot of cos(x + 2x) and cos x cos(2x) minus sin x sin(2x) for comparison If yousubtract the plot with sin x sin(2x) from cos x cos(2x) you will get cos(3x)

Proof for sin(α plusmn β )

Figure 111 Illustration for theproof of sin(α + β ) = sin α cos β +cos α sin β

Letrsquos take the right triangle ABC in Figure 111 such thatAK = 1 (unit length) For the proof we will need sin(α) =AC AB

so we need to express those sides in terms of cosine andsine

From ABC (α + β ) + γ = 90 there4 γ = 90 minus (α + β )From AKC angAKC + γ = 90 there4 angAKC = (α +

β ) since γ = 90 minus (α + β )Now we express side AC sin(α + β ) = AC

1 there4 AC =

sin(α + β )From ANK we are looking for expressions of sides

AN and NKcos β = AN

1 there4 AN = cos β Remember that we choose

AK to be of unit length - exactly for this Now find NKsin β = NK

1 there4 N K = sin β

From NBK we need to find NB that we need forthe proof of the formula (from Figure 111 you can see that

NB+AN = AB that we are looking for)tan α = NK

NB there4 NB = NK

tanα = sinβtanα = sinβ cosα

sinα We haveeverything we need by now and we turn back to our maintriangle ABC

Finally from ABC sin α = AC AB

= AC NB+AN

=sin(α+β)

cosβ+ sinβ cosαsinα

From this expression we need sin(α + β )

which is

11

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1126

sin(α + β ) = sin α

983080cos β +

sin β cos α

sin α

983081= sin α cos β + cos α sin β

This concludes the proof Formula for sin(αminusβ ) can be obtained simply substituting minusβ into the formula above which

gives Equation 13

Proof for cos(α plusmn β )

Figure 112 Illustration for the proof of cos(α + β ) = cos α cos β minussin α sin β

The proof is very similar to the previous one exceptwe put the angle β to the angKAC The side AK is stillof unit length as seen in Figure 112 For this proofwe will need tan(α) = AC

BC so we need to express those

sides in terms of cosine and sineFrom ABC (α+β )+γ = 90 there4 γ = 90minus(α+β )From ANK angNKA + γ = 90 there4 angN KA =

(α + β )Now we express the side NK cos(α + β ) = NK

1 there4

N K = cos(α + β ) Remember that we choose AK to beof unit length - exactly for this

From NBK sin α = NK BK

there4 BK = cos(α+β)sinα

From AKC we need to express the sides AC andKC in terms of trigonometric functions As before no-tice that AK is unit length that is AK = 1

cos β = AC 1

there4 AC = cos β

sin β = KC 1

there4 KC = sin β

Finally from ABC tan α = sinαcosα = AC

BC =

AC BK +KC = cosβ

cos(α+β)

sinα +sinβ

and all we need is to express

cos(α + β ) that we are looking for

sin α

cos α =

cos β sin α

cos(α + β ) + sin β sin α

from where

cos(α + β ) = cos α cos β minus sin α sin β

This concludes the proof

Formula for cos(α minus β ) can be obtained by simply substituting minusβ into the formula abovewhich gives Equation 12

Now since we have proven the formulas for sum and difference for cosine and sinefunctions we will get nearly all other formulas - again you donrsquot have to memorisethem mechanically since you can (relatively) simply derive them

133 Double-angle formulae

As before keep in mind that cosine and sine functions describe a wave thus cos(2x) is a waveof double frequency compared to a simple wave cos(x) The relationship between a wave of double and unit frequency is

12

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1226

sin2x = 2 sin x cos x (14)

You can simply derive the expression in Equation 14 using Equation 13 and the following

trick sin(2x) = sin(x + x) So sin 2x = sin x lowast cos x + sin x lowast cos x = 2 sin x cos x Derivationof the double-angle formula for cosine is similar just use Equation 12 and the same trickcos(2x) = cos(x + x)

cos2x = cos x lowast cos x minus sin x lowast sin x = cos2 x minus sin2 x = 2 cos2 x minus 1 = 1 minus 2sin2 x (15)

Why do we need the double-angle formula

An illustrative example this time comes from optics there are optical crystals that can double thefrequency of a lightwave such as lithium niobate (LN) or potassium titanyl phosphate (KTP)That is you can convert a light of a infra-red laser (with wavelength of 11microm that is easy toget) into a green laser light (wavelength 055microm) Most laser pointers that produce green light

use these frequency-doubling crystals

Figure 113 Doubling the lightwave frequency converting from cos(x) to cos(2x) in optics

134 Sum-to-Product Formulas

We already know by now that sine and cosine functions are models of waves and we cannot just sum them like cos x + cosy = cos(x + y) The following expressions will allow us to convertsum and difference of trigonometry functions into products

sin x plusmn sin y = 2 sin

983080x plusmn y

2

983081cos

983080x ∓ y

2

983081 (16)

cos x + cos y = 2 cos

983080x + y

2

983081cos

983080x minus y

2

983081 (17)

cos x minus cos y = minus2sin983080x + y

2983081

sin983080x minus y

2983081

(18)

These formulas can be derived using the expressions for double angles in Equation 14 andEquation 15 Letrsquos do it for sin(x)+sin(y) In this proof we take the right part of Equation 16and try to show that it is equivalent to the left part Use Equation 14 to get

2sin

983080x + y

2

983081cos

983080x minus y

2

983081= 2 lowast

1048616sin

x

2 cos

y

2 + cos

x

2 sin

y

2

1048617lowast1048616

cos x

2 cos

y

2 + sin

x

2 sin

y

2

1048617=

13

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1326

Here we just used the Equation 13 and Equation 12 Open the brackets and multiply theseitems to get

= 2 lowast1048616

sin x2

cos2 y2

cos x2

+ sin2 x2

cos y2

sin y2

+ sin y2

cos2 x2

cos y2

+ sin2 y2

cos x2

sin x2

1048617=

Take a closer look at item 1 and 4 - we can group them like this cos x2 sin x2 (sin2 y

2 +cos2 y2 )

Notice that the sum inside brackets equals 1 as we already know from sin2(x)+cos2(x) = 1 (seeEquation 11) The items 2 and 3 in the expression above can be grouped similarly so we get

= 2 lowast1048616

cos y

2 sin

y

2 + sin

x

2 cos

x

2

1048617=

Now open the brackets and look closely on each item for instance 2 cos y2 sin y2 looks similar

to Equation 14 Therefore 2 cos y2

sin y2

= sin(2 lowast y2

) = sin y and therefore

= 2 lowast 1048616cos y

2

sin y

2

+ sin x

2

cos x

21048617 = sin y + sin x

which is exactly the Equation 16 and concludes our proof

Why do we need sum-to-product formulas

These sum-to-product formulas are really special because your own brain does this all the time sounds that you hear with both ears are summed and processed by the brain so you can determinefor example where does the sound came from You can actually trick your own brain into findinga sum of two cosine waves (soundwaves) and hear binaural beats For example if a frequencyof 100 Hz is presented to your left ear and a frequency of 105 Hz is presented to your rightear your brain ldquohearsrdquo a third frequency pulsing at 5 Hz the exact difference between the twofrequencies Some binaural beat frequencies were found to be useful in auditory stimulation toenhance brain functioning

We can use the formula of sum-to-product to find the expression for sum of two sound waveswith frequency f 1 and f 2

cos(2πf 1t) + cos(2πf 2t) = 2 cos

9830802π

(f 1 + f 2)

2 t

983081cos

9830802π

(f 1 minus f 2)

2 t

983081

where t is a variable for time If the two sound frequencies are close (a difference f 1 minus f 2of about twenty hertz) the frequency of the sound wave is often too slow to be perceived as apitch Instead the sound wave is perceived as a periodic variation (beat) of the volume whichis described by the expression above We can see it in Figure 114

The program below (runs in MATLAB and GNUOctave) generates two sound waves (astereo sound) with two pure tones of frequencies f 1 = 500Hz and f 2 = 500 + 30 = 530Hz Thenthe sound is played for 4 seconds

Amplitude=10

duration=4 seconds

Frequency=500

Frequency diff= 30 frequency difference for beat

Freq sampling=10000 sampling frequency

values=01Freq samplingduration

left=Amplitudecos(2pi Frequencyvalues)

14

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1426

002 004 006 008 01 012

Figure 114 The sum (blue) of two cosine waves compared to a single wave (green) The functionplotted is yk = cos(2π lowast 500xk) + cos(2π lowast 530xk)

right = Amplitudecos(2pi (Frequency+Frequency diff)values)

stereosnd = [left right] combining two sounds at a stereo

soundsc(stereosnd Freq sampling) play the sound

You should use headphones to listen to this sound Put one earpiece in your ear and youwill hear a pure tone Then move the second earpiece slowly to your other ear - and instead of two separate tone you are going to hear a sound beat since the frequencies (or tones) differ

slightly (only by 30 Hz) Keep in mind that those two tones do not mix - they are in the left andright earpieces That is the tones do not interfere physically but are summed by the brainThis effect is related to the brainrsquos ability to locate sounds in three dimensions

See your own brain already knows and does the trigonometry and all this mathe-matical expressions just bring the trigonometric expressions to you in a convenient form

135 Product-to-sum formula

Letrsquos derive the reverse formulas which allow us to convert the product of two waves into thesum (or difference) of separate waves

2cos x cos y = cos(x minus y) + cos(x + y) (19)

2sin x sin y = cos(x minus y) minus cos(x + y) (110)

2sin x cos y = sin(x + y) + sin(x minus y) (111)

2cos x sin y = sin(x + y) minus sin(x minus y) (112)

These formulas can be used for transmitting the information via radiowaves as we will seeshortly The derivation of this formulas is very simple all you need is to use Equations 13and 12 For example the formula 2 cos x cos y = cos(x minus y) + cos(x + y) can be derived as sumof the two equations below

15

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1526

cos(x + y) = cos x cos y minus sin x sin y+cos(x minus y) = cos x cos y + sin x sin y

where sin x sin y are gone and therefore we get cos(x + y)+cos(xminus y) = 2 cos x cos y exactlyas in Equation 19 Other formulas can be derived in a similar way

Why do we need these Product-to-sum formulas

The product-to-sum trigonometric formulas can be used to transmit and receive informationEver wondered what are those FM and AM acronyms stand for They stand for AmplitudeModulation and Frequency Modulation respectively - these are the methods of transmittingmusic on a radio and we are going to use trigonometry for this

First we need a carrier wave - we are going to modify it with the input signal (our music) totransmit music using radiowaves The carrier wave is usually of a much higher frequency thanthe input signal which helps us to detect the actual signal Letrsquos take a carrier wave C (t) of

frequency F c and amplitude A given by

C (t) = A lowast cos(2πF ct)

which is a function of time t We are going to modify (or as engineers say modulate ) thiscarrier wave C (t) with a music but for simplicity letrsquos say we want to transmit just a pure toneS (t) This signal S (t) represent the modulation soundwave of a frequency F m (which must be amuch lower frequency than F c)

S (t) = M lowast cos(2πF mt)

where M is the amplitude of the modulation Letrsquos agree that M lt 1 so that (1+ S (t)) is alwayspositive Amplitude modulation occurs when the carrier wave C (t) is multiplied by (1 + S (t))

y(t) = [1 + S (t)] lowast C (t) = [1 + M lowast cos(2πF mt)] lowast A lowast cos(2πF ct) (113)

Using the Equation 19 the resulting signal (as a function of time) y(t) can be shown to be

y(t) = A lowast cos(2πF ct) + AM 2

[cos(2π(F c + F m)t) + cos(2π(F c minus F m)t)]

The modulated radiowave is shown in Figure 115 and the program for this demonstrationis provided below

A = 2 amplitude

duration=4 in seconds

Freq sampling = 10000

values=01Freq samplingduration

Carrier Frequency=1000

C t =Acos(2pi Carrier Frequencyvalues)

M = 01 modulation coefficient

Signal Frequency = 120

S t = Mcos(2piSignal Frequencyvalues)

y t = ( 1+ S t )C t

figure plot(values y t ) this is to plot a beat

16

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1626

0005 001 0015 002 0025 003 0035 004 0045 005

Figure 115 The Amplitude Modulation in action we have a carrier wave of 1000 Hz frequencywhich is modulated (modified) with a tone of 120 Hz using Equation 113 Notice the change inthe amplitude on the plot

136 The power of Trigonometry meet the Discrete Cosine Transform

Many textbooks mention the applications of trigonometry like determining the height of a build-ing if you know the distance to it and the angle to the rooftop or some equally boringexoticexamples Here we are going to see a real-world application of cosine functions which is reallyuseful for sound analysis and compression - the Discrete Cosine Transform (DCT)

Be not afraid of this fancy name it simply means that we are going to use Cosine function toTransform or decompose our sound signal on pure tones (cosine functions of various frequencies)The word Discrete simply means that the values of our signal are sampled with some fixed-stepinterval - for example we measure a value of our signal every 01 seconds

Using DCT we are going to mathematically de-compose our signal into pure tones (or cosinewaves) and calculate how many cosine waves of this particular frequency do we have in thesignal This is extremely useful for analysis of the signal for example you can reduce the noisein signal by simply zeroing out the unwanted frequencies and transforming the signal back

There are many applications of DCT that we use every day without even knowing it

signal analysis by decomposing the signal on the pure cosine waves we can see what arethe main waves in the signal This way you can analyse for example stock market pricesto find any recurring periodical fluctuations of prices (and predict when it happens next)

audio compression MP3 format uses a variety of DCT algorithm to determine which soundfrequencies to keep and which to throw away compressing the song without noticeable lossin quality

images compression JPEG format also compresses the images using DCT-like algorithmto reduce the size of the image by throwing away unnecessary details

17

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1726

Example of frequency analysis using Discrete Cosine Transform

Letrsquos go back to our previous example and take it one step further we combine a soundwave of frequency F 1 = 400 Hz and amplitude A = 1 with a soundwave of frequency F 2 = 800 Hz and

amplitude A = 2

yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) (114)

were indexes with the letter k in yk and xk simply mean the row number in the table with yand x Thatrsquos where the word discrete comes into play our computers can work with discretenumbers and all we need is to take enough samples of a function (cosine in this case) close toeach other to describe the signal

In the program code below we take L = 1000 samples for our signal from Equation 114 andwe take samples of our signal close to each other - say once every t = 14000th of a second Here4000 is our sampling frequency - this is how often we evaluate our function in Equation 114 Wetook F sampling = 4000 arbitrary - any number larger than 800 will be fine

1 Fs = 4000 Sampling frequency

2 T = 1Fs Sample time

3 L = 1000 Length of signal counts

4 x k = (1L)T Time count

56 Sum of a 400 Hz wave and a 800 Hz wave

7 y k = cos(2pi400x k) + 2cos(2pi800x k)

89 Now add some random noise to the sum of waves

10 y k n oisy = y k + 2randn(size(x k ))

1112 figure plot(Fsx k(1200)y k(1200))

13 title(Original signal (sum of two waves)) xlabel(time (milliseconds))

1415 figure plot(Fsx k(1200)y k noisy(1200))

16 title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

That is take L = 1000 numbers (line 3) and generate xk values (line 4) to be plugged intoEquation 114 (line 7) The plot of the signal can be seen in Figure 116(a)

The Discrete Cosine Transform Now the main part we are going to transform (decompose)our sound signal into pure tones (cosine waves of different frequencies) using the Discrete CosineTransform (DCT)

Dk =

N minus1991761n=0

yn cos

983131π

N

983080n +

1

2

983081k

983133 for every frequency k = 0 N minus 1 (115)

Now what does this formula2 actually mean

the signN minus1sumn=0

means ldquosumming elements with subscript n from n = 0 to n = N minus 1

N is the length of the signal y - in our case the signal has 1000 values (a row in a tablewith 1000 cells)

2This formula does not include a normalisation term to account for the number of samples - Irsquom skipping itto simplify the discussion

18

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1826

0 20 40 60 80 100 120 140 160 180 200minus2

minus15

minus1

minus05

0

05

1

15

2

25

3Original signal (sum of two waves)

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

40

X 400Y 2127

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 800Y 3618

(b)

Figure 116 Clean noiseless signal (a) The plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk)(b) the wave frequencies (Discrete Cosine Transform) in the noiseless signal you can see 400 Hzand 800 Hz peaks

yn we take from Equation 114

and we do this for every frequency k from 0 to N minus 1 At the end we get a row of numbersDk that tells us how many cosine waves with frequency 0 1 2 all the way up to frequency N minus1do we have in our signal The program code (MATLAB or Octave) for the DCT formula inEquation 115 is quite simple3

function D = my dct(y)

N = length(y) N rows do we have in the signal yD = zeros(N1) D stores the DCT transform of the signal y

for k = 01Nminus1 for every frequency k = 0 to Nminus1 with step 1

for n = 01Nminus1 for every row value of signal y do this

D(k+1) = D(k+1) + y(n+1)cos(piN (n + 12)k)

end the line above literary implements the DCT formula

end

There is no need to program the DCT formula in MATLAB and Octave it can be calledusing dct(Y) command to transform the signal stored in the variable Y

Now if we now plot the numbers in the variable Dk versus frequencies of a cosine wave (kfrom 0 to N-1) we will see the picture like the one in Fig 116(b) Notice two peaks at 400 and800 Hz - these peaks correspond to the cosine waves in our signal described by Equation 114

yk = cos(2 lowast pi lowast 400 lowast xk) + 2 lowast cos(2 lowast pi lowast 800 lowast xk)This is exactly what we expect after all our soundwave contains only 400 Hz and 800 Hz

cosine waves and those peaks of DCT indicate thisNow imagine that our soundwave was recorded with a bad microphone we have a lot of

noise in the recording If you look at Figure 117(a) there is so much noise that you donrsquot evensee the waves But if you use the DCT to decompose the noised signal and again make the plot

3The code is not efficient and it will take a lot of time for long signals However it is a simple word-for-wordimplementation of the DCT mathematical formula and serves its illustrative purpose

19

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1926

of its result you will be able to see those peaks (that correspond to soundwaves buried undernoise) in Figure 117(b)

0 20 40 60 80 100 120 140 160 180 200minus6

minus4

minus2

0

2

4

6

8

Signal Corrupted with Random Noise

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

X 800Y 3367

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 400Y 1858

(b)

Figure 117 Noised signal (a) the plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) with lotsof noise added (b) the wave frequencies (Discrete Cosine Transform) in the signal you can see400 Hz and 800 Hz peaks

This is the real power of trigonometric functions we can decompose even a very noisysignal and still see what are the cosine waves (that use pure tones) that make it And not justto look at the plot but also clean up the signal we can just zero-out the small numbers in theDCT variable Dk to clean up the noise and transform the signal back to its original state - andnoise is (almost) gone

The MATLAB (or Octave) code for this example is below

Fs = 4000 Sampling frequency

T = 1Fs Sample time

L = 1000 Length of signal counts

x k = (1L)T Time count

Sum of a 400 Hz wave and a 800 Hz wave

y k = cos(2pi400x k) + 2cos(2pi800x k)

Now add some random noise to the sum of waves

y k n oisy = y k + 2randn(size(x k )) Sinusoids plus noise

figure plot(Fsx k(1200)y k(1200))

title(Original signal (sum of two waves)) xlabel(time (milliseconds))

figure plot(Fsx k(1200)y k noisy(1200))

title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

How many cosine waves of different frequencies we have in the signal

D k dct clean signal = dct(y kL)

D k dct noisy signal = dct(y k noisyL)

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

20

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 8: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 826

13 Trigonometric identities derivation and meaning

As we have already seen we can think of trigonometric functions as models of waves that can bedescribed as y = A lowast cos(F lowast x) Here A stands for amplitude F stands for f requency and x isa running variable (time for example) But apart from generating pure tones cosine and sinusfunctions do not take us very far - we need to know the relationships between them if we want touse trigonometry for something useful Relationships between trigonometric functions are morecomplex than just adding numbers and there are formulas that describe those relationships

But there is no need to memorise all the formulas once you understand few basic trigono-metric identities how the really work you will be able to easily derive the rest of the formulas

131 Sum of squares

One of the most useful identity is a sum of cosine and sine squares

sin2(x) + cos2(x) = 1 (11)

If you look at Figure 18 you will notice that when a cos 2(x) has its Y -value at 05 so doesthe sin2(x) If you add them together the result will be equal 1 Moreover all other points onthe plot for cos2(x) and sin2(x) will give 1 in sum when one of the functions is at valley anotherhas a peak at 1 and so on Therefore the sum of squares sin2(x) + cos2(x) always equals 1

minus5 minus4 minus3 minus2 minus1 0 1 2 3 4 50

02

04

06

08

1

12

14

cos2(x)

sin2(x)

cos2(x) + sin

2(x)=1

Figure 18 The plot of sin2

(x) + cos2

(x) = 1

The computer program for MATLAB or Octave programming languages that makes this plot is

x = minus50015

figure plot(xcos(x)ˆ2xsin(x)ˆ2x cos(x) 2 + sin(x) 2 )

legend(cosˆ2(x) sinˆ2(x) cosˆ2(x) + sin 2(x)=1

Location SouthEast)

9

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 926

Proof of Sum of squares formula

Figure 19 A geometric proof for identitysin2(x) + cos2(x) = 1

This identity can be also derived without any plotsusing only geometry Recall that the trigonometric

functions are connected with a circle of unit radiush = 1 as shown in Figure 19

Take any point on a circle of unit radius h =1 and put a vertical line down - this gives us atriangle with right angle 90 with sides a and band hypotenuse h = 1

Pythagorean theorem tells us that a2 + b2 = h2

in the right triangle and all we need is to expressthe sides in terms of cosine and sinus of an anglex We know that sin(x) = opposite

hypotenuse = a

h and

cos(x) = adjacenthypotenuse = b

h

Since h = 1 we have a2+b2 = 1 and sin(x) = a1

and cos x = b1 Substituting it back we get

sin2(x) + cos2(x) = 1 just like in Equation 11

132 Sum and difference of angles for sin(x) and cos(x)

As you may have guessed cosine wave of sum of frequencies is not just a sum of cosine wavesthat is the expression cos(x + y) = cos(x)+cos(y) is wrong and the actual expression is a bitmore complicated

cos(x plusmn y) = cos x cos y ∓ sin x sin y (12)

sin(x plusmn y) = sin x cos y plusmn cos x sin y (13)

The expressions above are very important since once you understood and memorised themyou can derive pretty much any other expression for sine and cosine functions Youcan make a plot (like in Figure 110) and compare for example cos(x + 2x) and cos x cos(2x)minussin x sin(2x) to make sure that the expression from Equation 12 is true

The program code that can plot Figure 110 in MATLAB or Octave programming languageis quite simple

y cos 3x = cos(3x)

y sin x = sin(x)

y cos x = cos(x)

y sin 2x = sin(2x)

y cos 2x = cos(2

x)

figure plot(x y cos xy c o s 2 x minus y s i n x y s i n 2 x

x y c o s x y c os 2 x x y s i n xy s i n 2 x )

legend(cos(3x) cos(x)cos(2x) sin(x)sin(2x)Location SouthEast)

Both equations 13 and 12 are so important that they deserve a formal proof 1

1There are many ways to prove those identities like using complex exponentials The proof here is Smiley Land Smiley D rdquoGeometry of Addition and Subtraction Formulasrdquo

10

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1026

0 1 2 3 4 5 6 7minus1

minus08

minus06

minus04

minus02

0

02

04

06

08

1

cos(3x)

cos(x)cos(2x)

sin(x)sin(2x)

Figure 110 The plot of cos(x + 2x) and cos x cos(2x) minus sin x sin(2x) for comparison If yousubtract the plot with sin x sin(2x) from cos x cos(2x) you will get cos(3x)

Proof for sin(α plusmn β )

Figure 111 Illustration for theproof of sin(α + β ) = sin α cos β +cos α sin β

Letrsquos take the right triangle ABC in Figure 111 such thatAK = 1 (unit length) For the proof we will need sin(α) =AC AB

so we need to express those sides in terms of cosine andsine

From ABC (α + β ) + γ = 90 there4 γ = 90 minus (α + β )From AKC angAKC + γ = 90 there4 angAKC = (α +

β ) since γ = 90 minus (α + β )Now we express side AC sin(α + β ) = AC

1 there4 AC =

sin(α + β )From ANK we are looking for expressions of sides

AN and NKcos β = AN

1 there4 AN = cos β Remember that we choose

AK to be of unit length - exactly for this Now find NKsin β = NK

1 there4 N K = sin β

From NBK we need to find NB that we need forthe proof of the formula (from Figure 111 you can see that

NB+AN = AB that we are looking for)tan α = NK

NB there4 NB = NK

tanα = sinβtanα = sinβ cosα

sinα We haveeverything we need by now and we turn back to our maintriangle ABC

Finally from ABC sin α = AC AB

= AC NB+AN

=sin(α+β)

cosβ+ sinβ cosαsinα

From this expression we need sin(α + β )

which is

11

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1126

sin(α + β ) = sin α

983080cos β +

sin β cos α

sin α

983081= sin α cos β + cos α sin β

This concludes the proof Formula for sin(αminusβ ) can be obtained simply substituting minusβ into the formula above which

gives Equation 13

Proof for cos(α plusmn β )

Figure 112 Illustration for the proof of cos(α + β ) = cos α cos β minussin α sin β

The proof is very similar to the previous one exceptwe put the angle β to the angKAC The side AK is stillof unit length as seen in Figure 112 For this proofwe will need tan(α) = AC

BC so we need to express those

sides in terms of cosine and sineFrom ABC (α+β )+γ = 90 there4 γ = 90minus(α+β )From ANK angNKA + γ = 90 there4 angN KA =

(α + β )Now we express the side NK cos(α + β ) = NK

1 there4

N K = cos(α + β ) Remember that we choose AK to beof unit length - exactly for this

From NBK sin α = NK BK

there4 BK = cos(α+β)sinα

From AKC we need to express the sides AC andKC in terms of trigonometric functions As before no-tice that AK is unit length that is AK = 1

cos β = AC 1

there4 AC = cos β

sin β = KC 1

there4 KC = sin β

Finally from ABC tan α = sinαcosα = AC

BC =

AC BK +KC = cosβ

cos(α+β)

sinα +sinβ

and all we need is to express

cos(α + β ) that we are looking for

sin α

cos α =

cos β sin α

cos(α + β ) + sin β sin α

from where

cos(α + β ) = cos α cos β minus sin α sin β

This concludes the proof

Formula for cos(α minus β ) can be obtained by simply substituting minusβ into the formula abovewhich gives Equation 12

Now since we have proven the formulas for sum and difference for cosine and sinefunctions we will get nearly all other formulas - again you donrsquot have to memorisethem mechanically since you can (relatively) simply derive them

133 Double-angle formulae

As before keep in mind that cosine and sine functions describe a wave thus cos(2x) is a waveof double frequency compared to a simple wave cos(x) The relationship between a wave of double and unit frequency is

12

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1226

sin2x = 2 sin x cos x (14)

You can simply derive the expression in Equation 14 using Equation 13 and the following

trick sin(2x) = sin(x + x) So sin 2x = sin x lowast cos x + sin x lowast cos x = 2 sin x cos x Derivationof the double-angle formula for cosine is similar just use Equation 12 and the same trickcos(2x) = cos(x + x)

cos2x = cos x lowast cos x minus sin x lowast sin x = cos2 x minus sin2 x = 2 cos2 x minus 1 = 1 minus 2sin2 x (15)

Why do we need the double-angle formula

An illustrative example this time comes from optics there are optical crystals that can double thefrequency of a lightwave such as lithium niobate (LN) or potassium titanyl phosphate (KTP)That is you can convert a light of a infra-red laser (with wavelength of 11microm that is easy toget) into a green laser light (wavelength 055microm) Most laser pointers that produce green light

use these frequency-doubling crystals

Figure 113 Doubling the lightwave frequency converting from cos(x) to cos(2x) in optics

134 Sum-to-Product Formulas

We already know by now that sine and cosine functions are models of waves and we cannot just sum them like cos x + cosy = cos(x + y) The following expressions will allow us to convertsum and difference of trigonometry functions into products

sin x plusmn sin y = 2 sin

983080x plusmn y

2

983081cos

983080x ∓ y

2

983081 (16)

cos x + cos y = 2 cos

983080x + y

2

983081cos

983080x minus y

2

983081 (17)

cos x minus cos y = minus2sin983080x + y

2983081

sin983080x minus y

2983081

(18)

These formulas can be derived using the expressions for double angles in Equation 14 andEquation 15 Letrsquos do it for sin(x)+sin(y) In this proof we take the right part of Equation 16and try to show that it is equivalent to the left part Use Equation 14 to get

2sin

983080x + y

2

983081cos

983080x minus y

2

983081= 2 lowast

1048616sin

x

2 cos

y

2 + cos

x

2 sin

y

2

1048617lowast1048616

cos x

2 cos

y

2 + sin

x

2 sin

y

2

1048617=

13

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1326

Here we just used the Equation 13 and Equation 12 Open the brackets and multiply theseitems to get

= 2 lowast1048616

sin x2

cos2 y2

cos x2

+ sin2 x2

cos y2

sin y2

+ sin y2

cos2 x2

cos y2

+ sin2 y2

cos x2

sin x2

1048617=

Take a closer look at item 1 and 4 - we can group them like this cos x2 sin x2 (sin2 y

2 +cos2 y2 )

Notice that the sum inside brackets equals 1 as we already know from sin2(x)+cos2(x) = 1 (seeEquation 11) The items 2 and 3 in the expression above can be grouped similarly so we get

= 2 lowast1048616

cos y

2 sin

y

2 + sin

x

2 cos

x

2

1048617=

Now open the brackets and look closely on each item for instance 2 cos y2 sin y2 looks similar

to Equation 14 Therefore 2 cos y2

sin y2

= sin(2 lowast y2

) = sin y and therefore

= 2 lowast 1048616cos y

2

sin y

2

+ sin x

2

cos x

21048617 = sin y + sin x

which is exactly the Equation 16 and concludes our proof

Why do we need sum-to-product formulas

These sum-to-product formulas are really special because your own brain does this all the time sounds that you hear with both ears are summed and processed by the brain so you can determinefor example where does the sound came from You can actually trick your own brain into findinga sum of two cosine waves (soundwaves) and hear binaural beats For example if a frequencyof 100 Hz is presented to your left ear and a frequency of 105 Hz is presented to your rightear your brain ldquohearsrdquo a third frequency pulsing at 5 Hz the exact difference between the twofrequencies Some binaural beat frequencies were found to be useful in auditory stimulation toenhance brain functioning

We can use the formula of sum-to-product to find the expression for sum of two sound waveswith frequency f 1 and f 2

cos(2πf 1t) + cos(2πf 2t) = 2 cos

9830802π

(f 1 + f 2)

2 t

983081cos

9830802π

(f 1 minus f 2)

2 t

983081

where t is a variable for time If the two sound frequencies are close (a difference f 1 minus f 2of about twenty hertz) the frequency of the sound wave is often too slow to be perceived as apitch Instead the sound wave is perceived as a periodic variation (beat) of the volume whichis described by the expression above We can see it in Figure 114

The program below (runs in MATLAB and GNUOctave) generates two sound waves (astereo sound) with two pure tones of frequencies f 1 = 500Hz and f 2 = 500 + 30 = 530Hz Thenthe sound is played for 4 seconds

Amplitude=10

duration=4 seconds

Frequency=500

Frequency diff= 30 frequency difference for beat

Freq sampling=10000 sampling frequency

values=01Freq samplingduration

left=Amplitudecos(2pi Frequencyvalues)

14

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1426

002 004 006 008 01 012

Figure 114 The sum (blue) of two cosine waves compared to a single wave (green) The functionplotted is yk = cos(2π lowast 500xk) + cos(2π lowast 530xk)

right = Amplitudecos(2pi (Frequency+Frequency diff)values)

stereosnd = [left right] combining two sounds at a stereo

soundsc(stereosnd Freq sampling) play the sound

You should use headphones to listen to this sound Put one earpiece in your ear and youwill hear a pure tone Then move the second earpiece slowly to your other ear - and instead of two separate tone you are going to hear a sound beat since the frequencies (or tones) differ

slightly (only by 30 Hz) Keep in mind that those two tones do not mix - they are in the left andright earpieces That is the tones do not interfere physically but are summed by the brainThis effect is related to the brainrsquos ability to locate sounds in three dimensions

See your own brain already knows and does the trigonometry and all this mathe-matical expressions just bring the trigonometric expressions to you in a convenient form

135 Product-to-sum formula

Letrsquos derive the reverse formulas which allow us to convert the product of two waves into thesum (or difference) of separate waves

2cos x cos y = cos(x minus y) + cos(x + y) (19)

2sin x sin y = cos(x minus y) minus cos(x + y) (110)

2sin x cos y = sin(x + y) + sin(x minus y) (111)

2cos x sin y = sin(x + y) minus sin(x minus y) (112)

These formulas can be used for transmitting the information via radiowaves as we will seeshortly The derivation of this formulas is very simple all you need is to use Equations 13and 12 For example the formula 2 cos x cos y = cos(x minus y) + cos(x + y) can be derived as sumof the two equations below

15

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1526

cos(x + y) = cos x cos y minus sin x sin y+cos(x minus y) = cos x cos y + sin x sin y

where sin x sin y are gone and therefore we get cos(x + y)+cos(xminus y) = 2 cos x cos y exactlyas in Equation 19 Other formulas can be derived in a similar way

Why do we need these Product-to-sum formulas

The product-to-sum trigonometric formulas can be used to transmit and receive informationEver wondered what are those FM and AM acronyms stand for They stand for AmplitudeModulation and Frequency Modulation respectively - these are the methods of transmittingmusic on a radio and we are going to use trigonometry for this

First we need a carrier wave - we are going to modify it with the input signal (our music) totransmit music using radiowaves The carrier wave is usually of a much higher frequency thanthe input signal which helps us to detect the actual signal Letrsquos take a carrier wave C (t) of

frequency F c and amplitude A given by

C (t) = A lowast cos(2πF ct)

which is a function of time t We are going to modify (or as engineers say modulate ) thiscarrier wave C (t) with a music but for simplicity letrsquos say we want to transmit just a pure toneS (t) This signal S (t) represent the modulation soundwave of a frequency F m (which must be amuch lower frequency than F c)

S (t) = M lowast cos(2πF mt)

where M is the amplitude of the modulation Letrsquos agree that M lt 1 so that (1+ S (t)) is alwayspositive Amplitude modulation occurs when the carrier wave C (t) is multiplied by (1 + S (t))

y(t) = [1 + S (t)] lowast C (t) = [1 + M lowast cos(2πF mt)] lowast A lowast cos(2πF ct) (113)

Using the Equation 19 the resulting signal (as a function of time) y(t) can be shown to be

y(t) = A lowast cos(2πF ct) + AM 2

[cos(2π(F c + F m)t) + cos(2π(F c minus F m)t)]

The modulated radiowave is shown in Figure 115 and the program for this demonstrationis provided below

A = 2 amplitude

duration=4 in seconds

Freq sampling = 10000

values=01Freq samplingduration

Carrier Frequency=1000

C t =Acos(2pi Carrier Frequencyvalues)

M = 01 modulation coefficient

Signal Frequency = 120

S t = Mcos(2piSignal Frequencyvalues)

y t = ( 1+ S t )C t

figure plot(values y t ) this is to plot a beat

16

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1626

0005 001 0015 002 0025 003 0035 004 0045 005

Figure 115 The Amplitude Modulation in action we have a carrier wave of 1000 Hz frequencywhich is modulated (modified) with a tone of 120 Hz using Equation 113 Notice the change inthe amplitude on the plot

136 The power of Trigonometry meet the Discrete Cosine Transform

Many textbooks mention the applications of trigonometry like determining the height of a build-ing if you know the distance to it and the angle to the rooftop or some equally boringexoticexamples Here we are going to see a real-world application of cosine functions which is reallyuseful for sound analysis and compression - the Discrete Cosine Transform (DCT)

Be not afraid of this fancy name it simply means that we are going to use Cosine function toTransform or decompose our sound signal on pure tones (cosine functions of various frequencies)The word Discrete simply means that the values of our signal are sampled with some fixed-stepinterval - for example we measure a value of our signal every 01 seconds

Using DCT we are going to mathematically de-compose our signal into pure tones (or cosinewaves) and calculate how many cosine waves of this particular frequency do we have in thesignal This is extremely useful for analysis of the signal for example you can reduce the noisein signal by simply zeroing out the unwanted frequencies and transforming the signal back

There are many applications of DCT that we use every day without even knowing it

signal analysis by decomposing the signal on the pure cosine waves we can see what arethe main waves in the signal This way you can analyse for example stock market pricesto find any recurring periodical fluctuations of prices (and predict when it happens next)

audio compression MP3 format uses a variety of DCT algorithm to determine which soundfrequencies to keep and which to throw away compressing the song without noticeable lossin quality

images compression JPEG format also compresses the images using DCT-like algorithmto reduce the size of the image by throwing away unnecessary details

17

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1726

Example of frequency analysis using Discrete Cosine Transform

Letrsquos go back to our previous example and take it one step further we combine a soundwave of frequency F 1 = 400 Hz and amplitude A = 1 with a soundwave of frequency F 2 = 800 Hz and

amplitude A = 2

yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) (114)

were indexes with the letter k in yk and xk simply mean the row number in the table with yand x Thatrsquos where the word discrete comes into play our computers can work with discretenumbers and all we need is to take enough samples of a function (cosine in this case) close toeach other to describe the signal

In the program code below we take L = 1000 samples for our signal from Equation 114 andwe take samples of our signal close to each other - say once every t = 14000th of a second Here4000 is our sampling frequency - this is how often we evaluate our function in Equation 114 Wetook F sampling = 4000 arbitrary - any number larger than 800 will be fine

1 Fs = 4000 Sampling frequency

2 T = 1Fs Sample time

3 L = 1000 Length of signal counts

4 x k = (1L)T Time count

56 Sum of a 400 Hz wave and a 800 Hz wave

7 y k = cos(2pi400x k) + 2cos(2pi800x k)

89 Now add some random noise to the sum of waves

10 y k n oisy = y k + 2randn(size(x k ))

1112 figure plot(Fsx k(1200)y k(1200))

13 title(Original signal (sum of two waves)) xlabel(time (milliseconds))

1415 figure plot(Fsx k(1200)y k noisy(1200))

16 title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

That is take L = 1000 numbers (line 3) and generate xk values (line 4) to be plugged intoEquation 114 (line 7) The plot of the signal can be seen in Figure 116(a)

The Discrete Cosine Transform Now the main part we are going to transform (decompose)our sound signal into pure tones (cosine waves of different frequencies) using the Discrete CosineTransform (DCT)

Dk =

N minus1991761n=0

yn cos

983131π

N

983080n +

1

2

983081k

983133 for every frequency k = 0 N minus 1 (115)

Now what does this formula2 actually mean

the signN minus1sumn=0

means ldquosumming elements with subscript n from n = 0 to n = N minus 1

N is the length of the signal y - in our case the signal has 1000 values (a row in a tablewith 1000 cells)

2This formula does not include a normalisation term to account for the number of samples - Irsquom skipping itto simplify the discussion

18

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1826

0 20 40 60 80 100 120 140 160 180 200minus2

minus15

minus1

minus05

0

05

1

15

2

25

3Original signal (sum of two waves)

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

40

X 400Y 2127

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 800Y 3618

(b)

Figure 116 Clean noiseless signal (a) The plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk)(b) the wave frequencies (Discrete Cosine Transform) in the noiseless signal you can see 400 Hzand 800 Hz peaks

yn we take from Equation 114

and we do this for every frequency k from 0 to N minus 1 At the end we get a row of numbersDk that tells us how many cosine waves with frequency 0 1 2 all the way up to frequency N minus1do we have in our signal The program code (MATLAB or Octave) for the DCT formula inEquation 115 is quite simple3

function D = my dct(y)

N = length(y) N rows do we have in the signal yD = zeros(N1) D stores the DCT transform of the signal y

for k = 01Nminus1 for every frequency k = 0 to Nminus1 with step 1

for n = 01Nminus1 for every row value of signal y do this

D(k+1) = D(k+1) + y(n+1)cos(piN (n + 12)k)

end the line above literary implements the DCT formula

end

There is no need to program the DCT formula in MATLAB and Octave it can be calledusing dct(Y) command to transform the signal stored in the variable Y

Now if we now plot the numbers in the variable Dk versus frequencies of a cosine wave (kfrom 0 to N-1) we will see the picture like the one in Fig 116(b) Notice two peaks at 400 and800 Hz - these peaks correspond to the cosine waves in our signal described by Equation 114

yk = cos(2 lowast pi lowast 400 lowast xk) + 2 lowast cos(2 lowast pi lowast 800 lowast xk)This is exactly what we expect after all our soundwave contains only 400 Hz and 800 Hz

cosine waves and those peaks of DCT indicate thisNow imagine that our soundwave was recorded with a bad microphone we have a lot of

noise in the recording If you look at Figure 117(a) there is so much noise that you donrsquot evensee the waves But if you use the DCT to decompose the noised signal and again make the plot

3The code is not efficient and it will take a lot of time for long signals However it is a simple word-for-wordimplementation of the DCT mathematical formula and serves its illustrative purpose

19

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1926

of its result you will be able to see those peaks (that correspond to soundwaves buried undernoise) in Figure 117(b)

0 20 40 60 80 100 120 140 160 180 200minus6

minus4

minus2

0

2

4

6

8

Signal Corrupted with Random Noise

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

X 800Y 3367

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 400Y 1858

(b)

Figure 117 Noised signal (a) the plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) with lotsof noise added (b) the wave frequencies (Discrete Cosine Transform) in the signal you can see400 Hz and 800 Hz peaks

This is the real power of trigonometric functions we can decompose even a very noisysignal and still see what are the cosine waves (that use pure tones) that make it And not justto look at the plot but also clean up the signal we can just zero-out the small numbers in theDCT variable Dk to clean up the noise and transform the signal back to its original state - andnoise is (almost) gone

The MATLAB (or Octave) code for this example is below

Fs = 4000 Sampling frequency

T = 1Fs Sample time

L = 1000 Length of signal counts

x k = (1L)T Time count

Sum of a 400 Hz wave and a 800 Hz wave

y k = cos(2pi400x k) + 2cos(2pi800x k)

Now add some random noise to the sum of waves

y k n oisy = y k + 2randn(size(x k )) Sinusoids plus noise

figure plot(Fsx k(1200)y k(1200))

title(Original signal (sum of two waves)) xlabel(time (milliseconds))

figure plot(Fsx k(1200)y k noisy(1200))

title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

How many cosine waves of different frequencies we have in the signal

D k dct clean signal = dct(y kL)

D k dct noisy signal = dct(y k noisyL)

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

20

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 9: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 926

Proof of Sum of squares formula

Figure 19 A geometric proof for identitysin2(x) + cos2(x) = 1

This identity can be also derived without any plotsusing only geometry Recall that the trigonometric

functions are connected with a circle of unit radiush = 1 as shown in Figure 19

Take any point on a circle of unit radius h =1 and put a vertical line down - this gives us atriangle with right angle 90 with sides a and band hypotenuse h = 1

Pythagorean theorem tells us that a2 + b2 = h2

in the right triangle and all we need is to expressthe sides in terms of cosine and sinus of an anglex We know that sin(x) = opposite

hypotenuse = a

h and

cos(x) = adjacenthypotenuse = b

h

Since h = 1 we have a2+b2 = 1 and sin(x) = a1

and cos x = b1 Substituting it back we get

sin2(x) + cos2(x) = 1 just like in Equation 11

132 Sum and difference of angles for sin(x) and cos(x)

As you may have guessed cosine wave of sum of frequencies is not just a sum of cosine wavesthat is the expression cos(x + y) = cos(x)+cos(y) is wrong and the actual expression is a bitmore complicated

cos(x plusmn y) = cos x cos y ∓ sin x sin y (12)

sin(x plusmn y) = sin x cos y plusmn cos x sin y (13)

The expressions above are very important since once you understood and memorised themyou can derive pretty much any other expression for sine and cosine functions Youcan make a plot (like in Figure 110) and compare for example cos(x + 2x) and cos x cos(2x)minussin x sin(2x) to make sure that the expression from Equation 12 is true

The program code that can plot Figure 110 in MATLAB or Octave programming languageis quite simple

y cos 3x = cos(3x)

y sin x = sin(x)

y cos x = cos(x)

y sin 2x = sin(2x)

y cos 2x = cos(2

x)

figure plot(x y cos xy c o s 2 x minus y s i n x y s i n 2 x

x y c o s x y c os 2 x x y s i n xy s i n 2 x )

legend(cos(3x) cos(x)cos(2x) sin(x)sin(2x)Location SouthEast)

Both equations 13 and 12 are so important that they deserve a formal proof 1

1There are many ways to prove those identities like using complex exponentials The proof here is Smiley Land Smiley D rdquoGeometry of Addition and Subtraction Formulasrdquo

10

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1026

0 1 2 3 4 5 6 7minus1

minus08

minus06

minus04

minus02

0

02

04

06

08

1

cos(3x)

cos(x)cos(2x)

sin(x)sin(2x)

Figure 110 The plot of cos(x + 2x) and cos x cos(2x) minus sin x sin(2x) for comparison If yousubtract the plot with sin x sin(2x) from cos x cos(2x) you will get cos(3x)

Proof for sin(α plusmn β )

Figure 111 Illustration for theproof of sin(α + β ) = sin α cos β +cos α sin β

Letrsquos take the right triangle ABC in Figure 111 such thatAK = 1 (unit length) For the proof we will need sin(α) =AC AB

so we need to express those sides in terms of cosine andsine

From ABC (α + β ) + γ = 90 there4 γ = 90 minus (α + β )From AKC angAKC + γ = 90 there4 angAKC = (α +

β ) since γ = 90 minus (α + β )Now we express side AC sin(α + β ) = AC

1 there4 AC =

sin(α + β )From ANK we are looking for expressions of sides

AN and NKcos β = AN

1 there4 AN = cos β Remember that we choose

AK to be of unit length - exactly for this Now find NKsin β = NK

1 there4 N K = sin β

From NBK we need to find NB that we need forthe proof of the formula (from Figure 111 you can see that

NB+AN = AB that we are looking for)tan α = NK

NB there4 NB = NK

tanα = sinβtanα = sinβ cosα

sinα We haveeverything we need by now and we turn back to our maintriangle ABC

Finally from ABC sin α = AC AB

= AC NB+AN

=sin(α+β)

cosβ+ sinβ cosαsinα

From this expression we need sin(α + β )

which is

11

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1126

sin(α + β ) = sin α

983080cos β +

sin β cos α

sin α

983081= sin α cos β + cos α sin β

This concludes the proof Formula for sin(αminusβ ) can be obtained simply substituting minusβ into the formula above which

gives Equation 13

Proof for cos(α plusmn β )

Figure 112 Illustration for the proof of cos(α + β ) = cos α cos β minussin α sin β

The proof is very similar to the previous one exceptwe put the angle β to the angKAC The side AK is stillof unit length as seen in Figure 112 For this proofwe will need tan(α) = AC

BC so we need to express those

sides in terms of cosine and sineFrom ABC (α+β )+γ = 90 there4 γ = 90minus(α+β )From ANK angNKA + γ = 90 there4 angN KA =

(α + β )Now we express the side NK cos(α + β ) = NK

1 there4

N K = cos(α + β ) Remember that we choose AK to beof unit length - exactly for this

From NBK sin α = NK BK

there4 BK = cos(α+β)sinα

From AKC we need to express the sides AC andKC in terms of trigonometric functions As before no-tice that AK is unit length that is AK = 1

cos β = AC 1

there4 AC = cos β

sin β = KC 1

there4 KC = sin β

Finally from ABC tan α = sinαcosα = AC

BC =

AC BK +KC = cosβ

cos(α+β)

sinα +sinβ

and all we need is to express

cos(α + β ) that we are looking for

sin α

cos α =

cos β sin α

cos(α + β ) + sin β sin α

from where

cos(α + β ) = cos α cos β minus sin α sin β

This concludes the proof

Formula for cos(α minus β ) can be obtained by simply substituting minusβ into the formula abovewhich gives Equation 12

Now since we have proven the formulas for sum and difference for cosine and sinefunctions we will get nearly all other formulas - again you donrsquot have to memorisethem mechanically since you can (relatively) simply derive them

133 Double-angle formulae

As before keep in mind that cosine and sine functions describe a wave thus cos(2x) is a waveof double frequency compared to a simple wave cos(x) The relationship between a wave of double and unit frequency is

12

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1226

sin2x = 2 sin x cos x (14)

You can simply derive the expression in Equation 14 using Equation 13 and the following

trick sin(2x) = sin(x + x) So sin 2x = sin x lowast cos x + sin x lowast cos x = 2 sin x cos x Derivationof the double-angle formula for cosine is similar just use Equation 12 and the same trickcos(2x) = cos(x + x)

cos2x = cos x lowast cos x minus sin x lowast sin x = cos2 x minus sin2 x = 2 cos2 x minus 1 = 1 minus 2sin2 x (15)

Why do we need the double-angle formula

An illustrative example this time comes from optics there are optical crystals that can double thefrequency of a lightwave such as lithium niobate (LN) or potassium titanyl phosphate (KTP)That is you can convert a light of a infra-red laser (with wavelength of 11microm that is easy toget) into a green laser light (wavelength 055microm) Most laser pointers that produce green light

use these frequency-doubling crystals

Figure 113 Doubling the lightwave frequency converting from cos(x) to cos(2x) in optics

134 Sum-to-Product Formulas

We already know by now that sine and cosine functions are models of waves and we cannot just sum them like cos x + cosy = cos(x + y) The following expressions will allow us to convertsum and difference of trigonometry functions into products

sin x plusmn sin y = 2 sin

983080x plusmn y

2

983081cos

983080x ∓ y

2

983081 (16)

cos x + cos y = 2 cos

983080x + y

2

983081cos

983080x minus y

2

983081 (17)

cos x minus cos y = minus2sin983080x + y

2983081

sin983080x minus y

2983081

(18)

These formulas can be derived using the expressions for double angles in Equation 14 andEquation 15 Letrsquos do it for sin(x)+sin(y) In this proof we take the right part of Equation 16and try to show that it is equivalent to the left part Use Equation 14 to get

2sin

983080x + y

2

983081cos

983080x minus y

2

983081= 2 lowast

1048616sin

x

2 cos

y

2 + cos

x

2 sin

y

2

1048617lowast1048616

cos x

2 cos

y

2 + sin

x

2 sin

y

2

1048617=

13

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1326

Here we just used the Equation 13 and Equation 12 Open the brackets and multiply theseitems to get

= 2 lowast1048616

sin x2

cos2 y2

cos x2

+ sin2 x2

cos y2

sin y2

+ sin y2

cos2 x2

cos y2

+ sin2 y2

cos x2

sin x2

1048617=

Take a closer look at item 1 and 4 - we can group them like this cos x2 sin x2 (sin2 y

2 +cos2 y2 )

Notice that the sum inside brackets equals 1 as we already know from sin2(x)+cos2(x) = 1 (seeEquation 11) The items 2 and 3 in the expression above can be grouped similarly so we get

= 2 lowast1048616

cos y

2 sin

y

2 + sin

x

2 cos

x

2

1048617=

Now open the brackets and look closely on each item for instance 2 cos y2 sin y2 looks similar

to Equation 14 Therefore 2 cos y2

sin y2

= sin(2 lowast y2

) = sin y and therefore

= 2 lowast 1048616cos y

2

sin y

2

+ sin x

2

cos x

21048617 = sin y + sin x

which is exactly the Equation 16 and concludes our proof

Why do we need sum-to-product formulas

These sum-to-product formulas are really special because your own brain does this all the time sounds that you hear with both ears are summed and processed by the brain so you can determinefor example where does the sound came from You can actually trick your own brain into findinga sum of two cosine waves (soundwaves) and hear binaural beats For example if a frequencyof 100 Hz is presented to your left ear and a frequency of 105 Hz is presented to your rightear your brain ldquohearsrdquo a third frequency pulsing at 5 Hz the exact difference between the twofrequencies Some binaural beat frequencies were found to be useful in auditory stimulation toenhance brain functioning

We can use the formula of sum-to-product to find the expression for sum of two sound waveswith frequency f 1 and f 2

cos(2πf 1t) + cos(2πf 2t) = 2 cos

9830802π

(f 1 + f 2)

2 t

983081cos

9830802π

(f 1 minus f 2)

2 t

983081

where t is a variable for time If the two sound frequencies are close (a difference f 1 minus f 2of about twenty hertz) the frequency of the sound wave is often too slow to be perceived as apitch Instead the sound wave is perceived as a periodic variation (beat) of the volume whichis described by the expression above We can see it in Figure 114

The program below (runs in MATLAB and GNUOctave) generates two sound waves (astereo sound) with two pure tones of frequencies f 1 = 500Hz and f 2 = 500 + 30 = 530Hz Thenthe sound is played for 4 seconds

Amplitude=10

duration=4 seconds

Frequency=500

Frequency diff= 30 frequency difference for beat

Freq sampling=10000 sampling frequency

values=01Freq samplingduration

left=Amplitudecos(2pi Frequencyvalues)

14

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1426

002 004 006 008 01 012

Figure 114 The sum (blue) of two cosine waves compared to a single wave (green) The functionplotted is yk = cos(2π lowast 500xk) + cos(2π lowast 530xk)

right = Amplitudecos(2pi (Frequency+Frequency diff)values)

stereosnd = [left right] combining two sounds at a stereo

soundsc(stereosnd Freq sampling) play the sound

You should use headphones to listen to this sound Put one earpiece in your ear and youwill hear a pure tone Then move the second earpiece slowly to your other ear - and instead of two separate tone you are going to hear a sound beat since the frequencies (or tones) differ

slightly (only by 30 Hz) Keep in mind that those two tones do not mix - they are in the left andright earpieces That is the tones do not interfere physically but are summed by the brainThis effect is related to the brainrsquos ability to locate sounds in three dimensions

See your own brain already knows and does the trigonometry and all this mathe-matical expressions just bring the trigonometric expressions to you in a convenient form

135 Product-to-sum formula

Letrsquos derive the reverse formulas which allow us to convert the product of two waves into thesum (or difference) of separate waves

2cos x cos y = cos(x minus y) + cos(x + y) (19)

2sin x sin y = cos(x minus y) minus cos(x + y) (110)

2sin x cos y = sin(x + y) + sin(x minus y) (111)

2cos x sin y = sin(x + y) minus sin(x minus y) (112)

These formulas can be used for transmitting the information via radiowaves as we will seeshortly The derivation of this formulas is very simple all you need is to use Equations 13and 12 For example the formula 2 cos x cos y = cos(x minus y) + cos(x + y) can be derived as sumof the two equations below

15

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1526

cos(x + y) = cos x cos y minus sin x sin y+cos(x minus y) = cos x cos y + sin x sin y

where sin x sin y are gone and therefore we get cos(x + y)+cos(xminus y) = 2 cos x cos y exactlyas in Equation 19 Other formulas can be derived in a similar way

Why do we need these Product-to-sum formulas

The product-to-sum trigonometric formulas can be used to transmit and receive informationEver wondered what are those FM and AM acronyms stand for They stand for AmplitudeModulation and Frequency Modulation respectively - these are the methods of transmittingmusic on a radio and we are going to use trigonometry for this

First we need a carrier wave - we are going to modify it with the input signal (our music) totransmit music using radiowaves The carrier wave is usually of a much higher frequency thanthe input signal which helps us to detect the actual signal Letrsquos take a carrier wave C (t) of

frequency F c and amplitude A given by

C (t) = A lowast cos(2πF ct)

which is a function of time t We are going to modify (or as engineers say modulate ) thiscarrier wave C (t) with a music but for simplicity letrsquos say we want to transmit just a pure toneS (t) This signal S (t) represent the modulation soundwave of a frequency F m (which must be amuch lower frequency than F c)

S (t) = M lowast cos(2πF mt)

where M is the amplitude of the modulation Letrsquos agree that M lt 1 so that (1+ S (t)) is alwayspositive Amplitude modulation occurs when the carrier wave C (t) is multiplied by (1 + S (t))

y(t) = [1 + S (t)] lowast C (t) = [1 + M lowast cos(2πF mt)] lowast A lowast cos(2πF ct) (113)

Using the Equation 19 the resulting signal (as a function of time) y(t) can be shown to be

y(t) = A lowast cos(2πF ct) + AM 2

[cos(2π(F c + F m)t) + cos(2π(F c minus F m)t)]

The modulated radiowave is shown in Figure 115 and the program for this demonstrationis provided below

A = 2 amplitude

duration=4 in seconds

Freq sampling = 10000

values=01Freq samplingduration

Carrier Frequency=1000

C t =Acos(2pi Carrier Frequencyvalues)

M = 01 modulation coefficient

Signal Frequency = 120

S t = Mcos(2piSignal Frequencyvalues)

y t = ( 1+ S t )C t

figure plot(values y t ) this is to plot a beat

16

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1626

0005 001 0015 002 0025 003 0035 004 0045 005

Figure 115 The Amplitude Modulation in action we have a carrier wave of 1000 Hz frequencywhich is modulated (modified) with a tone of 120 Hz using Equation 113 Notice the change inthe amplitude on the plot

136 The power of Trigonometry meet the Discrete Cosine Transform

Many textbooks mention the applications of trigonometry like determining the height of a build-ing if you know the distance to it and the angle to the rooftop or some equally boringexoticexamples Here we are going to see a real-world application of cosine functions which is reallyuseful for sound analysis and compression - the Discrete Cosine Transform (DCT)

Be not afraid of this fancy name it simply means that we are going to use Cosine function toTransform or decompose our sound signal on pure tones (cosine functions of various frequencies)The word Discrete simply means that the values of our signal are sampled with some fixed-stepinterval - for example we measure a value of our signal every 01 seconds

Using DCT we are going to mathematically de-compose our signal into pure tones (or cosinewaves) and calculate how many cosine waves of this particular frequency do we have in thesignal This is extremely useful for analysis of the signal for example you can reduce the noisein signal by simply zeroing out the unwanted frequencies and transforming the signal back

There are many applications of DCT that we use every day without even knowing it

signal analysis by decomposing the signal on the pure cosine waves we can see what arethe main waves in the signal This way you can analyse for example stock market pricesto find any recurring periodical fluctuations of prices (and predict when it happens next)

audio compression MP3 format uses a variety of DCT algorithm to determine which soundfrequencies to keep and which to throw away compressing the song without noticeable lossin quality

images compression JPEG format also compresses the images using DCT-like algorithmto reduce the size of the image by throwing away unnecessary details

17

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1726

Example of frequency analysis using Discrete Cosine Transform

Letrsquos go back to our previous example and take it one step further we combine a soundwave of frequency F 1 = 400 Hz and amplitude A = 1 with a soundwave of frequency F 2 = 800 Hz and

amplitude A = 2

yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) (114)

were indexes with the letter k in yk and xk simply mean the row number in the table with yand x Thatrsquos where the word discrete comes into play our computers can work with discretenumbers and all we need is to take enough samples of a function (cosine in this case) close toeach other to describe the signal

In the program code below we take L = 1000 samples for our signal from Equation 114 andwe take samples of our signal close to each other - say once every t = 14000th of a second Here4000 is our sampling frequency - this is how often we evaluate our function in Equation 114 Wetook F sampling = 4000 arbitrary - any number larger than 800 will be fine

1 Fs = 4000 Sampling frequency

2 T = 1Fs Sample time

3 L = 1000 Length of signal counts

4 x k = (1L)T Time count

56 Sum of a 400 Hz wave and a 800 Hz wave

7 y k = cos(2pi400x k) + 2cos(2pi800x k)

89 Now add some random noise to the sum of waves

10 y k n oisy = y k + 2randn(size(x k ))

1112 figure plot(Fsx k(1200)y k(1200))

13 title(Original signal (sum of two waves)) xlabel(time (milliseconds))

1415 figure plot(Fsx k(1200)y k noisy(1200))

16 title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

That is take L = 1000 numbers (line 3) and generate xk values (line 4) to be plugged intoEquation 114 (line 7) The plot of the signal can be seen in Figure 116(a)

The Discrete Cosine Transform Now the main part we are going to transform (decompose)our sound signal into pure tones (cosine waves of different frequencies) using the Discrete CosineTransform (DCT)

Dk =

N minus1991761n=0

yn cos

983131π

N

983080n +

1

2

983081k

983133 for every frequency k = 0 N minus 1 (115)

Now what does this formula2 actually mean

the signN minus1sumn=0

means ldquosumming elements with subscript n from n = 0 to n = N minus 1

N is the length of the signal y - in our case the signal has 1000 values (a row in a tablewith 1000 cells)

2This formula does not include a normalisation term to account for the number of samples - Irsquom skipping itto simplify the discussion

18

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1826

0 20 40 60 80 100 120 140 160 180 200minus2

minus15

minus1

minus05

0

05

1

15

2

25

3Original signal (sum of two waves)

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

40

X 400Y 2127

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 800Y 3618

(b)

Figure 116 Clean noiseless signal (a) The plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk)(b) the wave frequencies (Discrete Cosine Transform) in the noiseless signal you can see 400 Hzand 800 Hz peaks

yn we take from Equation 114

and we do this for every frequency k from 0 to N minus 1 At the end we get a row of numbersDk that tells us how many cosine waves with frequency 0 1 2 all the way up to frequency N minus1do we have in our signal The program code (MATLAB or Octave) for the DCT formula inEquation 115 is quite simple3

function D = my dct(y)

N = length(y) N rows do we have in the signal yD = zeros(N1) D stores the DCT transform of the signal y

for k = 01Nminus1 for every frequency k = 0 to Nminus1 with step 1

for n = 01Nminus1 for every row value of signal y do this

D(k+1) = D(k+1) + y(n+1)cos(piN (n + 12)k)

end the line above literary implements the DCT formula

end

There is no need to program the DCT formula in MATLAB and Octave it can be calledusing dct(Y) command to transform the signal stored in the variable Y

Now if we now plot the numbers in the variable Dk versus frequencies of a cosine wave (kfrom 0 to N-1) we will see the picture like the one in Fig 116(b) Notice two peaks at 400 and800 Hz - these peaks correspond to the cosine waves in our signal described by Equation 114

yk = cos(2 lowast pi lowast 400 lowast xk) + 2 lowast cos(2 lowast pi lowast 800 lowast xk)This is exactly what we expect after all our soundwave contains only 400 Hz and 800 Hz

cosine waves and those peaks of DCT indicate thisNow imagine that our soundwave was recorded with a bad microphone we have a lot of

noise in the recording If you look at Figure 117(a) there is so much noise that you donrsquot evensee the waves But if you use the DCT to decompose the noised signal and again make the plot

3The code is not efficient and it will take a lot of time for long signals However it is a simple word-for-wordimplementation of the DCT mathematical formula and serves its illustrative purpose

19

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1926

of its result you will be able to see those peaks (that correspond to soundwaves buried undernoise) in Figure 117(b)

0 20 40 60 80 100 120 140 160 180 200minus6

minus4

minus2

0

2

4

6

8

Signal Corrupted with Random Noise

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

X 800Y 3367

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 400Y 1858

(b)

Figure 117 Noised signal (a) the plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) with lotsof noise added (b) the wave frequencies (Discrete Cosine Transform) in the signal you can see400 Hz and 800 Hz peaks

This is the real power of trigonometric functions we can decompose even a very noisysignal and still see what are the cosine waves (that use pure tones) that make it And not justto look at the plot but also clean up the signal we can just zero-out the small numbers in theDCT variable Dk to clean up the noise and transform the signal back to its original state - andnoise is (almost) gone

The MATLAB (or Octave) code for this example is below

Fs = 4000 Sampling frequency

T = 1Fs Sample time

L = 1000 Length of signal counts

x k = (1L)T Time count

Sum of a 400 Hz wave and a 800 Hz wave

y k = cos(2pi400x k) + 2cos(2pi800x k)

Now add some random noise to the sum of waves

y k n oisy = y k + 2randn(size(x k )) Sinusoids plus noise

figure plot(Fsx k(1200)y k(1200))

title(Original signal (sum of two waves)) xlabel(time (milliseconds))

figure plot(Fsx k(1200)y k noisy(1200))

title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

How many cosine waves of different frequencies we have in the signal

D k dct clean signal = dct(y kL)

D k dct noisy signal = dct(y k noisyL)

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

20

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 10: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1026

0 1 2 3 4 5 6 7minus1

minus08

minus06

minus04

minus02

0

02

04

06

08

1

cos(3x)

cos(x)cos(2x)

sin(x)sin(2x)

Figure 110 The plot of cos(x + 2x) and cos x cos(2x) minus sin x sin(2x) for comparison If yousubtract the plot with sin x sin(2x) from cos x cos(2x) you will get cos(3x)

Proof for sin(α plusmn β )

Figure 111 Illustration for theproof of sin(α + β ) = sin α cos β +cos α sin β

Letrsquos take the right triangle ABC in Figure 111 such thatAK = 1 (unit length) For the proof we will need sin(α) =AC AB

so we need to express those sides in terms of cosine andsine

From ABC (α + β ) + γ = 90 there4 γ = 90 minus (α + β )From AKC angAKC + γ = 90 there4 angAKC = (α +

β ) since γ = 90 minus (α + β )Now we express side AC sin(α + β ) = AC

1 there4 AC =

sin(α + β )From ANK we are looking for expressions of sides

AN and NKcos β = AN

1 there4 AN = cos β Remember that we choose

AK to be of unit length - exactly for this Now find NKsin β = NK

1 there4 N K = sin β

From NBK we need to find NB that we need forthe proof of the formula (from Figure 111 you can see that

NB+AN = AB that we are looking for)tan α = NK

NB there4 NB = NK

tanα = sinβtanα = sinβ cosα

sinα We haveeverything we need by now and we turn back to our maintriangle ABC

Finally from ABC sin α = AC AB

= AC NB+AN

=sin(α+β)

cosβ+ sinβ cosαsinα

From this expression we need sin(α + β )

which is

11

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1126

sin(α + β ) = sin α

983080cos β +

sin β cos α

sin α

983081= sin α cos β + cos α sin β

This concludes the proof Formula for sin(αminusβ ) can be obtained simply substituting minusβ into the formula above which

gives Equation 13

Proof for cos(α plusmn β )

Figure 112 Illustration for the proof of cos(α + β ) = cos α cos β minussin α sin β

The proof is very similar to the previous one exceptwe put the angle β to the angKAC The side AK is stillof unit length as seen in Figure 112 For this proofwe will need tan(α) = AC

BC so we need to express those

sides in terms of cosine and sineFrom ABC (α+β )+γ = 90 there4 γ = 90minus(α+β )From ANK angNKA + γ = 90 there4 angN KA =

(α + β )Now we express the side NK cos(α + β ) = NK

1 there4

N K = cos(α + β ) Remember that we choose AK to beof unit length - exactly for this

From NBK sin α = NK BK

there4 BK = cos(α+β)sinα

From AKC we need to express the sides AC andKC in terms of trigonometric functions As before no-tice that AK is unit length that is AK = 1

cos β = AC 1

there4 AC = cos β

sin β = KC 1

there4 KC = sin β

Finally from ABC tan α = sinαcosα = AC

BC =

AC BK +KC = cosβ

cos(α+β)

sinα +sinβ

and all we need is to express

cos(α + β ) that we are looking for

sin α

cos α =

cos β sin α

cos(α + β ) + sin β sin α

from where

cos(α + β ) = cos α cos β minus sin α sin β

This concludes the proof

Formula for cos(α minus β ) can be obtained by simply substituting minusβ into the formula abovewhich gives Equation 12

Now since we have proven the formulas for sum and difference for cosine and sinefunctions we will get nearly all other formulas - again you donrsquot have to memorisethem mechanically since you can (relatively) simply derive them

133 Double-angle formulae

As before keep in mind that cosine and sine functions describe a wave thus cos(2x) is a waveof double frequency compared to a simple wave cos(x) The relationship between a wave of double and unit frequency is

12

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1226

sin2x = 2 sin x cos x (14)

You can simply derive the expression in Equation 14 using Equation 13 and the following

trick sin(2x) = sin(x + x) So sin 2x = sin x lowast cos x + sin x lowast cos x = 2 sin x cos x Derivationof the double-angle formula for cosine is similar just use Equation 12 and the same trickcos(2x) = cos(x + x)

cos2x = cos x lowast cos x minus sin x lowast sin x = cos2 x minus sin2 x = 2 cos2 x minus 1 = 1 minus 2sin2 x (15)

Why do we need the double-angle formula

An illustrative example this time comes from optics there are optical crystals that can double thefrequency of a lightwave such as lithium niobate (LN) or potassium titanyl phosphate (KTP)That is you can convert a light of a infra-red laser (with wavelength of 11microm that is easy toget) into a green laser light (wavelength 055microm) Most laser pointers that produce green light

use these frequency-doubling crystals

Figure 113 Doubling the lightwave frequency converting from cos(x) to cos(2x) in optics

134 Sum-to-Product Formulas

We already know by now that sine and cosine functions are models of waves and we cannot just sum them like cos x + cosy = cos(x + y) The following expressions will allow us to convertsum and difference of trigonometry functions into products

sin x plusmn sin y = 2 sin

983080x plusmn y

2

983081cos

983080x ∓ y

2

983081 (16)

cos x + cos y = 2 cos

983080x + y

2

983081cos

983080x minus y

2

983081 (17)

cos x minus cos y = minus2sin983080x + y

2983081

sin983080x minus y

2983081

(18)

These formulas can be derived using the expressions for double angles in Equation 14 andEquation 15 Letrsquos do it for sin(x)+sin(y) In this proof we take the right part of Equation 16and try to show that it is equivalent to the left part Use Equation 14 to get

2sin

983080x + y

2

983081cos

983080x minus y

2

983081= 2 lowast

1048616sin

x

2 cos

y

2 + cos

x

2 sin

y

2

1048617lowast1048616

cos x

2 cos

y

2 + sin

x

2 sin

y

2

1048617=

13

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1326

Here we just used the Equation 13 and Equation 12 Open the brackets and multiply theseitems to get

= 2 lowast1048616

sin x2

cos2 y2

cos x2

+ sin2 x2

cos y2

sin y2

+ sin y2

cos2 x2

cos y2

+ sin2 y2

cos x2

sin x2

1048617=

Take a closer look at item 1 and 4 - we can group them like this cos x2 sin x2 (sin2 y

2 +cos2 y2 )

Notice that the sum inside brackets equals 1 as we already know from sin2(x)+cos2(x) = 1 (seeEquation 11) The items 2 and 3 in the expression above can be grouped similarly so we get

= 2 lowast1048616

cos y

2 sin

y

2 + sin

x

2 cos

x

2

1048617=

Now open the brackets and look closely on each item for instance 2 cos y2 sin y2 looks similar

to Equation 14 Therefore 2 cos y2

sin y2

= sin(2 lowast y2

) = sin y and therefore

= 2 lowast 1048616cos y

2

sin y

2

+ sin x

2

cos x

21048617 = sin y + sin x

which is exactly the Equation 16 and concludes our proof

Why do we need sum-to-product formulas

These sum-to-product formulas are really special because your own brain does this all the time sounds that you hear with both ears are summed and processed by the brain so you can determinefor example where does the sound came from You can actually trick your own brain into findinga sum of two cosine waves (soundwaves) and hear binaural beats For example if a frequencyof 100 Hz is presented to your left ear and a frequency of 105 Hz is presented to your rightear your brain ldquohearsrdquo a third frequency pulsing at 5 Hz the exact difference between the twofrequencies Some binaural beat frequencies were found to be useful in auditory stimulation toenhance brain functioning

We can use the formula of sum-to-product to find the expression for sum of two sound waveswith frequency f 1 and f 2

cos(2πf 1t) + cos(2πf 2t) = 2 cos

9830802π

(f 1 + f 2)

2 t

983081cos

9830802π

(f 1 minus f 2)

2 t

983081

where t is a variable for time If the two sound frequencies are close (a difference f 1 minus f 2of about twenty hertz) the frequency of the sound wave is often too slow to be perceived as apitch Instead the sound wave is perceived as a periodic variation (beat) of the volume whichis described by the expression above We can see it in Figure 114

The program below (runs in MATLAB and GNUOctave) generates two sound waves (astereo sound) with two pure tones of frequencies f 1 = 500Hz and f 2 = 500 + 30 = 530Hz Thenthe sound is played for 4 seconds

Amplitude=10

duration=4 seconds

Frequency=500

Frequency diff= 30 frequency difference for beat

Freq sampling=10000 sampling frequency

values=01Freq samplingduration

left=Amplitudecos(2pi Frequencyvalues)

14

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1426

002 004 006 008 01 012

Figure 114 The sum (blue) of two cosine waves compared to a single wave (green) The functionplotted is yk = cos(2π lowast 500xk) + cos(2π lowast 530xk)

right = Amplitudecos(2pi (Frequency+Frequency diff)values)

stereosnd = [left right] combining two sounds at a stereo

soundsc(stereosnd Freq sampling) play the sound

You should use headphones to listen to this sound Put one earpiece in your ear and youwill hear a pure tone Then move the second earpiece slowly to your other ear - and instead of two separate tone you are going to hear a sound beat since the frequencies (or tones) differ

slightly (only by 30 Hz) Keep in mind that those two tones do not mix - they are in the left andright earpieces That is the tones do not interfere physically but are summed by the brainThis effect is related to the brainrsquos ability to locate sounds in three dimensions

See your own brain already knows and does the trigonometry and all this mathe-matical expressions just bring the trigonometric expressions to you in a convenient form

135 Product-to-sum formula

Letrsquos derive the reverse formulas which allow us to convert the product of two waves into thesum (or difference) of separate waves

2cos x cos y = cos(x minus y) + cos(x + y) (19)

2sin x sin y = cos(x minus y) minus cos(x + y) (110)

2sin x cos y = sin(x + y) + sin(x minus y) (111)

2cos x sin y = sin(x + y) minus sin(x minus y) (112)

These formulas can be used for transmitting the information via radiowaves as we will seeshortly The derivation of this formulas is very simple all you need is to use Equations 13and 12 For example the formula 2 cos x cos y = cos(x minus y) + cos(x + y) can be derived as sumof the two equations below

15

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1526

cos(x + y) = cos x cos y minus sin x sin y+cos(x minus y) = cos x cos y + sin x sin y

where sin x sin y are gone and therefore we get cos(x + y)+cos(xminus y) = 2 cos x cos y exactlyas in Equation 19 Other formulas can be derived in a similar way

Why do we need these Product-to-sum formulas

The product-to-sum trigonometric formulas can be used to transmit and receive informationEver wondered what are those FM and AM acronyms stand for They stand for AmplitudeModulation and Frequency Modulation respectively - these are the methods of transmittingmusic on a radio and we are going to use trigonometry for this

First we need a carrier wave - we are going to modify it with the input signal (our music) totransmit music using radiowaves The carrier wave is usually of a much higher frequency thanthe input signal which helps us to detect the actual signal Letrsquos take a carrier wave C (t) of

frequency F c and amplitude A given by

C (t) = A lowast cos(2πF ct)

which is a function of time t We are going to modify (or as engineers say modulate ) thiscarrier wave C (t) with a music but for simplicity letrsquos say we want to transmit just a pure toneS (t) This signal S (t) represent the modulation soundwave of a frequency F m (which must be amuch lower frequency than F c)

S (t) = M lowast cos(2πF mt)

where M is the amplitude of the modulation Letrsquos agree that M lt 1 so that (1+ S (t)) is alwayspositive Amplitude modulation occurs when the carrier wave C (t) is multiplied by (1 + S (t))

y(t) = [1 + S (t)] lowast C (t) = [1 + M lowast cos(2πF mt)] lowast A lowast cos(2πF ct) (113)

Using the Equation 19 the resulting signal (as a function of time) y(t) can be shown to be

y(t) = A lowast cos(2πF ct) + AM 2

[cos(2π(F c + F m)t) + cos(2π(F c minus F m)t)]

The modulated radiowave is shown in Figure 115 and the program for this demonstrationis provided below

A = 2 amplitude

duration=4 in seconds

Freq sampling = 10000

values=01Freq samplingduration

Carrier Frequency=1000

C t =Acos(2pi Carrier Frequencyvalues)

M = 01 modulation coefficient

Signal Frequency = 120

S t = Mcos(2piSignal Frequencyvalues)

y t = ( 1+ S t )C t

figure plot(values y t ) this is to plot a beat

16

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1626

0005 001 0015 002 0025 003 0035 004 0045 005

Figure 115 The Amplitude Modulation in action we have a carrier wave of 1000 Hz frequencywhich is modulated (modified) with a tone of 120 Hz using Equation 113 Notice the change inthe amplitude on the plot

136 The power of Trigonometry meet the Discrete Cosine Transform

Many textbooks mention the applications of trigonometry like determining the height of a build-ing if you know the distance to it and the angle to the rooftop or some equally boringexoticexamples Here we are going to see a real-world application of cosine functions which is reallyuseful for sound analysis and compression - the Discrete Cosine Transform (DCT)

Be not afraid of this fancy name it simply means that we are going to use Cosine function toTransform or decompose our sound signal on pure tones (cosine functions of various frequencies)The word Discrete simply means that the values of our signal are sampled with some fixed-stepinterval - for example we measure a value of our signal every 01 seconds

Using DCT we are going to mathematically de-compose our signal into pure tones (or cosinewaves) and calculate how many cosine waves of this particular frequency do we have in thesignal This is extremely useful for analysis of the signal for example you can reduce the noisein signal by simply zeroing out the unwanted frequencies and transforming the signal back

There are many applications of DCT that we use every day without even knowing it

signal analysis by decomposing the signal on the pure cosine waves we can see what arethe main waves in the signal This way you can analyse for example stock market pricesto find any recurring periodical fluctuations of prices (and predict when it happens next)

audio compression MP3 format uses a variety of DCT algorithm to determine which soundfrequencies to keep and which to throw away compressing the song without noticeable lossin quality

images compression JPEG format also compresses the images using DCT-like algorithmto reduce the size of the image by throwing away unnecessary details

17

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1726

Example of frequency analysis using Discrete Cosine Transform

Letrsquos go back to our previous example and take it one step further we combine a soundwave of frequency F 1 = 400 Hz and amplitude A = 1 with a soundwave of frequency F 2 = 800 Hz and

amplitude A = 2

yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) (114)

were indexes with the letter k in yk and xk simply mean the row number in the table with yand x Thatrsquos where the word discrete comes into play our computers can work with discretenumbers and all we need is to take enough samples of a function (cosine in this case) close toeach other to describe the signal

In the program code below we take L = 1000 samples for our signal from Equation 114 andwe take samples of our signal close to each other - say once every t = 14000th of a second Here4000 is our sampling frequency - this is how often we evaluate our function in Equation 114 Wetook F sampling = 4000 arbitrary - any number larger than 800 will be fine

1 Fs = 4000 Sampling frequency

2 T = 1Fs Sample time

3 L = 1000 Length of signal counts

4 x k = (1L)T Time count

56 Sum of a 400 Hz wave and a 800 Hz wave

7 y k = cos(2pi400x k) + 2cos(2pi800x k)

89 Now add some random noise to the sum of waves

10 y k n oisy = y k + 2randn(size(x k ))

1112 figure plot(Fsx k(1200)y k(1200))

13 title(Original signal (sum of two waves)) xlabel(time (milliseconds))

1415 figure plot(Fsx k(1200)y k noisy(1200))

16 title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

That is take L = 1000 numbers (line 3) and generate xk values (line 4) to be plugged intoEquation 114 (line 7) The plot of the signal can be seen in Figure 116(a)

The Discrete Cosine Transform Now the main part we are going to transform (decompose)our sound signal into pure tones (cosine waves of different frequencies) using the Discrete CosineTransform (DCT)

Dk =

N minus1991761n=0

yn cos

983131π

N

983080n +

1

2

983081k

983133 for every frequency k = 0 N minus 1 (115)

Now what does this formula2 actually mean

the signN minus1sumn=0

means ldquosumming elements with subscript n from n = 0 to n = N minus 1

N is the length of the signal y - in our case the signal has 1000 values (a row in a tablewith 1000 cells)

2This formula does not include a normalisation term to account for the number of samples - Irsquom skipping itto simplify the discussion

18

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1826

0 20 40 60 80 100 120 140 160 180 200minus2

minus15

minus1

minus05

0

05

1

15

2

25

3Original signal (sum of two waves)

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

40

X 400Y 2127

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 800Y 3618

(b)

Figure 116 Clean noiseless signal (a) The plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk)(b) the wave frequencies (Discrete Cosine Transform) in the noiseless signal you can see 400 Hzand 800 Hz peaks

yn we take from Equation 114

and we do this for every frequency k from 0 to N minus 1 At the end we get a row of numbersDk that tells us how many cosine waves with frequency 0 1 2 all the way up to frequency N minus1do we have in our signal The program code (MATLAB or Octave) for the DCT formula inEquation 115 is quite simple3

function D = my dct(y)

N = length(y) N rows do we have in the signal yD = zeros(N1) D stores the DCT transform of the signal y

for k = 01Nminus1 for every frequency k = 0 to Nminus1 with step 1

for n = 01Nminus1 for every row value of signal y do this

D(k+1) = D(k+1) + y(n+1)cos(piN (n + 12)k)

end the line above literary implements the DCT formula

end

There is no need to program the DCT formula in MATLAB and Octave it can be calledusing dct(Y) command to transform the signal stored in the variable Y

Now if we now plot the numbers in the variable Dk versus frequencies of a cosine wave (kfrom 0 to N-1) we will see the picture like the one in Fig 116(b) Notice two peaks at 400 and800 Hz - these peaks correspond to the cosine waves in our signal described by Equation 114

yk = cos(2 lowast pi lowast 400 lowast xk) + 2 lowast cos(2 lowast pi lowast 800 lowast xk)This is exactly what we expect after all our soundwave contains only 400 Hz and 800 Hz

cosine waves and those peaks of DCT indicate thisNow imagine that our soundwave was recorded with a bad microphone we have a lot of

noise in the recording If you look at Figure 117(a) there is so much noise that you donrsquot evensee the waves But if you use the DCT to decompose the noised signal and again make the plot

3The code is not efficient and it will take a lot of time for long signals However it is a simple word-for-wordimplementation of the DCT mathematical formula and serves its illustrative purpose

19

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1926

of its result you will be able to see those peaks (that correspond to soundwaves buried undernoise) in Figure 117(b)

0 20 40 60 80 100 120 140 160 180 200minus6

minus4

minus2

0

2

4

6

8

Signal Corrupted with Random Noise

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

X 800Y 3367

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 400Y 1858

(b)

Figure 117 Noised signal (a) the plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) with lotsof noise added (b) the wave frequencies (Discrete Cosine Transform) in the signal you can see400 Hz and 800 Hz peaks

This is the real power of trigonometric functions we can decompose even a very noisysignal and still see what are the cosine waves (that use pure tones) that make it And not justto look at the plot but also clean up the signal we can just zero-out the small numbers in theDCT variable Dk to clean up the noise and transform the signal back to its original state - andnoise is (almost) gone

The MATLAB (or Octave) code for this example is below

Fs = 4000 Sampling frequency

T = 1Fs Sample time

L = 1000 Length of signal counts

x k = (1L)T Time count

Sum of a 400 Hz wave and a 800 Hz wave

y k = cos(2pi400x k) + 2cos(2pi800x k)

Now add some random noise to the sum of waves

y k n oisy = y k + 2randn(size(x k )) Sinusoids plus noise

figure plot(Fsx k(1200)y k(1200))

title(Original signal (sum of two waves)) xlabel(time (milliseconds))

figure plot(Fsx k(1200)y k noisy(1200))

title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

How many cosine waves of different frequencies we have in the signal

D k dct clean signal = dct(y kL)

D k dct noisy signal = dct(y k noisyL)

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

20

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 11: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1126

sin(α + β ) = sin α

983080cos β +

sin β cos α

sin α

983081= sin α cos β + cos α sin β

This concludes the proof Formula for sin(αminusβ ) can be obtained simply substituting minusβ into the formula above which

gives Equation 13

Proof for cos(α plusmn β )

Figure 112 Illustration for the proof of cos(α + β ) = cos α cos β minussin α sin β

The proof is very similar to the previous one exceptwe put the angle β to the angKAC The side AK is stillof unit length as seen in Figure 112 For this proofwe will need tan(α) = AC

BC so we need to express those

sides in terms of cosine and sineFrom ABC (α+β )+γ = 90 there4 γ = 90minus(α+β )From ANK angNKA + γ = 90 there4 angN KA =

(α + β )Now we express the side NK cos(α + β ) = NK

1 there4

N K = cos(α + β ) Remember that we choose AK to beof unit length - exactly for this

From NBK sin α = NK BK

there4 BK = cos(α+β)sinα

From AKC we need to express the sides AC andKC in terms of trigonometric functions As before no-tice that AK is unit length that is AK = 1

cos β = AC 1

there4 AC = cos β

sin β = KC 1

there4 KC = sin β

Finally from ABC tan α = sinαcosα = AC

BC =

AC BK +KC = cosβ

cos(α+β)

sinα +sinβ

and all we need is to express

cos(α + β ) that we are looking for

sin α

cos α =

cos β sin α

cos(α + β ) + sin β sin α

from where

cos(α + β ) = cos α cos β minus sin α sin β

This concludes the proof

Formula for cos(α minus β ) can be obtained by simply substituting minusβ into the formula abovewhich gives Equation 12

Now since we have proven the formulas for sum and difference for cosine and sinefunctions we will get nearly all other formulas - again you donrsquot have to memorisethem mechanically since you can (relatively) simply derive them

133 Double-angle formulae

As before keep in mind that cosine and sine functions describe a wave thus cos(2x) is a waveof double frequency compared to a simple wave cos(x) The relationship between a wave of double and unit frequency is

12

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1226

sin2x = 2 sin x cos x (14)

You can simply derive the expression in Equation 14 using Equation 13 and the following

trick sin(2x) = sin(x + x) So sin 2x = sin x lowast cos x + sin x lowast cos x = 2 sin x cos x Derivationof the double-angle formula for cosine is similar just use Equation 12 and the same trickcos(2x) = cos(x + x)

cos2x = cos x lowast cos x minus sin x lowast sin x = cos2 x minus sin2 x = 2 cos2 x minus 1 = 1 minus 2sin2 x (15)

Why do we need the double-angle formula

An illustrative example this time comes from optics there are optical crystals that can double thefrequency of a lightwave such as lithium niobate (LN) or potassium titanyl phosphate (KTP)That is you can convert a light of a infra-red laser (with wavelength of 11microm that is easy toget) into a green laser light (wavelength 055microm) Most laser pointers that produce green light

use these frequency-doubling crystals

Figure 113 Doubling the lightwave frequency converting from cos(x) to cos(2x) in optics

134 Sum-to-Product Formulas

We already know by now that sine and cosine functions are models of waves and we cannot just sum them like cos x + cosy = cos(x + y) The following expressions will allow us to convertsum and difference of trigonometry functions into products

sin x plusmn sin y = 2 sin

983080x plusmn y

2

983081cos

983080x ∓ y

2

983081 (16)

cos x + cos y = 2 cos

983080x + y

2

983081cos

983080x minus y

2

983081 (17)

cos x minus cos y = minus2sin983080x + y

2983081

sin983080x minus y

2983081

(18)

These formulas can be derived using the expressions for double angles in Equation 14 andEquation 15 Letrsquos do it for sin(x)+sin(y) In this proof we take the right part of Equation 16and try to show that it is equivalent to the left part Use Equation 14 to get

2sin

983080x + y

2

983081cos

983080x minus y

2

983081= 2 lowast

1048616sin

x

2 cos

y

2 + cos

x

2 sin

y

2

1048617lowast1048616

cos x

2 cos

y

2 + sin

x

2 sin

y

2

1048617=

13

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1326

Here we just used the Equation 13 and Equation 12 Open the brackets and multiply theseitems to get

= 2 lowast1048616

sin x2

cos2 y2

cos x2

+ sin2 x2

cos y2

sin y2

+ sin y2

cos2 x2

cos y2

+ sin2 y2

cos x2

sin x2

1048617=

Take a closer look at item 1 and 4 - we can group them like this cos x2 sin x2 (sin2 y

2 +cos2 y2 )

Notice that the sum inside brackets equals 1 as we already know from sin2(x)+cos2(x) = 1 (seeEquation 11) The items 2 and 3 in the expression above can be grouped similarly so we get

= 2 lowast1048616

cos y

2 sin

y

2 + sin

x

2 cos

x

2

1048617=

Now open the brackets and look closely on each item for instance 2 cos y2 sin y2 looks similar

to Equation 14 Therefore 2 cos y2

sin y2

= sin(2 lowast y2

) = sin y and therefore

= 2 lowast 1048616cos y

2

sin y

2

+ sin x

2

cos x

21048617 = sin y + sin x

which is exactly the Equation 16 and concludes our proof

Why do we need sum-to-product formulas

These sum-to-product formulas are really special because your own brain does this all the time sounds that you hear with both ears are summed and processed by the brain so you can determinefor example where does the sound came from You can actually trick your own brain into findinga sum of two cosine waves (soundwaves) and hear binaural beats For example if a frequencyof 100 Hz is presented to your left ear and a frequency of 105 Hz is presented to your rightear your brain ldquohearsrdquo a third frequency pulsing at 5 Hz the exact difference between the twofrequencies Some binaural beat frequencies were found to be useful in auditory stimulation toenhance brain functioning

We can use the formula of sum-to-product to find the expression for sum of two sound waveswith frequency f 1 and f 2

cos(2πf 1t) + cos(2πf 2t) = 2 cos

9830802π

(f 1 + f 2)

2 t

983081cos

9830802π

(f 1 minus f 2)

2 t

983081

where t is a variable for time If the two sound frequencies are close (a difference f 1 minus f 2of about twenty hertz) the frequency of the sound wave is often too slow to be perceived as apitch Instead the sound wave is perceived as a periodic variation (beat) of the volume whichis described by the expression above We can see it in Figure 114

The program below (runs in MATLAB and GNUOctave) generates two sound waves (astereo sound) with two pure tones of frequencies f 1 = 500Hz and f 2 = 500 + 30 = 530Hz Thenthe sound is played for 4 seconds

Amplitude=10

duration=4 seconds

Frequency=500

Frequency diff= 30 frequency difference for beat

Freq sampling=10000 sampling frequency

values=01Freq samplingduration

left=Amplitudecos(2pi Frequencyvalues)

14

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1426

002 004 006 008 01 012

Figure 114 The sum (blue) of two cosine waves compared to a single wave (green) The functionplotted is yk = cos(2π lowast 500xk) + cos(2π lowast 530xk)

right = Amplitudecos(2pi (Frequency+Frequency diff)values)

stereosnd = [left right] combining two sounds at a stereo

soundsc(stereosnd Freq sampling) play the sound

You should use headphones to listen to this sound Put one earpiece in your ear and youwill hear a pure tone Then move the second earpiece slowly to your other ear - and instead of two separate tone you are going to hear a sound beat since the frequencies (or tones) differ

slightly (only by 30 Hz) Keep in mind that those two tones do not mix - they are in the left andright earpieces That is the tones do not interfere physically but are summed by the brainThis effect is related to the brainrsquos ability to locate sounds in three dimensions

See your own brain already knows and does the trigonometry and all this mathe-matical expressions just bring the trigonometric expressions to you in a convenient form

135 Product-to-sum formula

Letrsquos derive the reverse formulas which allow us to convert the product of two waves into thesum (or difference) of separate waves

2cos x cos y = cos(x minus y) + cos(x + y) (19)

2sin x sin y = cos(x minus y) minus cos(x + y) (110)

2sin x cos y = sin(x + y) + sin(x minus y) (111)

2cos x sin y = sin(x + y) minus sin(x minus y) (112)

These formulas can be used for transmitting the information via radiowaves as we will seeshortly The derivation of this formulas is very simple all you need is to use Equations 13and 12 For example the formula 2 cos x cos y = cos(x minus y) + cos(x + y) can be derived as sumof the two equations below

15

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1526

cos(x + y) = cos x cos y minus sin x sin y+cos(x minus y) = cos x cos y + sin x sin y

where sin x sin y are gone and therefore we get cos(x + y)+cos(xminus y) = 2 cos x cos y exactlyas in Equation 19 Other formulas can be derived in a similar way

Why do we need these Product-to-sum formulas

The product-to-sum trigonometric formulas can be used to transmit and receive informationEver wondered what are those FM and AM acronyms stand for They stand for AmplitudeModulation and Frequency Modulation respectively - these are the methods of transmittingmusic on a radio and we are going to use trigonometry for this

First we need a carrier wave - we are going to modify it with the input signal (our music) totransmit music using radiowaves The carrier wave is usually of a much higher frequency thanthe input signal which helps us to detect the actual signal Letrsquos take a carrier wave C (t) of

frequency F c and amplitude A given by

C (t) = A lowast cos(2πF ct)

which is a function of time t We are going to modify (or as engineers say modulate ) thiscarrier wave C (t) with a music but for simplicity letrsquos say we want to transmit just a pure toneS (t) This signal S (t) represent the modulation soundwave of a frequency F m (which must be amuch lower frequency than F c)

S (t) = M lowast cos(2πF mt)

where M is the amplitude of the modulation Letrsquos agree that M lt 1 so that (1+ S (t)) is alwayspositive Amplitude modulation occurs when the carrier wave C (t) is multiplied by (1 + S (t))

y(t) = [1 + S (t)] lowast C (t) = [1 + M lowast cos(2πF mt)] lowast A lowast cos(2πF ct) (113)

Using the Equation 19 the resulting signal (as a function of time) y(t) can be shown to be

y(t) = A lowast cos(2πF ct) + AM 2

[cos(2π(F c + F m)t) + cos(2π(F c minus F m)t)]

The modulated radiowave is shown in Figure 115 and the program for this demonstrationis provided below

A = 2 amplitude

duration=4 in seconds

Freq sampling = 10000

values=01Freq samplingduration

Carrier Frequency=1000

C t =Acos(2pi Carrier Frequencyvalues)

M = 01 modulation coefficient

Signal Frequency = 120

S t = Mcos(2piSignal Frequencyvalues)

y t = ( 1+ S t )C t

figure plot(values y t ) this is to plot a beat

16

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1626

0005 001 0015 002 0025 003 0035 004 0045 005

Figure 115 The Amplitude Modulation in action we have a carrier wave of 1000 Hz frequencywhich is modulated (modified) with a tone of 120 Hz using Equation 113 Notice the change inthe amplitude on the plot

136 The power of Trigonometry meet the Discrete Cosine Transform

Many textbooks mention the applications of trigonometry like determining the height of a build-ing if you know the distance to it and the angle to the rooftop or some equally boringexoticexamples Here we are going to see a real-world application of cosine functions which is reallyuseful for sound analysis and compression - the Discrete Cosine Transform (DCT)

Be not afraid of this fancy name it simply means that we are going to use Cosine function toTransform or decompose our sound signal on pure tones (cosine functions of various frequencies)The word Discrete simply means that the values of our signal are sampled with some fixed-stepinterval - for example we measure a value of our signal every 01 seconds

Using DCT we are going to mathematically de-compose our signal into pure tones (or cosinewaves) and calculate how many cosine waves of this particular frequency do we have in thesignal This is extremely useful for analysis of the signal for example you can reduce the noisein signal by simply zeroing out the unwanted frequencies and transforming the signal back

There are many applications of DCT that we use every day without even knowing it

signal analysis by decomposing the signal on the pure cosine waves we can see what arethe main waves in the signal This way you can analyse for example stock market pricesto find any recurring periodical fluctuations of prices (and predict when it happens next)

audio compression MP3 format uses a variety of DCT algorithm to determine which soundfrequencies to keep and which to throw away compressing the song without noticeable lossin quality

images compression JPEG format also compresses the images using DCT-like algorithmto reduce the size of the image by throwing away unnecessary details

17

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1726

Example of frequency analysis using Discrete Cosine Transform

Letrsquos go back to our previous example and take it one step further we combine a soundwave of frequency F 1 = 400 Hz and amplitude A = 1 with a soundwave of frequency F 2 = 800 Hz and

amplitude A = 2

yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) (114)

were indexes with the letter k in yk and xk simply mean the row number in the table with yand x Thatrsquos where the word discrete comes into play our computers can work with discretenumbers and all we need is to take enough samples of a function (cosine in this case) close toeach other to describe the signal

In the program code below we take L = 1000 samples for our signal from Equation 114 andwe take samples of our signal close to each other - say once every t = 14000th of a second Here4000 is our sampling frequency - this is how often we evaluate our function in Equation 114 Wetook F sampling = 4000 arbitrary - any number larger than 800 will be fine

1 Fs = 4000 Sampling frequency

2 T = 1Fs Sample time

3 L = 1000 Length of signal counts

4 x k = (1L)T Time count

56 Sum of a 400 Hz wave and a 800 Hz wave

7 y k = cos(2pi400x k) + 2cos(2pi800x k)

89 Now add some random noise to the sum of waves

10 y k n oisy = y k + 2randn(size(x k ))

1112 figure plot(Fsx k(1200)y k(1200))

13 title(Original signal (sum of two waves)) xlabel(time (milliseconds))

1415 figure plot(Fsx k(1200)y k noisy(1200))

16 title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

That is take L = 1000 numbers (line 3) and generate xk values (line 4) to be plugged intoEquation 114 (line 7) The plot of the signal can be seen in Figure 116(a)

The Discrete Cosine Transform Now the main part we are going to transform (decompose)our sound signal into pure tones (cosine waves of different frequencies) using the Discrete CosineTransform (DCT)

Dk =

N minus1991761n=0

yn cos

983131π

N

983080n +

1

2

983081k

983133 for every frequency k = 0 N minus 1 (115)

Now what does this formula2 actually mean

the signN minus1sumn=0

means ldquosumming elements with subscript n from n = 0 to n = N minus 1

N is the length of the signal y - in our case the signal has 1000 values (a row in a tablewith 1000 cells)

2This formula does not include a normalisation term to account for the number of samples - Irsquom skipping itto simplify the discussion

18

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1826

0 20 40 60 80 100 120 140 160 180 200minus2

minus15

minus1

minus05

0

05

1

15

2

25

3Original signal (sum of two waves)

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

40

X 400Y 2127

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 800Y 3618

(b)

Figure 116 Clean noiseless signal (a) The plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk)(b) the wave frequencies (Discrete Cosine Transform) in the noiseless signal you can see 400 Hzand 800 Hz peaks

yn we take from Equation 114

and we do this for every frequency k from 0 to N minus 1 At the end we get a row of numbersDk that tells us how many cosine waves with frequency 0 1 2 all the way up to frequency N minus1do we have in our signal The program code (MATLAB or Octave) for the DCT formula inEquation 115 is quite simple3

function D = my dct(y)

N = length(y) N rows do we have in the signal yD = zeros(N1) D stores the DCT transform of the signal y

for k = 01Nminus1 for every frequency k = 0 to Nminus1 with step 1

for n = 01Nminus1 for every row value of signal y do this

D(k+1) = D(k+1) + y(n+1)cos(piN (n + 12)k)

end the line above literary implements the DCT formula

end

There is no need to program the DCT formula in MATLAB and Octave it can be calledusing dct(Y) command to transform the signal stored in the variable Y

Now if we now plot the numbers in the variable Dk versus frequencies of a cosine wave (kfrom 0 to N-1) we will see the picture like the one in Fig 116(b) Notice two peaks at 400 and800 Hz - these peaks correspond to the cosine waves in our signal described by Equation 114

yk = cos(2 lowast pi lowast 400 lowast xk) + 2 lowast cos(2 lowast pi lowast 800 lowast xk)This is exactly what we expect after all our soundwave contains only 400 Hz and 800 Hz

cosine waves and those peaks of DCT indicate thisNow imagine that our soundwave was recorded with a bad microphone we have a lot of

noise in the recording If you look at Figure 117(a) there is so much noise that you donrsquot evensee the waves But if you use the DCT to decompose the noised signal and again make the plot

3The code is not efficient and it will take a lot of time for long signals However it is a simple word-for-wordimplementation of the DCT mathematical formula and serves its illustrative purpose

19

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1926

of its result you will be able to see those peaks (that correspond to soundwaves buried undernoise) in Figure 117(b)

0 20 40 60 80 100 120 140 160 180 200minus6

minus4

minus2

0

2

4

6

8

Signal Corrupted with Random Noise

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

X 800Y 3367

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 400Y 1858

(b)

Figure 117 Noised signal (a) the plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) with lotsof noise added (b) the wave frequencies (Discrete Cosine Transform) in the signal you can see400 Hz and 800 Hz peaks

This is the real power of trigonometric functions we can decompose even a very noisysignal and still see what are the cosine waves (that use pure tones) that make it And not justto look at the plot but also clean up the signal we can just zero-out the small numbers in theDCT variable Dk to clean up the noise and transform the signal back to its original state - andnoise is (almost) gone

The MATLAB (or Octave) code for this example is below

Fs = 4000 Sampling frequency

T = 1Fs Sample time

L = 1000 Length of signal counts

x k = (1L)T Time count

Sum of a 400 Hz wave and a 800 Hz wave

y k = cos(2pi400x k) + 2cos(2pi800x k)

Now add some random noise to the sum of waves

y k n oisy = y k + 2randn(size(x k )) Sinusoids plus noise

figure plot(Fsx k(1200)y k(1200))

title(Original signal (sum of two waves)) xlabel(time (milliseconds))

figure plot(Fsx k(1200)y k noisy(1200))

title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

How many cosine waves of different frequencies we have in the signal

D k dct clean signal = dct(y kL)

D k dct noisy signal = dct(y k noisyL)

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

20

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 12: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1226

sin2x = 2 sin x cos x (14)

You can simply derive the expression in Equation 14 using Equation 13 and the following

trick sin(2x) = sin(x + x) So sin 2x = sin x lowast cos x + sin x lowast cos x = 2 sin x cos x Derivationof the double-angle formula for cosine is similar just use Equation 12 and the same trickcos(2x) = cos(x + x)

cos2x = cos x lowast cos x minus sin x lowast sin x = cos2 x minus sin2 x = 2 cos2 x minus 1 = 1 minus 2sin2 x (15)

Why do we need the double-angle formula

An illustrative example this time comes from optics there are optical crystals that can double thefrequency of a lightwave such as lithium niobate (LN) or potassium titanyl phosphate (KTP)That is you can convert a light of a infra-red laser (with wavelength of 11microm that is easy toget) into a green laser light (wavelength 055microm) Most laser pointers that produce green light

use these frequency-doubling crystals

Figure 113 Doubling the lightwave frequency converting from cos(x) to cos(2x) in optics

134 Sum-to-Product Formulas

We already know by now that sine and cosine functions are models of waves and we cannot just sum them like cos x + cosy = cos(x + y) The following expressions will allow us to convertsum and difference of trigonometry functions into products

sin x plusmn sin y = 2 sin

983080x plusmn y

2

983081cos

983080x ∓ y

2

983081 (16)

cos x + cos y = 2 cos

983080x + y

2

983081cos

983080x minus y

2

983081 (17)

cos x minus cos y = minus2sin983080x + y

2983081

sin983080x minus y

2983081

(18)

These formulas can be derived using the expressions for double angles in Equation 14 andEquation 15 Letrsquos do it for sin(x)+sin(y) In this proof we take the right part of Equation 16and try to show that it is equivalent to the left part Use Equation 14 to get

2sin

983080x + y

2

983081cos

983080x minus y

2

983081= 2 lowast

1048616sin

x

2 cos

y

2 + cos

x

2 sin

y

2

1048617lowast1048616

cos x

2 cos

y

2 + sin

x

2 sin

y

2

1048617=

13

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1326

Here we just used the Equation 13 and Equation 12 Open the brackets and multiply theseitems to get

= 2 lowast1048616

sin x2

cos2 y2

cos x2

+ sin2 x2

cos y2

sin y2

+ sin y2

cos2 x2

cos y2

+ sin2 y2

cos x2

sin x2

1048617=

Take a closer look at item 1 and 4 - we can group them like this cos x2 sin x2 (sin2 y

2 +cos2 y2 )

Notice that the sum inside brackets equals 1 as we already know from sin2(x)+cos2(x) = 1 (seeEquation 11) The items 2 and 3 in the expression above can be grouped similarly so we get

= 2 lowast1048616

cos y

2 sin

y

2 + sin

x

2 cos

x

2

1048617=

Now open the brackets and look closely on each item for instance 2 cos y2 sin y2 looks similar

to Equation 14 Therefore 2 cos y2

sin y2

= sin(2 lowast y2

) = sin y and therefore

= 2 lowast 1048616cos y

2

sin y

2

+ sin x

2

cos x

21048617 = sin y + sin x

which is exactly the Equation 16 and concludes our proof

Why do we need sum-to-product formulas

These sum-to-product formulas are really special because your own brain does this all the time sounds that you hear with both ears are summed and processed by the brain so you can determinefor example where does the sound came from You can actually trick your own brain into findinga sum of two cosine waves (soundwaves) and hear binaural beats For example if a frequencyof 100 Hz is presented to your left ear and a frequency of 105 Hz is presented to your rightear your brain ldquohearsrdquo a third frequency pulsing at 5 Hz the exact difference between the twofrequencies Some binaural beat frequencies were found to be useful in auditory stimulation toenhance brain functioning

We can use the formula of sum-to-product to find the expression for sum of two sound waveswith frequency f 1 and f 2

cos(2πf 1t) + cos(2πf 2t) = 2 cos

9830802π

(f 1 + f 2)

2 t

983081cos

9830802π

(f 1 minus f 2)

2 t

983081

where t is a variable for time If the two sound frequencies are close (a difference f 1 minus f 2of about twenty hertz) the frequency of the sound wave is often too slow to be perceived as apitch Instead the sound wave is perceived as a periodic variation (beat) of the volume whichis described by the expression above We can see it in Figure 114

The program below (runs in MATLAB and GNUOctave) generates two sound waves (astereo sound) with two pure tones of frequencies f 1 = 500Hz and f 2 = 500 + 30 = 530Hz Thenthe sound is played for 4 seconds

Amplitude=10

duration=4 seconds

Frequency=500

Frequency diff= 30 frequency difference for beat

Freq sampling=10000 sampling frequency

values=01Freq samplingduration

left=Amplitudecos(2pi Frequencyvalues)

14

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1426

002 004 006 008 01 012

Figure 114 The sum (blue) of two cosine waves compared to a single wave (green) The functionplotted is yk = cos(2π lowast 500xk) + cos(2π lowast 530xk)

right = Amplitudecos(2pi (Frequency+Frequency diff)values)

stereosnd = [left right] combining two sounds at a stereo

soundsc(stereosnd Freq sampling) play the sound

You should use headphones to listen to this sound Put one earpiece in your ear and youwill hear a pure tone Then move the second earpiece slowly to your other ear - and instead of two separate tone you are going to hear a sound beat since the frequencies (or tones) differ

slightly (only by 30 Hz) Keep in mind that those two tones do not mix - they are in the left andright earpieces That is the tones do not interfere physically but are summed by the brainThis effect is related to the brainrsquos ability to locate sounds in three dimensions

See your own brain already knows and does the trigonometry and all this mathe-matical expressions just bring the trigonometric expressions to you in a convenient form

135 Product-to-sum formula

Letrsquos derive the reverse formulas which allow us to convert the product of two waves into thesum (or difference) of separate waves

2cos x cos y = cos(x minus y) + cos(x + y) (19)

2sin x sin y = cos(x minus y) minus cos(x + y) (110)

2sin x cos y = sin(x + y) + sin(x minus y) (111)

2cos x sin y = sin(x + y) minus sin(x minus y) (112)

These formulas can be used for transmitting the information via radiowaves as we will seeshortly The derivation of this formulas is very simple all you need is to use Equations 13and 12 For example the formula 2 cos x cos y = cos(x minus y) + cos(x + y) can be derived as sumof the two equations below

15

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1526

cos(x + y) = cos x cos y minus sin x sin y+cos(x minus y) = cos x cos y + sin x sin y

where sin x sin y are gone and therefore we get cos(x + y)+cos(xminus y) = 2 cos x cos y exactlyas in Equation 19 Other formulas can be derived in a similar way

Why do we need these Product-to-sum formulas

The product-to-sum trigonometric formulas can be used to transmit and receive informationEver wondered what are those FM and AM acronyms stand for They stand for AmplitudeModulation and Frequency Modulation respectively - these are the methods of transmittingmusic on a radio and we are going to use trigonometry for this

First we need a carrier wave - we are going to modify it with the input signal (our music) totransmit music using radiowaves The carrier wave is usually of a much higher frequency thanthe input signal which helps us to detect the actual signal Letrsquos take a carrier wave C (t) of

frequency F c and amplitude A given by

C (t) = A lowast cos(2πF ct)

which is a function of time t We are going to modify (or as engineers say modulate ) thiscarrier wave C (t) with a music but for simplicity letrsquos say we want to transmit just a pure toneS (t) This signal S (t) represent the modulation soundwave of a frequency F m (which must be amuch lower frequency than F c)

S (t) = M lowast cos(2πF mt)

where M is the amplitude of the modulation Letrsquos agree that M lt 1 so that (1+ S (t)) is alwayspositive Amplitude modulation occurs when the carrier wave C (t) is multiplied by (1 + S (t))

y(t) = [1 + S (t)] lowast C (t) = [1 + M lowast cos(2πF mt)] lowast A lowast cos(2πF ct) (113)

Using the Equation 19 the resulting signal (as a function of time) y(t) can be shown to be

y(t) = A lowast cos(2πF ct) + AM 2

[cos(2π(F c + F m)t) + cos(2π(F c minus F m)t)]

The modulated radiowave is shown in Figure 115 and the program for this demonstrationis provided below

A = 2 amplitude

duration=4 in seconds

Freq sampling = 10000

values=01Freq samplingduration

Carrier Frequency=1000

C t =Acos(2pi Carrier Frequencyvalues)

M = 01 modulation coefficient

Signal Frequency = 120

S t = Mcos(2piSignal Frequencyvalues)

y t = ( 1+ S t )C t

figure plot(values y t ) this is to plot a beat

16

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1626

0005 001 0015 002 0025 003 0035 004 0045 005

Figure 115 The Amplitude Modulation in action we have a carrier wave of 1000 Hz frequencywhich is modulated (modified) with a tone of 120 Hz using Equation 113 Notice the change inthe amplitude on the plot

136 The power of Trigonometry meet the Discrete Cosine Transform

Many textbooks mention the applications of trigonometry like determining the height of a build-ing if you know the distance to it and the angle to the rooftop or some equally boringexoticexamples Here we are going to see a real-world application of cosine functions which is reallyuseful for sound analysis and compression - the Discrete Cosine Transform (DCT)

Be not afraid of this fancy name it simply means that we are going to use Cosine function toTransform or decompose our sound signal on pure tones (cosine functions of various frequencies)The word Discrete simply means that the values of our signal are sampled with some fixed-stepinterval - for example we measure a value of our signal every 01 seconds

Using DCT we are going to mathematically de-compose our signal into pure tones (or cosinewaves) and calculate how many cosine waves of this particular frequency do we have in thesignal This is extremely useful for analysis of the signal for example you can reduce the noisein signal by simply zeroing out the unwanted frequencies and transforming the signal back

There are many applications of DCT that we use every day without even knowing it

signal analysis by decomposing the signal on the pure cosine waves we can see what arethe main waves in the signal This way you can analyse for example stock market pricesto find any recurring periodical fluctuations of prices (and predict when it happens next)

audio compression MP3 format uses a variety of DCT algorithm to determine which soundfrequencies to keep and which to throw away compressing the song without noticeable lossin quality

images compression JPEG format also compresses the images using DCT-like algorithmto reduce the size of the image by throwing away unnecessary details

17

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1726

Example of frequency analysis using Discrete Cosine Transform

Letrsquos go back to our previous example and take it one step further we combine a soundwave of frequency F 1 = 400 Hz and amplitude A = 1 with a soundwave of frequency F 2 = 800 Hz and

amplitude A = 2

yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) (114)

were indexes with the letter k in yk and xk simply mean the row number in the table with yand x Thatrsquos where the word discrete comes into play our computers can work with discretenumbers and all we need is to take enough samples of a function (cosine in this case) close toeach other to describe the signal

In the program code below we take L = 1000 samples for our signal from Equation 114 andwe take samples of our signal close to each other - say once every t = 14000th of a second Here4000 is our sampling frequency - this is how often we evaluate our function in Equation 114 Wetook F sampling = 4000 arbitrary - any number larger than 800 will be fine

1 Fs = 4000 Sampling frequency

2 T = 1Fs Sample time

3 L = 1000 Length of signal counts

4 x k = (1L)T Time count

56 Sum of a 400 Hz wave and a 800 Hz wave

7 y k = cos(2pi400x k) + 2cos(2pi800x k)

89 Now add some random noise to the sum of waves

10 y k n oisy = y k + 2randn(size(x k ))

1112 figure plot(Fsx k(1200)y k(1200))

13 title(Original signal (sum of two waves)) xlabel(time (milliseconds))

1415 figure plot(Fsx k(1200)y k noisy(1200))

16 title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

That is take L = 1000 numbers (line 3) and generate xk values (line 4) to be plugged intoEquation 114 (line 7) The plot of the signal can be seen in Figure 116(a)

The Discrete Cosine Transform Now the main part we are going to transform (decompose)our sound signal into pure tones (cosine waves of different frequencies) using the Discrete CosineTransform (DCT)

Dk =

N minus1991761n=0

yn cos

983131π

N

983080n +

1

2

983081k

983133 for every frequency k = 0 N minus 1 (115)

Now what does this formula2 actually mean

the signN minus1sumn=0

means ldquosumming elements with subscript n from n = 0 to n = N minus 1

N is the length of the signal y - in our case the signal has 1000 values (a row in a tablewith 1000 cells)

2This formula does not include a normalisation term to account for the number of samples - Irsquom skipping itto simplify the discussion

18

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1826

0 20 40 60 80 100 120 140 160 180 200minus2

minus15

minus1

minus05

0

05

1

15

2

25

3Original signal (sum of two waves)

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

40

X 400Y 2127

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 800Y 3618

(b)

Figure 116 Clean noiseless signal (a) The plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk)(b) the wave frequencies (Discrete Cosine Transform) in the noiseless signal you can see 400 Hzand 800 Hz peaks

yn we take from Equation 114

and we do this for every frequency k from 0 to N minus 1 At the end we get a row of numbersDk that tells us how many cosine waves with frequency 0 1 2 all the way up to frequency N minus1do we have in our signal The program code (MATLAB or Octave) for the DCT formula inEquation 115 is quite simple3

function D = my dct(y)

N = length(y) N rows do we have in the signal yD = zeros(N1) D stores the DCT transform of the signal y

for k = 01Nminus1 for every frequency k = 0 to Nminus1 with step 1

for n = 01Nminus1 for every row value of signal y do this

D(k+1) = D(k+1) + y(n+1)cos(piN (n + 12)k)

end the line above literary implements the DCT formula

end

There is no need to program the DCT formula in MATLAB and Octave it can be calledusing dct(Y) command to transform the signal stored in the variable Y

Now if we now plot the numbers in the variable Dk versus frequencies of a cosine wave (kfrom 0 to N-1) we will see the picture like the one in Fig 116(b) Notice two peaks at 400 and800 Hz - these peaks correspond to the cosine waves in our signal described by Equation 114

yk = cos(2 lowast pi lowast 400 lowast xk) + 2 lowast cos(2 lowast pi lowast 800 lowast xk)This is exactly what we expect after all our soundwave contains only 400 Hz and 800 Hz

cosine waves and those peaks of DCT indicate thisNow imagine that our soundwave was recorded with a bad microphone we have a lot of

noise in the recording If you look at Figure 117(a) there is so much noise that you donrsquot evensee the waves But if you use the DCT to decompose the noised signal and again make the plot

3The code is not efficient and it will take a lot of time for long signals However it is a simple word-for-wordimplementation of the DCT mathematical formula and serves its illustrative purpose

19

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1926

of its result you will be able to see those peaks (that correspond to soundwaves buried undernoise) in Figure 117(b)

0 20 40 60 80 100 120 140 160 180 200minus6

minus4

minus2

0

2

4

6

8

Signal Corrupted with Random Noise

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

X 800Y 3367

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 400Y 1858

(b)

Figure 117 Noised signal (a) the plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) with lotsof noise added (b) the wave frequencies (Discrete Cosine Transform) in the signal you can see400 Hz and 800 Hz peaks

This is the real power of trigonometric functions we can decompose even a very noisysignal and still see what are the cosine waves (that use pure tones) that make it And not justto look at the plot but also clean up the signal we can just zero-out the small numbers in theDCT variable Dk to clean up the noise and transform the signal back to its original state - andnoise is (almost) gone

The MATLAB (or Octave) code for this example is below

Fs = 4000 Sampling frequency

T = 1Fs Sample time

L = 1000 Length of signal counts

x k = (1L)T Time count

Sum of a 400 Hz wave and a 800 Hz wave

y k = cos(2pi400x k) + 2cos(2pi800x k)

Now add some random noise to the sum of waves

y k n oisy = y k + 2randn(size(x k )) Sinusoids plus noise

figure plot(Fsx k(1200)y k(1200))

title(Original signal (sum of two waves)) xlabel(time (milliseconds))

figure plot(Fsx k(1200)y k noisy(1200))

title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

How many cosine waves of different frequencies we have in the signal

D k dct clean signal = dct(y kL)

D k dct noisy signal = dct(y k noisyL)

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

20

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 13: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1326

Here we just used the Equation 13 and Equation 12 Open the brackets and multiply theseitems to get

= 2 lowast1048616

sin x2

cos2 y2

cos x2

+ sin2 x2

cos y2

sin y2

+ sin y2

cos2 x2

cos y2

+ sin2 y2

cos x2

sin x2

1048617=

Take a closer look at item 1 and 4 - we can group them like this cos x2 sin x2 (sin2 y

2 +cos2 y2 )

Notice that the sum inside brackets equals 1 as we already know from sin2(x)+cos2(x) = 1 (seeEquation 11) The items 2 and 3 in the expression above can be grouped similarly so we get

= 2 lowast1048616

cos y

2 sin

y

2 + sin

x

2 cos

x

2

1048617=

Now open the brackets and look closely on each item for instance 2 cos y2 sin y2 looks similar

to Equation 14 Therefore 2 cos y2

sin y2

= sin(2 lowast y2

) = sin y and therefore

= 2 lowast 1048616cos y

2

sin y

2

+ sin x

2

cos x

21048617 = sin y + sin x

which is exactly the Equation 16 and concludes our proof

Why do we need sum-to-product formulas

These sum-to-product formulas are really special because your own brain does this all the time sounds that you hear with both ears are summed and processed by the brain so you can determinefor example where does the sound came from You can actually trick your own brain into findinga sum of two cosine waves (soundwaves) and hear binaural beats For example if a frequencyof 100 Hz is presented to your left ear and a frequency of 105 Hz is presented to your rightear your brain ldquohearsrdquo a third frequency pulsing at 5 Hz the exact difference between the twofrequencies Some binaural beat frequencies were found to be useful in auditory stimulation toenhance brain functioning

We can use the formula of sum-to-product to find the expression for sum of two sound waveswith frequency f 1 and f 2

cos(2πf 1t) + cos(2πf 2t) = 2 cos

9830802π

(f 1 + f 2)

2 t

983081cos

9830802π

(f 1 minus f 2)

2 t

983081

where t is a variable for time If the two sound frequencies are close (a difference f 1 minus f 2of about twenty hertz) the frequency of the sound wave is often too slow to be perceived as apitch Instead the sound wave is perceived as a periodic variation (beat) of the volume whichis described by the expression above We can see it in Figure 114

The program below (runs in MATLAB and GNUOctave) generates two sound waves (astereo sound) with two pure tones of frequencies f 1 = 500Hz and f 2 = 500 + 30 = 530Hz Thenthe sound is played for 4 seconds

Amplitude=10

duration=4 seconds

Frequency=500

Frequency diff= 30 frequency difference for beat

Freq sampling=10000 sampling frequency

values=01Freq samplingduration

left=Amplitudecos(2pi Frequencyvalues)

14

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1426

002 004 006 008 01 012

Figure 114 The sum (blue) of two cosine waves compared to a single wave (green) The functionplotted is yk = cos(2π lowast 500xk) + cos(2π lowast 530xk)

right = Amplitudecos(2pi (Frequency+Frequency diff)values)

stereosnd = [left right] combining two sounds at a stereo

soundsc(stereosnd Freq sampling) play the sound

You should use headphones to listen to this sound Put one earpiece in your ear and youwill hear a pure tone Then move the second earpiece slowly to your other ear - and instead of two separate tone you are going to hear a sound beat since the frequencies (or tones) differ

slightly (only by 30 Hz) Keep in mind that those two tones do not mix - they are in the left andright earpieces That is the tones do not interfere physically but are summed by the brainThis effect is related to the brainrsquos ability to locate sounds in three dimensions

See your own brain already knows and does the trigonometry and all this mathe-matical expressions just bring the trigonometric expressions to you in a convenient form

135 Product-to-sum formula

Letrsquos derive the reverse formulas which allow us to convert the product of two waves into thesum (or difference) of separate waves

2cos x cos y = cos(x minus y) + cos(x + y) (19)

2sin x sin y = cos(x minus y) minus cos(x + y) (110)

2sin x cos y = sin(x + y) + sin(x minus y) (111)

2cos x sin y = sin(x + y) minus sin(x minus y) (112)

These formulas can be used for transmitting the information via radiowaves as we will seeshortly The derivation of this formulas is very simple all you need is to use Equations 13and 12 For example the formula 2 cos x cos y = cos(x minus y) + cos(x + y) can be derived as sumof the two equations below

15

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1526

cos(x + y) = cos x cos y minus sin x sin y+cos(x minus y) = cos x cos y + sin x sin y

where sin x sin y are gone and therefore we get cos(x + y)+cos(xminus y) = 2 cos x cos y exactlyas in Equation 19 Other formulas can be derived in a similar way

Why do we need these Product-to-sum formulas

The product-to-sum trigonometric formulas can be used to transmit and receive informationEver wondered what are those FM and AM acronyms stand for They stand for AmplitudeModulation and Frequency Modulation respectively - these are the methods of transmittingmusic on a radio and we are going to use trigonometry for this

First we need a carrier wave - we are going to modify it with the input signal (our music) totransmit music using radiowaves The carrier wave is usually of a much higher frequency thanthe input signal which helps us to detect the actual signal Letrsquos take a carrier wave C (t) of

frequency F c and amplitude A given by

C (t) = A lowast cos(2πF ct)

which is a function of time t We are going to modify (or as engineers say modulate ) thiscarrier wave C (t) with a music but for simplicity letrsquos say we want to transmit just a pure toneS (t) This signal S (t) represent the modulation soundwave of a frequency F m (which must be amuch lower frequency than F c)

S (t) = M lowast cos(2πF mt)

where M is the amplitude of the modulation Letrsquos agree that M lt 1 so that (1+ S (t)) is alwayspositive Amplitude modulation occurs when the carrier wave C (t) is multiplied by (1 + S (t))

y(t) = [1 + S (t)] lowast C (t) = [1 + M lowast cos(2πF mt)] lowast A lowast cos(2πF ct) (113)

Using the Equation 19 the resulting signal (as a function of time) y(t) can be shown to be

y(t) = A lowast cos(2πF ct) + AM 2

[cos(2π(F c + F m)t) + cos(2π(F c minus F m)t)]

The modulated radiowave is shown in Figure 115 and the program for this demonstrationis provided below

A = 2 amplitude

duration=4 in seconds

Freq sampling = 10000

values=01Freq samplingduration

Carrier Frequency=1000

C t =Acos(2pi Carrier Frequencyvalues)

M = 01 modulation coefficient

Signal Frequency = 120

S t = Mcos(2piSignal Frequencyvalues)

y t = ( 1+ S t )C t

figure plot(values y t ) this is to plot a beat

16

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1626

0005 001 0015 002 0025 003 0035 004 0045 005

Figure 115 The Amplitude Modulation in action we have a carrier wave of 1000 Hz frequencywhich is modulated (modified) with a tone of 120 Hz using Equation 113 Notice the change inthe amplitude on the plot

136 The power of Trigonometry meet the Discrete Cosine Transform

Many textbooks mention the applications of trigonometry like determining the height of a build-ing if you know the distance to it and the angle to the rooftop or some equally boringexoticexamples Here we are going to see a real-world application of cosine functions which is reallyuseful for sound analysis and compression - the Discrete Cosine Transform (DCT)

Be not afraid of this fancy name it simply means that we are going to use Cosine function toTransform or decompose our sound signal on pure tones (cosine functions of various frequencies)The word Discrete simply means that the values of our signal are sampled with some fixed-stepinterval - for example we measure a value of our signal every 01 seconds

Using DCT we are going to mathematically de-compose our signal into pure tones (or cosinewaves) and calculate how many cosine waves of this particular frequency do we have in thesignal This is extremely useful for analysis of the signal for example you can reduce the noisein signal by simply zeroing out the unwanted frequencies and transforming the signal back

There are many applications of DCT that we use every day without even knowing it

signal analysis by decomposing the signal on the pure cosine waves we can see what arethe main waves in the signal This way you can analyse for example stock market pricesto find any recurring periodical fluctuations of prices (and predict when it happens next)

audio compression MP3 format uses a variety of DCT algorithm to determine which soundfrequencies to keep and which to throw away compressing the song without noticeable lossin quality

images compression JPEG format also compresses the images using DCT-like algorithmto reduce the size of the image by throwing away unnecessary details

17

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1726

Example of frequency analysis using Discrete Cosine Transform

Letrsquos go back to our previous example and take it one step further we combine a soundwave of frequency F 1 = 400 Hz and amplitude A = 1 with a soundwave of frequency F 2 = 800 Hz and

amplitude A = 2

yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) (114)

were indexes with the letter k in yk and xk simply mean the row number in the table with yand x Thatrsquos where the word discrete comes into play our computers can work with discretenumbers and all we need is to take enough samples of a function (cosine in this case) close toeach other to describe the signal

In the program code below we take L = 1000 samples for our signal from Equation 114 andwe take samples of our signal close to each other - say once every t = 14000th of a second Here4000 is our sampling frequency - this is how often we evaluate our function in Equation 114 Wetook F sampling = 4000 arbitrary - any number larger than 800 will be fine

1 Fs = 4000 Sampling frequency

2 T = 1Fs Sample time

3 L = 1000 Length of signal counts

4 x k = (1L)T Time count

56 Sum of a 400 Hz wave and a 800 Hz wave

7 y k = cos(2pi400x k) + 2cos(2pi800x k)

89 Now add some random noise to the sum of waves

10 y k n oisy = y k + 2randn(size(x k ))

1112 figure plot(Fsx k(1200)y k(1200))

13 title(Original signal (sum of two waves)) xlabel(time (milliseconds))

1415 figure plot(Fsx k(1200)y k noisy(1200))

16 title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

That is take L = 1000 numbers (line 3) and generate xk values (line 4) to be plugged intoEquation 114 (line 7) The plot of the signal can be seen in Figure 116(a)

The Discrete Cosine Transform Now the main part we are going to transform (decompose)our sound signal into pure tones (cosine waves of different frequencies) using the Discrete CosineTransform (DCT)

Dk =

N minus1991761n=0

yn cos

983131π

N

983080n +

1

2

983081k

983133 for every frequency k = 0 N minus 1 (115)

Now what does this formula2 actually mean

the signN minus1sumn=0

means ldquosumming elements with subscript n from n = 0 to n = N minus 1

N is the length of the signal y - in our case the signal has 1000 values (a row in a tablewith 1000 cells)

2This formula does not include a normalisation term to account for the number of samples - Irsquom skipping itto simplify the discussion

18

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1826

0 20 40 60 80 100 120 140 160 180 200minus2

minus15

minus1

minus05

0

05

1

15

2

25

3Original signal (sum of two waves)

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

40

X 400Y 2127

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 800Y 3618

(b)

Figure 116 Clean noiseless signal (a) The plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk)(b) the wave frequencies (Discrete Cosine Transform) in the noiseless signal you can see 400 Hzand 800 Hz peaks

yn we take from Equation 114

and we do this for every frequency k from 0 to N minus 1 At the end we get a row of numbersDk that tells us how many cosine waves with frequency 0 1 2 all the way up to frequency N minus1do we have in our signal The program code (MATLAB or Octave) for the DCT formula inEquation 115 is quite simple3

function D = my dct(y)

N = length(y) N rows do we have in the signal yD = zeros(N1) D stores the DCT transform of the signal y

for k = 01Nminus1 for every frequency k = 0 to Nminus1 with step 1

for n = 01Nminus1 for every row value of signal y do this

D(k+1) = D(k+1) + y(n+1)cos(piN (n + 12)k)

end the line above literary implements the DCT formula

end

There is no need to program the DCT formula in MATLAB and Octave it can be calledusing dct(Y) command to transform the signal stored in the variable Y

Now if we now plot the numbers in the variable Dk versus frequencies of a cosine wave (kfrom 0 to N-1) we will see the picture like the one in Fig 116(b) Notice two peaks at 400 and800 Hz - these peaks correspond to the cosine waves in our signal described by Equation 114

yk = cos(2 lowast pi lowast 400 lowast xk) + 2 lowast cos(2 lowast pi lowast 800 lowast xk)This is exactly what we expect after all our soundwave contains only 400 Hz and 800 Hz

cosine waves and those peaks of DCT indicate thisNow imagine that our soundwave was recorded with a bad microphone we have a lot of

noise in the recording If you look at Figure 117(a) there is so much noise that you donrsquot evensee the waves But if you use the DCT to decompose the noised signal and again make the plot

3The code is not efficient and it will take a lot of time for long signals However it is a simple word-for-wordimplementation of the DCT mathematical formula and serves its illustrative purpose

19

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1926

of its result you will be able to see those peaks (that correspond to soundwaves buried undernoise) in Figure 117(b)

0 20 40 60 80 100 120 140 160 180 200minus6

minus4

minus2

0

2

4

6

8

Signal Corrupted with Random Noise

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

X 800Y 3367

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 400Y 1858

(b)

Figure 117 Noised signal (a) the plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) with lotsof noise added (b) the wave frequencies (Discrete Cosine Transform) in the signal you can see400 Hz and 800 Hz peaks

This is the real power of trigonometric functions we can decompose even a very noisysignal and still see what are the cosine waves (that use pure tones) that make it And not justto look at the plot but also clean up the signal we can just zero-out the small numbers in theDCT variable Dk to clean up the noise and transform the signal back to its original state - andnoise is (almost) gone

The MATLAB (or Octave) code for this example is below

Fs = 4000 Sampling frequency

T = 1Fs Sample time

L = 1000 Length of signal counts

x k = (1L)T Time count

Sum of a 400 Hz wave and a 800 Hz wave

y k = cos(2pi400x k) + 2cos(2pi800x k)

Now add some random noise to the sum of waves

y k n oisy = y k + 2randn(size(x k )) Sinusoids plus noise

figure plot(Fsx k(1200)y k(1200))

title(Original signal (sum of two waves)) xlabel(time (milliseconds))

figure plot(Fsx k(1200)y k noisy(1200))

title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

How many cosine waves of different frequencies we have in the signal

D k dct clean signal = dct(y kL)

D k dct noisy signal = dct(y k noisyL)

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

20

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 14: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1426

002 004 006 008 01 012

Figure 114 The sum (blue) of two cosine waves compared to a single wave (green) The functionplotted is yk = cos(2π lowast 500xk) + cos(2π lowast 530xk)

right = Amplitudecos(2pi (Frequency+Frequency diff)values)

stereosnd = [left right] combining two sounds at a stereo

soundsc(stereosnd Freq sampling) play the sound

You should use headphones to listen to this sound Put one earpiece in your ear and youwill hear a pure tone Then move the second earpiece slowly to your other ear - and instead of two separate tone you are going to hear a sound beat since the frequencies (or tones) differ

slightly (only by 30 Hz) Keep in mind that those two tones do not mix - they are in the left andright earpieces That is the tones do not interfere physically but are summed by the brainThis effect is related to the brainrsquos ability to locate sounds in three dimensions

See your own brain already knows and does the trigonometry and all this mathe-matical expressions just bring the trigonometric expressions to you in a convenient form

135 Product-to-sum formula

Letrsquos derive the reverse formulas which allow us to convert the product of two waves into thesum (or difference) of separate waves

2cos x cos y = cos(x minus y) + cos(x + y) (19)

2sin x sin y = cos(x minus y) minus cos(x + y) (110)

2sin x cos y = sin(x + y) + sin(x minus y) (111)

2cos x sin y = sin(x + y) minus sin(x minus y) (112)

These formulas can be used for transmitting the information via radiowaves as we will seeshortly The derivation of this formulas is very simple all you need is to use Equations 13and 12 For example the formula 2 cos x cos y = cos(x minus y) + cos(x + y) can be derived as sumof the two equations below

15

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1526

cos(x + y) = cos x cos y minus sin x sin y+cos(x minus y) = cos x cos y + sin x sin y

where sin x sin y are gone and therefore we get cos(x + y)+cos(xminus y) = 2 cos x cos y exactlyas in Equation 19 Other formulas can be derived in a similar way

Why do we need these Product-to-sum formulas

The product-to-sum trigonometric formulas can be used to transmit and receive informationEver wondered what are those FM and AM acronyms stand for They stand for AmplitudeModulation and Frequency Modulation respectively - these are the methods of transmittingmusic on a radio and we are going to use trigonometry for this

First we need a carrier wave - we are going to modify it with the input signal (our music) totransmit music using radiowaves The carrier wave is usually of a much higher frequency thanthe input signal which helps us to detect the actual signal Letrsquos take a carrier wave C (t) of

frequency F c and amplitude A given by

C (t) = A lowast cos(2πF ct)

which is a function of time t We are going to modify (or as engineers say modulate ) thiscarrier wave C (t) with a music but for simplicity letrsquos say we want to transmit just a pure toneS (t) This signal S (t) represent the modulation soundwave of a frequency F m (which must be amuch lower frequency than F c)

S (t) = M lowast cos(2πF mt)

where M is the amplitude of the modulation Letrsquos agree that M lt 1 so that (1+ S (t)) is alwayspositive Amplitude modulation occurs when the carrier wave C (t) is multiplied by (1 + S (t))

y(t) = [1 + S (t)] lowast C (t) = [1 + M lowast cos(2πF mt)] lowast A lowast cos(2πF ct) (113)

Using the Equation 19 the resulting signal (as a function of time) y(t) can be shown to be

y(t) = A lowast cos(2πF ct) + AM 2

[cos(2π(F c + F m)t) + cos(2π(F c minus F m)t)]

The modulated radiowave is shown in Figure 115 and the program for this demonstrationis provided below

A = 2 amplitude

duration=4 in seconds

Freq sampling = 10000

values=01Freq samplingduration

Carrier Frequency=1000

C t =Acos(2pi Carrier Frequencyvalues)

M = 01 modulation coefficient

Signal Frequency = 120

S t = Mcos(2piSignal Frequencyvalues)

y t = ( 1+ S t )C t

figure plot(values y t ) this is to plot a beat

16

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1626

0005 001 0015 002 0025 003 0035 004 0045 005

Figure 115 The Amplitude Modulation in action we have a carrier wave of 1000 Hz frequencywhich is modulated (modified) with a tone of 120 Hz using Equation 113 Notice the change inthe amplitude on the plot

136 The power of Trigonometry meet the Discrete Cosine Transform

Many textbooks mention the applications of trigonometry like determining the height of a build-ing if you know the distance to it and the angle to the rooftop or some equally boringexoticexamples Here we are going to see a real-world application of cosine functions which is reallyuseful for sound analysis and compression - the Discrete Cosine Transform (DCT)

Be not afraid of this fancy name it simply means that we are going to use Cosine function toTransform or decompose our sound signal on pure tones (cosine functions of various frequencies)The word Discrete simply means that the values of our signal are sampled with some fixed-stepinterval - for example we measure a value of our signal every 01 seconds

Using DCT we are going to mathematically de-compose our signal into pure tones (or cosinewaves) and calculate how many cosine waves of this particular frequency do we have in thesignal This is extremely useful for analysis of the signal for example you can reduce the noisein signal by simply zeroing out the unwanted frequencies and transforming the signal back

There are many applications of DCT that we use every day without even knowing it

signal analysis by decomposing the signal on the pure cosine waves we can see what arethe main waves in the signal This way you can analyse for example stock market pricesto find any recurring periodical fluctuations of prices (and predict when it happens next)

audio compression MP3 format uses a variety of DCT algorithm to determine which soundfrequencies to keep and which to throw away compressing the song without noticeable lossin quality

images compression JPEG format also compresses the images using DCT-like algorithmto reduce the size of the image by throwing away unnecessary details

17

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1726

Example of frequency analysis using Discrete Cosine Transform

Letrsquos go back to our previous example and take it one step further we combine a soundwave of frequency F 1 = 400 Hz and amplitude A = 1 with a soundwave of frequency F 2 = 800 Hz and

amplitude A = 2

yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) (114)

were indexes with the letter k in yk and xk simply mean the row number in the table with yand x Thatrsquos where the word discrete comes into play our computers can work with discretenumbers and all we need is to take enough samples of a function (cosine in this case) close toeach other to describe the signal

In the program code below we take L = 1000 samples for our signal from Equation 114 andwe take samples of our signal close to each other - say once every t = 14000th of a second Here4000 is our sampling frequency - this is how often we evaluate our function in Equation 114 Wetook F sampling = 4000 arbitrary - any number larger than 800 will be fine

1 Fs = 4000 Sampling frequency

2 T = 1Fs Sample time

3 L = 1000 Length of signal counts

4 x k = (1L)T Time count

56 Sum of a 400 Hz wave and a 800 Hz wave

7 y k = cos(2pi400x k) + 2cos(2pi800x k)

89 Now add some random noise to the sum of waves

10 y k n oisy = y k + 2randn(size(x k ))

1112 figure plot(Fsx k(1200)y k(1200))

13 title(Original signal (sum of two waves)) xlabel(time (milliseconds))

1415 figure plot(Fsx k(1200)y k noisy(1200))

16 title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

That is take L = 1000 numbers (line 3) and generate xk values (line 4) to be plugged intoEquation 114 (line 7) The plot of the signal can be seen in Figure 116(a)

The Discrete Cosine Transform Now the main part we are going to transform (decompose)our sound signal into pure tones (cosine waves of different frequencies) using the Discrete CosineTransform (DCT)

Dk =

N minus1991761n=0

yn cos

983131π

N

983080n +

1

2

983081k

983133 for every frequency k = 0 N minus 1 (115)

Now what does this formula2 actually mean

the signN minus1sumn=0

means ldquosumming elements with subscript n from n = 0 to n = N minus 1

N is the length of the signal y - in our case the signal has 1000 values (a row in a tablewith 1000 cells)

2This formula does not include a normalisation term to account for the number of samples - Irsquom skipping itto simplify the discussion

18

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1826

0 20 40 60 80 100 120 140 160 180 200minus2

minus15

minus1

minus05

0

05

1

15

2

25

3Original signal (sum of two waves)

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

40

X 400Y 2127

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 800Y 3618

(b)

Figure 116 Clean noiseless signal (a) The plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk)(b) the wave frequencies (Discrete Cosine Transform) in the noiseless signal you can see 400 Hzand 800 Hz peaks

yn we take from Equation 114

and we do this for every frequency k from 0 to N minus 1 At the end we get a row of numbersDk that tells us how many cosine waves with frequency 0 1 2 all the way up to frequency N minus1do we have in our signal The program code (MATLAB or Octave) for the DCT formula inEquation 115 is quite simple3

function D = my dct(y)

N = length(y) N rows do we have in the signal yD = zeros(N1) D stores the DCT transform of the signal y

for k = 01Nminus1 for every frequency k = 0 to Nminus1 with step 1

for n = 01Nminus1 for every row value of signal y do this

D(k+1) = D(k+1) + y(n+1)cos(piN (n + 12)k)

end the line above literary implements the DCT formula

end

There is no need to program the DCT formula in MATLAB and Octave it can be calledusing dct(Y) command to transform the signal stored in the variable Y

Now if we now plot the numbers in the variable Dk versus frequencies of a cosine wave (kfrom 0 to N-1) we will see the picture like the one in Fig 116(b) Notice two peaks at 400 and800 Hz - these peaks correspond to the cosine waves in our signal described by Equation 114

yk = cos(2 lowast pi lowast 400 lowast xk) + 2 lowast cos(2 lowast pi lowast 800 lowast xk)This is exactly what we expect after all our soundwave contains only 400 Hz and 800 Hz

cosine waves and those peaks of DCT indicate thisNow imagine that our soundwave was recorded with a bad microphone we have a lot of

noise in the recording If you look at Figure 117(a) there is so much noise that you donrsquot evensee the waves But if you use the DCT to decompose the noised signal and again make the plot

3The code is not efficient and it will take a lot of time for long signals However it is a simple word-for-wordimplementation of the DCT mathematical formula and serves its illustrative purpose

19

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1926

of its result you will be able to see those peaks (that correspond to soundwaves buried undernoise) in Figure 117(b)

0 20 40 60 80 100 120 140 160 180 200minus6

minus4

minus2

0

2

4

6

8

Signal Corrupted with Random Noise

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

X 800Y 3367

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 400Y 1858

(b)

Figure 117 Noised signal (a) the plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) with lotsof noise added (b) the wave frequencies (Discrete Cosine Transform) in the signal you can see400 Hz and 800 Hz peaks

This is the real power of trigonometric functions we can decompose even a very noisysignal and still see what are the cosine waves (that use pure tones) that make it And not justto look at the plot but also clean up the signal we can just zero-out the small numbers in theDCT variable Dk to clean up the noise and transform the signal back to its original state - andnoise is (almost) gone

The MATLAB (or Octave) code for this example is below

Fs = 4000 Sampling frequency

T = 1Fs Sample time

L = 1000 Length of signal counts

x k = (1L)T Time count

Sum of a 400 Hz wave and a 800 Hz wave

y k = cos(2pi400x k) + 2cos(2pi800x k)

Now add some random noise to the sum of waves

y k n oisy = y k + 2randn(size(x k )) Sinusoids plus noise

figure plot(Fsx k(1200)y k(1200))

title(Original signal (sum of two waves)) xlabel(time (milliseconds))

figure plot(Fsx k(1200)y k noisy(1200))

title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

How many cosine waves of different frequencies we have in the signal

D k dct clean signal = dct(y kL)

D k dct noisy signal = dct(y k noisyL)

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

20

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 15: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1526

cos(x + y) = cos x cos y minus sin x sin y+cos(x minus y) = cos x cos y + sin x sin y

where sin x sin y are gone and therefore we get cos(x + y)+cos(xminus y) = 2 cos x cos y exactlyas in Equation 19 Other formulas can be derived in a similar way

Why do we need these Product-to-sum formulas

The product-to-sum trigonometric formulas can be used to transmit and receive informationEver wondered what are those FM and AM acronyms stand for They stand for AmplitudeModulation and Frequency Modulation respectively - these are the methods of transmittingmusic on a radio and we are going to use trigonometry for this

First we need a carrier wave - we are going to modify it with the input signal (our music) totransmit music using radiowaves The carrier wave is usually of a much higher frequency thanthe input signal which helps us to detect the actual signal Letrsquos take a carrier wave C (t) of

frequency F c and amplitude A given by

C (t) = A lowast cos(2πF ct)

which is a function of time t We are going to modify (or as engineers say modulate ) thiscarrier wave C (t) with a music but for simplicity letrsquos say we want to transmit just a pure toneS (t) This signal S (t) represent the modulation soundwave of a frequency F m (which must be amuch lower frequency than F c)

S (t) = M lowast cos(2πF mt)

where M is the amplitude of the modulation Letrsquos agree that M lt 1 so that (1+ S (t)) is alwayspositive Amplitude modulation occurs when the carrier wave C (t) is multiplied by (1 + S (t))

y(t) = [1 + S (t)] lowast C (t) = [1 + M lowast cos(2πF mt)] lowast A lowast cos(2πF ct) (113)

Using the Equation 19 the resulting signal (as a function of time) y(t) can be shown to be

y(t) = A lowast cos(2πF ct) + AM 2

[cos(2π(F c + F m)t) + cos(2π(F c minus F m)t)]

The modulated radiowave is shown in Figure 115 and the program for this demonstrationis provided below

A = 2 amplitude

duration=4 in seconds

Freq sampling = 10000

values=01Freq samplingduration

Carrier Frequency=1000

C t =Acos(2pi Carrier Frequencyvalues)

M = 01 modulation coefficient

Signal Frequency = 120

S t = Mcos(2piSignal Frequencyvalues)

y t = ( 1+ S t )C t

figure plot(values y t ) this is to plot a beat

16

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1626

0005 001 0015 002 0025 003 0035 004 0045 005

Figure 115 The Amplitude Modulation in action we have a carrier wave of 1000 Hz frequencywhich is modulated (modified) with a tone of 120 Hz using Equation 113 Notice the change inthe amplitude on the plot

136 The power of Trigonometry meet the Discrete Cosine Transform

Many textbooks mention the applications of trigonometry like determining the height of a build-ing if you know the distance to it and the angle to the rooftop or some equally boringexoticexamples Here we are going to see a real-world application of cosine functions which is reallyuseful for sound analysis and compression - the Discrete Cosine Transform (DCT)

Be not afraid of this fancy name it simply means that we are going to use Cosine function toTransform or decompose our sound signal on pure tones (cosine functions of various frequencies)The word Discrete simply means that the values of our signal are sampled with some fixed-stepinterval - for example we measure a value of our signal every 01 seconds

Using DCT we are going to mathematically de-compose our signal into pure tones (or cosinewaves) and calculate how many cosine waves of this particular frequency do we have in thesignal This is extremely useful for analysis of the signal for example you can reduce the noisein signal by simply zeroing out the unwanted frequencies and transforming the signal back

There are many applications of DCT that we use every day without even knowing it

signal analysis by decomposing the signal on the pure cosine waves we can see what arethe main waves in the signal This way you can analyse for example stock market pricesto find any recurring periodical fluctuations of prices (and predict when it happens next)

audio compression MP3 format uses a variety of DCT algorithm to determine which soundfrequencies to keep and which to throw away compressing the song without noticeable lossin quality

images compression JPEG format also compresses the images using DCT-like algorithmto reduce the size of the image by throwing away unnecessary details

17

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1726

Example of frequency analysis using Discrete Cosine Transform

Letrsquos go back to our previous example and take it one step further we combine a soundwave of frequency F 1 = 400 Hz and amplitude A = 1 with a soundwave of frequency F 2 = 800 Hz and

amplitude A = 2

yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) (114)

were indexes with the letter k in yk and xk simply mean the row number in the table with yand x Thatrsquos where the word discrete comes into play our computers can work with discretenumbers and all we need is to take enough samples of a function (cosine in this case) close toeach other to describe the signal

In the program code below we take L = 1000 samples for our signal from Equation 114 andwe take samples of our signal close to each other - say once every t = 14000th of a second Here4000 is our sampling frequency - this is how often we evaluate our function in Equation 114 Wetook F sampling = 4000 arbitrary - any number larger than 800 will be fine

1 Fs = 4000 Sampling frequency

2 T = 1Fs Sample time

3 L = 1000 Length of signal counts

4 x k = (1L)T Time count

56 Sum of a 400 Hz wave and a 800 Hz wave

7 y k = cos(2pi400x k) + 2cos(2pi800x k)

89 Now add some random noise to the sum of waves

10 y k n oisy = y k + 2randn(size(x k ))

1112 figure plot(Fsx k(1200)y k(1200))

13 title(Original signal (sum of two waves)) xlabel(time (milliseconds))

1415 figure plot(Fsx k(1200)y k noisy(1200))

16 title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

That is take L = 1000 numbers (line 3) and generate xk values (line 4) to be plugged intoEquation 114 (line 7) The plot of the signal can be seen in Figure 116(a)

The Discrete Cosine Transform Now the main part we are going to transform (decompose)our sound signal into pure tones (cosine waves of different frequencies) using the Discrete CosineTransform (DCT)

Dk =

N minus1991761n=0

yn cos

983131π

N

983080n +

1

2

983081k

983133 for every frequency k = 0 N minus 1 (115)

Now what does this formula2 actually mean

the signN minus1sumn=0

means ldquosumming elements with subscript n from n = 0 to n = N minus 1

N is the length of the signal y - in our case the signal has 1000 values (a row in a tablewith 1000 cells)

2This formula does not include a normalisation term to account for the number of samples - Irsquom skipping itto simplify the discussion

18

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1826

0 20 40 60 80 100 120 140 160 180 200minus2

minus15

minus1

minus05

0

05

1

15

2

25

3Original signal (sum of two waves)

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

40

X 400Y 2127

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 800Y 3618

(b)

Figure 116 Clean noiseless signal (a) The plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk)(b) the wave frequencies (Discrete Cosine Transform) in the noiseless signal you can see 400 Hzand 800 Hz peaks

yn we take from Equation 114

and we do this for every frequency k from 0 to N minus 1 At the end we get a row of numbersDk that tells us how many cosine waves with frequency 0 1 2 all the way up to frequency N minus1do we have in our signal The program code (MATLAB or Octave) for the DCT formula inEquation 115 is quite simple3

function D = my dct(y)

N = length(y) N rows do we have in the signal yD = zeros(N1) D stores the DCT transform of the signal y

for k = 01Nminus1 for every frequency k = 0 to Nminus1 with step 1

for n = 01Nminus1 for every row value of signal y do this

D(k+1) = D(k+1) + y(n+1)cos(piN (n + 12)k)

end the line above literary implements the DCT formula

end

There is no need to program the DCT formula in MATLAB and Octave it can be calledusing dct(Y) command to transform the signal stored in the variable Y

Now if we now plot the numbers in the variable Dk versus frequencies of a cosine wave (kfrom 0 to N-1) we will see the picture like the one in Fig 116(b) Notice two peaks at 400 and800 Hz - these peaks correspond to the cosine waves in our signal described by Equation 114

yk = cos(2 lowast pi lowast 400 lowast xk) + 2 lowast cos(2 lowast pi lowast 800 lowast xk)This is exactly what we expect after all our soundwave contains only 400 Hz and 800 Hz

cosine waves and those peaks of DCT indicate thisNow imagine that our soundwave was recorded with a bad microphone we have a lot of

noise in the recording If you look at Figure 117(a) there is so much noise that you donrsquot evensee the waves But if you use the DCT to decompose the noised signal and again make the plot

3The code is not efficient and it will take a lot of time for long signals However it is a simple word-for-wordimplementation of the DCT mathematical formula and serves its illustrative purpose

19

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1926

of its result you will be able to see those peaks (that correspond to soundwaves buried undernoise) in Figure 117(b)

0 20 40 60 80 100 120 140 160 180 200minus6

minus4

minus2

0

2

4

6

8

Signal Corrupted with Random Noise

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

X 800Y 3367

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 400Y 1858

(b)

Figure 117 Noised signal (a) the plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) with lotsof noise added (b) the wave frequencies (Discrete Cosine Transform) in the signal you can see400 Hz and 800 Hz peaks

This is the real power of trigonometric functions we can decompose even a very noisysignal and still see what are the cosine waves (that use pure tones) that make it And not justto look at the plot but also clean up the signal we can just zero-out the small numbers in theDCT variable Dk to clean up the noise and transform the signal back to its original state - andnoise is (almost) gone

The MATLAB (or Octave) code for this example is below

Fs = 4000 Sampling frequency

T = 1Fs Sample time

L = 1000 Length of signal counts

x k = (1L)T Time count

Sum of a 400 Hz wave and a 800 Hz wave

y k = cos(2pi400x k) + 2cos(2pi800x k)

Now add some random noise to the sum of waves

y k n oisy = y k + 2randn(size(x k )) Sinusoids plus noise

figure plot(Fsx k(1200)y k(1200))

title(Original signal (sum of two waves)) xlabel(time (milliseconds))

figure plot(Fsx k(1200)y k noisy(1200))

title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

How many cosine waves of different frequencies we have in the signal

D k dct clean signal = dct(y kL)

D k dct noisy signal = dct(y k noisyL)

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

20

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 16: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1626

0005 001 0015 002 0025 003 0035 004 0045 005

Figure 115 The Amplitude Modulation in action we have a carrier wave of 1000 Hz frequencywhich is modulated (modified) with a tone of 120 Hz using Equation 113 Notice the change inthe amplitude on the plot

136 The power of Trigonometry meet the Discrete Cosine Transform

Many textbooks mention the applications of trigonometry like determining the height of a build-ing if you know the distance to it and the angle to the rooftop or some equally boringexoticexamples Here we are going to see a real-world application of cosine functions which is reallyuseful for sound analysis and compression - the Discrete Cosine Transform (DCT)

Be not afraid of this fancy name it simply means that we are going to use Cosine function toTransform or decompose our sound signal on pure tones (cosine functions of various frequencies)The word Discrete simply means that the values of our signal are sampled with some fixed-stepinterval - for example we measure a value of our signal every 01 seconds

Using DCT we are going to mathematically de-compose our signal into pure tones (or cosinewaves) and calculate how many cosine waves of this particular frequency do we have in thesignal This is extremely useful for analysis of the signal for example you can reduce the noisein signal by simply zeroing out the unwanted frequencies and transforming the signal back

There are many applications of DCT that we use every day without even knowing it

signal analysis by decomposing the signal on the pure cosine waves we can see what arethe main waves in the signal This way you can analyse for example stock market pricesto find any recurring periodical fluctuations of prices (and predict when it happens next)

audio compression MP3 format uses a variety of DCT algorithm to determine which soundfrequencies to keep and which to throw away compressing the song without noticeable lossin quality

images compression JPEG format also compresses the images using DCT-like algorithmto reduce the size of the image by throwing away unnecessary details

17

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1726

Example of frequency analysis using Discrete Cosine Transform

Letrsquos go back to our previous example and take it one step further we combine a soundwave of frequency F 1 = 400 Hz and amplitude A = 1 with a soundwave of frequency F 2 = 800 Hz and

amplitude A = 2

yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) (114)

were indexes with the letter k in yk and xk simply mean the row number in the table with yand x Thatrsquos where the word discrete comes into play our computers can work with discretenumbers and all we need is to take enough samples of a function (cosine in this case) close toeach other to describe the signal

In the program code below we take L = 1000 samples for our signal from Equation 114 andwe take samples of our signal close to each other - say once every t = 14000th of a second Here4000 is our sampling frequency - this is how often we evaluate our function in Equation 114 Wetook F sampling = 4000 arbitrary - any number larger than 800 will be fine

1 Fs = 4000 Sampling frequency

2 T = 1Fs Sample time

3 L = 1000 Length of signal counts

4 x k = (1L)T Time count

56 Sum of a 400 Hz wave and a 800 Hz wave

7 y k = cos(2pi400x k) + 2cos(2pi800x k)

89 Now add some random noise to the sum of waves

10 y k n oisy = y k + 2randn(size(x k ))

1112 figure plot(Fsx k(1200)y k(1200))

13 title(Original signal (sum of two waves)) xlabel(time (milliseconds))

1415 figure plot(Fsx k(1200)y k noisy(1200))

16 title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

That is take L = 1000 numbers (line 3) and generate xk values (line 4) to be plugged intoEquation 114 (line 7) The plot of the signal can be seen in Figure 116(a)

The Discrete Cosine Transform Now the main part we are going to transform (decompose)our sound signal into pure tones (cosine waves of different frequencies) using the Discrete CosineTransform (DCT)

Dk =

N minus1991761n=0

yn cos

983131π

N

983080n +

1

2

983081k

983133 for every frequency k = 0 N minus 1 (115)

Now what does this formula2 actually mean

the signN minus1sumn=0

means ldquosumming elements with subscript n from n = 0 to n = N minus 1

N is the length of the signal y - in our case the signal has 1000 values (a row in a tablewith 1000 cells)

2This formula does not include a normalisation term to account for the number of samples - Irsquom skipping itto simplify the discussion

18

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1826

0 20 40 60 80 100 120 140 160 180 200minus2

minus15

minus1

minus05

0

05

1

15

2

25

3Original signal (sum of two waves)

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

40

X 400Y 2127

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 800Y 3618

(b)

Figure 116 Clean noiseless signal (a) The plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk)(b) the wave frequencies (Discrete Cosine Transform) in the noiseless signal you can see 400 Hzand 800 Hz peaks

yn we take from Equation 114

and we do this for every frequency k from 0 to N minus 1 At the end we get a row of numbersDk that tells us how many cosine waves with frequency 0 1 2 all the way up to frequency N minus1do we have in our signal The program code (MATLAB or Octave) for the DCT formula inEquation 115 is quite simple3

function D = my dct(y)

N = length(y) N rows do we have in the signal yD = zeros(N1) D stores the DCT transform of the signal y

for k = 01Nminus1 for every frequency k = 0 to Nminus1 with step 1

for n = 01Nminus1 for every row value of signal y do this

D(k+1) = D(k+1) + y(n+1)cos(piN (n + 12)k)

end the line above literary implements the DCT formula

end

There is no need to program the DCT formula in MATLAB and Octave it can be calledusing dct(Y) command to transform the signal stored in the variable Y

Now if we now plot the numbers in the variable Dk versus frequencies of a cosine wave (kfrom 0 to N-1) we will see the picture like the one in Fig 116(b) Notice two peaks at 400 and800 Hz - these peaks correspond to the cosine waves in our signal described by Equation 114

yk = cos(2 lowast pi lowast 400 lowast xk) + 2 lowast cos(2 lowast pi lowast 800 lowast xk)This is exactly what we expect after all our soundwave contains only 400 Hz and 800 Hz

cosine waves and those peaks of DCT indicate thisNow imagine that our soundwave was recorded with a bad microphone we have a lot of

noise in the recording If you look at Figure 117(a) there is so much noise that you donrsquot evensee the waves But if you use the DCT to decompose the noised signal and again make the plot

3The code is not efficient and it will take a lot of time for long signals However it is a simple word-for-wordimplementation of the DCT mathematical formula and serves its illustrative purpose

19

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1926

of its result you will be able to see those peaks (that correspond to soundwaves buried undernoise) in Figure 117(b)

0 20 40 60 80 100 120 140 160 180 200minus6

minus4

minus2

0

2

4

6

8

Signal Corrupted with Random Noise

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

X 800Y 3367

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 400Y 1858

(b)

Figure 117 Noised signal (a) the plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) with lotsof noise added (b) the wave frequencies (Discrete Cosine Transform) in the signal you can see400 Hz and 800 Hz peaks

This is the real power of trigonometric functions we can decompose even a very noisysignal and still see what are the cosine waves (that use pure tones) that make it And not justto look at the plot but also clean up the signal we can just zero-out the small numbers in theDCT variable Dk to clean up the noise and transform the signal back to its original state - andnoise is (almost) gone

The MATLAB (or Octave) code for this example is below

Fs = 4000 Sampling frequency

T = 1Fs Sample time

L = 1000 Length of signal counts

x k = (1L)T Time count

Sum of a 400 Hz wave and a 800 Hz wave

y k = cos(2pi400x k) + 2cos(2pi800x k)

Now add some random noise to the sum of waves

y k n oisy = y k + 2randn(size(x k )) Sinusoids plus noise

figure plot(Fsx k(1200)y k(1200))

title(Original signal (sum of two waves)) xlabel(time (milliseconds))

figure plot(Fsx k(1200)y k noisy(1200))

title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

How many cosine waves of different frequencies we have in the signal

D k dct clean signal = dct(y kL)

D k dct noisy signal = dct(y k noisyL)

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

20

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 17: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1726

Example of frequency analysis using Discrete Cosine Transform

Letrsquos go back to our previous example and take it one step further we combine a soundwave of frequency F 1 = 400 Hz and amplitude A = 1 with a soundwave of frequency F 2 = 800 Hz and

amplitude A = 2

yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) (114)

were indexes with the letter k in yk and xk simply mean the row number in the table with yand x Thatrsquos where the word discrete comes into play our computers can work with discretenumbers and all we need is to take enough samples of a function (cosine in this case) close toeach other to describe the signal

In the program code below we take L = 1000 samples for our signal from Equation 114 andwe take samples of our signal close to each other - say once every t = 14000th of a second Here4000 is our sampling frequency - this is how often we evaluate our function in Equation 114 Wetook F sampling = 4000 arbitrary - any number larger than 800 will be fine

1 Fs = 4000 Sampling frequency

2 T = 1Fs Sample time

3 L = 1000 Length of signal counts

4 x k = (1L)T Time count

56 Sum of a 400 Hz wave and a 800 Hz wave

7 y k = cos(2pi400x k) + 2cos(2pi800x k)

89 Now add some random noise to the sum of waves

10 y k n oisy = y k + 2randn(size(x k ))

1112 figure plot(Fsx k(1200)y k(1200))

13 title(Original signal (sum of two waves)) xlabel(time (milliseconds))

1415 figure plot(Fsx k(1200)y k noisy(1200))

16 title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

That is take L = 1000 numbers (line 3) and generate xk values (line 4) to be plugged intoEquation 114 (line 7) The plot of the signal can be seen in Figure 116(a)

The Discrete Cosine Transform Now the main part we are going to transform (decompose)our sound signal into pure tones (cosine waves of different frequencies) using the Discrete CosineTransform (DCT)

Dk =

N minus1991761n=0

yn cos

983131π

N

983080n +

1

2

983081k

983133 for every frequency k = 0 N minus 1 (115)

Now what does this formula2 actually mean

the signN minus1sumn=0

means ldquosumming elements with subscript n from n = 0 to n = N minus 1

N is the length of the signal y - in our case the signal has 1000 values (a row in a tablewith 1000 cells)

2This formula does not include a normalisation term to account for the number of samples - Irsquom skipping itto simplify the discussion

18

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1826

0 20 40 60 80 100 120 140 160 180 200minus2

minus15

minus1

minus05

0

05

1

15

2

25

3Original signal (sum of two waves)

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

40

X 400Y 2127

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 800Y 3618

(b)

Figure 116 Clean noiseless signal (a) The plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk)(b) the wave frequencies (Discrete Cosine Transform) in the noiseless signal you can see 400 Hzand 800 Hz peaks

yn we take from Equation 114

and we do this for every frequency k from 0 to N minus 1 At the end we get a row of numbersDk that tells us how many cosine waves with frequency 0 1 2 all the way up to frequency N minus1do we have in our signal The program code (MATLAB or Octave) for the DCT formula inEquation 115 is quite simple3

function D = my dct(y)

N = length(y) N rows do we have in the signal yD = zeros(N1) D stores the DCT transform of the signal y

for k = 01Nminus1 for every frequency k = 0 to Nminus1 with step 1

for n = 01Nminus1 for every row value of signal y do this

D(k+1) = D(k+1) + y(n+1)cos(piN (n + 12)k)

end the line above literary implements the DCT formula

end

There is no need to program the DCT formula in MATLAB and Octave it can be calledusing dct(Y) command to transform the signal stored in the variable Y

Now if we now plot the numbers in the variable Dk versus frequencies of a cosine wave (kfrom 0 to N-1) we will see the picture like the one in Fig 116(b) Notice two peaks at 400 and800 Hz - these peaks correspond to the cosine waves in our signal described by Equation 114

yk = cos(2 lowast pi lowast 400 lowast xk) + 2 lowast cos(2 lowast pi lowast 800 lowast xk)This is exactly what we expect after all our soundwave contains only 400 Hz and 800 Hz

cosine waves and those peaks of DCT indicate thisNow imagine that our soundwave was recorded with a bad microphone we have a lot of

noise in the recording If you look at Figure 117(a) there is so much noise that you donrsquot evensee the waves But if you use the DCT to decompose the noised signal and again make the plot

3The code is not efficient and it will take a lot of time for long signals However it is a simple word-for-wordimplementation of the DCT mathematical formula and serves its illustrative purpose

19

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1926

of its result you will be able to see those peaks (that correspond to soundwaves buried undernoise) in Figure 117(b)

0 20 40 60 80 100 120 140 160 180 200minus6

minus4

minus2

0

2

4

6

8

Signal Corrupted with Random Noise

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

X 800Y 3367

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 400Y 1858

(b)

Figure 117 Noised signal (a) the plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) with lotsof noise added (b) the wave frequencies (Discrete Cosine Transform) in the signal you can see400 Hz and 800 Hz peaks

This is the real power of trigonometric functions we can decompose even a very noisysignal and still see what are the cosine waves (that use pure tones) that make it And not justto look at the plot but also clean up the signal we can just zero-out the small numbers in theDCT variable Dk to clean up the noise and transform the signal back to its original state - andnoise is (almost) gone

The MATLAB (or Octave) code for this example is below

Fs = 4000 Sampling frequency

T = 1Fs Sample time

L = 1000 Length of signal counts

x k = (1L)T Time count

Sum of a 400 Hz wave and a 800 Hz wave

y k = cos(2pi400x k) + 2cos(2pi800x k)

Now add some random noise to the sum of waves

y k n oisy = y k + 2randn(size(x k )) Sinusoids plus noise

figure plot(Fsx k(1200)y k(1200))

title(Original signal (sum of two waves)) xlabel(time (milliseconds))

figure plot(Fsx k(1200)y k noisy(1200))

title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

How many cosine waves of different frequencies we have in the signal

D k dct clean signal = dct(y kL)

D k dct noisy signal = dct(y k noisyL)

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

20

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 18: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1826

0 20 40 60 80 100 120 140 160 180 200minus2

minus15

minus1

minus05

0

05

1

15

2

25

3Original signal (sum of two waves)

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

40

X 400Y 2127

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 800Y 3618

(b)

Figure 116 Clean noiseless signal (a) The plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk)(b) the wave frequencies (Discrete Cosine Transform) in the noiseless signal you can see 400 Hzand 800 Hz peaks

yn we take from Equation 114

and we do this for every frequency k from 0 to N minus 1 At the end we get a row of numbersDk that tells us how many cosine waves with frequency 0 1 2 all the way up to frequency N minus1do we have in our signal The program code (MATLAB or Octave) for the DCT formula inEquation 115 is quite simple3

function D = my dct(y)

N = length(y) N rows do we have in the signal yD = zeros(N1) D stores the DCT transform of the signal y

for k = 01Nminus1 for every frequency k = 0 to Nminus1 with step 1

for n = 01Nminus1 for every row value of signal y do this

D(k+1) = D(k+1) + y(n+1)cos(piN (n + 12)k)

end the line above literary implements the DCT formula

end

There is no need to program the DCT formula in MATLAB and Octave it can be calledusing dct(Y) command to transform the signal stored in the variable Y

Now if we now plot the numbers in the variable Dk versus frequencies of a cosine wave (kfrom 0 to N-1) we will see the picture like the one in Fig 116(b) Notice two peaks at 400 and800 Hz - these peaks correspond to the cosine waves in our signal described by Equation 114

yk = cos(2 lowast pi lowast 400 lowast xk) + 2 lowast cos(2 lowast pi lowast 800 lowast xk)This is exactly what we expect after all our soundwave contains only 400 Hz and 800 Hz

cosine waves and those peaks of DCT indicate thisNow imagine that our soundwave was recorded with a bad microphone we have a lot of

noise in the recording If you look at Figure 117(a) there is so much noise that you donrsquot evensee the waves But if you use the DCT to decompose the noised signal and again make the plot

3The code is not efficient and it will take a lot of time for long signals However it is a simple word-for-wordimplementation of the DCT mathematical formula and serves its illustrative purpose

19

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1926

of its result you will be able to see those peaks (that correspond to soundwaves buried undernoise) in Figure 117(b)

0 20 40 60 80 100 120 140 160 180 200minus6

minus4

minus2

0

2

4

6

8

Signal Corrupted with Random Noise

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

X 800Y 3367

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 400Y 1858

(b)

Figure 117 Noised signal (a) the plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) with lotsof noise added (b) the wave frequencies (Discrete Cosine Transform) in the signal you can see400 Hz and 800 Hz peaks

This is the real power of trigonometric functions we can decompose even a very noisysignal and still see what are the cosine waves (that use pure tones) that make it And not justto look at the plot but also clean up the signal we can just zero-out the small numbers in theDCT variable Dk to clean up the noise and transform the signal back to its original state - andnoise is (almost) gone

The MATLAB (or Octave) code for this example is below

Fs = 4000 Sampling frequency

T = 1Fs Sample time

L = 1000 Length of signal counts

x k = (1L)T Time count

Sum of a 400 Hz wave and a 800 Hz wave

y k = cos(2pi400x k) + 2cos(2pi800x k)

Now add some random noise to the sum of waves

y k n oisy = y k + 2randn(size(x k )) Sinusoids plus noise

figure plot(Fsx k(1200)y k(1200))

title(Original signal (sum of two waves)) xlabel(time (milliseconds))

figure plot(Fsx k(1200)y k noisy(1200))

title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

How many cosine waves of different frequencies we have in the signal

D k dct clean signal = dct(y kL)

D k dct noisy signal = dct(y k noisyL)

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

20

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 19: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 1926

of its result you will be able to see those peaks (that correspond to soundwaves buried undernoise) in Figure 117(b)

0 20 40 60 80 100 120 140 160 180 200minus6

minus4

minus2

0

2

4

6

8

Signal Corrupted with Random Noise

time (milliseconds)

(a)

0 200 400 600 800 1000 1200 1400 1600 1800 20000

5

10

15

20

25

30

35

X 800Y 3367

How many waves of different frequencies do we have in the Signal

Frequency (Hz)

X 400Y 1858

(b)

Figure 117 Noised signal (a) the plot of yk = cos(2π lowast 400xk) + 2 lowast cos(2π lowast 800xk) with lotsof noise added (b) the wave frequencies (Discrete Cosine Transform) in the signal you can see400 Hz and 800 Hz peaks

This is the real power of trigonometric functions we can decompose even a very noisysignal and still see what are the cosine waves (that use pure tones) that make it And not justto look at the plot but also clean up the signal we can just zero-out the small numbers in theDCT variable Dk to clean up the noise and transform the signal back to its original state - andnoise is (almost) gone

The MATLAB (or Octave) code for this example is below

Fs = 4000 Sampling frequency

T = 1Fs Sample time

L = 1000 Length of signal counts

x k = (1L)T Time count

Sum of a 400 Hz wave and a 800 Hz wave

y k = cos(2pi400x k) + 2cos(2pi800x k)

Now add some random noise to the sum of waves

y k n oisy = y k + 2randn(size(x k )) Sinusoids plus noise

figure plot(Fsx k(1200)y k(1200))

title(Original signal (sum of two waves)) xlabel(time (milliseconds))

figure plot(Fsx k(1200)y k noisy(1200))

title(Signal Corrupted with Random Noise) xlabel(time (milliseconds))

How many cosine waves of different frequencies we have in the signal

D k dct clean signal = dct(y kL)

D k dct noisy signal = dct(y k noisyL)

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

20

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 20: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2026

figure plot(freq abs(D k dct clean signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

xlabel(Frequency (Hz))

figure plot(freq abs(D k dct noisy signal (1L)))

title(How many waves of different frequencies do we have in the Signal)

This example is your first glimpse into a wonderful world of Signal Processing - the areaof engineering that deals with signals and noise that always stands in our way But the DCThas another (and much more entertaining) application - you can use DCT to break a wine glass

without touching it

Fun application of DCT breaking the wine glass using soundwaves

Who said that trigonometry is boring After all we study to do something with our knowledgeand what is the best application of the knowledge than having fun

In the example above we used the Discrete Cosine Transform to figure out the frequenciesof the signal even when the signal had a lot of noise We can take it a bit further and use tohave some fun - we are going to use DCT to figure out the sound frequency that is inherent toa wine glass When we play that specific sound frequency through a loudspeaker we can breakthe glass

WARNING This trick can be dangerous wear a protective plastic glassessince small pieces of the glass can land in your eye and damage it Also use a plasticwrap to surround the glass so the pieces will not fly away and damage something (orsomeone) else This trick is better be performed by a teacher

First a bit of physics Many objects including a wine glass have a natural resonancefrequency F R - a frequency that is inherent to the structure and the material of this particular

object If we apply a soundwave cos(F ) of the same frequency F = F R as resonance cos(F R)using loudspeakers we will force the glass to vibrate the most Mathematically this isexactly what the Equation 17 is all about we add two sound waves

cos(F R) + cos(F ) = 2cos

983080F R + F

2

983081cos

983080F R minus F

2

983081

where the F R is the resonant sound frequency of the glass and F is just about any othersound frequency If we want to break the glass we need to make it vibrate as violently as possible- that is we need to put a soundwave of exactly the same frequency as the resonant frequencyof the glass (F = F R) and the equation above will be

2cos

983080F R + F R

2

983081cos

983080F R minus F R

2

983081= 2 cos

9830802 lowast F R

2

983081= 2cos (F R)

It is not the volume of the sound that breaks the glass - it is the correct (resonant) frequencythat does the trick The only problem is to find it - and here we are going to use the DiscreteCosine Transform again

Figuring out the resonant frequency of the glass with DCT we need to record thesound of the glass and take the DCT of the signal To find the resonance frequency gently pingthe glass and record the sound on a computer Then we need to take DCT of the signal to seethe frequencies of the sound - here is an example of the program

21

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 21: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2126

recObj = audiorecorder

disp(Start speaking)

recordblocking(recObj 5) Record your voice for 5 seconds

disp(End of Recording)

play(recObj) Play back the recording

myRecording = getaudiodata(recObj) Store data in myRecording table of numbers

Compute the Discrete Cosine Transform

L = size(myRecording1)

Fs = 8000 sampling rate in Hz Default is 8000 for audiorecorder

D k dct = dct(myRecording) take DCT

plot(myRecording) Plot the waveform

Plot the number of cosine waves versus cosine waves frequencies

freq = Fs2[0(1L)1minus1L]

figure plot(freq abs(D k d ct))

We are looking for the most ldquovocalrdquo (prominent) sound frequencies so we make a plot of thefrequencies found by the DCT like in Figure 118

200 400 600 800 1000 1200 1400 1600 1800 2000 2200

X 6154

Y 1724

Figure 118 The Discrete Cosine Transform of the sound of the glass notice large peaks - theseare resonant frequencies and the most prominent of them in this case is F R = 615Hz

Figure 118 gives us the spectrum of the sound produced by the wine glass and it turnsout that the frequency F R = 615Hz is the resonant frequency of the glass (the most prominentfrequency) Now we know what frequency of the sound we need - letrsquos get dangerous

Note however that the frequency is not the only factor - volume is also important Thelouder the sound the more violent the vibrations will be When they reach a level that the

22

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 22: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2226

glass cannot withstand - it will shatter This process is very quick - it is hard to see without ahigh-speed camera but we can add a straw and notice that it will be tossed from side to side asthe glass vibrates more and more

The rim of the glass will be bending back and forth Figure 119 illustrates this the soundwaves (in blue) push the rim of the glass with the same frequency as the glass itself vibratesand this what causes the glass to break apart Again the soundwave cos(F R) with exactly rightfrequency F R is what does the trick

Figure 119 If we put the correct soundwave with the resonant frequency of the glass (whichwe determined with DCT) the glass will break Notice how the rim of the glass is bent - this iswhat causes the glass to shutter

The effect of resonance is studied in physics and occurs in many engineering and sciencefields For example we put the electromagnetic waves of specific frequency through the food

in microwave ovens and water molecules happen to absorb those specific frequencies (about800 MHz) which heats the food up Another example is the resonance in civil engineeringlike bridges and skyscrapers which we obviously want to eliminate One of the most famousexamples of unwanted structural resonances is Tacoma Narrows Bridge

23

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 23: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2326

15 Pythagorean theorem and its proof

The Pythagorean theorem states that the square of the hypotenuse (the side opposite the rightangle) is equal to the sum of the squares of the other two sides

a2 + b2 = c2 (116)

where c is the length of the hypotenuse a and b are the lengths of the trianglersquos other sidesThis theorem is very important for the geometry and we will see how to prove it There are

many proofs of the Pythagorean theorem but here we have two ways Euclidrsquos original proof and a more simple algebraic proof

151 Euclidrsquos proof

Perhaps the most famous proof of all times is Euclidrsquos geometric proof although it is neither thesimplest nor the most obvious4 Euclidrsquos proof used the Figure 121

Figure 121 Illustration for the proof from Euclid

The idea of Euclidrsquos proof is to draw a square for each side of the right triangle ABC anddivide the biggest square BCED into two rectangles BKLD and KCEL The idea is toshow that the area of the biggest square is the sum of two smaller ones which can be expressedthrough trianglesrsquo sides and thus complete the proof

A triangle BAD is constructed such that it has half the area of the left rectangle BKLD(pink in Figure 121) Another triangle F BC is constructed such that it has half the area of thesquare BFGA These two triangles are shown to be congruent proving the square BFGAhas the same area as the rectangle BKLD This argument is followed by a similar version forthe right rectangle KCEL and the square AHIC Putting the two rectangles together toreform the square on the hypotenuse its area is the same as the sum of the area of the othertwo squares

Necessary assumptions (lemmas) We need four elementary assumptions

If two triangles have two sides of the one equal to two sides of the other each to each andthe angles included by those sides equal then the triangles are congruent (side-angle-side)

4The philosopher Schopenhauer has described this proof as a rdquobrilliant piece of perversityrdquo (Schopenhauer1977 Gardner 1984 p 153)

26

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 24: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2426

The area of a triangle is half the area of any parallelogram on the same base and havingthe same altitude

The area of a rectangle is equal to the product of two adjacent sides

The area of a square is equal to the product of two of its sides (follows from 3)

The following steps prove the theorem

1 Let ACB be a right-angled triangle with right angle CAB

2 Draw squares CBDE BAGF and ACIH on each of the sides BC AB and CA of theACB

3 Drop a perpendicular from A to the side opposite the hypotenuse in the square BFGAThat line divides the square BCED on two rectangles That is C L||BD||CE

4 Join CF and AD to form the triangles BCF and BDA These triangles are equivalent

except for rotation

5 Angles angCAB = angBAG = 90 therefore C A and G are collinear Similarly for B Aand H

6 Angles angCBD = angF BA = 90 therefore angle angABD equals angle angFBC since both arethe sum of a right angle (90) and angle angABC

7 Since AB = F B and B D = BC triangle ABD must be congruent to triangle FBC

8 Since the points A K and L lie on a straight line AL||BD then S BDLK = 2 lowast S ABDThis is because they share the base BD and have the same altitude BK (See lemma 2)

9 Since C is collinear with A and G then square S BAGF = 2 lowast F BC

10 Therefore rectangle BDLK must have the same area as square BAGF S BDLK = S BAGF =AB2

11 Similarly it can be shown that rectangle CKLE must have the same area as square ACIHS CKLE = S ACIH = AC 2

12 Adding these two results AB2 + AC 2 = BD times BK + KL times KC

13 Since B D = K L B D times BK + KL times KC = BD(BK + KC ) = BD times BC

14 Therefore AB2 + AC 2 = BC 2 since CBDE is a square

This completes the proof which would be enjoyable by real jedi math warriors Those who

have less midichlorians and still learning the Way of mathematical Force are invited to look intosimpler (and more straightforward) algebraic proof

27

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 25: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2526

152 Algebraic proof

There is a much simpler proof of the Pythagorean theorem from Equation 116 using a simplealgebra and the area of square and right-angle triangles

Consider Figure 122 where there are two squares a big blue square ABCD and a smalleryellow KLMN We fitted the yellow square KLMN into ABCD so it touches the sides of the ABCD and cuts the same pieces from the sides AL = BM = N C = DK = a andLB = M C = DN = AK = b as in Figure 122 Letrsquos denote the side of the small yellow squareKLMN as K L = c

Notice that the length of each side of a big blue square ABCD is AB = BC = C D = AD =a + b We express the areas of the whole square ABCD and its pieces (4 blue right triangularsinside and a smaller yellow square KLMN) in terms of a b and c

Figure 122 Illustration for the proof in Subsection 152

The central idea is to use the fact that the area of the big square is equal to the sum of itspieces which is S ABCD = S KLMN + S ALK + S LBM + S MNC + S NDK

Area of the big square ABCD The total area of a square ABCD is

S ABCD = AB2 = (a + b)(a + b) = a2 + 2ab + b2

Now letrsquos consider the areas of the blue right triangles and yellow smaller square

Area of the pieces of the square ABCD The area of the yellow square KLMN is

S KLMN = K L2 = c2

All four triangles have the same area since the smaller square KLMN cuts the same portionsof the sides of a bigger square ABCD The area of each of the triangular say S ALK is

S ALK = 1

2ab

28

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29

Page 26: Part the Dark Side of Mathematics

7172019 Part the Dark Side of Mathematics

httpslidepdfcomreaderfullpart-the-dark-side-of-mathematics 2626

The area of all four triangles is

S = S ALK + S LBM + S MNC + S NDK = 4 lowast S ALK = 4 lowast 1

2ab = 2ab

The area of the pieces of the square ABCD is therefore

S KLMN + S = c2 + 2ab

Areas of pieces comprise the area of the big square As mentioned above the idea of theproof is to show that the area of the large square ABCD is equal to sum of its pieces namelysmaller yellow square KLMN and 4 blue triangles

S KLMN + S = S ABCD

We found the area in terms of the trianglesrsquo sides a b and c Letrsquos substitute them intoexpression above to get

(a + b)(a + b) = c2 + 2ab

Open the brackets

a2 + 2ab + b2 = c2 + 2ab

The part 2ab is the same at the left and right so it can be cancelled

a2 + b2 = c2

which gives us the proof of the Equation 116

29