63
Mathematical problem-solving for Earth sciences 1 MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES — Part II Lecturer Prof. Richard Katz — [email protected], Demonstrator Dr. Yves Plancherel — [email protected] Books During this term we’ll make use of the books: Statistics and Data Analysis in Geology by John Davis, published by John Wiley & Sons. (Hereafter DA) Geostatistics Explained by McKillup and Dyar, published by Cambridge University press. (Hereafter MD) You are encouraged to purchase these for use during the course, for consultation during future courses at Oxford, and as a reference throughout your career in science. Both books are available at University and college libraries. Matlab We will use the Matlab software package throughout the course. Please revise the first lecture and first problem set of Michaelmas term on basic Matlab usage, and be sure to understand the Matlab refresher and associated problem set in full detail. You should install Matlab on your personal computer, if possible. To do so, please connect your computer to the University network and follow this link: https://register.oucs.ox.ac.uk/self/software Here you will be able to download Matlab and obtain a license. The software will only work when you are connected to the University computer network (i.e. blah.ox.ac.uk). Lectures Weekly — check term schedule. Lecture topics (Subject to modification) Week 1 Geochemical fractionation and mixing Week 2 Intro to time-series analysis Week 3 Continuous Fourier series Week 4 Discrete Fourier series and spectra Week 5 Detrending, spectra Week 6 Box models Week 7 Diffusion I Week 8 Diffusion II Problem classes Will meet weekly (check term schedule) in the Computing Laboratory (usu- ally). The first few minutes of the problem class will involve Matlab tips from the instructor and additional instructions about the problem set. The rest of the time will be for independent work. Please come having read the assignment and worked on any problems that you know how to do. Other important points Please read carefully: These notes are not a complete description of the information that is to be under- stood as part of the course. The complete description is contained in the union of these notes, the lectures themselves, and the book-sections referred to below and in the lectures. The level of mathematics that will be required on an examination of this material is approximately equivalent to that of the assigned problems.

MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

Page 1: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Mathematical problem-solving for Earth sciences 1

MATHEMATICAL PROBLEM SOLVINGFOR EARTH SCIENCES — Part II

Lecturer Prof. Richard Katz — [email protected],

Demonstrator Dr. Yves Plancherel — [email protected]

Books During this term we’ll make use of the books:

• Statistics and Data Analysis in Geology by John Davis, published by John Wiley &Sons. (Hereafter DA)

• Geostatistics Explained by McKillup and Dyar, published by Cambridge Universitypress. (Hereafter MD)

You are encouraged to purchase these for use during the course, for consultation duringfuture courses at Oxford, and as a reference throughout your career in science. Both booksare available at University and college libraries.

Matlab We will use the Matlab software package throughout the course. Please revise the firstlecture and first problem set of Michaelmas term on basic Matlab usage, and be sure tounderstand the Matlab refresher and associated problem set in full detail. You shouldinstall Matlab on your personal computer, if possible. To do so, please connect yourcomputer to the University network and follow this link:

https://register.oucs.ox.ac.uk/self/software

Here you will be able to download Matlab and obtain a license. The software will onlywork when you are connected to the University computer network (i.e. blah.ox.ac.uk).

Lectures Weekly — check term schedule.

Lecture topics (Subject to modification)

Week 1 Geochemical fractionation and mixing

Week 2 Intro to time-series analysis

Week 3 Continuous Fourier series

Week 4 Discrete Fourier series and spectra

Week 5 Detrending, spectra

Week 6 Box models

Week 7 Diffusion I

Week 8 Diffusion II

Problem classes Will meet weekly (check term schedule) in the Computing Laboratory (usu-ally). The first few minutes of the problem class will involve Matlab tips from theinstructor and additional instructions about the problem set. The rest of the time willbe for independent work. Please come having read the assignment and worked on anyproblems that you know how to do.

Other important points Please read carefully:

• These notes are not a complete description of the information that is to be under-stood as part of the course. The complete description is contained in the union ofthese notes, the lectures themselves, and the book-sections referred to below and inthe lectures. The level of mathematics that will be required on an examination ofthis material is approximately equivalent to that of the assigned problems.

Page 2: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

2 Mathematical problem-solving for Earth sciences

• Questions in the notes are meant as a check on your understanding. Try to answerthem; if a question confuses you, it is an indication that you should review the coursematerials and, perhaps, seek help from a peer, a tutor, or the lecturer.

• Problems A problem-set will be distributed at the end of each lecture. You will needto submit a completed paper at the beginning of the next lecture. The laboratorymeeting will give you time to work on the problems and ask questions about thingsthat you don’t understand.

Contents

1 Geochemical mixing and fractionation 3

1.1 Adding masses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.2 Adding concentrations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.3 Mixing in one chemical dimension . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.4 Mixing in two chemical dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.5 Mixing lines for an isotope ratio . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1.6 Geochemical fractionation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1.6.1 Batch crystallisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

1.6.2 Fractional crystallisation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

1.7 An example of isotope fractionation: clouds . . . . . . . . . . . . . . . . . . . . . 9

2 Introduction to the Analysis of Sequence Data 12

2.1 Types of sequence data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.2 Preparing a time-series for analysis: Interpolation . . . . . . . . . . . . . . . . . . 13

2.2.1 Linear interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2.2.2 Cubic interpolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

2.2.3 Practical considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2.3 Analysing a time-series by autocorrelation . . . . . . . . . . . . . . . . . . . . . . 16

2.4 Review of trigonometric functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

2.5 Matlab notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

3 Fourier Series 21

3.1 Aside: coordinate systems and orthogonality . . . . . . . . . . . . . . . . . . . . 21

3.2 Periodic functions: a general definition . . . . . . . . . . . . . . . . . . . . . . . . 22

3.3 The Fourier series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

3.4 (NON-EXAMINABLE) Applying the orthogonality conditions . . . . . . . . . . 23

3.5 Calculating the Fourier coefficients . . . . . . . . . . . . . . . . . . . . . . . . . . 24

3.6 A worked example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

3.7 Fourier series of discontinuous functions . . . . . . . . . . . . . . . . . . . . . . . 25

Page 3: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Mathematical problem-solving for Earth sciences 3

4 Discrete Fourier Series and Power Spectra I 27

4.1 From time-series to radian-series . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

4.2 Discrete Fourier series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

4.3 (NON-EXAMINABLE) Determining the coefficients of the Discrete Fourier series 29

4.4 Putting it together to compute the discrete Fourier series . . . . . . . . . . . . . 30

4.5 The variance spectrum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

4.6 Worked examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

5 Discrete Fourier Series and Spectra II 34

5.1 What is a spectrum? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

5.2 Detrending . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

5.2.1 Removing nonlinear trends . . . . . . . . . . . . . . . . . . . . . . . . . . 36

5.3 (NON-EXAMINABLE) The Fourier transform and its discrete version . . . . . . 37

5.4 Using Matlab’s fft function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

5.5 Spectra, waves, and the Earth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

6 Box models 42

6.1 A one-box model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

6.2 Residence time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

6.3 A two-box model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

6.4 Multi-box models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

6.5 An Earth sciences example: ocean circulation . . . . . . . . . . . . . . . . . . . . 47

7 Diffusion I 49

7.1 The diffusive flux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

7.2 Steady conduction in one dimension . . . . . . . . . . . . . . . . . . . . . . . . . 50

7.3 Adding a source term . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

7.4 Example: the continental geotherm . . . . . . . . . . . . . . . . . . . . . . . . . . 52

7.5 Radial heat conduction in a sphere or spherical shell . . . . . . . . . . . . . . . . 53

8 Diffusion II 56

8.1 The time-dependent diffusion equation . . . . . . . . . . . . . . . . . . . . . . . . 56

8.2 Diffusion in an insulated rod of infinite length . . . . . . . . . . . . . . . . . . . . 57

8.3 Mathematical lessons about diffusion . . . . . . . . . . . . . . . . . . . . . . . . . 60

8.4 Solving the infinite-rod diffusion problem with Matlab . . . . . . . . . . . . . . 61

Page 4: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

4 Mathematical problem-solving for Earth sciences – Hilary term

1 Geochemical mixing and fractionation

In this lecture we’ll look at the mathematics of geochemical mixing and fractionation. Theseare two simple but powerful ways of understanding geochemical data. The idea is to use data toquantify the physical processes that underly the observed characteristics of geological materials.

1.1 Adding masses

Consider the combination of two distinct waters or magmas or sediments. The bulk compositionof the mixture should be intermediate to the composition of the two starting compositions, butthe mass M of the mixture is obviously the sum,

M1 +M2 = Mmix. (1)

It is more useful, however to talk about fractional masses, such that the sum is unity. Hence wedivide by the mixture mass,

M1

Mmix+

M2

Mmix= 1. (2)

We can define the mass fractions as fi = Mi/Mmix and of course

f1 + f2 = 1. (3)

1.2 Adding concentrations

Suppose that we are interested in Strontium, Sr. If we know the number of atoms, Sr1 and Sr2in each of the initial masses, we know that the number of atoms in the mixture is just the sumof these two

Sr1 + Sr2 = Srmix. (4)

But counting atoms is inconvenient; it is handy to work with concentrations. Let’s be explictabout the meaning of concentration,

[Sr]1 =Sr1M1

, (5)

where we use square brackets to denote the concentration: the number of atoms divided by themass of the stuff they reside in. Rearranging (5) and substituting into (4) we have

[Sr]1M1 + [Sr]2M2 = [Sr]mixMmix, (6)

or dividing through by Mmix and using f2 = 1− f1,

f1 [Sr]1 + (1− f1) [Sr]2 = [Sr]mix . (7)

The beauty of equation (7) is that it allows us to compute the mixing fraction f1 from mea-surements of concentration in the input masses and the mixture. This is the equation fortwo-component mixing, where the components are the two materials that were mixed together.

1.3 Mixing in one chemical dimension

Sometimes geochemical data indicates that there are a set of mixtures (also called samples) ofthe same two input materials (also called end-members). Suppose we measure seven samples

Page 5: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 5

A,B,C,D,E, F,G and find they have concentrations [Sr]A , [Sr]B , ..., [Sr]G. If we know the end-

member compositions, [Sr]1 and [Sr]2, we can compute the mixing fractions f(A)1 , f

(B)1 , ..., f

(G)1

by rearranging (7),

f(Q)1 =

[Sr]2 − [Sr]Q[Sr]2 − [Sr]1

, (8)

where Q = {A,B,C,D,E, F,G} represents any of the samples.

1.4 Mixing in two chemical dimensions

Of course there is more than one element that is mixed when our two end-members are combined!The use of two elements gives us added power of interpretation, as we shall see.

Suppose we mix two end-members containing Sr and Sodium (Na) with a mixing fraction f1(recall that f2 = 1− f1). Then we have

f1 =[Sr]2 − [Sr]mix

[Sr]2 − [Sr]1and f1 =

[Na]2 − [Na]mix

[Na]2 − [Na]1. (9)

We can eliminate f1 from this pair of equations and rearrange to obtain

[Na]mix =

([Na]2 − [Na]1[Sr]2 − [Sr]1

)([Sr]mix − [Sr]2) + [Na]2 . (10)

Remember that the end-member concentrations are constants: they are the same for any mixedsample. So this equation has the form of a straight line on a plot of [Na]mix versus [Sr]mix!The slope of the line is given by the ratio of the differences in end-member concentrations([Na]2 − [Na]1)/([Sr]2 − [Sr]1). Think about this until it is intuitively obvious why this is true.

[Sr]

[Na]

(a)

C1

C2

[Sr]

(b)

C1

C2

C3

Figure 1: Mixing lines in an element–element space. (a) Data and line consistent with a two-componentmixture between end-member compositions C1 and C2. The points do not fall exactly on the line becausea small amount of “noise” was added. (b) Blue squares are generated by mixing C1, C2, and C3. Blackcircles are the same binary mixture as in panel a.

This is an important result because it allows us to infer, from a geochemical dataset, whethertwo-component mixing may have taken place (e.g. in the magma chamber) to produce the arrayof data. If, as in Figure 1a, the data form a linear array—even if we don’t know the end-membercompositions—then mixing of two materials may be responsible.

If, as in Figure 1b, some of the data fall off the mixing line, then it may mean that there areone or more additional components being mixed. We’ll look at three-component mixing in theproblem set.

Page 6: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

6 Mathematical problem-solving for Earth sciences – Hilary term

1.5 Mixing lines for an isotope ratio

One must take a bit of care in deriving the mixing equation for isotope ratios — it is really theratio of the mixing equations of two separate isotope concentrations.

Let’s consider isotope concentrations of Strontium[86Sr

]and

[87Sr

], and their ratio([

87Sr]/[86Sr

])≡(87Sr/86Sr

). We know from the foregoing that

f1 =

[87Sr

]2−[87Sr

]mix

[87Sr]2 − [87Sr]1and f1 =

[86Sr

]2−[86Sr

]mix

[86Sr]2 − [86Sr]1. (11)

Combining these two to eliminate f1 and using(87Sr86Sr

)mix

[86Sr

]mix

=[87Sr

]mix

, (12)

we can derive the isotope mixing equation(87Sr86Sr

)mix

= C11

[86Sr]mix

+ C2, (13)

where C1 and C2 are constants that you will derive in the problem set.

Here we can bring in some geochemical knowledge to simplify the story. Isotope ratios tendto vary by parts per thousand (or much less) around a mean value for the Earth. This meansthat although the 87–86 ratio of Sr may vary in meaningful ways, the concentration of 86Sris always approximately equal 9.86% of the elemental concentration of Sr (variations in the Srisotope ratio are measured in parts-per-ten-thousand). So we can write[

86Sr]mix≈ C3 [Sr]mix , (14)

where this is a very good approximation. Then we can reformulate equation (13) as(87Sr86Sr

)mix

= C41

[Sr]mix

+ C2, (15)

where C4 = C1/C3 and, again, this is a very good approximation (so good that we can write =instead of ≈).

Equation (15) can be plotted in one of two ways. If we plot(87Sr/86Sr

)versus [Sr] then we

find a curved mixing line, as shown in Figure 2a. However, if we take the x-coordinate to be1/ [Sr], then the mixing line becomes straight, as in Figure 2b. Both approaches are used bygeochemists.

1.6 Geochemical fractionation

Geochemical fractionation can be though of an unmixing : removal of material from a homoge-neous reservoir, where the material removed has a different composition from the reservoir.

A classic example of fractionation is crystallisation in a magma chamber. The magmachamber is well-mixed and hence chemically homogeneous; it cools and forms some crystals,which have a composition that is different from the magma; these crystals settle to the bottomof the chamber, where they accumulate (and may remain chemically isolated). This processleads to chemical evolution of the magma chamber, which we’d like to model.

The model we’ll consider is called Rayleigh fractionation. It was developed to describedistillation of mixtures of liquids with different vapour pressures. As applied to the magma-chamber problem, it has two variants: fractional crystallisation and batch crystallisation. The

Page 7: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 7

[Sr]

(87Sr/

86Sr)

(a)

1/[Sr]

(b)

Figure 2: Mixing array for an isotope ratio versus the elemental concentration from equation (15). End-member compositions are now shown. (a) Isotope ratio versus the elemental concentration (b) Versusinverse concentration.

Xtals Xtals

Melt MeltdMsol

Chemical equilibrium Chemical equilibrium

(a) (b)

Figure 3: Schematic diagrams of (a) batch and (b) fractional crystallisation.

difference, illustrated in Figure 3 is in whether the crystals that accumulate at the bottom ofthe magma chamber remain in chemical equilibrium with the magma or are chemically isolated.

Let’s begin with a magma chamber that is fully liquid, with mass Mliq. We watch thechamber as it cools and begins to crystallise. The growing pile of crystals has mass Msol. We’lltrack some particular trace chemical constituent below, but for now we remain generic (i.e. wedon’t specify the chemical element).

1.6.1 Batch crystallisation

The total number of atoms of the constituent in the liquid-solid system is given by N0,

N0 = Nliq +Nsol. (16)

N0 remains constant throughout the crystallisation, as long as the system is closed (which weassume to be true). We can define concentrations with the notation

Cq =Nq

Mq(17)

Page 8: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

8 Mathematical problem-solving for Earth sciences – Hilary term

where q = 0, liq, sol is a generic subscript. Rearranging equation (17) and substituting into (16)gives

C0 = CliqF + Csol(1− F ), (18)

where F = Mliq/M0 is the fraction of mass that remains liquid after some crystallisation hasoccured. This is often called the melt fraction. Initially F = 1; with time, F decreases until itF = 0 and the system is fully crystallised.

In equilibrium, there is a relationship between the composition of the crystals and the com-position of the liquid:

D =Csol

Cliq, (19)

where D is the partition coefficient of the trace constituent. We can use (19) to simplify (18)by eliminating Csol and rearranging to obtain

Cliq

C0=

1

D + F (1−D)(20)

(confirm this by working out the algebra yourself). This is the batch melting (or, equivalently, thebatch crystallisation) equation. To derive it, we have assumed that all the accumulated crystalsare in equilibrium with the melt. Hence the crystal composition and the melt composition evolvesimultaneously.

0 0.2 0.4 0.6 0.8 110

−2

10−1

100

101

102

D = 0 .001

0 .5

1

2

5

10

←Xtals F Melt→

Cliq/C

0

(a)

0 0.2 0.4 0.6 0.8 1

D = 0 .001

0 .5

1

25 10

←Xtals F Melt→

(b)

Figure 4: Chemical evolution of a magma chamber with progressive crystallisation at different values ofpartition coefficient D. (a) Batch crystallisation paths from equation (20). (b) Fractional crystallisationpaths from equation (34).

Figure 4a shows the chemical evolution of the liquid in a magma chamber with progressivebatch crystallisation (as F goes from 1 to 0). We see that when D = 1, the crystals have thesame composition as the melt, and hence their production does not change the composition ofthe melt. When D < 1, crystals are depleted in the trace element, and hence crystallisationincreases the concentration in the melt. When D > 1, crystal formation sequesters the traceelement and reduces the concentration in the melt. However, since the full accumulation ofcrystals is always in equilibrium with the melt, the effect of fractionation is muted with respectto the fractional model in Figure 4b.

Page 9: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 9

Finally, consider the batch melting equation (20) in the limit of D → 0 and F > D,

Cliq

C0∼ 1

F. (21)

The concentration can become very large as F becomes small. This is evident in the curve forD = 0.001 in Figure 4a. Interestingly, however, as F → 0 and D > F , we can see that

Cliq

C0→ 1

D; (22)

you can see this behaviour if you look at the y-intercept of the curves in Figure 4a.

1.6.2 Fractional crystallisation

In fractional crystallisation, the liquid is in equilibrium with crystals when they are created,but the accumulated crystals are assumed to be chemically isolated from the melt, and hencethey do not evolve in composition. We therefore work with incremental changes in the problemvariables, expressed as infinitessimal quantities. In this context, mass balance tells us that

− dMliq = dMsol, (23)

meaning that an incremental mass subtracted from the liquid by crystallisation is added to thesolid. This is also true for atoms of the trace constituent that gets frozen into the crystals,

− dNliq = dNsol. (24)

As always, mass and atoms are related by the concentration and hence we can write the par-tioning equation (19) as

D =Csol

Cliq=

dNsol/dMsol

Nliq/Mliq. (25)

Note that in contrast to the solid, the liquid remains a homogeneous unit and hence we don’tneed to consider it in infinitessimal quantities.

We want an equation for the liquid alone, and so we can eliminate variables that refer to thesolid from (25) using (23) and (24) to give, after rearranging,

dNliq

Nliq= D

dMliq

Mliq. (26)

Now reconsider the definition of concentration in equation (17) and take the natural logarithmof both sides

lnCliq = lnNliq − lnMliq. (27)

Then, taking the total differential of both sides and recalling that d lnx = dx/x we find

dCliq

Cliq=

dNliq

Nliq− dMliq

Mliq. (28)

Using this with equation (26) to eliminate Nliq we obtain

dCliq

Cliq= (D − 1)

dMliq

Mliq. (29)

We can simplify (29) by noting that

F =Mliq

M0and dF =

dMliq

M0such that

dMliq

Mliq=

dF

F. (30)

Page 10: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

10 Mathematical problem-solving for Earth sciences – Hilary term

Substitution into (29) givesdCliq

Cliq= (D − 1)

dF

F. (31)

Now we must integrate this equation, to remove the infinitessimals. We integrate from the initialstate, when F = 1 and Cliq = C0 to some arbitrary final state of partial crystallisation. Usingdummy variables F ′ and C ′liq we write∫ Cliq

C0

dC ′liqC ′liq

= (D − 1)

∫ F

1

dF ′

F ′(32)

and integrate to obtainlnCliq − lnC0 = (D − 1)(lnF − ln 1). (33)

and exponentiate to get (noting ln 1 = 0)

Cliq

C0= FD−1. (34)

This is the fractional crystallisation equation. It describes the evolution of the liquid compositionas F goes from unity toward zero with progressive crystallisation.

Figure 4b shows the chemical evolution of the magma from F = 1 to F = 0 (right to left!)under fractional crystallisation. As for batch crystallisation, when D = 1, the melt doesn’tevolve because the crystals have a concentration of the trace element that is the equal to thatin the melt. The chemical evolution paths rapidly attain more extreme values, however, thanfor the batch system. This is because crystals that were extracted early, when F was larger, donot reequilibrate as the composition of the melt changes.

We can look at the small-D and small-F limits of fractional crystallisation and comparethem to batch. As D → 0, equation (34) states that Cliq/C0 ∼ F−1. Note that this result isidentical to the result for batch crystallisation in equation (21). This is because the crystalstake up none of the trace element when D = 0, so their composition is fixed, regardless of themode of crystallisation. The behaviour differs from batch when we look at F → 0. In this case,for D < 1 we find that Cliq/C0 →∞. This is obviously unphysical∗, and so care must be takenin applying the fraction crystallisation model at small F .

The crystals produced by batch and fractional crystallisation differ chemically. In batchcrystallisation, the crystal pile has a uniform trace element composition (assuming the samesolid phase is being precipitated). This is because the crystals adjust their composition to stayin equilibrium with the evolving liquid. In fractional crystallisation, there is no reequilibration.The crystals at the bottom of the pile have a different composition than those above them,reflecting their early crystalisation time and the composition of the melt at that time.

1.7 An example of isotope fractionation: clouds

As water vapour condenses, isotopes 18 and 16 of oxygen enter the liquid at different rates. Wewant to derive an equation that predicts the evolution of the oxygen isotope ratio in the vapourwith progressive condensation.

The kinetic factors associated with this process ki quantify the rate at which each isotope isadded to the water as it condenses. These rates are used to write

d18Ovap = k1818Ovap dt, (35)a

d16Ovap = k1616Ovap dt, (35)b

∗At some level of enrichment, the element is no longer a trace element and begins to crystallise its own mineralphase.

Page 11: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 11

where iOq is the concentration of oxygen isotope i in phase q. The ratio of the kinetic equationsgives the fractionation factor,

α =k18k16

=d18Ovap/d

16Ovap

18Ovap/16Ovap, (36)

Rearranging we find thatd18Ovap

18Ovap= α

d16Ovap

16Ovap. (37)

Integrating both sides from the initial condition iOvap = iO0,vap gives

ln

( 18Ovap

18O0,vap

)= α ln

( 16Ovap

16O0,vap

). (38)

Exponentiating and rearranging gives

18/16Ovap

18/16O0,vap=

( 16Ovap

16O0,vap

)α−1, (39)

where 18/16Ovap = 18Ovap/16Ovap is the isotope ratio in the vapour.

Figure 5: Fractionation by Rayleigh distillation of oxygen isotopes during condensation of water vapourin the atmosphere. The y axis of the bottom plot is in delta-notation: the deviation of the isotope ratiofrom a standard, normalised by the standard, times 1000. So it is the deviation in parts-per-thousand orper-mil. The difference between the rain/snow line and the water vapour line, ε, is approximately equalto α.

Because 16O is more than 99% of all oxygen atoms on Earth, we can accurately approximatethe fraction f of vapour that remains uncondensed as f = 16Ovap/

16O0,vap, the proportion of all16-oxygen that remains in the vapour.

18/16Ovap

18/16O0,vap= fα−1. (40)

Page 12: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

12 Mathematical problem-solving for Earth sciences – Hilary term

This is the Rayleigh distillation equation for isotope evolution of water vapour.

Page 13: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 13

2 Introduction to the Analysis of Sequence Data

In this lecture We will learn about different types of series data. We’ll discuss interpolationof irregularly timed measurements onto a regular interval, and we’ll analyse series using auto-correlation. Finally, we will review some basic aspects of trigonometric functions that will beuseful in the next lectures.

2.1 Types of sequence data

Earth scientists frequently need to analyse measurements that form a sequence—an orderedseries. This series may be ordered in space (e.g. down a stratigraphic section) or in time (e.g. overthe past 100 years). In either case, these are known as time series, and the term time-seriesanalysis is used to describe the application of quantitative methods to discover patterns in thedata. DA pp.

159–163MD 21.1

The series variable can be defined either by a rank-order or by a quantitative measure ofposition along the series axis (time or space). To illustrate this, consider a stratigraphic section.A rank-order series is defined by the order that the layers appear, from top to bottom: first,second, third, ..., last. A quantitative sequence measure, on the other hand, can be defined ifeach layer is radiometrically dated, from top to bottom, with ages: t1, t2, t3, ..., tN .

A time-series consists of an observation at each entry in the rank-order or measured-timelist. This measurement can also be qualitative or quantitative. As an example of the former,we might have a record of the presence or absence of a certain fossil-type in each layer of thestratigraphic sequence. The latter type of time-series, composed of quantitative observations,might be the height of water in a lake, the lateral displacement of a GPS station, or, in the caseof our stratigraphic sequence, the mass-fraction of biosilica.

In the following lectures, we will only be concerned with methods of analysis for time-seriesin which both the series position and observation are expressed quantitatively. Methods foranalysing other types of time-series are discussed in DA and MD. In analysing a time-series,we might ask

• Does it possess a trend? If so, is it a linear trend? What are the characteristics of thetrend?

• Does it possess a repeating pattern? Multiple repeating patterns? Do they recur with aregular frequency or frequencies?

• Does it contain some noise? How large is the noise relative to the signal?

In general, we will consider time-series composed of N entries indexed by an integer i thatgoes from 1 to N . For each value of i we will have a measure of the position (e.g. time), ti, anda measure of some quantity at that time, qi. Hence a general time-series can be represented as

t1, t2, t3, ..., tN−1, tN ;

q1, q2, q3, ..., qN−1, qN .

A primary consideration in analysing a time-series is whether its entries are regularly spaced.Regular spacing means that there is a constant difference between ti+1 and ti:

ti+1 − ti = ∆t, const. for all i.

The spacing between successive measurements, ∆t, could be a microsecond, or a metre, or amillion years; the important point is that the same spacing applies to any pair of consecutiveentries in the series.

Page 14: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

14 Mathematical problem-solving for Earth sciences – Hilary term

2.2 Preparing a time-series for analysis: Interpolation

Many of the methods that are used to analyse time-series require regularly spaced data. Whatif you have data that is not regularly spaced? For example, perhaps your time-series is missingan entry because the measurement device failed:

t1 = 0, t2 = 5, t3 = 10, t4 = 15, t5 = 25, t6 = 30, ...

q1 = 1, q2 = 0.87, q3 = 0.5, q4 = 0.0, q5 = −0.87, q6 = −1.0, ...(41)

Note that in this case, measurements were taken every five units, but the measurement at t = 20is absent. To analyse the data we might need to correct this absence.

Another problematic case is that of irregularly spaced entries:

t1 = 0, t2 = 5.3, t3 = 9.4, t4 = 16.0, t5 = 20.1, t6 = 25.8, ...

q1 = 1, q2 = 0.85, q3 = 0.55, q4 = −0.10, q5 = −0.51, q6 = −0.90, ...(42)

Dealing with this clearly requires more than the replacement of a single entry.

Interpolation is a method that is frequently employed to handle issues with data such as theabove. It uses available data to estimate the value of the measured quantity between observations.It provides a guess at what the measurement would have been at the point of interpolation, shouldwe have taken that measurement. We will consider two types of interpolation, linear and cubic,and then discuss the benefits and pitfalls of each.

2.2.1 Linear interpolation

Linear interpolation estimates the value of q between two measurements, qi and qi+1, using astraight line between those two measurements.DA pp.

163–165

ti t∗ ti+1

q i

q (t∗)

q i+1

t

q

Figure 6: Linear interpo-lation between two val-ues of a generic time-series. The black line isthe interpolant, and thestar marks the interpo-lated point.

Suppose we want to know the value of q at t = t∗, for ti < t∗ < ti+1. We can construct thelinear interpolant

q(t∗) = qi +

[qi+1 − qiti+1 − ti

](t∗ − ti). (43)

This equation states that the value of q at t∗ is equal to the value of q at ti plus the slope of theline connecting qi to qi+1, times the change in the independent variable, t∗− ti. The interpolantis illustrated in Figure 6. Notice that Equation (43) is simply the slope–intercept form, whereqi is the “intercept” and the slope is given by (qi+1 − qi)/(ti+1 − ti).

There is a quick-and-easy check that you should always perform when you write the formulafor a linear interpolant. First, let t∗ = ti; your formula should give you q(t∗) = qi. Second,let t∗ = ti+1; your formula should give you q(t∗) = qi+1. If both of these check out and yourinterpolant is linear, then it is correct.

Question: Given that f(10) = 33 and f(20) = −17, use linear interpolation to find f(12.5).

Page 15: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 15

2.2.2 Cubic interpolation

In real life, things rarely vary with the jaggedness assumed by linear interpolation: straight linesbetween points, with sharp turns on the points. Often, variations of a quantity with time ordistance are smoothly curving.

We can interpolate using a cubic polynomial to capture some of this curvature. A generalcubic polynomial can be written

q(t) = c0 + c1t+ c2t2 + c3t

3, (44)

where t is the independent variable, and q is the dependent variable. Equation (44) has fourunknown coefficients, c0, c1, c2, and c3.

Notice that if c2 = c3 = 0, then Equation (44) is the equation of a line in slope–intercept form,equivalent to Equation (43). Recall that for linear interpolation, we used the measured data-points that surround the time-value where we wanted to interpolate. These two points allowedus to determine c0 and c1. To determine the four unknown constants in the expression for acubic polynomial, we need four measured data-points. In particular, if we wish to interpolatefor q(t∗), we need qi(ti), qi+1(ti+1), qi+2(ti+2), and qi+3(ti+3), such that ti ≤ t∗ ≤ ti+3. Thesefour points need not be regularly spaced in t, though in practise, bunching of points in theindependent variable can produce bad results.

Figure 7: Cubic interpolation be-tween four values of a generictime-series. The black line is theinterpolant and the star marks theinterpolated value. Circles arecontrol points. ti+0

q i+0

ti+1

q i+1

ti+2

q i+2

ti+3

q i+3

t

q

Fortunately, it is not necessary to solve for the four constants of the cubic polynomial eachtime we wish to interpolate. A standard formula exists for a kth-degree polynomial that passesthrough k + 1 control points; this is known as the Lagrange polynomial. For k = 3 (cubic), werequire four control points, (t1, q1), (t2, q2), (t3, q3), (t4, q4), and the Lagrange polynomial is

q(t∗) =(t∗ − t2)(t∗ − t3)(t∗ − t4)(t1 − t2)(t1 − t3)(t1 − t4)

q1+

(t∗ − t1)(t∗ − t3)(t∗ − t4)(t2 − t1)(t2 − t3)(t2 − t4)

q2+

(t∗ − t1)(t∗ − t2)(t∗ − t4)(t3 − t1)(t3 − t2)(t3 − t4)

q3+

(t∗ − t1)(t∗ − t2)(t∗ − t3)(t4 − t1)(t4 − t2)(t4 − t3)

q4.

(45)

This equation may look complicated at first glance, but if you examine it closely, you will see apattern in the subscript values that makes it easier to remember. It is left as an exercise for thestudent to multiply each of these terms out and sum like powers of t to put the polynomial in theform of Equation (44)! To use this formula on a time-series, we simply map ti, ti+1, ti+2, ti+3 ontot1, t2, t3, t4, and likewise with qi, ... onto q1, .... An example interpolation is shown in Figure 7.

Page 16: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

16 Mathematical problem-solving for Earth sciences – Hilary term

Just as for linear interpolation, it is important that you check a new equation for cubicinterpolation (probably contained in a Matlab function). This can be done by interpolating atthe control points.

2.2.3 Practical considerations

0 5 10 15 20 25 30 35 40

−1

−0.5

0

0.5

1

t

q

Figure 8: Cubic interpolation tofill in the gap in the time-seriesfrom Equation (41). The inter-polant (black line) was calculatedusing Equation (45).

Now we can return to the time-series given in Equation (41) and solve the problem ofthe missing data-point. Figure 8 shows the use of the Lagrange cubic interpolant to replacethe missing data point with an interpolated point. The time-series could then be modified toinclude this replacement point, and then analysed.

As you may have guessed, Matlab has a built-in function for interpolation, and using itcan make our lives (and our code) better. The function name is interp1 (NB. this is differentfrom the Matlab function interp!). Reading the help message for interp1 reveals that thefunction has various methods of interpolation. The calling sequence is

Vq = interp1(X,V,Xq)

where inputs X is the “position” or “time” vector (t), V is the vector of measured quantities (q),and Xq is a vector of positions at which to interpolate. Vq is the output vector of interpolatedvalues. The default method of interpolation is linear, but an optional input argument can beused to change this:

Vq = interp1(X,V,Xq,METHOD)

where METHOD is a string specifying the type of interpolation to use. To get cubic interpolationas described above, the METHOD would be ’spline’. See help interp1 for more details.

To perform the interpolation shown in Figure 8, we would enter>> t = [0 5 10 15 25 30 35];

>> q = [1 0.87 0.5 0 -0.87 -1 -0.87];

>> qi = interp1(t,q,20,’spline’);

and to form the corrected time series we would then enter>> t = 0:5:35;

>> q = [q(1:4), qi, q(5:end)];

and check that this worked by saying>> plot(t,q,’-ok’);

If you try this you will notice that the added point lines up correctly, but the plot-line looksjagged—inconsistent with our use of cubic interpolation for the missing point. Interpolation canalso be used to make a smooth-looking plot line. Try this

Page 17: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 17

>> t smooth = linspace(t(1),t(end),1000);

>> q smooth = interp1(t,q,t smooth,’spline’);

>> plot(t,q,’ok’,’MarkerSize’,10); hold on;

>> plot(t smooth,q smooth,’-k’); hold off;

Figure 9: Cubic interpolation us-ing interp1 to create a regularlyspaced time-series from Equa-tion (42). The circles are theoriginal, irregularly spaced time-series, the stars are the inter-polated, regularly spaced series.The black line is a cubic inter-polant. 0 5 10 15 20 25 30 35 40

−1

−0.5

0

0.5

1

t

q

The function interp1 makes it easy to interpolate from an irregularly spaced series to aregular one. Let’s deal with the series in Equation (42) using Matlab:

>> t = [0 5.3 9.4 16.0 20.1 25.8 31.0 36.8];

>> q = [1.0 0.85 0.55 -0.10 -0.51 -0.90 -0.99 -0.76];

>> treg = [0:5:35];

>> qreg = interp1(t,q,treg,’spline’);

>> plot(t,q,’ok’,’MarkerSize’,6); hold on; grid on;

>> plot(treg,qreg,’*k’,’MarkerSize’,10);

and for plotting a smooth line,>> tsm = linspace(t(1),t(end),1000);

>> qsm = interp1(t,q,tsm,’spline’);

>> plot(tsm,qsm,’-k’); hold off;

The result of this set of commands (with some annotation added) is shown in in Figure 9.

2.3 Analysing a time-series by autocorrelation

As with any data, the most important analysis tool is plotting. Always plot your data and lookat it carefully before you do anything else. This will give you qualitative expectations that willhelp to determine what method of quantitative analysis is best.

Figure 10: Figure 21.2 fromMD illustrating the conceptof a lag in autocorrelation.The lag k increases from k =0 in (a) to k = 3 in (d).For each lag we compute thecorrelation of the overlappingpart of the time-series. Fora series with N entries, thisoverlap has N − k entries.

Page 18: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

18 Mathematical problem-solving for Earth sciences – Hilary term

q

(a)

−1

−0.5

0

0.5

1

r

(b)

q

(c)

−1

−0.5

0

0.5

1

r

(d)

0 100 200 300 400 500

q

(e)

Observation number0 50 100

−1

−0.5

0

0.5

1

r

(f )

Lag, k

Figure 11: Various time-series and their autocorrelation functions. NB. the autocorrelation functionis only shown for lags less than 125 to emphasise the structure near k = 0. (a) A perfectly periodictime-series gives rise to a repeating autocorrelation function in (b). (c) A perfectly random time-seriesgives rise to an autocorrelation function that has rk ≈ 0 for all k > 0, and r0 = 1, shown in (d). (e)A time-series with memory. Each value is related to the previous 10 values, plus a random difference.Notice that the autocorrelation function in panel (f) has r0 = 1, but it also has rk > 0 for k ≤ 10.

Autocorrelation is a means to detect memory in a time-series. Memory refers to the persistentinfluence of an event in a time-series. For example, a breaking news story may cause some stockmarket index to increase suddenly; four days later the index is still higher than usual, but bythe following week, the effect of the news event has disappeared. Autocorrelation helps us todetermine the time-scale of memory.

Autocorrelation involves comparison of a time-series with a shifted version of itself. The shiftMD 21.4is called a lag, which is given by an integer index k. At each lag, we compute the correlationbetween the time-series and the lagged version of the time-series. The concept of a lag isillustrated in Figure 10. Note that this method can only be applied to regularly spaced data!

To normalise the autocorrelation function we must take two factors into account. First, thesize of the autocorrelation for lag k = 0 will increase with the mean and the variation of thetime-series. This makes it difficult to compare the autocorrelation of one time-series with thatof another time-series, which has a different mean and/or variance. To avoid this problem, wereplace the time-series by its Z-score (which you should remember from last term),

Zi =qi − µσ

,

where µ and σ are the mean and standard deviation of the time-series.

The second factor is related to the increasing lag at each step, which means a decreasingoverlap region. This decreasing overlap will bias the autocorrelation to smaller absolute valuesas the lag increases. To account for this bias, we normalise at each lag by the number of time-series entries in the overlapping region, N − k. Accounting for these two considerations gives us

Page 19: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 19

Figure 12: Figures 4-67 and 4-68 from DA. (a) Geometric view of the trigonometric functions. (b) Plotof cos θ over one period of oscillation.

the formula for the autocorrelation as a function of lag,

rk =1

N − kN−k∑i=1

Zi Zi+k. (46)

Using this formula will always give r0 = 1, independent of the time-series that is analysed.The values of r1, r2, r3 and so forth will depend on the details of the time-series, i.e. whetherit displays memory or repetitions. Figure 11 shows three examples of time-series and theirassociated autocorrelation functions (other examples are shown in Figure 21.3 of MD).

2.4 Review of trigonometric functions

In the next three lectures, we will learn about a technique for analysing time-series in termsof their frequency content—the relative amounts of oscillations with different repeat-times thatcompose the time-series.

To do this, we will break down the time-series into a set of trigonometric functions: sinesand cosines. It is therefore essential to have a thorough understanding of these functions beforewe move on. In particular, the key concepts of amplitude, angular frequency, and phase thatare associated with trigonometric functions should be clear in your mind. To that end, we willreview them here.

As a reminder, the two important trigonometric functions we’ll be dealing with are DA pp.266-268

cos θ =X

Vsin θ =

Y

V. (47)

These functions are called trigonometric because they are derived from the geometry of trianglesinscribed in a circle, as shown in Figure 12a. The cosine function represents the extent of thetriangle in the x-direction X, in proportion to the radius V . The sine function represents theextent of the triangle in the y-direction Y , in proportion to the radius. By the geometry of thetriangle within the circle, the maximum value of | sin θ| and | cos θ| cannot be greater than 1.This is evident in Figure 12b.

Furthermore, the argument θ represents an angle, measured counterclockwise from the +x-axis, in radians. One radian is the angle subtended by an arc with arc-length equal to V , theradius of the circle; 2π radians subtends the whole circle.

Page 20: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

20 Mathematical problem-solving for Earth sciences – Hilary term

Now imagine that the radius vector is sweeping around the circle with time, in the coun-terclockwise direction. If it makes one complete revolution every 2π seconds, then we couldwrite

X = V cos t, Y = V sin t, (48)

where t is measured in seconds. From Equation (48) we can see that the maximum value thatX and Y can obtain is V ; this value is termed the amplitude and is often denoted as A.

The radius vector in the previous example goes around the circle every 2π seconds—this isits repeat period, or simply its period. Equivalently, if t actually represented distance along aline in space, then we would refer to 2π as the wavelength of the oscillation. So wavelength andperiod are mathematically identical, though they have different physical units.

We can generalise Equation (48) to any temporal period of oscillation as follows

g(t) = A cos(ωt), (49)

where ω is the angular frequency, the number of radians per second. We can write ω in termsof the period of oscillation T , or the frequency f , as

ω =2π

T= 2πf.

Frequency is often measured in Hertz (Hz, cycles per second). For the special case where T = 2π,we get ω = 1, which is consistent with Equation (48).

Equation (49) can be generalised further: we can shift the oscillation in time, so that insteadof starting at t = 0, it starts at a different time. To do this, we subtract the phase angle (orsimply the phase) φ to give

g(t) = A cos(ωt− φ), (50)

In this form, a cycle begins when t = φ/ω.

The attentive reader will notice that applying a phase of φ = π/2 to the cosine function willturn it into a sine function. This can be made explicit using the trigonometric identity

cos(R− S) = cosS cosR+ sinS sinR

as follows

g(t) = A cos(ωt− φ),

= A cosφ cos(ωt) +A sinφ sin(ωt),

= α cos(ωt) + β sin(ωt).

where α and β are new constants. You will now notice that if φ = π/2, α = 0 and β = A.

Suppose we wish to represent the family of sinusoidal functions that go through an integernumber of oscillations within the period T . These are called harmonics and can be written as

g(t) = cos

(2πr

Tt

), (51)

where r is an integer, often referred to as the harmonic. This function has a period of τ = T/rand is illustrated in Figure 13a for several values of r.

Page 21: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 21

−1

0

1

0 T2

T

cos(2πrt/T )

(a)

0 T2

T

sin(2πrt/T )

(b)

Figure 13: Harmonics of cosine (a) and sine (b) functions for r = 0, 1, 2, 3. Increasing values of rcorrespond to smaller line-width curves.

2.5 Matlab notes

We will make extensive use of trig functions in Matlab in the coming weeks, so it is essentialthat you are familiar with the nomenclature and can link it with calculations. For clarity inwhat follows, I choose variable names corresponding to the variables described above. Note,however, that this will not always be the case; you should recognise these mathematical objectsby their formula or their use, not (only) by the variable name or symbol.

Suppose that we wish to use Matlab to plot the first 10 harmonics of sine over the periodT = 24 hours. We can first create an array of harmonic numbers,

>> r = [1:10];

The period of each harmonic is then computed as>> T = 24;

>> tau = T./r;

The frequency and angular frequency are>> f = 1./tau;

>> omega = 2*pi*f;

To make a plot of the 5th harmonic, we first need to create a variable for the independentcoordinate (time, in this case)

>> t = linspace(0,T,200);

We choose 200 entries to ensure that our plot looks smooth. Now we can compute the functionof interest

>> y = sin(2*pi/tau(5)*t);

and plot it>> plot(t,y,’-k’); xlabel(’Time, hours’); hold on;

We could then plot the other nine harmonics in a similar manner.

Page 22: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

22 Mathematical problem-solving for Earth sciences – Hilary term

3 Fourier Series

In this lecture we’ll learn about how a finite, periodic function can be expressed as a sum ofsine and cosine functions of different amplitudes and frequencies. We’ll learn how to calculateall of the terms of that sum. We’ll be doing only analytical maths in this lecture; no Matlabstuff. None of the main books for this course have good coverage of the material in this lecture.Two books that should be helpful for alternative explanations and going beyond the lectures are

• Seeley, RT; An introduction to Fourier series and integrals, W.A. Benjamin (New York),1996.

• Riley, Hobson, and Bence; Mathematical methods for physics and engineering, CambridgeUniversity Press (Cambridge), 2006.

Both of these are available through the Oxford library system.

3.1 Aside: coordinate systems and orthogonality

We’re familiar with the concept of Cartesian, three dimensional space: any point can be de-scribed as the sum of three independent basis vectors, pointing in each of the three independentdirections,

V = c1e1 + c2e2 + c3e3 =3∑j=1

cjej , (52)

where

e1 =

100

, e2 =

010

, e3 =

001

.The essential property of these basis vectors is that they are mutually orthogonal :

ei · ej =

{1 if i = j,

0 if i 6= j.(53)

For example, basis vector 1 contains no amount of basis vector 2; each basis vector is entirelyindependent of the others. This means that we can determine the y-value of a vector indepen-dently of the x and z-values. Furthermore, any point in Cartesian space has a unique set ofcoordinates. It is therefore true that any vector in Cartesian space can be decomposed into asum of basis vectors, as we did above. To find the, say, x-component of a vector, one need onlytake the dot-product of the vector with the basis vector in the x-direction:

V · e1 = c1.

This is a trivial example, but it demonstrates a concept that is important in understandingFourier series.

It turns out that we can decompose functions in a manner similar to vectors. Just as ageneral vector was decomposed into a set of simpler basis vectors, a function can be decomposedinto a set of basis functions. We’ll see how below.

Page 23: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 23

Figure 14: A square wavewith period T and unitamplitude, as described byEquation (55).

−1

0

1

−T − T2

0 T2

T t

f

3.2 Periodic functions: a general definition

A periodic function is one that repeats, identically, once each period, from −∞ to +∞. If thefunction is denoted by f(t) and the period is T , then the following equation defines a periodicfunction

f(t+ T ) = f(t). (54)

One obvious example of a periodic function is cos t; it has a period of T = 2π, and of coursecos(t) = cos(t+2π), which satisfies Equation (54). Here’s another example of a periodic function:

f(t) =

{−1 for − T/2 ≤ t < 0,

+1 for 0 ≤ t < T/2.(55)

This is called a square wave, and is represented in Figure 14.

3.3 The Fourier series

Amazing but true: any periodic function∗, including the one in Figure 14, can be represented bythe sum of a series of sines and cosines. For a periodic function g(t) with period T , this series is

g(t) = a0 +∞∑r=1

[ar cos

(2πr

Tt

)+ br sin

(2πr

Tt

)]. (56)

Some remarks about this important equation:

• Compare Equation (56) to Equation (52): whereas a vector is composed of different quan-tities of each basis vector, a periodic function is composed of different quantities of eachsine and cosine in the series. The quantities c1, c2, c3 are the coordinates of a point inphysical space. The quantities a0, a1, ... and b1, b2, ... are the coordinates of a function infrequency space.

• The series contains an infinite number of terms; calculating all of them is impractical.Often, we will sum up a large number, but not all the terms. Doing this changes Equa-tion (56) into an approximation, rather than an equality.

• The a0 term in the equation is a constant and represents the mean of the function g(t).Since g is periodic, we can calculate the mean by averaging over one period

a0 =1

T

∫ t0+T

t0

g(t) dt. (57)

∗Terms and conditions apply, see Riley, Hobson, & Bence,Mathematical Methods for Physics and Engineering, Cambridge University Press.

Page 24: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

24 Mathematical problem-solving for Earth sciences – Hilary term

There is no b0 term in the series because sin(0) = 0.

• The coefficients a1, a2, ... and b1, b2, ... are constants to be determined. Fortunately, it ispossible to calculate them, because each term in the series is mutually orthogonal, just aswere the basis vectors in Equation (53):∫ t0+T

t0

cos

(2πr

Tt

)sin

(2πs

Tt

)dt = 0 for all integers r and s, (58)a∫ t0+T

t0

cos

(2πr

Tt

)cos

(2πs

Tt

)dt =

{T/2 for r = s

0 for r 6= s, (58)b

∫ t0+T

t0

sin

(2πr

Tt

)sin

(2πs

Tt

)dt =

{T/2 for r = s

0 for r 6= s. (58)c

These relations indicate that each entry in the series adds a unique contribution thatcannot be obtained by any other entry.

3.4 (NON-EXAMINABLE) Applying the orthogonality conditions

To obtain values for the Fourier coefficients, we need a means to isolate and solve for them. Theorthogonality conditions (58) provide a means. To see this, take Equation (56), multiply bothsides of the equation by, say, cos(2πst/T ), and integrate over one period. This gives∫ t0+T

t0

cos

(2πs

Tt

)g(t) dt =∫ t0+T

t0

cos

(2πs

Tt

){a0 +

∞∑r=1

[ar cos

(2πr

Tt

)+ br sin

(2πr

Tt

)]}dt (59)

Now focus on the right-hand side of Equation (59). We can bring the integral into the summationand write the RHS as

a0

∫ t0+T

t0

cos

(2πs

Tt

)dt+ [term 1]

∞∑r=1

[ar

∫ t0+T

t0

cos

(2πs

Tt

)cos

(2πr

Tt

)dt

]+ [term 2]

∞∑r=1

[br

∫ t0+T

t0

cos

(2πs

Tt

)sin

(2πr

Tt

)dt

]. [term 3]

First consider [term 1]: integrating cosine over a full period (or s full periods) gives zero byinspection. Now [term 3]: orthogonality condition Equation (58)a clearly applies, so this term isalso zero. Finally, consider [term 2]: this matches with orthogonality condition Equation (58)b;this term is only non-zero if r = s. This means that all terms with r 6= s in the summation arezero! We can therefore discard the summation!

Using these three simplifications, we can rewrite Equation (59) as

asT

2=

∫ t0+T

t0

cos

(2πs

Tt

)g(t) dt, (60)

which is a formula for calculating cosine coefficient, as. We can apply a similar method (multiplyeqn. (56) by sin(2πst/T ) and integrate over one period) to obtain the sine coefficients bs.

Page 25: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 25

3.5 Calculating the Fourier coefficients

In the previous section, we used the orthogonality conditions to derive the following formulaefor the coefficients

ar =2

T

∫ t0+T

t0

g(t) cos

(2πr

Tt

)dt, (61)a

br =2

T

∫ t0+T

t0

g(t) sin

(2πr

Tt

)dt. (61)b

(These formulae are examinable).

Equation (61) can be used blindly to compute the coefficients of a Fourier series, but asusual, a bit of care will save us work. This comes from noting that sin is an odd function whilecos is an even function:

sin(−x) = − sin(x), therefore odd,

cos(−x) = cos(x), therefore even.

If the function g(t) is odd, then we can infer that all ar must equal zero, since these are thecoefficients of cos terms, which are even (and therefore couldn’t contribute to an odd function).If g(t) is even, then all br must equal zero.

A recipe for calculating the Fourier series of a periodic function

1. Determine the period T of the function. Choose a starting point t0, usually the beginningof a period of oscillation.

2. Calculate the mean of the function over one period, and assign this value to a0.

3. Ascertain whether the function is even, odd, or neither.

4. Use Equation (61) to calculate the required coefficients depending on your result from theprevious step.

5. Assemble the coefficients with their respective sine and cosine functions and frequencies,and write down the resulting Fourier series.

6. Check your result!

3.6 A worked example

Let’s calculate a Fourier series of the square wave from Figure 14 and Equation (55).

1. By construction, the period of the function is T . Let’s choose t0 = −T/2 because it is thebeginning of a cycle.

2. By inspection of Figure 14, we can see that the mean of this function is zero, and hencea0 = 0.

3. By inspection of Figure 14, we can see that the function is odd. We can therefore takear = 0 for all r > 0.

Page 26: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

26 Mathematical problem-solving for Earth sciences – Hilary term

4. We now use Equation (61) to determine br:

br =2

T

∫ T/2

−T/2g(t) sin

(2πr

Tt

)dt by using Equation (61)b

=2

T

[∫ 0

−T/2(−1) sin

(2πr

Tt

)dt+

∫ T/2

0(1) sin

(2πr

Tt

)dt

]split the integral into two parts

=4

T

∫ T/2

0g(t) sin

(2πr

Tt

)dt by exploiting symmetry about t = 0

=4

T

∫ T/2

0sin

(2πr

Tt

)dt by substituting for g(t)

= − 4

T

(T

2πr

)[cos

(2πr

Tt

)]T/20

by integration

= − 2

πr[cos(πr)− cos(0)] =

2

πr[1− (−1)r] by algebra

=

{4πr for r odd,

0 for r even.by splitting into cases

5. Hence we can assemble the Fourier series as

g(t) =4

π

[sin(ωt) +

sin(3ωt)

3+

sin(5ωt)

5+ ...

],

where ω = 2π/T is the angular frequency.

6. To check our work we plot the solution in Figure 15.

3.7 Fourier series of discontinuous functions

While it is possible to find the Fourier series of discontinuous functions (we did so in the exampleabove), the series will always “overshoot” the function at the discontinuities. Such overshoot isevident in Figure 15. It is called the Gibb’s phenomenon, and it does not disappear no matterhow many terms we of the series that we sum. For functions without discontinuities the Fourierseries generally does not have any problems.

Page 27: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 27

−1

−0.5

0

0.5

1 (a) 1

−1

−T /2

T /2

(b) 1

−1

−T /2

T /2

−1 −0.5 0 0.5 1

−1

−0.5

0

0.5

1 (c) 1

−1

−T /2

T /2

−1 −0.5 0 0.5 1

(d) 1

−1

−T /2

T /2

Figure 15: The convergence of a Fourier series expansion of a square-wave function, including (a) one term(r = 1), (b) two terms (r = 1, 3), (c) three terms (r = 1, 3, 5), (d) twenty terms (r = 1, 3, 5, 7, ..., 39).

Page 28: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

28 Mathematical problem-solving for Earth sciences – Hilary term

4 Discrete Fourier Series and Power Spectra I

In this lecture We learn about how the same concepts that were used to develop the Fourierseries can be applied to the analysis of time-series data. We’ll also learn how the resulting seriescan be converted into a spectrum, a useful plot that can give fundamental information aboutthe processes that are reflected in the time-series.

4.1 From time-series to radian-seriesDA pp.268–272 Let’s consider a time-series y consisting of N observations, with an equal spacing in time ∆t,

starting from time zero (if our time-series were not equally spaced, we could use interpolationto obtain an equally spaced series that represents the data). Our goal is to somehow apply tothis time-series a Fourier analysis like what we saw in the last lecture.

We can represent the time-series as

y = y0, y1, y2, y3, ... yN−1,

t = t0, t1, t2, t3, ... tN−1.

Furthermore, since we wish to apply Fourier analysis, we must make a periodic extension ofthe series, to turn it into a periodic function of time that extends from −∞ to +∞ (analogousto our periodic functions from the last lecture). This means that stepping past the end of ourtime-series should take us back to the beginning; we have wrapped the time-series around acircle, as shown in Figure 16.

t0

t1

t2t3

t4

t5

t6t7

t8

←tim

e

θ1

Figure 16: A time-series with N = 9 en-tries wrapped around a circle, making itperiodic. Each time tj corresponds to aangle θj .

The time-series shown in Figure 16 has N = 9 entries. The total time to complete the triparound the circle and arrive back at the initial point is period T = N∆t. This motivates us toconvert the time-series into radians as follows

θj =2πtjT

.

Since our entries are regularly spaced in time, we can substitute tj = j∆t, as well as our definitionfor the period T to obtain

θj =2πj

N(62)

and we can rewrite our time-series as

y = y0, y1, y2, y3, ... yN−1,

θ = θ0, θ1, θ2, θ3, ... θN−1.

Page 29: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 29

Here we have replaced the time-coordinate of our series with a corresponding angle in radians,such that the series becomes periodic. By construction θ0 = 0 and θN = 2π. This makes itamenable to Fourier analysis.

4.2 Discrete Fourier series

We now posit a new type of Fourier series that decomposes a discrete rather than continuoussignal. Instead of a periodic function, we’re going to analyse a series of discrete points in atime-series. Similar to Equation (56), we use the equation

y =∑k

[αk cos(kθ) + βk sin(kθ)] (63)

to represent the discrete Fourier series. As before, αk and βk are unknown coefficients, and kis an integer, called the harmonic number. For k = 0, the sine term drops out and the cosineterm becomes a constant α0; this is the mean of the time-series. We can substitute our discretevalues of θ from Equation (62) to obtain

yj =∑k

[αk cos

(2πk

Nj

)+ βk sin

(2πk

Nj

)]. (64)

Here the integer index j has replaced time t as the independent variable. The angular frequency2πk/N has replaced ω.

For the series represented by Equation (64), there are always an odd number of unknowncoefficients. This can be seen by considering that the unknown coefficients of the series comein pairs (αk, βk) except for at k = 0, where there is only one coefficient, α0. To solve for theunknown coefficients, we must have an equal number of data points in our time-series; hence Nmust be odd∗. We can accommodate this by interpolation, or by simply dropping the last entrybefore analysing the series.

The sine and cosine oscillations with k = 1 represent the longest period that we can resolvein our analysis of the time-series. In fact, they represent the oscillations with discrete period N ,which correspond to period T .

At larger harmonic number k, the frequency of the corresponding oscillation grows (in otherwords, the period shrinks). What is the largest frequency (smallest period) that can be resolved?Equivalently, what is the maximum harmonic number k in the summation in Equation (64)?Think back to what you learned about aliasing in problem 4 of Laboratory 5 from this term:to represent an oscillation, you need to sample it at least twice per period. This means that fora given sampling rate ∆t, the smallest period that you can hope to capture is the one with aTmin = 2∆t, corresponding to a harmonic number kmax = N/2. This value of k is known as theNyquist frequency ; it is the largest frequency that we can resolve in a time-series. In practise,for N odd, the best we can do is Tmin = 2∆tN/(N − 1) or

kmax =N − 1

2.

Using these limits on k, we can rewrite Equation (64) as

yj = α0 +

N−12∑

k=1

[αk cos

(2πk

Nj

)+ βk sin

(2πk

Nj

)], (65)

for j going from 0 to N − 1.

∗A modified version of Equation (64) can be used to compute the discrete Fourier series of a time-series withN even. We will not consider that modification here.

Page 30: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

30 Mathematical problem-solving for Earth sciences – Hilary term

4.3 (NON-EXAMINABLE) Determining the coefficients of the DiscreteFourier series

To make Equation (65) useful, we need to solve for the coefficients αk and βk. This can bedone in a way that is analogous to our approach from the previous lecture on continuous Fourierseries, except that we replace integration with matrix multiplication.

The first step is to rewrite Equation (65) in matrix–vector notation. We already know thaty is a vector composed of its entries

y = [y0, y1, ... yN−1]′ (66)

where the ′ symbol indicates to take the transpose (giving a column vector). Each of our sineand cosine oscillations is also a vector, and can be written in the same way, for a single value ofk,

Ck =

[cos

(2πk

N0

), cos

(2πk

N1

), ... cos

(2πk

N(N − 1)

)]′, (67)a

Sk =

[sin

(2πk

N0

), sin

(2πk

N1

), ... sin

(2πk

N(N − 1)

)]′. (67)b

We can combine these two vectors into a N × 2 (read: N rows by 2 columns) matrix,

Zk = [Ck, Sk]. (68)

There are (N − 1)/2 of these Zk matrices: one for each value of k. There is also one pair ofcoefficients, αk and βk for each value of k. These become a two-component column vector:

Gk = [αk, βk]′. (69)

We can combine Equation (66), Equation (68), and Equation (69) to rewrite Equation (65)as follows:

y = α0 +

N−12∑

k=1

ZkGk, (70)

or, equivalently,y0y1...

yN−1

=

α0

α0...α0

+

N−12∑

k=1

cos(2πkN 0

)sin(2πkN 0

)cos(2πkN 1

)sin(2πkN 1

)...

...

cos(2πkN (N − 1)

)sin(2πkN (N − 1)

)[αkβk

]. (71)

The second step is to recognise the orthogonality condition:

2

NCk · Sl = 0 for all k and l

2

NCk ·Cl =

{1 for k = l,

0 for k 6= l,

2

NSk · Sl =

{1 for k = l,

0 for k 6= l,

Page 31: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 31

Or, more usefully,

2

NZ′k Zl =

[1 0

0 1

]= I for k = l,[

0 0

0 0

]for k 6= l.

(72)

This means that each of the Zk is orthogonal to all of the others; hence each coefficient codesfor a unique contribution that is independent of all the other contributions.

We can now use Equation (72) to isolate and solve for our coefficients by multiplying thewhole equation by 2

NZ′l

2

NZ′l (y− α0) =

2

NZ′l

N−12∑

k=1

ZkGk,

=

N−12∑

k=1

(2

NZ′l Zk

)Gk,

= IGl = Gl.

And so we have derived an equation for each pair of coefficients,[αlβl

]=

2

NZ′l (y− α0). (73)

With this equation, we can compute the values of the coefficients, and hence fully determine thediscrete Fourier series.

4.4 Putting it together to compute the discrete Fourier series

The following Matlab function implements the calculation in Equation (73). (Note that it usesa data structure F to return the result; a data structure is simply a bundle of variables).

function F = dfs(Y);

% DFS Discrete Fourier series

% DFS(Y) computes the Discrete Fourier series of an input

% time-series Y. Y must be a vector with a length N that

% is greater than 1 and odd in number. F=DFS(Y) returns a

% structure F as follows:

% F.alpha0 = mean of the time-series

% F.alpha = coefficients of cosine terms for k=1:(N-1)/2

% F.beta = coefficients of the sine terms for k=1:(N-1)/2

% F.power = normalised power-spectrum of the time-series

% Check length of time-series. Must be odd and longer than 1

N = length(Y);

if (mod(N,2)==0 || N==1)

error('Input vector must have length greater than 1 and ODD.');

end

% Ensure that Y is a column vector

[rows cols] = size(Y);

Page 32: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

32 Mathematical problem-solving for Earth sciences – Hilary term

if rows==1; Y = Y'; end

% Create index of time-series entries

j = 0:N-1;

% Calculate the coefficients at each frequency

for k=1:(N-1)/2;

C = cos(2*pi*j*k/N);

S = sin(2*pi*j*k/N);

Z = [C', S'];

G(:,k) = (2/N) * Z' * (Y - mean(Y));

end

% Assemble structure containing results

F.alpha0 = mean(Y);

F.alpha = G(1,:);

F.beta = G(2,:);

F.power = 0.5*(F.alpha.^2 + F.beta.^2)/var(Y);

You can download this function, called dfs.m, from http://www.earth.ox.ac.uk/

~richardk/teaching/SYM/.

Try using it on synthetic time-series. For example, try>> t = linspace(0,2*pi,1002);

>> y = 2*cos(3*t) + 3*sin(t);

>> y = y(1:end-1); % shorten to an odd number of points

>> F = dfs(y);

Now guess which values of αk and βk are non-zero. You can check your guess by entering>> semilogx(F.alpha,’-or’); hold on;

>> semilogx(F.beta,’-xb’); hold off;

The function semilogx makes a plot with a logarithmic x-scale (which spreads out the first fewvalues and makes them easier to identify).

Question: Given the result F from the function dfs, reconstruct the time-series values and findthe mean difference between the original time-series and the reconstructed one.

4.5 The variance spectrum

The frequency of the oscillators in the discrete Fourier series depends on the integer k. For thesame value of k, both the sine and cosine terms have the same frequency. Having both sineand cosine allows us to resolve the phase of the original signal. In many cases however, we’reonly interested in the spectrum of the time-series: what amount of variance comes from eachfrequency? This is given by

σ2k =α2k + β2k

2.

This can be normalised by the total variance of the time-series as

σ2k =α2k + β2k2σ2

, (74)

where σ2 is the variance of the time-series y. In electrical engineering, the power of an electricalsignal is proportional to its variance, so σ2k is often called the power, and a plot of its values is

Page 33: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 33

0 1 2 3 4 5 6 7 8 9 10−100

−50

0

50

100

t, years

y,

Watt

s

(a)

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.60

0.2

0.4

0.6

0.8

Frequency, yr−1

Norm

ali

sed

vari

ance

(b)

Figure 17: (a) Synthetic time-series and (b) normalised variance (power) spectrum.

called a power spectrum†. The variance or power spectrum is an extremely important tool inthe observational sciences!

Note that in the last line of the function dfs, the power spectrum is calculated according toEquation (74).

4.6 Worked examples

Let’s first consider an example with a synthetic time-series with known frequency content. Firstwe construct the synthetic time-series:

>> T = 10; % total duration, years

>> A1 = 33; % watts

>> A2 = 75; % watts

>> f1 = 4/T; % 1/years

>> f2 = 13/T; % 1/years

>> t = linspace(0,T,2002);

>> y = A1*sin(2*pi*f1*t) + A2*sin(2*pi*f2*t);

>> plot(t,y,’-k’);

>> xlabel(’Time, years’); ylabel(’Watts’);

Now we analyse the time-series, noting that we should first strip off the last data-point sothat our series is periodic and has an odd number of entries:

>> y = y(1:end-1);

>> F = dfs(y);

Lastly, we produce our variance spectrum, calculating the frequency values that go on thex-axis:

>> N = length(y);

>> k = 1:(N-1)/2;

>> freq = k/T;

>> plot(freq(1:16),F.power(1:16),’-ok’); % Just plot first 16

>> xlabel(’Frequency, 1/year’); ylabel(’Normalised variance’);

†This is a plot with many names. It is sometimes called a periodogram, or a variogram.

Page 34: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

34 Mathematical problem-solving for Earth sciences – Hilary term

20 40 60 80 100 120 140 160 180 2000

200

400

600

800(a)

Month number

Runoff

,10−

2in

100

101

102

0

0.2

0.4

Period, months

Norm

ali

sed

vari

ance

(b)12 months1/Nyquist 18 years

Figure 18: (a) Observed runoff at Cave Creek, and (b) normalised variance (power) spectrum. Theshortest period, the 12-month, and the longest period oscillations are labelled.

A plot of the time-series and frequency spectrum are shown in Figure 17.

As a second example, let’s work with some real data: an 18-year record of total monthlyrunoff of Cave Creek, in Kentucky, France‡. The data are given in hundredths of an inch.Figure 18a is a plot of the time-series. Over the 18 years of recordings, there are about 18 peaks;this suggests that the runoff peak occurs annually, which makes sense. Let’s analyse the data.

Assuming that the data has been loaded and the time-series vector is called runoff,>> N = length(runoff); % check that N is odd!

>> F = dfs(runoff);

>> T = 18*12+1; % total duration, months

>> k = 1:(N-1)/2; % harmonic number

>> per = T./k; % periods

>> semilogx(per,F.power,’-ok’,’LineWidth’,1.5,’MarkerSize’,5);

>> xlabel(’Period, months’); ylabel(’Normalised variance’);

The resulting plot is shown in Figure 18b. Note that in this case, we have plotted the normalisedvariance against the period of oscillation, rather than the frequency. This sometimes makes thegraph easier to understand. Just as we anticipated, most of the power in the signal is in the12-month oscillation.

‡Actually, there are 18 years plus 1 month of data in this series. Why the extra month? Download the datafrom http://www.earth.ox.ac.uk/~richardk/teaching/SYM/CaveCreekData.txt

Page 35: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 35

5 Discrete Fourier Series and Spectra II

In this lecture First, we’ll reflect on the meaning of a spectrum via an analogy to light passingthrough a prism. We’ll then consider a special consideration when calculating the discrete Fourierseries for time-series data. We’ll then introduce the concept of a Fourier transform and learnabout the built-in functionality of Matlab for Fourier analysis.

5.1 What is a spectrum?

In trying to get a feeling for the meaning of a spectrum, it is helpful to consider what happensto visible light as it goes through a prism. Figure 19 shows electromagnetic waves of white lightincident on a prism from the right. The prism bends different frequencies of electromagneticoscillations to different extents, and hence separates the white light into its components. Theintensity of each band of colour in the spectrum corresponds to the contribution of that frequencyto the white light. This is a good analogy for the variance or power spectrum: a plot of thecontribution to the total signal as a function of frequency (or period, or harmonic number, etc).

Figure 19: (Fig. 4.75 from DA). Aprism acts as a frequency analyser,transforming the incident whitelight (time or spatial view) intoits constituent spectrum of colours(frequency view). The intensity ofeach colour in the frequency viewis analogous to the amplitude in avariance (power) spectrum.

5.2 Detrending

So far, we’ve applied Fourier analysis to time-series that are stationary : they have a mean thatis roughly constant with time, if one averages over the observed oscillations. This is not true ofall time-series. Some have a trend, as well as periodic and random components. Let’s consideran example of a synthetic time-series.

>> T = 100; % years

>> N = 1001; % data points

>> t = linspace(0,T,N+1);

>> y = 2*cos(2*pi*t*5/T)+sin(2*pi*t*12/T)+8*t/T+0.4*randn(size(t));

Our time-series y, shown in Figure 20a, has four components:

1. 2*cos(2*pi*t*5/T) is a cosine component with amplitude 2 and period T/5 = 20 years.We therefore expect α5 = 2.

2. sin(2*pi*t*12/T) is a sine component with unit amplitude and period 100/12. Weexpect β12 = 1.

3. 8*t/T is the trend in the dataset. The time-series has a mean slope of 8/100.

4. 0.4*randn(size(t)) is a normally-distributed random (noise) component with amplitude0.4 (see help randn for details).

Page 36: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

36 Mathematical problem-solving for Earth sciences – Hilary term

0 10 20 30 40 50 60 70 80 90 100−5

0

5

10

15

Time, years

Am

pli

tude

(a)

100

101

102

−3

−2

−1

0

1

2

3

Harmonic number, k

Coef.

am

pli

tude (b) αk

βk

100

101

102

0

1

2

3

Harmonic number, k

Coef.

am

pli

tude

αk

βk

(c)

Figure 20: (a) Synthetictime-series with two peri-odic components, a trend,and a random component.(b) Amplitude spectrumfrom the discrete Fourierseries of the raw time-series, showing αk (circles)and βk, (crosses). Har-monic numbers 5 and 12are marked with verticaldotted lines. (c) Ampli-tude spectrum of the de-trended time-series.

We then calculate and plot the discrete Fourier series,>> F = dfs(y(1:end-1));

>> k = [1:(N-1)/2];

>> semilogx(k,F.alpha,’-ok’); hold on;

>> semilogx(k,F.beta,’-xk’);

>> plot([5 5],[-3 3],’:k’,[12 12],[-3 3],’:k’); hold off;

>> xlabel(’Harmonic number’); ylabel(’Coef. amplitude’);

This amplitude spectrum is shown in Figure 20b. Note that the values of of αk are as expected:close to zero with a spike at k = 5 to about 2 (the random noise causes slight variations fromzero). The values of βk are not as expected, however. Although we see the expected spike atk = 12, the values are below zero for smaller values of k. This downward curve is a consequenceof the trend in the time-series; remember that to compute the discrete Fourier series, we assumedthat the time-series is periodic. The trend pollutes the Fourier coefficients with deviations fromzero that are unrelated to oscillations in the Fourier series. To avoid this problem, it is oftennecessary to detrend a time-series before analysing. This means determining the linear (ornon-linear) trend of the data-series and subtracting it from the raw data.

Let’s detrend the data and try the Fourier analysis again. In this case, we know the lineartrend in the data, so we can subtract it off directly; normally, if you had a measured time-series,you’d need to regress the series to find the best-fitting trend, and then subtract that trend off.

>> ydt = y - 8/T*t;

>> Fdt = dfs(ydt(1:end-1));

>> semilogx(k,Fdt.alpha,’-ok’); hold on;

Page 37: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 37

>> semilogx(k,Fdt.beta,’-xk’);

A plot of the coefficients of the discrete Fourier series of the detrended time-series is shown inFigure 20c. Note that the spurious depression of the sine coefficients has been eliminated.

5.2.1 Removing nonlinear trends

Figure 21: A synthetictime-series with a nonlin-ear trend. Note that thedotted line, which is thebest fit for a first orderpolynomial, is a still a poorfit to the trend in thedata, while the second or-der (quadratic) polynomialcaptures the trend well. Time, years

0 20 40 60 80 100

Am

plitu

de

-15

-10

-5

0

5

Time-seriesLinear -t: y = p1t + p2

Quadratic -t: y = q1t2 + q2t + q3

Trends in time-series are not always linear. Sometimes they have obvious curvature, whichcannot be accommodated by a best fitting straight line. Let’s consider another synthetic time-series as an example, as shown in Figure 21. In this figure, the best-fitting straight line clearlydoes not fit the data. However, the best-fitting quadratic polynomial fits the data very well.Both of these lines were calculated using the Matlab built-in function polyfit. Here’s howit works (assuming that we have a vector of times t and a vector of data y, both of the samelength):

>> p = polyfit(t,y,1)

where 1 indicates that we want to use a polynomial of degree one, i.e. y = p1t + p2, where p1and p2 are constants to be determined by Matlab. This function returns

p =

-0.1359 3.0590

which are the constants p1 and p2 of our linear (degree one) polynomial. We can use the samefunction to obtain the coefficients of a best-fitting quadratic polynomial,

>> q = polyfit(t,y,2)

q =

-0.0022 0.0840 -0.6033

Matlab computes the coefficients of these polynomials using a linear least squared error algo-rithm, that is very similar to what you studied at the end of last term. It is very easy to makea plot like the one in Figure 21:

>> plot(t, y, ’-k’); hold on;

>> plot(t, p(1)*t + p(2), ’:k’);

>> plot(t, q(1)*t.^2 + q(2)*t + q(3), ’--k’); hold off;

Wonderful! We could easily plot a detrended version of the data by saying>> plot(t, y - (q(1)*t.^2 + q(2)*t + q(3)), ’-k’);

What order of polynomial should you use? The higher the order, the closer the fit to the time-series. But higher order polynomials also have more “wiggles,” and it is exactly these wiggles

Page 38: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

38 Mathematical problem-solving for Earth sciences – Hilary term

that spectral analysis seeks to quantify. So a good policy is to use lowest order polynomial thateffectively captures the trend without capturing the wiggles that you are interested in. This issomewhat subjective!

5.3 (NON-EXAMINABLE) The Fourier transform and its discrete version

Fourier transforms are closely related to Fourier series, but take a mathematical approach that ismore complicated in order to achieve greater generality of usage. For example, Fourier transformscan be used on non-periodic functions. You can think of a non-periodic function as a periodicfunction where the period has gone to infinity. In this limit, the summation over frequenciesthat appears in Equation (56) becomes an integral, and we have

f(t) =1

∫ +∞

−∞eiωtF (ω) dω, (75)a

F (ω) =

∫ +∞

−∞e−iωtf(t) dt, (75)b

where F (ω) is the Fourier transform of the function f(t). Equation (75)a reconstructs the func-tion in the time-domain from its Fourier transform, and hence corresponds with Equation (56),while Equation (75)b corresponds to recipe for calculating the Fourier series coefficients, Equa-tion (61).

The mathematics of the Fourier transform is beyond the scope of this course, but we canmake a couple of remarks about Equation (75).

• The Fourier transform replaces the integer harmonic number k with a continuous angularfrequency ω.

• It replaces the pair of coefficients αk and βk with a complex function F . Recalling Euler’sformula

eiθ = cos θ + i sin θ,

we can see that the real part of F corresponds to the coefficients of the cosine terms α,while the imaginary part of F corresponds to the coefficients of the sine terms β.

Like the Fourier series, the Fourier transform can be applied to analytical functions, not totime-series data. To analyse discrete time-series data, we need the discrete version of the Fourierseries.

The discrete Fourier transform is the method of spectral analysis that is preferred by mostscientists, and it is the method that is built into Matlab. It is therefore a goal of this courseto make it familiar to you on a practical level.

Suppose that you have a time-series y composed of N observations, equally spaced in timeand covering a total time T . To analyse this we use a discrete version of Equation (75)b, weconvert the integral back into a sum to give

Yk =N∑n=1

yn exp

[−2πi(k − 1)

n− 1

N

], 1 ≤ k ≤ N, (76)

where n is an index of the observations in the time-series and k is the integer harmonic number.Yk are the entries in a vector of complex numbers, where

αk = Real(Yk), (77)

βk = −Imag(Yk). (78)

Page 39: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 39

You may wonder why k goes from 1 to N in Equation (76), whereas in the discrete Fourierseries it went from 1 to the Nyquist frequency at (N − 1)/2. The harmonics for k greater thanthe Nyquist frequency are image frequencies, and are actually duplicates of the regular set. Fortechnical reasons, it is easier to compute this complete series and discard the image frequencies;this is what Matlab does.

5.4 Using Matlab’s fft function

It should come as no surprise that Matlab has a built-in function to do spectral analysis. Thisfunction is called fft, which is an abbreviation of “Fast Fourier transform”. fft is a rathercomplicated tool. It performs a discrete Fourier transform as described in the previous section,and returns a set of complex coefficients that has the same length as the input time-series. Forexample

>> y = rand([1 100]);

>> Y = fft(y);

>> length(Y)

ans =

100

More details about fft can be obtained using help.

What we seek here is a means to convert the output of fft into something we understand: theoutput of dfs. The following Matlab function achieves this∗, and demonstrates the relationshipbetween Matlab’s fft and the discrete Fourier series.

function F = dft(y)

% DFT Discrete Fourier transform

% DFT(Y) computes the Discrete Fourier transform of an input

% time-series Y. F=DFT(Y) uses the built-in FFT and returns a

% structure F as follows:

% F.alpha0 = mean of the time-series

% F.alpha = coefficients of cosine terms for k=1:Nyquist

% F.beta = coefficients of the sine terms for k=1:Nyquist

% F.power = normalised power-spectrum of the time-series

%1. Compute the discrete Fourier transform using Matlab's fft

G = fft(y);

%2. Determine and select the unique entries

N = length(y);

Nu = ceil((N+1)/2);

G = G(1:Nu);

%3. Scale value appropriately and assemble output structure

F.alpha0 = real(G(1))/N;

F.alpha = 2*real(G(2:end))/N;

F.beta = -2*imag(G(2:end))/N;

F.power = 0.5*(F.alpha.^2 + F.beta.^2)/var(y);

Let’s examine this function in terms of its three steps:

∗For a more thorough discussion, see http://www.mathworks.com/support/tech-notes/1700/1702.html.

Page 40: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

40 Mathematical problem-solving for Earth sciences – Hilary term

220 440 660 880FREQUENCY (Hz)

Figure 22: Variance spec-trum of the sound pro-duced by a plucked guitarstring. Grey lines are in-dividual instances; heavyblack line is the averageof six instances. Adaptedfrom report by M. Owen.

1. Apply fft to the data-series. The fft function works regardless of the length (even orodd) of the input time-series y.

2. Extract only the fft coefficients that are unique. This means discarding the second halfof the entries, which correspond to the image frequencies. Since N can be even or odd, wemust use rounding to ensure that Nu is an integer; ceil rounds upward, which is correctfor any value of N. We then restrict Y to the desired set of values.

3. Scale the results appropriately, so that they are independent of time-series length, andconsistent with the results of dfs.

5.5 Spectra, waves, and the Earth

Fourier analysis decomposes a signal into a set of oscillations, and represents the relative con-tributions of those oscillations on a spectrum plot. One of the most commonly encounteredoscillations is a vibration: the oscillatory physical motion of a material. Because vibrations areinherently periodic, they are amenable to Fourier analysis.

Consider the vibration of a guitar string. The averaged Fourier spectrum of a pluckedstring is shown in Figure 22. Note the regular peaks in power at multiples of the fundamentalfrequency, which in this case is 110 Hz. The fundamental frequency has the most power (i.e. itis the loudest), but the vibrations at higher frequency contribute substantially to the sound,while vibrations at frequencies between the peaks are relatively quiet. These regular peaks atfrequencies that are multiples of the fundamental frequency are known as overtones, and theircontribution is what gives a musical instrument its unique sound.

Figure 23: Normal modes of a vibrating string that is fixed at its ends. The fundamental mode has thelongest wavelength, equal to twice the length of the string, and can be written as y(x, t) = A(t) sin (πx/L),where L is the length of the string. The others are described by y(x, t) = A(t) sin (nπx/L) for n = 2, 3, ...

Page 41: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 41

Where do overtones come from? They are associated with a particular set of oscillationsthat have a spatial structure that is unchanging with time, and goes to zero at the fixed end-points. Hence they are sometimes called standing waves. Of course, since they are vibrations,the displacement of the string must change with time; this can be accommodated with a time-dependent amplitude

y(x, t) = A(t) sin (nπx/L) = A0 sin(ωnt) sin (nπx/L) , (79)

where A0 is a constant amplitude, L is the length of the string, and n is an integer. Suchoscillations are also known as the normal modes of the string. The wavenumber of each modeis defined as

κn =nπ

L;

n = 1 corresponds to the fundamental mode, and oscillations with n > 1 are overtones.

As we will learn next term when we consider the physics of waves, there is a physical rela-tionship between the angular frequency of oscillation for each normal mode ωn and the modenumber n. This relationship is expressed mathematically as

ωn = cκn =cnπ

L, (80)

where c is a constant, and a property of the string. Examining the spectrum shown in Figure 22,we can identify the n = 2 mode with 220 Hz. We then expect the fundamental mode at 110 Hz,and the n = 4 mode at 440 Hz. The observations bear this out.

(a) (b) (c) (d)

Figure 24: Four normal modes of a vibrating hoop. The dashed circle shows the undeformed hoop.

Any finite vibrating object can possess a set of normal modes. Consider, for example, a hoopas shown in Figure 24. This is different from the string in that its ends are not fixed, but ratherit “bites its own tail;” hence the radial displacement of the hoop must be periodic around thehoop with period 2π. With a little imagination, you can generalise from a hoop to a sphericalshell, or a solid sphere, or even to the Earth! Just as for the spectral analysis of the soundproduced by the vibrating guitar string, spectral analysis of a carefully recorded seismogramreveals the so-called free oscillations of the Earth. Figure 25 is an example of the spectrum offree oscillations recorded after the great Sumatra-Andaman earthquake of December 2004.

Page 42: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

42 Mathematical problem-solving for Earth sciences – Hilary term

Figure 25: A spectrum of the normal modes of the Earth, also known as free oscillations. The modeslabelled S are spheroidal modes, where the displacement is toward or away from the centre of the Earth.The modes labelled T are toroidal modes, which involve displacements that are tangential to the surfaceof the Earth. This spectrum was produced by a Fourier analysis of the free oscillations excited during thegreat Sumatra-Andaman earthquake of December 2004. (Figure credit Jeffrey Parks, Yale University).

Page 43: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 43

6 Box models

In this lecture we’ll consider a class of models called box models. Box models are concernedwith interconnected reservoirs and the exchange of material between them. Think of a series oflakes of different size, connected by rivers. How do the composition of the waters in downstreamlakes evolve if pollution is dumped into an upstream lake? Box models give us a simple way toaddress that question.

6.1 A one-box model

M

F1

F2

F3

F4

Figure 26: A one-box model of a reservoir with flows in and out.

The basic unit of box models is a single box with input and output flows and so we’ll considerit first. Figure 26 shows an example. Let’s suppose that the box or reservoir represents a lakecontaining a mass of water M . There are three streams flowing into the lake; each is labeledwith the rate of flow Fi in units of mass per time; there is one stream flowing out of the lakewith flow rate F4 in units of mass per time.

What is the value of M? It could change with time or it could be constant, depending on therelative sizes of the flows and the initial value of M . We can obtain an equation by consideringthe principle of conservation of mass: mass cannot be created or destroyed. Hence the massthat flows into the reservoir increases the mass content of the reservoir; the mass that flows outdecreases it. We express this as

dM

dt= F1 + F2 + F3 − F4, (81)

where all flow rates are positive: Fi > 0. Note that F1, F2 and F3 cause M to increase withtime, while F4 causes M to decrease. The rate of change of M then depends on the net flow.In the special case that F4 = F1 + F2 + F3, the mass contained in the reservoir is unchanging,dM/dt = 0, and we say that the reservoir is in steady state.

Perhaps one of the streams (say number 3) flowing into the reservoir contains a pollutant withconcentration [P3] (units of mass pollutant per mass of solution). We can write a conservationof mass equation for pollutant that will allow us to track the level of pollution in the reservoir[PR]. The rate of flow of pollutant is given by Fi[Pi]. Pollution comes into the reservoir only instream three, and so we can write

d(M [PR])

dt= F3[P3]− F4[P4]. (82)

The rate of change of the pollution content of the reservoir is equal to the net flow of pollutant.If the mass of the reservoir is in steady state then M = const. and F4 = F1 + F2 + F3; we have

d([PR])

dt= (F3[P3]− F4[P4])/M. (83)

At this point we make an important assumption that is typical of box models: we assumeperfect, instantaneous mixing in the reservoir. This means that as pollution flows in through

Page 44: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

44 Mathematical problem-solving for Earth sciences – Hilary term

stream 3, the atoms of pollutant in that flow are immediately distributed uniformly over thereservoir. Under this assumption, the concentration in the outflow from the reservoir is equalto the concentration of the reservoir itself:

[P4] = [PR], (84)

and hence we can writed[PR]

dt= (F3[P3]− F4[PR])/M. (85)

In steady state, we can solve for the concentration of the reservoir directly:

[PR] =F3

F4[P3]. (86)

This is a useful result. It tells us the level of pollution that will eventually be reached in thelake is linearly related to the concentration in the incoming stream.

Consider the case where at t = 0, the reservoir is pristine and a constant concentration ofpollution appears in stream 3. This is clearly NOT a steady-state problem. We need to solvefor the time-dependent concentration of pollution in the reservoir. To tackle this, it is helpfulto rewrite equation (85) as

dp

dt= f1 − f2p, (87)

where p = [PR], f1 = F3[P3]/M , and f2 = F4/M . Using techniques for ODE integration learnedin first-year mathematics, we can find the solution as

p(t) = c e−f2t + f1/f2, (88)

or

[PR] = c e−F4t/M +F3

F4[P3]. (89)

We can see immediately that this has the correct long-term behaviour: when t → ∞, [PR] →F3[P3]/F4. To determine the value of the constant of integration c, we use the initial condition,which says that the reservoir concentration is zero at t = 0. This gives c = −F3[P3]/F4 andhence

[PR] =F3

F4[P3]

(1− e−F4t/M

). (90)

6.2 Residence time

How long does an atom of pollution remain in the lake before it gets flushed out through theoutflow stream? Of course there will be a distribution of such times due to the chaotic nature ofmixing. We are interested, however, in a characteristic time that the atom resides in the lake:this is the residence time. The residence time is defined, in steady state, as

τ =amount in reservoir

rate of input to reservoir=

amount in reservoir

rate of output from reservoir. (91)

It is essential to remember that the residence time only applies when the system is in steadystate. If the system is evolving, then so is the mean time that an atom remains in the reservoir.

Let’s apply equation (91) to the box model of a lake with polluted inflow, above. At steadystate, the amount of pollution in the reservoir is M(F3[P3]/F4) (recall eqn. (86)), while theinflow rate is [P3]F3. Hence we have

τ =M

F4. (92)

Page 45: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 45

Note that this constant, with units of time, depends only on the mass of water in the reservoirand the rate of mass flow out of the reservoir. It does not depend on the concentration of thepollutant.

Also note that equation (90) can be rewritten as

[PR] =F3

F4[P3]

(1− e−t/τ

), (93)

where we have substituted from (92). The residence time sets the time-scale of decay towardthe steady state concentration.

6.3 A two-box model

F1

F2

F3

F4

F5

F6MA MB

Figure 27: A two-box model of reservoirs A and B, with flows in and out.

As a step toward more general, multi-box models, we next consider a two-box model, asshown in Figure 27. In this case, we have coupled our one-box model from Figure 26 to anadditional box, representing another lake. The new lake is downstream from the first lake, andis connected to it by a stream. It also has an independent, inflowing stream with flow rate F5.Of course the system also requires an outflow from the second lake.

We’ll assume that the masses of water in the lakes MA and MB are in steady state and focuson the concentrations. Consider the time-dependent case, represented by equations for each ofthe lakes:

MAd[PA]

dt= F1[P1] + F2[P2] + F3[P3]− F4[PA], (94)a

MBd[PB]

dt= F4[PA] + F5[P5]− F6[PB]. (94)b

Here we have again assumed that the lakes are well mixed and so the concentration in a streamflowing out of a lake has the same concentration of pollutant as the lake it drains. A simplerrepresentation of these equations is

yA = c1 − c2yA, (95)a

yB = c3 + c4yA − c5yB, (95)b

where a dot above a variable indicates the time-derivative of that variable, and we have defined:yA = [PA], yB = [PB], c1 = (F1[P1] + F2[P2] + F3[P3])/MA, c2 = F4/MA, c3 = F5[P5]/MB,c4 = F4/MB and c5 = F6/MB. This is a system of coupled, linear, ordinary differential equations.

Equation (95)a models the evolution of the concentration in lake A. Note that this equation isindependent of the concentration of lake B—specifically, the variable yB doesn’t appear in (95)a.This is because lake B is downstream from lake A: there is no flow carrying polluted water fromB into A. In contrast, equation (95)b does depend on yA. This is because of the water flow F4

(see Fig. 27), which introduces the coupling into the equations.

Page 46: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

46 Mathematical problem-solving for Earth sciences – Hilary term

We can find the steady-state solution of (95) by setting yA = yB = 0 and solving to obtain

ysteadyA =c1c2

=F1[P1] + F2[P2] + F3[P3]

F4, (96)a

ysteadyB =c1c4c2c5

+c3c5

=F1[P1] + F2[P2] + F3[P3]

F6+F5[P5]

F6. (96)b

Equations (95) admit an analytical solution that contains two integration constants k1 andk2:

yA(t) =c1c2− k1

(c2c4− c5c4

)e−c2t, (97)a

yB(t) =c1c4c2c5

+c3c5

+ k1e−c2t + k2e

−c5t (97)b

These constants are determined using the initial concentrations of pollutant in the lakes, yA(t =0) and yB(t = 0). You will examine the properties of the two-box model in the problem sheet.

6.4 Multi-box models

Box models can be made arbitrarily complex, either by adding more boxes, or by tracking morethings that move between them. We’ll now consider a system with four boxes, as shown in Fig-ure 28; we assume that the reservoir masses are in steady state and track only the concentrationof a single element.

MA MB

MCMD

F1 F2

F3

F4

F5

F6

F7

Figure 28: A four-box model

Since one of our assumptions is that the reservoir masses are in steady state, we must ensurethat any choice of flows Fi is consistent with this assumption. This means that the net flow intoeach reservoir must be zero. For example, reservoir A must have

F1 + F5 − F2 − F6 = 0. (98)

A similar statement must be enforced for each box.

Perfect mixing implies outflow concentrations are equal to reservoir concentrations, and sowith the specification of only the inflow concentration Cin associated with F1, we can write asystem of governing ODEs for the concentrations in each reservoir of Figure 28 as

MACA = CinF1 + CDF5 − CA(F2 + F6), (99)a

MBCB = CAF2 − CBF3, (99)b

MCCC = CAF6 + CBF3 − CC(F4 + F7), (99)c

MDCD = CCF4 − CDF5. (99)d

Page 47: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 47

While an analytical solution to this system of ODEs may exist, it will be complicated and noteasy to obtain. We hence use this example to introduce a Matlab-based numerical methodfor solving the time-dependent ODEs. This is implemented in the code below. The core of thiscode is the Matlab function ode23(), which is a numerical integrator, used for solving systemsof ODEs. Use help ode23 to learn more about it.

function [t C] = FourBoxModel(C0, par)

% FourBoxModel - solve system of ODEs representing

% box model illustrated in SYM lecture notes.

% Input: C0 - array of 4 entries specifying the initial

% concentration is each reservoir.

% par - OPTIONAL parameter structure. Must have

% same form as given in this function.

% Output: t - array of times at which concentration

% is output, length N.

% C - array of output concentrations of dimension

% of size N by 4.

% check for minimum required input

if ~exist('C0');

error('User must specify an initial condition for C (e.g. C0 = [a b c d])');

end

% check if user has specified the parameter structure

if ~exist('par');

% if not, define the problem parameters

par.Ma = 10;

par.Mb = 6;

par.Mc = 20;

par.Md = 10;

par.Cin = 0.1;

par.F(1) = 1;

par.F(2) = par.F(1)/3;

par.F(4) = par.F(1)/5;

% changning the parameters below may result in NOT satisfying

% the mass conservation constraints

par.F(3) = par.F(2);

par.F(5) = par.F(4);

par.F(6) = par.F(1) + par.F(5) - par.F(2);

par.F(7) = par.F(1);

end

% check for mass conservation

ck(1) = par.F(1) + par.F(5) - par.F(2) - par.F(6);

ck(2) = par.F(2) - par.F(3);

ck(3) = par.F(3) + par.F(6) - par.F(4) - par.F(7);

ck(4) = par.F(4) - par.F(5);

if (max(abs(ck)) > 1e-8);

error('Fluxes must conserve mass in steady state!');

end

% find the residence times

rt(1) = par.Ma/(par.F(1) + par.F(5));

rt(2) = par.Mb/(par.F(2));

rt(3) = par.Mc/(par.F(3) + par.F(6));

rt(4) = par.Md/(par.F(4));

tmax = 3*max(rt);

Page 48: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

48 Mathematical problem-solving for Earth sciences – Hilary term

% solve system of ODEs

% NOTE THE USE OF Matlab ODE SOLVER ode23

% @ODE_function is a function handle that tells the ODE solver to

% use the function specifying the ODEs, below.

[t C] = ode23(@ODE_function,[0 tmax],C0,[],par);

% make plot

h = plot(t,C,'linewidth',2); grid on;

leg = legend(h,'$C_A$','$C_B$','$C_C$','$C_D$',1);

set(leg,'Interpreter','latex','Fontsize',16,'box','on');

xlabel('time (units of $M/F$)','Interpreter','latex','fontsize',18);

ylabel('Reservoir concentration','Interpreter','latex','fontsize',18);

%%%% FUNCTION THAT ENCODES THE DIFFERENTIAL EQUATIONS %%%%

function dCdt = ODE_function(t,C,par)

% arguments: t is the current model time

% C is an array of concentrations at the current time

% par is the parameter structure

% output: dCdt is the time-derivative of concentrations, computed using

% the system of ODEs. It must be in column format.

dCdt(1,1) = (par.F(1)*par.Cin + par.F(5)*C(4) - (par.F(2)+par.F(6))*C(1))/par.Ma;

dCdt(2,1) = (par.F(2)*C(1) - par.F(3)*C(2))/par.Mb;

dCdt(3,1) = (par.F(3)*C(2) + par.F(6)*C(1) - (par.F(4)+par.F(7))*C(3))/par.Mc;

dCdt(4,1) = (par.F(4)*C(3) - par.F(5)*C(4))/par.Md;

0 20 40 60 80 100 120 140 160 180 2000

0.01

0.02

0.03

0.04

0.05

0.06

0.07

0.08

0.09

0.1

time (units of M/F )

Reservoir

concentration

CA

CB

CC

CD

Figure 29: Output from a run of FourBoxModel() with C0=[0 0 0 0].

Figure 29 shows the time-dependent solution of the ODEs (99) with parameters as set inthe FourBoxModel() function. The initial condition is zero concentration in all the reservoirs.Note that the reservoirs evolve on different time-scales, according to their residence times andthe relative flows. Note also that all reservoirs are approaching steady state.

6.5 An Earth sciences example: ocean circulation

Figure 30 shows a box model of ocean circulation. Reservoirs are labelled with the mass-contentof water; flows between reservoirs are labelled with the rate of mass transfer.

Page 49: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 49

Figure 30: Box model of ocean circulation. Reservoir volumes in 1015 m3, fluxes in 1015 m3/year.

Page 50: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

50 Mathematical problem-solving for Earth sciences – Hilary term

7 Diffusion I

In this lecture we’ll review the derivation of the differential equation that models diffusion insteady-state. Using thermal diffusion as an example, we’ll consider how the addition of internalheat production by radioactive decay enters the equation. Finally we’ll solve for the conductivetemperature profile in the continental crust. Note that diffusion of heat gives rise to conductiveheat flow, or simply to heat conduction.

7.1 The diffusive flux

Recall that a flux is the amount of transported stuff (energy, mass, etc) per unit area, per unittime. Think of sunlight coming in through a window: the window has area of 1 m2 and wemeasure the total solar energy during 1 second as s Joules. Then the flux of sunlight throughthe window is s Joules–m−2–sec−1.

The familiar case of sunlight is an example of radiative transfer of energy; in this lecturewe’re interested the diffusive transfer of energy. You learned in thermodynamics that diffusionof heat is based on the random motions of individual atoms. Recall that a temperature gradientin a gas translated to a gradient in kinetic energy, and that the kinetic energy diffused as themore energetic atoms spread out into the less energetic ones. Similarly, you learned last termabout chemical diffusion as a random molecular process.

In thermodynamics, we used the kinetic theory of atoms in a gas to derive an equation forthe diffusive flux. We found thatTS 4-2

q(y) = −kd(stuff)

dy, (100)

where q(y) is a flux (of say heat or a chemical) in the y-direction, at a the position y. Equa-tion (100) tells us that the flux is proportional to the gradient of stuff, with a constant ofproportionality k (question: what are the units of k?). This constant is known as the conduc-tivity. The conductivity can vary with space or time; it could even be a function of the (stuff).For these lectures, however, we will treat it as a constant.

Equation (100) is known as Fourier’s law, or Fick’s first law. It turns out that this law holdsfor thermal diffusion even when the atoms are locked in place (i.e. in a solid); in that case,energy is transferred through the bonds between atoms.

(a) (b)

Figure 31: Heat conduction through a slab. (a) Linear temperature gradient. (b) Nonlinear temperaturegradient.(source: TS chap. 4)

Page 51: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 51

Consider a slab of rock with thickness l in the y-direction, as shown in Figure 31a. If oneside of the slab (at y = 0) has a higher temperature and the other side of the slab (at y = l) hasa lower temperature, what is the temperature gradient between the two? The answer is

dT

dy= −∆T

l,

where ∆T is the positive temperature difference between the sides. There is a negative signbecause temperature decreases in the y-direction. The heat flux from Fourier’s law is thus

q =k∆T

l.

We will see that the temperature profile need not be linear through the slab. Figure 31bshows a temperature profile with a gradient that varies with respect to y. The heat flux at eachpoint is proportional the local gradient in temperature. As we will see, this curvature indicateseither that there are sources/sinks of heat in the slab, or the temperature profile is changingwith time.

7.2 Steady conduction in one dimension

Now think back to thermodynamics and recall the first law, which states that energy is conserved,and that heat and work are both forms of energy. In this lecture we’re not interested in energeticwork, so we can write the first law as

dU

dt=

dQ

dt, (101)

which states that the rate of change in internal energy of a system is equal to the rate at whichheat is added to it (to obtain this form we’ve simply divided the usual statement of the Firstlaw by dt).

On the left-hand side, we have the rate of change in internal energy. For starters, let’sconsider a system where this rate is zero, and hence the temperature doesn’t change with time(it can still vary in space though). Problems where the quantities don’t change with time arecalled steady or steady-state.

On the right-hand side, we have the rate of net addition of heat into the system. SincedU/dt = 0, we know that the rate of net heat addition is also zero. However, that doesn’t meanthat there is no diffusion! In simply means that whatever heat comes into the system also goesout at the same rate.

So what is the “system” that we are considering? In this case, it is an infinitessimal slab ofrock, as shown in Figure 32. It has thickness δy in the y-direction. The flux of heat going intothe slab is q(y), while the flux going out of the slab is q(y + δy). Since we know that the netheat addition is zero, we can write

q(y + δy)− q(y) = 0. (102)

As you will show in your first problem set, we can use a Taylor series expansion of q(y+ δy),truncated at first order in δy, combined with Fourier’s law, to find that

q(y + δy)− q(y) = δy

(−kd2T

dy2

). (103)

Combining equations (102) and (103) tells us that

δy

(−kd2T

dy2

)= 0 or, more simply,

d2T

dy2= 0. (104)

Page 52: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

52 Mathematical problem-solving for Earth sciences – Hilary term

Figure 32: Heat flow into and out of a thin slab of rock. (source: TS chap. 4)

This is an equation for the one-dimensional temperature distribution inside of a material inwhich heat is being transferred by diffusion, but the temperature is steady (not changing withtime).

Example problem Consider a perfectly insulated metal rod, 1 metre in length. One end ofthe rod is held at 10◦C and the other is held at 0◦C. What is the temperature distribution inthe rod, when it has reached steady-state? Solution. We can use Equation (104) to obtain thetemperature distribution in the rod. Integrating twice gives

T (y) = c0y + c1,

where c0 and c1 are constants of integration. Using the stated boundary conditions T (y = 0) = 0and T (y = 1) = 10, we can solve for the constant and obtain

T (y) = 10y,

for T in degrees Celcius and y in metres.

Equation (104) tells us that when heat diffusion is in steady-state, the curvature of thetemperature function (i.e. the second derivative) is zero. As we shall see next, we must addanother “if” to this: if there are internal sources of heat, we can have non-zero curvature atsteady-state.

7.3 Adding a source term

“A source of heat!? I thought that energy is conserved! How can there be a source?” A goodquestion! Of course energy is conserved, but it turns out that there are forms besides heat andwork. One example is nuclear energy: the energy stored in the forces that hold together thenuclei of atoms. When atoms spontaneously decay, some of that energy is converted to heat,which can raise the temperature of the surrounding material. In our mathematical formulation,this is energy accounted for by including a source term.

Suppose that we’re interested in the continental crust; it is made of something like granite.Granite contains uranium, thorium, and potassium, all of which undergo radioactive decay. Let’saggregate all of those elements into a single source of heat and call it H, where H is positiveand has units of Joules–kg−1–sec−1. The volumetric heat production is ρH, and in our slab of

Page 53: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 53

thickness δy (Figure 32), the heat production per unit area per unit time is ρHδy. Note thatthis has the same units as the flux! We can now use the First law of thermodynamics to writeTS 4-6

0 = qout − qin − qsource,= q(y + δy)− q(y)− ρHδy,

= δy

(k

d2T

dy2+ ρH

),

= kd2T

dy2+ ρH. (105)

This equation says that the curvature of the temperature function is negative if there is a heatsource in the physical medium.

We can use this equation to solve for the steady-state distribution of temperature in a half-space∗ that is heated by radioactive decay. Since Equation (105) is a second-order equation,we need two boundary conditions. If the half-space represents the surface of a planet, we couldmeasure the surface temperature of the planet to be T (y = 0) = T0. We could also measure thesurface heat flux as q(y = 0) = −q0, where the negative sign indicates that heat is flowing inthe negative y-direction.

We now integrate Equation (105) once to obtain

ρHy = −kdT

dy+ c0. (106)

We can use our heat-flux boundary condition to evaluate the constant of integration c0. Aty = 0,

ρH × 0 = q(0) + c0 = −q0 + c0,

which gives use c0 = q0 and

ρHy = −kdT

dy+ q0.

Integrating again gives

ρHy2

2= −kT + q0y + c1,

where c1 is another constant of integration. Using T (0) = T0 we find that c1 = kT0. So thesolution to the problem is

T = T0 +q0ky − ρH

2ky2.

Although we were able to obtain a solution, a uniform distribution with depth is not a verygood model for heat-producing elements in the Earth. In the next section we produce a bettermodel.

7.4 Example: the continental geotherm

Because the continental crust is very old, time-dependent effects far from plate boundaries arenegligible, and our steady-state analysis should apply. We could assume that the concentrationof heat producing elements decreases exponentially with depth in the Earth, and therefore TS 4-8

H = H0 e−y/hr , (107)

where H0 is the rate of heat production (Joules/kg) at the surface, and hr is a scale-depth overwhich it decreases by a factor of e−1. Figure 33 shows a schematic diagram of a model of thecontinental crust with exponentially decreasing H.

∗A half-space is a domain that extends from y = 0 to y = ∞

Page 54: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

54 Mathematical problem-solving for Earth sciences – Hilary term

Figure 33: Schematic diagram of a model of the continental crust with exponential radiogenic heat sourcedistribution. (source TS chap. 4)

Substituting Equation (107) into Equation (105) gives our model:

0 = kd2T

dy2+ ρH0e

−y/hr . (108)

Far beneath the surface where the concentration of heat-producing elements is low, we canassume that the upward heat flux takes some background value. That is,

q → −qm as y →∞. (109)

Integrating (108) once gives

c1 = kdT

dy− ρH0hre

−y/hr ,

= −q − ρH0hre−y/hr . (110)

Using the boundary condition (109) we find that c1 = qm, and hence we have

q = −qm − ρH0hre−y/hr . (111)

This equation can be integrated again (with a specified surface temperature) to obtain thetemperature as a function of depth, i.e. the continental geotherm. The result of such a calculation(with representative values for ρ, k, hr and H0) is shown in Figure 34a.

We can use Equation (111) to make a prediction of the surface heat flux q0. Recall thatq0 = −q(y = 0), and so we have

q0 = qm + ρH0hr. (112)

This equation states that the surface heat flux is linearly proportional to the surface concentra-tion of heat-producing elements. This is a prediction that can be tested against data, as shownin Figure 34b.

7.5 Radial heat conduction in a sphere or spherical shell

To round out our study of heat diffusion, let’s consider what happens when we have a sphericalbody with radiogenic heat sources inside (e.g. a planet). Assume that everything in the planet isspherically symmetric, i.e. it only depends on the radius r. We’ll first need to derive a governing

Page 55: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 55

(a) (b)

Figure 34: (a) A typical geotherm through the continental crust. (b) Surface heat flow versus volumetricheat production in surface rocks. Symbols correspond to different regions (Sierra Nevada, solid squares;Eastern US, solid circles; Norway and Sweden, open squares; Eastern Canadian shield, open circles).Lines are best-fits of the data to Equation (112). (source TS chap. 4)

(a) (b)

Figure 35: (a) Heat flow into and out of a spherical shell. (b) the geotherm in a stagnant planet withinternal heat source H. (source TS chap. 4)

equation based on conservation of energy. To do so, consider the thin spherical shell shown inFigure 35a. Its inner surface is located at a radius r and it has thickness δr.TS 4-9

The outer and inner surfaces of the shell have respective areas

Aouter = 4π(r + δr)2, Ainner = 4πr2, (113)

and the approximate volume of the shell is

Vshell = 4πr2δr. (114)

Therefore the heat flow (Joules/sec) through the outer and inner surfaces are, respectively,

Fout = 4π(r + δr)2 qr(r + δr), Fin = 4πr2 qr(r), (115)

while the internal heating in the shell (Joules/sec) is

Fsource = 4πr2δrρH. (116)

Page 56: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

56 Mathematical problem-solving for Earth sciences – Hilary term

As above, we use a Taylor series expansion of qr(r+ δr) to resolve the difference in heat flowFout − Fin into a differential:

Fout − Fin = 4π[(r + δr)2 qr(r + δr)− r2 qr(r)],

= 4πr2(

2

rqr +

dqrdr

)δr. (117)

Putting this together with Equation (116) in a statement of conservation of energy for the shellgives

0 = Fout − Fin − Fsource,

= 4πr2δr

(2

rqr +

dqrdr− ρH

),

=dqrdr

+2

rqr − ρH. (118)

Just as for our treatment of the slab, the next step is to use Fourier’s law, which now takesthe form

qr = −kdT

dr. (119)

Substituting into Equation (118) gives the temperature equation

0 = k

(d2T

dr2+

2

r

dT

dr

)+ ρH,

or, more compactly,

0 =k

r2d

dr

(r2

dT

dr

)+ ρH. (120)

This is the equation that we must solve to obtain the planetary geotherm at steady-state withinternal heat production.

Assuming that H(r) = const and integrating Equation (120) twice with respect to r oneobtains a general expression for the temperature as a function of depth,

T (r) = −ρH6k

r2 +c1r

+ c2. (121)

To have a finite temperature at the centre of the planet we must have c1 = 0. If the surface isat r = a and the temperature there is T0, we can find

c2 = T0 +ρHa2

6k,

and hence we have the temperature distribution

T = T0 +ρH

6k

(a2 − r2

). (122)

This temperature distribution is plotted in Figure 35b.

Page 57: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 57

8 Diffusion II

In this lecture We’ll derive the diffusion equation for non-steady situations. We’ll theninvestigate how a spatially oscillating temperature field changes with time, due to diffusion.This will allow us to apply tools of Fourier analysis to create mathematical models of diffusion.Finally, we’ll study the case of a time-dependent forcing : periodic heating of a half-space (e.g. byseasonal temperature fluctuations).

8.1 The time-dependent diffusion equation

Figure 36: Heat flow into and out of a thin slab of rock. (source: TS chap. 4)

Let’s return to the trusty First law of thermodynamics, which tells us that energy is con-served. We’ll again consider the case of a slab of rock of thickness δy as shown in Figure 36.The First law reads

dU

dt=

dQ

dt, (123)

which says that the rate of change of internal energy is equal to the rate of net addition of heat.Let’s treat the right-hand side first. The rate of net addition of heat can be broken down intoits component fluxes as

dQ

dt= qin − qout + qsource. (124)

In the last lecture, where we considered only steady-state, this sum was equal to zero. Whenwe allow for changes in internal energy, the left-hand side of Equation (123) becomes

dU

dt= ρc

dT

dtδy, (125)

since the changes in internal energy comes only from changes in temperature. In this equation,ρ is the density (kg-m−3) and c is the specific heat capacity (J-kg−1-K−1). Then the units ofEquation (125) are J-m−2-sec−1, which is the same units as the various fluxes q.

Equating the left-hand side and the right-hand side of the First law we have

ρc∂T

∂tδy = qin − qout + qsource,

= δy

(k∂2T

∂y2+ ρH

), (126)

Page 58: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

58 Mathematical problem-solving for Earth sciences – Hilary term

and hence we have

ρc∂T

∂t= k

∂2T

∂y2+ ρH.

This is the time-dependent diffusion equation with a source term. It can also be written

∂T

∂t= κ

∂2T

∂y2+H

c, (127)

where κ = k/(ρc) is the thermal diffusivity. When there is no radiogenic heat production, thisequation becomes

∂T

∂t= κ

∂2T

∂y2. (128)

Note the use of partial differentials in equations (126)–(128). This is simply because we now seethat the temperature T varies with both time t and position y.

Equation (128) is the canonical diffusion equation in one dimension, with constant thermaldiffusivity. A few remarks about this equation

• It is an equation for temperature T as a function of time t and space y. This can berepresented mathematically as T = T (t, y).

• It is a linear equation, because it does not involve nonlinear functions of T .

• It is a first-order partial differential equation in time, because it has a first derivative ofT with respect to t. To solve it we must therefore specify an initial condition in the formof T (0, y) = f(y), where f(y) is some function of position only.

• It is a second-order partial differential equation in space, because it has a second derivativeof T with respect to y. To solve it on a finite domain, we must therefore specify twoboundary conditions. For example, if the domain is 0 ≤ y ≤ 1, we could specify theboundary conditions

y(t, 0) = 0, (129)a

y(t, 1) = 12. (129)b

Note that in the previous lecture, when we solved the steady-state diffusion equation, wealso needed two boundary conditions. That equation is also second-order in space.

The rest of the lecture will focus on methods of solving this equation.

8.2 Diffusion in an insulated rod of infinite length

Let’s begin solving the diffusion equation with a simple example. We’ll consider a perfectlyinsulated rod of infinite length. Since the rod is insulated, we can assume that temperature isonly conducted along the rod, in the y-direction. By giving the rod infinite length, we avoidthe neccessity to specify boundary conditions. We still need an initial condition, however. Forreasons that will become clear later, let’s choose a sinusoidal variation

T (0, y) = A sin

(2π

λy

), (130)

where A is the amplitude of the variations and λ is the wavelength (note that when y = λ,the argument to the sine function is 2π, and hence we’ve gone through a full cycle). Theproblem becomes the following: how does the initial distribution of temperature evolve with

Page 59: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 59

time? Another way of stating this is given this initial condition, what is the distribution oftemperature at time t?

Our physical intuition tells us that heat should diffuse away from the peaks in temperatureand towards the troughs. Our mathematical intuition confirms this: at the temperature peaks,∂2T/∂y2 < 0; hence we have ∂T/∂t < 0 at the peaks. At the troughs, the situation is reversed,and the temperature should trend upwards. So we should expect the amplitude of the oscillationto decay away with time.

With this expectation in mind, let’s start with a clever guess. Having solved linear equationsin the past, we know that the solution often takes the form eαx, where x is the independentvariable. In this case, our independent variable is t, and so we could try to solve the equationusing the guess

T (t, y) = Aeαt sin

(2π

λy

). (131)

Is this the correct form of the solution? A first check: when t = 0, Equation (131) returnsour initial condition from Equation (130). As a second check, let’s plug Equation (131) in thediffusion equation (128) and see if it works:

∂T

∂t= κ

∂2T

∂y2, Diffusion equation.

αAeαt sin

(2π

λy

)= −κ

(2π

λ

)2

Aeαt sin

(2π

λy

), By plugging in (131).

α = −κ(

λ

)2

. By cancellation. (132)

So what we find is that as long as α takes the form given in Equation (132), then our guesssolution will work. Hence we can write the solution to our problem as

T (t, y) = A exp

[−(

λ

)2

κ t

]sin

(2π

λy

). (133)

Try plugging this equation into Equation (128) to verify that it is, indeed a solution.

→←

←→

T

y

(2π/λ)2κt = 0 (2π/λ)2κt = 1 (2π/λ)2κt = 2

Figure 37: A decaying, sinusoidal temperature variation. The black line is the initial condition; thelighter lines are solutions at subsequent times. The single-stemmed arrows indicate the directions of heatflow; the double-stemmed arrows indicate the change in temperature with time.

What does our solution tell us about diffusion? A few things are evident:

Page 60: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

60 Mathematical problem-solving for Earth sciences – Hilary term

• Equation (132) tells us that the rate of decay is inversely proportional to the square of thewavelength. Longer wavelength oscillations decay much slower than shorter wavelengthoscillations.

• Equation (132) tells us that the rate of decay is proportional to the diffusivity.

• Equation (133) tells us that diffusion does not cause a change in the wavelength of theoscillations, it only causes those oscillations to decay in amplitude.

• This solution is only valid on an infinite domain. We did not impose boundary conditionsbecause there are no boundaries!

We can generalise this example to something more useful. Let’s consider a more complexinitial condition:

T (0, y) = A1 sin

(2π

λ1y

)+A2 cos

(2π

λ2y

)+A3 sin

(2π

λ3y

), (134)

where Ai and λi are the amplitude and wavelength of the three different sinusoidal oscillationsthat compose our initial distribution of temperature. Since the governing equation (128) islinear, we know that simpler solutions can be added together to create more complex ones. Wecan break our problem up into three sub-problems, one for each term in Equation (134), findtheir solutions, and then sum them. Each sub-problem will have a solution like Equation (133),and hence we can immediately write that the evolution of our initial condition (134) is given by

T (t, y) =A1 exp[−l21κ t

]sin

(2π

λ1y

)+

A2 exp[−l22κ t

]cos

(2π

λ2y

)+

A3 exp[−l23κ t

]sin

(2π

λ3y

), (135)

where li = 2π/λi is the wavenumber. We can see from this solution that each of the initialoscillations decays at its own rate, dependent on its wavelength (and on the thermal diffusivity),independent of the others. The solution is plotted for four different times in Figure 38.

More generally still, if our initial condition is the sum of sinusoidal functions in space onan infinite domain, then we can we can immediately write down a solution for their temporalevolution under diffusion. But we learned last term that we can write any periodic function interms of the sum of sinusoidal functions! So we can apply this solution to any periodic function!

For example, let’s consider a situation where T (0, y) = f(y), with f(y) = f(y + Y ). Thismeans that we have an initial condition given by some function f , which is periodic in they-direction, with some period Y . We can use the Fourier series representation of our initialcondition

T (0, y) = a0 +∞∑n=0

[an sin(lny) + bn cos(lny)] , (136)

where ln = 2π/λn is the wavenumber corresponding to each entry in the sum. Given somefunction f(y), coefficients an and bn can be obtained in the usual way, which we learned lastterm.

Without further ado, we can write down the time-evolution of the initial condition as

T (t, y) = a0 +

∞∑n=0

exp(−l2nκt

)[an sin(lny) + bn cos(lny)] . (137)

Page 61: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 61

(a) κt = 0 (b) κt = 1

(c) κt = 25 (d) κt = 4000

Figure 38: A plot of Equation (135) four different times. Note the three superimposed oscillations at t = 0.By κt = 25, the shortest wavelength oscillation has diffused away. By κt = 4000, the middle wavelengthoscillations has diffused away, and the longest wavelength oscillation has decreased in amplitude.

(a) κt = 0 (b) κt = 1

(c) κt = 10 (d) κt = 100

Figure 39: Romance, diffusion-style.

This result is the exact solution of the diffusion equation (128) for the initial condition given byf(y).

Wow! Fantastic! We can see this wonderful result in action in Figure 39. Only one periodof the function is shown, but in fact this pattern repeats every Y units from −∞ to +∞.

8.3 Mathematical lessons about diffusion

We noted above that the rate of decay for a particular Fourier mode under diffusion increaseswith the wave-number (or the inverse wavelength) of the mode. We can see from Figure 39 thatbecause of this, diffusion acts as a smoother, rounding out sharp edges and blurring the initialcondition. Since heat is conserved, the integral of T (t, y) must be constant for this model.

Page 62: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

62 Mathematical problem-solving for Earth sciences – Hilary term

8.4 Solving the infinite-rod diffusion problem with Matlab

In the previous section we learned that since each oscillatory component of the initial conditiondecays independently of the others, we can use the Fourier series of the initial condition as ameans to express the effect of diffusion over time. How do we implement this in Matlab? Wecan build on the functions we developed last term.

We first need a function that, given an initial distribution of temperature, and the time overwhich diffusion has taken place, will return the temperature distribution at that time. The stepsto do this are as follows

1. Compute the discrete Fourier series of the initial condition.

2. Determine the decay constant for each pair of Fourier coefficients αn, βn.

3. Calculate and apply the amount of decay for each pair of Fourier modes.

4. Reconstruct and return the diffused temperature function from the decayed Fourier coef-ficients.

Here’s a function that does the trick:

function Tf = dfs_diffusion(y,Ti,kappa,time)

% DFS_DIFFUSION 1D diffusion calculation by discrete Fourier series

% DFS_DIFFUSION(y,Ti,kappa,time) returns the temperature distribution

% after a specified time or times.

% INPUT:

% y - A vector of positions corresponding to the temperatures in Ti.

% Ti - The initial distribution of temperature in the y-direction.

% NOTE: y and Ti must have an odd number of entries!

% kappa - The diffusivity.

% time - The elapsed time of diffusion. This may be a vector or a single number.

% OUTPUT: Tf - The distribution of temperatures at points in the y-direction

% specified by the input vector y, after specified time. If time is a

% vector of times, then Tf will be a matrix with each column corresponding

% to an entry in the time vector.

% Compute the total length of the time-series

Y = y(end)-y(1);

% Compute the discrete Fourier series

Fi = dfs(Ti);

% Compute an array of wavelengths and decay constants

lambda = Y./[1:length(Fi.alpha)];

wavenumber = 2*pi./lambda;

% For each requested time

for i=1:length(time)

%compute the amount of decay

decay_factor = exp(-wavenumber.^2 * kappa * time(i));

Page 63: MATHEMATICAL PROBLEM SOLVING FOR EARTH SCIENCES | …foalab.earth.ox.ac.uk/files/SecondYearMathematicsPartII.pdf · 2015-03-01 · 2 Mathematical problem-solving for Earth sciences

Introduction to Series Analysis 63

% apply the decay to the Fourier coefficients

Ff.alpha0 = Fi.alpha0; % the mean does not decay!

Ff.alpha = Fi.alpha .* decay_factor;

Ff.beta = Fi.beta .* decay_factor;

% reconstruct the temperature field by inverting the DFT

Tf(:,i) = idfs(Ff);

end

Using this function, we can solve for the evolution of an arbitrary (periodic) distribution ofinitial temperature in the rod. Let’s try an example in Matlab.