COM 1021 Mathematical Methods for Computing I...

144
COM 1021 Mathematical Methods for Computing I 2010/2011 John F. Rayman Department of Mathematics University of Surrey

Transcript of COM 1021 Mathematical Methods for Computing I...

Page 1: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

COM 1021Mathematical Methods for Computing I

2010/2011

John F. Rayman

Department of Mathematics

University of Surrey

Page 2: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Contents

1 Functions and Graphs 5

1.1 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1.2 Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

1.3 Indices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

1.4 Some special functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

1.5 Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

1.6 Some important graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

2 Trigonometry 36

2.1 Commonly occurring values . . . . . . . . . . . . . . . . . . . . . . . . . . 37

2.2 Graphs of the trigonometric functions . . . . . . . . . . . . . . . . . . . . . 38

2.3 Compound angle formulae . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

2.4 Half angle formulae . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

2.5 The sine rule and the cosine rule . . . . . . . . . . . . . . . . . . . . . . . 41

2.6 Distance between two points . . . . . . . . . . . . . . . . . . . . . . . . . . 42

3 Equations and inequalities 44

3.1 Linear equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

3.2 Making a given variable the subject of an equation or a formula . . . . . . 46

3.3 Quadratic equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

3.4 Inequalities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

3.5 Other equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

4 Introduction to linear algebra 57

4.1 Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

4.2 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

4.3 Elementary vector spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

1

Page 3: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

5 Differential calculus 85

5.1 The general case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

5.2 Key properties of differentials . . . . . . . . . . . . . . . . . . . . . . . . . 88

5.3 Applications of differentiation . . . . . . . . . . . . . . . . . . . . . . . . . 90

5.4 The Newton Raphson method . . . . . . . . . . . . . . . . . . . . . . . . . 96

5.5 Exercises for chapter 5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99

6 Introduction to Mathematical Economics 101

6.1 Supply and demand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

6.2 Excise tax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

6.3 Sales tax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

6.4 Revenue, costs and profit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

7 Series 113

7.1 Arithmetic series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

7.2 Geometric series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

7.3 The binomial expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

7.4 The binomial series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

7.5 Maclaurin Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

8 Introduction to Financial Mathematics 127

8.1 Simple interest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

8.2 Compound interest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

8.3 Investment appraisal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

8.4 Annuities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

8.5 Savings accounts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136

8.6 Mortgages and loans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137

2

Page 4: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Mathematical methods forComputing ISpring Semester 2010-2011

The module consists of lectures, computer laboratory sessions and tutorials. There arenumerous exercise sheets, with illustrative examples, contained in these notes, which willbe covered in the tutorial sessions. There are five maple worksheets which provide thematerial for the laboratory sessions. The assessment for the module is 30% courseworkand 70% examination.

The coursework will consist of two assignments counting for equal marks.

Contacting the lecturer

My office is 16AA04, my internal telephone extension 2637. If I am not in my office pleasefeel free to e-mail me on [email protected] to make an appointment. My website ishttp://personal.maths.surrey.ac.uk/st/J.Rayman.

Notes

These notes are issued with numerous gaps which will be completed during lectures. Sup-plementary material will also be distributed from time to time.

Lecture attendance is therefore essential to gain a full understanding of the material.

Exercises

There are exercises for each chapter and solutions will be distributed progressively. Slightlymore challenging exercises are marked with an asterisk.

3

Page 5: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Background material

Prior to the start of the module you will have received a H.E.L.M. booklet on Algebrawhich you should have worked through fully. During the module further booklets in thesame series, on Functions and on Differentiation will be issued. Electronic copies of thethree booklets can be found on my website.

Internet resources

There is a huge amount of material available on the internet. Some suggested sites are:

You will not require any other books for this module.

4

Page 6: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Chapter 1

Functions and Graphs

1.1 Functions

1.1.1 Introduction

A function is a rule that associates an input with a unique output. We call the inputthe argument of the function. In the first case x is the argument of the function f.

Example 1f(x) =

√1 + x2

The rule for function f is

(1) square the argument, (2) add 1,(3) take the positive square root of the result

Example 2

g(x) =4

3 − x

The rule for function g is

(1) subtract the argument from 3, (2) take the reciprocal,(3) multiply the result by 4

Note that the argument of g cannot take the value 3.

In this module we shall be concerned with functions of a single variable only, but afunction can be defined with many variables.

Notation

We write y = f(x) which means that y is some function f of x. We usually use letters likef, g, h, p, q to denote functions, sometimes φ, ψ. If we want to emphasise that, say, y is a

5

Page 7: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

function of x, as opposed to some other variable, we write y(x). So all of the followingare precisely equivalent

f(x) = x3, y = x3, y(x) = x3, f : x 7→ x3.

The last expression means “f maps x to x3”.

If the argument is a number then the function will have a number as its output so thatf(3) = 27.

1.1.2 Domain of a function

The domain of a function is the set of values that the argument of the function cantake. The complete definition of a function must include the domain.

Example 3 Find the domains of the following functions:

• f(x) = x2, x can take any value, so the domain of f is x ∈ R.

• g(x) =√x, x ≥ 0, equivalently x ∈ [0,∞).

• h(x) =√

1 − x2, x2 ≤ 1, equivalently x ∈ [−1, 1], or − 1 ≤ x ≤ 1.

• φ(x) =1

x2 − 2x− 3=

1

(x− 1)(x− 3)x 6= −1, x 6= 3,

equivalently x ∈ {R \ {−1, 3}}.

Note the symbols: ∈ which means that the subject is included in a set, (a, b) whichis an interval from a to b excluding a and b themselves (an open interval) and [a, b]which includes the end points (a closed interval). {a, b} is a set which comprises the twonumbers a and b.

A note on sets of numbers

The counting numbers 1, 2, 3 are known as the natural numbers, the set has the symbolN, if we include negative numbers we obtain the integers, Z. Adding fractions givesus the rational numbers Q, while, finally, including the irrational numbers, such as πgives us the the real numbers R. (There is a further group of numbers we include in thecomplex numbers C but we will not be concerned with them in this module).

1.1.3 Range of a function

The range of a function consists of all the values that the function can possibly take.

Example 4

6

Page 8: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Find the ranges of the following functions:

• f(x) = (x− 1)2, range: f(x) ≥ 0.

• g(x) =√

1 − x2, range: g(x) ∈ [0, 1].

• h(x) = 1 −√x, range: h(x) ∈ (−∞, 1].

Example 5

Find the domain of f(x) =√x2 − 4.

Solution

The quantity under the square root sign must be non-negative. This is the graph off(x) =

√x2 − 4 :

The function is non-negative when x2 ≥ 4 so we need x ≥ 2 or x ≤ 2. We can also writex ∈ {R \ {(−2, 2)}

Example 6

Find the domain of g(x) =1√

x2 − 2x− 3.

Solution

The denominator cannot be zero, so the values x = −1 and x = 3 are not allowed. Alsowe must have the quantity under the square root non-negative. Hence (x+1)(x− 3) ≥ 0.If x > 3 then both terms are positive, if x < −1 both terms are negative. If we plot thecurve of y = x2 − 2x− 3 we see why this is:

7

Page 9: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

The domain is thus x ∈ (−∞,−1] and x ∈ [3,∞).

Exercise 1 Find the range of h(x) = x2 + 2x+ 2.

Solution

Clearly the maximum value of h is infinity. To find the minimum we could draw thegraph, use calculus (see later) or complete the square:

x2 + 2x+ 2 ≡ (x2 + 2x+ 1) + 1 ≡ (x+ 1)2 + 1.

We see immediately that the minimum value of h = 1 when x = −1. The range is thush(x) ∈ [1,∞).

Functions acting on sets

A set is any collection of objects - e.g. all the real numbers R. We can represent the actionof a function on a set as

B

xy

rangedomain

A

Here A and B are sets. In the case of the function h(x), we write f : A → B x 7→x2 + 2x+ 2. The function takes an argument in Set A and gives an output in set B.

1.1.4 Composition of functions

The argument of a function can itself be a function.

Example 7

8

Page 10: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Let f(x) =√

1 + x2, g(x) = 1 − x

• f(g(x)) =√

1 + (g(x))2 =√

1 + (1 − x)2 =√x2 − 2x+ 2

• g(f(x)) = 1 − (f(x)) = 1 −√

1 + x2.

Note that the order is critical. f(g(x)) means do g then f and obviously in this case (andin general) f(g(x)) 6= g(f(x)). We describe f(g(x)) as “f of g of x”. We can also call it“ f composed with g” and write it as f ◦ g. Clearly we can have f(g(h(x))) which meansdo h, then do g then do f .

Example 8

Suppose that we define f(x) = x+ 3 and g(x) = (x+ 2)2.

Then

• f(g(x)) = g(x) + 3 = (x+ 2)2 + 3 = x2 + 4x+ 7.

• g(f(x)) = (f(x) + 2)2 = (x+ 3 + 2)2 = x2 + 10x+ 25.

• f(f(x) = f(x) + 3 = x+ 3 + 3 = x+ 6.

• g(g(x)) = ((g(x) + 2))2 = ((x+ 2)2 + 2)2

= x4 + 24x3 + 12x2 + 24x+ 36.

Remark 1

We can also create many kinds of function from f(x) as defined in example 6 with anappropriate argument:

f(x2) = x2 + 3, f(x− 3) = x, f

(1

x

)= 3 +

1

xetc.

Example 9

Let us define p(x) =√

1 − x and q(x) = 1 − x3.

Then

• p(q(x)) =√

1 − q(x) =√

1 − (1 − x3) = x32 x ≥ 0.

• q(p(x)) = 1 − p(x)3 = 1 − (1 − x)32 x ≥ 1.

• p(p(x)) =√

1 − p(x) =√

1 −√

1 − x.

• q(q(x)) = 1 − q(x)3 = 1 − (1 − x3)3 = x3 (3 − 3x3 + x6) .

Example 10

Find the domain and range of p(p(x)).

9

Page 11: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

We must have x ≤ 1 for the argument of√

1 − x to be non-negative. We also need√1 − x ≤ 1 so that we have a non-negative quantity under the overall square root. If√1 − x ≤ 1 then we must also have x ≥ 0.

The domain is thus x ∈ [0, 1]. The range is p(p(x)) ≥ 0.

We write f(f(f(f(x)))) as f (4)(x) for brevity.

1.1.5 One to one functions

Consider the function f : A→ B.

x1

2x f(x2

f(x

)

)1

f

f

A B

If f is a one to one (or injective) function then f(x) = f(y) if and only if x = y, i.e. thereis a unique argument x for each value of f(x).

Example 11

Suppose that f(x) = x3 + 7, is this a one to one function?

Solution

Evidently f(y) = y3 + 7. If f(x) = f(y) then x3 + 7 = y3 + 7 to which the only solutionis x = y. Thus f is one to one.

Example 12

On the other hand, let ψ(x) = x2, is this a one to one function?

ψ(x) = ψ(y) ⇒ x2 = y2 ⇒ x = y and x = −y

Thus two different values of the argument give the same result. We call ψ a many to onefunction or describe it as not injective.

10

Page 12: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

x1

2x(x)ψ

A B

ψ

ψ

1.1.6 Inverse functions

One to one functions will have inverses such that

if y = f(x) then x = f−1(y).

Here f means do the rule, f−1 means undo the rule, so that

f−1(f(x)) = x = f(f−1(x)

).

f(x)x

f

f −1

A B

Example 13

Find the inverse of f(x) = 3x− 1

The procedure is as follows:

1. put y = 3x− 1,

2. solve for x, thus x = y+13,

3. interchange x and y, thus y = x+13,

11

Page 13: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

4. thus f−1(x) =x+ 1

3.

As a check we have

f−1(f(x)) =(3x− 1) + 1

3= x, f

(f−1(x)

)= 3

(x+ 1

3

)− 1 = x.

Compare the rules:f multiply the argument by 3 and subtract 1 from the resultf−1 add 1 to the argument and divide the result by 3

A practical example of the use of inverses

If f is a function that converts temperature from oC to oF then

f(C) =9

5C + 32.

Thus at 20oC, f(20) = 95× 20 + 32 = 68oF.

Then f−1 converts temperatures from oF to oC so

f−1(F ) =5

9(F − 32).

So at 80oF, f−1(80) = 59(80 − 32) = 27oC.

Example 14

Find the inverse of f(x) =2 − 3x

4x+ 1and prove your solution is correct.

Solution

y =2 − 3x

4x+ 1⇒ y(4x+ 1) = 2 − 3x

⇒ 4xy + y = 2 − 3x⇒ 4xy + 3x = 2 − y

⇒ x(4y + 3) = 2 − y ⇒ x =2 − y

4y + 3

The inverse function f−1(x) =2 − x

4x+ 3.

We check that this is correct

f (f−1(x)) =2 − f−1(x)

4f−1(x) + 1=

2 − 2 − x

4x+ 3

4

(2 − x

4x+ 3

)+ 1

=8x+ 6 − 3(2 − x)

4(2 − x) + 4x+ 3= x

12

Page 14: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Example 15

Find the inverse of f(x) =1 − x

1 + x

Solution

We find that f−1(x) =1 − x

1 + x, so that in this case f is self inverse. This is true of all

functions which are symmetrical about the line y = x.

1.2 Graphs

We can represent all functions of one variable by planar graphs. Graphs provide us witha great deal of information about the behaviour of the function and are an invaluablevisual aid. If y = f(x) we call y the dependant variable and x the independent variableand draw graphs with x as the horizontal axis and y as the vertical axis. Any point onthe graph of f can be described by the ordered pair (x, y) or (x, f(x))

The domain and the range of a function are immediately apparent from the graph. Con-sider f(x) = x2, x ∈ [1, 4]

The are four quadrants to the graph as shown

13

Page 15: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

first quadrantsecond quadrant

third quadrant fourth quadrant

y

x0

When drawing a graph you should consider that you are producing a sketch, with thekey features clearly displayed, rather than an exact scale drawing. Choose a suitable scaleso that the features are evident.

1.2.1 Continuous and discontinuous functions

The graph of a continuous function can be drawn without the pen leaving the paper.Thus y = x2 + 2x+ 3 has the graph

A discontinuous function cannot be drawn in this way. Consider y =1

x− 1. The line

x = 1 is a vertical asymptote (to which y tends as x approaches 1 but never actuallyreaches).

14

Page 16: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

1.2.2 One to one and many to one functions

The graph of a one to one function is such that any horizontal line cuts the curve no morethan once.

The case of a many to one function shows that a horizontal line may cross the curve morethan once, here is is clear that f(x1) 6= f(x2)

1.2.3 Transformations of graphs

If we know the shape of say, y = φ(x) we can immediately deduce the shape ofφ(x+ a), φ(x− a), φ(kx) and kφ(x) as the following graphs illustrate

15

Page 17: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

We see that the graph of φ(x+a) has precisely the same shape as that of the graph of φ(x)shifted in the x direction a distance of a, to positive x for a < 0 and to negative x for a > 0.

We can move the graph up or down the y axis by a quantity c with y = φ(x) + c, topositive y for c > 0 and to negative y for c < 0.

We can stretch or contract in the y direction with y = kφ(x). If k > 1 we stretch thegraph, with k < 1 we compress it.

On the other hand stretching or contracting in the x direction is achieved with y = φ(bx).If b < 1 we stretch the graph, with b > 1 we compress it.

16

Page 18: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

1.2.4 Graphs of inverse functions

A function and its inverse are symmetrical about the line y = x, or equivalently the graphof one is obtained by rotating the graph of the other by 180o around the origin.

Any function which is symmetrical about the line y = x is its own inverse.

1.2.5 Discrete and continuous functions

In a function such as y = x2, the domain of x ∈ R, but suppose we are considering thedemand for a particular kind of motor car and find that the numbers sold, QD was givenby some function of the price, P, f(P ). We cannot consider a portion of a car so thedomain of P must be such that QD ∈ N. In practice, although the real world is largelydiscrete we normally use continuous models in our models and in effect join up the points.

Piecewise functions

These functions are defined separately for different intervals of x. Thus, consider

f(x) =

{1 − x x ≤ 0

1 + x2 x > 0g(x) =

{1 − x x < 11x

x ≥ 1

f(x) is piecewise continuous, g(x) is discontinuous. in the graph of g9x) the symbol ◦means that the point (1, 0) is not included on the straight line. The symbol • means thatthe point (1, 1) is on the curve.

17

Page 19: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

1.3 Indices

We writex× x ≡ x2, x× x× x ≡ x3 x× x× x× x ≡ x4 . . .

andx× x× x× x . . . . . . x︸ ︷︷ ︸

n times

≡ xn.

Here n can be any number, to give expressions such as x1.23 and even xπ.

1.3.1 Laws of indices and notation

1

xa= x−a, xaxb = xa+b,

xa

xb= xa−b

(xa)b = xab for x > 0, b√x = x

1b , x0 = 1

We can see why the multiplication law, xaxb = xa+b, for indices works:

x · x · x · x · . . . x︸ ︷︷ ︸a times

· x · x · x · x · . . . x︸ ︷︷ ︸b times

= x · x · x · x · . . . x · x · x · x︸ ︷︷ ︸a+ b times

Thus 20 = 1, 21 = 2, 212 = 1.414213562 . . ., an approximation to an irrational number, we

call√

2 a surd, it is the exact value of the square root of 2. Irrational numbers are those

that cannot be expressed in the forma

bwhere a, b ∈ z.

Example 16

Calculate 212 35 × 53, 34 − 43,34

37, 223

, (22)3.

Solution

4096, 2187, 17, 127, 256, 64.

18

Page 20: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Example 17

Simplify

(i)x2y3z4

x3yz5(ii)

x12y

12 z

72

x2yz3

Solution

(i) y2x−1z−1 (ii)1

x

√z

xy

1.4 Some special functions

1.4.1 Absolute value

The modulus or the absolute value is defined as follows

|x| =

{−x x ≤ 0

x x > 0

The graph of y = |x| is

1.4.2 The exponential function

The following graph shows curves of y = ax for different values of a:

19

Page 21: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

If we calculate their slopes at x = 0, y = 1 we find the following results:

For y = 2x, 0.693, for y = 3x, 1.099 and for y = 4x, 1.386.We could chose any number we wished between 2 and 3 and would find one where theslope at (0, 1) is exactly 1. This number has the symbol e and is an irrational number2.718281828 . . .

The graphs of ex and e−x are shown as follows:

Exponentials are always positive. e0 = 1, e1 = e, e−1 = 1e

= 0.3678794412 . . . , ea+x = eaex.A more precise ways to define e is

e = limn→∞

(1 +

1

n

)n

Example 18

Using your calculator, evaluate(1 + 1

10

)10,(1 + 1

100

)100,(1 + 1

1000

)1000etc.

Solution (1 + 1

10

)10= 2.59374246(

1 + 1100

)100= 2.704813829(

1 + 11,000

)1,000

= 2.716923932(1 + 1

10,000

)10,000

= 2.718145927(1 + 1

1,000,000

)1,000,000

= 2.718280469

Example 19

Sketch graphs of y = e2x, y = ex and y = ex2 on the same plot.

20

Page 22: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

1.4.3 The logarithmic function

If f(x) = ex we might ask - what is f−1(x)? We define f−1(x) = ln x, where “ln” is thenatural logarithm. Thus:

if y = ex then x = ln y.

f(f−1(x)) = eln x = x and f−1(x)) = ln ex = x

ln x is the power to which e must be raised to give x. We say that e is the base ofnatural logarithms. lnx is only defined for x > 0, ln e = 1 and ln 1 = 0.

This is the graph of ln x

The laws of logarithms

These follow from the laws of indices:

ln x+ ln y = ln(x× y), ln x− ln y = ln

(x

y

)

ln xn = n ln x, ln

(1

x

)= ln

(x−1)

= − ln x

21

Page 23: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Example 20

Simplify the following:

1. ln 8 = ln 23 = 3 ln 2.

2. ln 3 + ln 7 = ln 3 × 7 = ln 21.

3. ln 2 − ln 4 = ln 24

= ln 12

= ln 2−1 = − ln 2.

Example 21

Simplify1

2ln 4 − 2 ln 3.

Solution

12ln 4 − 2 ln 3 = ln 4

12 − ln 32 = ln 4

12

32 = ln 29.

Computational use of the logarithm function

In the days before calculators or computers, logarithms were used to perform multipli-cation (and division) and exponentiation. Logarithms with 10 as the base were used, sothat if a = 10b, b = log10 a.

Using logarithms transforms multiplication to addition in the case of multiplication:

Example 22

Evaluate1.234 × 5.678

Using log10 ab = log10 a+ log10 b and consulting log tables we have

log10 1.234 = 0.09132+

log10 5.678 = 0.775200.84552

Now we consult antilog tables to find the value of 100.84552 = 7.0068.

We transform exponentiation to multiplication:

Example 231.2345.678

22

Page 24: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

We use log10 ab = b log10 a hence

log10 1.234 = 0.09132 5.678 × log10 1.234 = 0.51849 - using logarithms for the multi-plication if necessary.

Then 100.51849 = 3.2998.

Common uses of logarithms

• The Richter scaleWe define the magnitude of an earthquake, ML as

ML = log10

A

A0

,

where A is the amplitude of the seismograph wave and A0 is the background motion.This means that magnitude 4 on the Richter scale is 10 times the power of magnitude3, while magnitude 7 is 10,000 times as powerful as magnitude 3

• pHAcidity is measured by pH where

pH = − log10

([H+]

),

where [H+] is the concentration of hydrogen ions. pH 1 is the most acid, pH 7 isneutral, pH 14 the most alkaline.

• Sound volumeMeasured in decibels (dB) we define volume Lp as

Lp = 10 log10

(p2

p2ref

),

where p is the pressure of the sound wave and pref is the threshold of human hearing.Thus 80 dB is 10 times louder than 70 dB and the sound of loud music, 120 dB, is100,000 times louder than 70 dB.

1.4.4 Odd and even functions

An even function f is one for which

f(−x) = f(x)

Thus if f(x) = x4 + x2 + 1, f(−x) = (−x)4 + (−x)2 + 1 = f(x) and f is even.The graph of an even function is symmetric about the y axis:

23

Page 25: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

An odd function g is one such that

g(−x) = −g(x).

Thus if g(x) = x3 + x then g(−x) = (−x)3 + (−x) = −x3 − x = g(−x).

The graph of an odd function is symmetric with respect to a rotation of 180o aroundthe origin.

1.4.5 Periodic functions

A function for whichh(x) = h(x+ nT )

where n ∈ N and T ∈ R is periodic with period T . Periodic functions are extremely usefulin modeling systems with seasonal variations.

24

Page 26: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

1.4.6 Monotone functions

Monotone functions are those which are either increasing or decreasing.

Increasing functions are such that if x1 ≥ x2 then f(x1) ≥ f(x2). If the inequal-ity is > the function is strictly increasing. Thus ex, x + 2, x3 are examples ofstrictly increasing functions.

Decreasing functions are such that if x1 ≥ x2 then f(x1) ≤ f(x2). If the inequalityis < the function is strictly decreasing. Hence e−x, 3 − x are examples of strictlydecreasing functions.

The graphs of monotone functions are as follows:

Strictly increasing or strictly decreasing functions are always one to one.

1.5 Limits

Let us consider the function

y = 1 +1

nwhere x ∈ N

If we calculate the values of y as a sequence for different values of n we obtain{2,

3

2,

4

3,

5

4,

6

5, . . .

n+ 1

n...

}.

We see that these values get closer and closer to y = 1 as n gets larger but never actuallyget there.

We write

limn→∞

(1 +

1

n

)= 1 + lim

n→∞

1

n= 1

We note that for large n, n+1n

≈ nn

= 1, e.g for n = 10, 000 we have n+1n

= 1.000001

25

Page 27: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Example 24

Find the following limits:

• 1 − e−x as x→ ∞

• 1−x3

1−xas x→ 1 (Can you explain the result?)

Solution

(a) 1 (b) 3 (factorise the numerator as (1 − x)(1 + x+ x2) and cancel the 1 − x factor.)

For a continuous function f(x) we have that

limx→a

f(x) = f(a)

and this is in fact a definition of a continuous function. For a discontinuous functionssuch f(x) = 1

x−1we find that this is not true. In fact for a > 1

limx→a+

f(x) = f(a) but limx→a−

f(x) = −∞

26

Page 28: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

1.5.1 Behaviour of xn as n→ ∞

The rules are:

limn→∞

xn =

0 |x| < 1

1 x = 1

∞ otherwise

If x < 0 then the sequence as n increases alternates between positive and negative terms.

Example 25

Investigate the behaviour as n gets large of

(a)2n+ 7

3n2 + n+ 1, (b)

2n2 + 7

3n2 + n+ 1, (c)

2n3 + 7

3n2 + n+ 1,

Divide through by n2 and use the previous result about limn→∞ xn:

(a)2n

+ 7n

3 + 1n

+ 1n2

→ 0

(b)2 + 7

n

3 + 1n

+ 1n2

→ 2

3

(c)2n+ 7

n

3 + 1n

+ 1n2

→ ∞.

1.6 Some important graphs

1.6.1 The straight line

A linear function (containing no square or higher powers) is represented by a straight lineon the graph. Many important models of the real world use linear functions only.

A unique straight line can be drawn between two points.

The slope of a straight line is constant. We define the slope as

slope =corresponding change in y

change in x

If we calculate the slope of the line in the graph below at the point (x1, y1) and the generalpoint (x, y) we have

y1 − y2

x1 − x2

=y − y1

x− x1

using the fact that the slope is constant. We can rearrange this to give the standard formof the equation for the line between the two points (x1, y1) and (x2, y2)

y − y1 =

(y1 − y2

x1 − x2

)(x− x1)

27

Page 29: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

y

xx x

y

y

y)(x,

1

2

21

The equation of a straight line is also written as

y = mx+ c,

where m is the slope or gradient (m > 0 the line slopes upwards, m < 0 the line slopesdownwards) and c is the intercept with the vertical axis. The intercept with the horizontalaxis is − c

m.

Drawing a straight line

To draw a straight line e.g. 3x + 4y = 2 (which can equally be written y = 3 − 34x or

x = 4 − 43y) work out the intercept with the vertical and horizontal axes and draw a line

through the two points. Thus when y = 0, x = 4 and when x = 0, y = 3.

Example 26

Draw the graphs of (a) y = 2x− 3 (b) y = −4x+ 1.

28

Page 30: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

1.6.2 The parabola

The graph of a quadratic function, such as

y = ax2 + bx+ x,

where the highest power of x is x2, is called a parabola. If a > 0 the parabola pointsdownwards, if a < 0 it points upwards. The parabola is symmetric about a vertical linedrawn through its maximum or minimum point.

Example 27 Draw the graph of y = x2 + 4x+ 3.

We can factorise the right hand side to give y = (x + 3)(x + 1) so y = 0 when x = −3and x = −1. When x = 0, y = 3. The coefficient of x is positive so we know that thecurve points downwards. To find the minimum value we can use calculus (see later) orwe complete the square.

Completing the square

This is a very important process and enables us to quickly find maxima, minima, rangesof functions and (see next subsection) equations of circles as well as solving quadraticequations.

Consider 2x2 + 3x+ 4. The steps in the process of completing the square are:

29

Page 31: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

1. Divide through so the coefficient of x is 1 −→ 2(x2 + 3

2x+ 2

)2. Add and subtract half of the square of the coefficient of x

2

(x2 +

3

2x+

9

16− 9

16+ 2

)3. Write the first three term as a square, the constant term is half the coefficient of x

2

((x+

3

4

)2

− 9

16+ 2

)

4. Simplify the last two constant terms −→ 2((x+ 3

4

)2+ 7

16

)Applying the procedure in example 15;

x2 + 4x+ 3 ≡ (x2 + 4x+ 4) − 4 + 3 ≡ (x+ 2)2 − 1

The minimum value occurs when x = −2, and y(−2) = −1. We can now draw the graph:

Example 28

Draw the graphs of (a) y = x2 − 6x+ 5 (b) y = −x2 − 3x− 2.

Solution

30

Page 32: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

1.6.3 The circle

Consider a circle with its centre at the origin and radius r.

0 x

r

x

y

y

the circle

At any point on the circle, by Pythagoras we have x2 +y2 = r2. If the circle has its centreat (a, b) then, as in the section on transformation of graphs, the equation of the circle is(x − a)2 + (y − b)2 = r2. More commonly we might find the equation of the circle in aform which needs to be processed to obtain the key information.

Example 29 Find the centre and radius of

x2 + 3x+ y2 − 4y + 5 = 0.

We first complete the square in x and y.

x2 + 3x+9

4+ y2 − 4y + 4 − 9

4− 4 + 5 = 0 ⇒

(x+

3

2

)2

+ (y − 2)2 =5

4

The centre is at (−32, 2), the radius is

√5

2.

Example 30

Find the centre and radius of

1. 2x2 + 5x+ 2y2 − 4y + 1 = 0

2. 4x2 − 12x+ y2 + 8y − 24 = 0.

Solution

1. centre(−5

4, 1), radius

√334.

2. centre(

32,−4

), radius 7.

31

Page 33: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

1.6.4 Sketching the graph of a rational function

A function of the form

f(x) = a0 + a1x+ a2x2 . . . anx

n n ∈ Nis known as a polynomial of order n.

A rational function is of the form

R(x) =f(x)

g(x)g(x) 6= 0

where both f(x) and g(x) are polynomials.

Example 31

Draw the graph of y =x2 − 1

x− 3

We follow this procedure:

1. Find the intercepts on the horizontal axis (if any)

y = 0 when x = −1 and x = 1.

2. Find the intercepts on the vertical axis (if any), here y(0) = 13.

3. Investigate what happens as x goes to ±∞x→ ∞y → ∞, x→ −∞y → −∞

4. When x is very large y ≈ x so the line y = x is an oblique asymptote.

5. Find the values of x at which the denominator is zero, these correspond to verticalasymptotes, x = 3 in this case.

6. Find the x and y values of local maxima and minima. We use calculus for this(see later). In this case we find the maximum is (3−2

√2,√

2(−4 + 3

√2)) and the

minimum (3 + 2√

2,√

2(4 + 3

√2)

Example 32

Draw the graphs of (a) y =1

x2 + 4x+ 3(b) y =

x2 − 4x+ 3

x+ 4

32

Page 34: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

33

Page 35: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Exercises for Chapter 1

1. if f(x) = x2 + 2x and g(x) = x− 1 find f(g(x)), g(f(x)), f(f(x), g(g(x)).

2. If f(x) = 3x+2 and g(x) = 4x+ c, find f(g(x)), g(f(x)) and a value for c such thatf(g(x)) = g(f(x)).

3. Find the domains of the following functions:

(i) y =√x− 3 (ii) y =

√1 − 2x2 (iii) y =

1

1 − x2(iv) y =

1√x2 − 3

.

4. Find the ranges of the following functions:(i)y = 4x2 + 3,−4 ≤ x ≤ 1. (ii) y = 4 − 3x2,−2 ≤ x ≤ 3.

5. Find the ranges of the following functions(i) y = x2 + 2x+ 5 (ii) y = x2 + 7x+ 13 (iii) y = 3 − 2x− x2 (iv) y = 2x x ≤ 5.

6. Find the inverse of f(x) = 4x− 7. Verify that f(f−1(x)) = f−1(f(x)) = x.

7. Find the inverse of f(x) = 2x−3x−4

, x 6= 4.

8. Find the inverses of the following functions and sketch the graph of the functionand the inverse on the same plot:

(i)f(x) =2 − 3x

5x+ 6(ii) g(x) =

3x− 7

1 − 2x

9. Determine whether the following functions are odd, even or neither:(i) x4 + 5x2 + 3 (ii) x5 + x3 − x (iii) x3 + 4x2 + 4 (iv) |x3 + x|.

10. State whether (or where if appropriate) the following functions are one to one, odd,even or neither, increasing or decreasing:(i) x3 (ii) x2 + 4 (iii) x4 + 3x2 + 2 (iv) x3 − x5 (v) e−3x (vi) 4 − e3x (vii) ex − lnx.

11. Sketch the graphs of the following:(i) 3x+ 5y − 30 = 0 (ii) 5x+ 3y − 15 = 0 (iii) 4x− 3y + 12 = 0 (iv) y = |2x− 1|.

12. Sketch on the same graph

(i) y = x2 + 3 (ii) y = x2 (iii) y = x2 − 3 (iv) y = (x− 1)2 + 3 (v) y =x2

4.

13. Sketch the graphs of(i) y = 1 + 3e−x (ii) y = x− lnx.

14. Find the equations of the straight lines which pass through the following pairs ofpoints and state their gradients.(i) (1,−2) and (−2, 7) (ii) (−3, 5) and (1,−2) (iii) (9, 3) and (−1, 8)(iv) (−1,−3) and (−5, 1).

15. Find the radius and centre of the circle given by x2 + y2 − 6x+ 2y − 15 = 0

16. Calculate(i) 45 ÷ 4−3 (ii) 54 − 45 (iii) 323

(iv) (32)3

34

Page 36: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

17. Simplify the following as much as possible:

(i) ln x+ 2 lnx2 − ln√x (ii) ln e3 + 3 ln

1

e2(iii) ln(x+ xy) − ln(y + xy)

18. *Find the domain and range of the following functions:

(i) f(x) =√

(1 − x2) (ii) g(x) =√x2 + x− 2 (iii) h(x) =

1√x2 + x− 2

(iv) f(x) =1√

x2 + 3x+ 2(v) f(x) = ln(x− 4) (vi) y = ln(3 − x2)

19. *Show that if p(x) and q(x) are both odd functions that p(x) × q(x) is an evenfunction and that if f(x) and g(x) are both even functions then f(x)× g(x) is even.What can you say about p(x) × f(x)?

20. *Show that f(x) =x− 1

x+ 1is a one to one function.

21. *Find the inverses of the following:

(i) p(x) = e2x−3 (ii) q(x) = ln(2 − 3x) (iii) r(x) = 103x.

22. *Evaluate:

(i) limx→∞

2x2 + 3 − 1

x2 − x+ 11(ii) lim

x→∞

2x+ 3 − 1

x2 − x+ 11(iii) lim

x→∞

2x3 + 3 − 1

x2 − x+ 11

23. * Sketch the following graphs

(i) y =x2 + 5x+ 4

4x+ 1(ii) y =

4x+ 1

x2 + 5x+ 4.

35

Page 37: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Chapter 2

Trigonometry

Trigonometric functions are extremely useful mathematically with a wide range of appli-cations.

We define the trigonometric functions sine, cosine and tangent as follows, in a rightangled triangle:

c

b

a

90 − θ

θ

sin θ =b

ccos θ =

a

ctan θ =

b

a

The reciprocals of sin, cos and tan are cosec ( for cosecant), sec (secant) and cot (cotan-gent) respectively.

We see from the diagram that

tan θ =sin θ

cos θand sin θ = cos(90 − θ), cos θ = sin(90 − θ).

By Pythagoras’ theorem

a2 + b2 = c2 =⇒ a2

c2+b2

c2= 1,

from the definitionscos2 θ + sin2 θ = 1,

dividing by cos2 θ1 + tan2 θ = sec2 θ.

36

Page 38: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Radian measure

We are familiar with there being 360o in a circle. More usually in mathematics we useradian measure - there are 2π radians in a circle.

Thus 1 radian =360

2π≈ 57.3o and 1 degree =

360≈ 0.0175c.

Example 33

Convert 32π radians to degrees and 135o to radians.

Solution

To convert 32π radians to degrees we compute 3

2π × 180

π= 270o.

To convert 135o to radians we compute 135 × π180

= 3π4.

Area of segments of a circle

The area of a circle of radius r is πr2. The area of a segment of a circle of angle θ isθ2π

× πr2 which is θr2

2. Thus the area of a 60o segment from a circle of radius 10 cms is

π3× 100

2≈ 162

3cm2.

2.1 Commonly occurring values

Some values of trigonometric functions for common angles are as follows

radians degrees sine cosine tangent

0 0 0 1 0π6

30 12

√3

21√3

π4

45 1√2

1√2

1

π3

60√

32

12

√3

π2

90 1 0 ∞

π 180 0 -1 0

37

Page 39: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

2.2 Graphs of the trigonometric functions

We can extend the idea of trigonometric functions to all angles as the following diagramshows, the coordinates of x and y lying on a unit circle centre at the origin are x =cos θ, y = sin θ.

0

y

x

1

θ

sin θ)θ,

θ= π/2

θ=0

θ=2π

θ=3π/2

θ=π

(cos

We can draw the graphs of the trigonometric functions from which we see that they areperiodic. The period of sine and cosine is 2π and that of tangent is π

More generally the period of sinnx or cosnx is given by T = 2πn. We also see that sin x

and tanx are odd functions, while cosx is an even function.

The graphs of secx and cotx are as follows

38

Page 40: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

2.3 Compound angle formulae

We state, without proof, the following important trigonometric identities:

sin(x± y) = sinx cos y ± cos x sin y. (2.1)

cos(x+ y) = cos x cos y − sinx sin ycos(x− y) = cosx cos y + sin x sin y.

(2.2)

In equation 2.1 if we put x = y we obtain

sin 2x = 2 sin x cos x.

While if we put x = y in equation 2.2 we have

cos 2x = cos2 x− sin2 x

which we can also express as

cos 2x = 1 − 2 sin2 x = 2 cos2 x− 1.

Finally, from equations 2.1 and 2.2 we obtain:

tan(x± y) =tanx± tan y

1 ∓ tanx tan y. (2.3)

If we put x = y in 2.3 we have

tan 2x =2 tanx

1 − tan2 x

Example 34

Expand (a) cos(x+ π

4

)(b) tan

(x− π

3

)(c) sin

(x− π

6

)Solution

• cos(x+ π

4

)= cos x cos π

4− sin x sin π

4= 1√

2(cosx− sinx).

• tan(x− π

3

)=

tanx− tan π3

1 + tanx tan π3

=tanx−

√3

1 +√

3 tanx.

• sin(x− π

6

)= sinx cos π

6− cosx sin π

6= 1

2(√

3 sin x− cos x).

Example 35

Find cos 75o and sin 75o in surd form.

39

Page 41: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

• cos 75o = cos(30o + 45o) = cos 30o cos 45o − sin 30o sin 45o =√

32

1√2− 1

21√2

=√

3−12√

2.

• sin 75o = sin(30o + 45o) = sin 30o cos 45o − cos 30o sin 45o =√

12

1√2−

√3

21√2

=√

3+12√

2.

From equations 2.1,2.2 and 2.3 further identities can be derived e.g.

sin x± sin y = 2 sin(

x±y2

)cos(

x∓y2

)cos x+ cos y = 2 cos

(x+y

2

)cos(

x−y2

)cos x− cos y = −2 sin

(x+y

2

)sin(

x−y2

).

(2.4)

2.4 Half angle formulae

Another useful set of formulae can be derived for half angles

sin2 x2

= 12(1 − cos x)

cos2 x2

= 12(1 + cosx)

tan2 x2

=1 − cosx

1 + cosx.

(2.5)

Example 36

Find (a) sin 2212

o, (b) cos 15o, (c) tan 221

2

o. as surds.

Solution

• sin 2212

o=√

12(1 − cos 45o) =

√√2 − 1

2√

2.

• cos 15o =√

12(1 + cos 30o) =

2 +√

3

2.

• tan 2212

o=

√1 − cos 45o

1 + cos 45o=

√√2 − 1√2 + 1

.

40

Page 42: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

2.5 The sine rule and the cosine rule

We state these rules without proof, but they can be derived straightforwardly from thedefinitions of the trigonometric functions and Pythagoras’ theorem.

In any triangle with sides a, b, c and corresponding angles A,B,C we have the sine rule

a

sinA=

b

sinB=

c

sinC,

and the cosine rule

a2 = b2 + c2 − 2bc cosA, b2 = a2 + c2 − 2ac cosB, c2 = a2 + b2 − 2ab cosC.

These identities allow us to solve (i.e. find all the sides and angles of) triangles for whichonly one side and two angles or two sides and one angle, or the sides or angles are known.Which rule to use depends on the situation as shown in the diagram below:

B

BB

CC

a

a

ab b

b

c

+ 1 side

cosine rulesine rule

Example 37

Solve the following triangles:

bCC

c

AA

10 14 12

8

1230

(i) (ii)

• We use the sine rule for (i)

sinA

10=

sin 30

14=⇒ sinA =

5

14=⇒ A = 20.9o to 1 d.p..

Now we find C by subtraction 180− 30− 20.9 = 129.1o. We apply the sine rule onemore time to obtain the length of side c.

sin 30

14=

sin 129.1

c=⇒ c = 28 sin 129.1 = 21.7 to 1 d.p..

41

Page 43: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

• We use the cosine rule first for (ii)

b2 = 122 +82−12×8 cos 45 ⇒ b2 = 144+64− 96√2

= 140.118 ⇒ b = 11.8 to 1 d.p..

Now we use the sine rule

11.8

sin 45=

12

sinA=⇒ sinA =

12

11.8 × 2= 0.5058 =⇒ A = 30.6o to 1 d.p.

Finally by subtraction we find that C = 180 − 45 − 30.6 = 104.4o

Remark 2 When using the sine rule be aware that sinx = sin(180 − x) and check thatthe angles in the triangle add to 180o.

2.6 Distance between two points

An important application of Pythagoras’ theorem is to find the distance between the twopoints (x1, y1) and (x2, y2)

The length of b is y1 − y2, the length of c is x1 −x2. Thus if the distance between the twopoints is a then

a2 = (x1 − x2)2 + (y1 − y2)

2

so that the distance between the two points (x1, y1) and (x2, y2) is

distance =√

(x1 − x2)2 + (y1 − y2)2.

The formula can be extended to three dimensions:

distance =√

(x1 − x2)2 + (y1 − y2)2 + (z1 − z2)2.

Example 38

Find the distance between (3, 8,−4) and (−1, 3, 6).

Solution

The distance is√

42 + 52 + 102 =√

141.

42

Page 44: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Exercises for Chapter 2

1. Convert the following angles

(a) From radians to degrees: π5, 3π,−5π

12, 1.36, 2.45.

(b) From degrees to radians: 225o, 15o, 315o, 720o.

2. A pizza has radius 18 cm. A slice is cut with an angle of 68o at the point. What isthe area of the top of the slice?

3. Calculate the unknown sides and angles in the following right angled triangles:

c13

a

b5

A

B 53o

4

A

(i) (ii)

4. Find the exact values of (a) cos 2212

o(b) sin 15o (c) tan 75o.

5. Expand (a) sin(x+ π

6

)(b) tan

(x+ π

4

)(c) cos

(x− π

3

).

6. Solve the following triangles expressing your answers accurate to 2 d.p.s and ex-pressing angles in degrees.

(a) a = 7, b = 6, c = 9.

(b) A = 25o, b = 27, c = 32.

(c) A = 74o, B = 10o, c = 14.

7. Find the period of (a) cos 5x (b) sin 7x (c) cos(3x− 5) (d) sinx

2.

8. Find the distance between the following pairs of points(i) (1,−2) and (−2, 7), (ii) (−3, 5) and (1,−2), (iii) (9, 3) and (−1, 8),(iv) (−1,−3) and (−5, 1), (v) (4, 11,−5) and (7,−3,−1), (vi) (−3, 0, 7) and (−2,−3,−9).

9. Find sin 3x in terms of sin x.

10. * If tanx

2= t find expressions for sinx, cos x and tanx in terms of t.

43

Page 45: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Chapter 3

Equations and inequalities

If y = f(x) then a root of the function is x0 if f(x0) = 0. We also say that x0 is asolution of the equation f(x) = 0.

An equation is a statement that

right hand side = left hand side,

so that we may do any operation we wish with both sides of the equation and it remainstrue.

An equation is true for specific values of the variable only, thus

x2 + 2x+ 1 = 0 is true only if x = −1,

whereas an identity is true for all values of the variable

x2 + 2x+ 1 ≡ (x = 1)2 is true ∀x.

Solutions of equations should always be checked by substitution.

3.1 Linear equations

A linear equation of the form f(x) = ax + b = 0, a 6= 0 will always have precisely onesolution, x = − b

a.

3.1.1 Systems of linear equations

These are known as simultaneous equation since the solutions must satisfy all the equa-tions simultaneously. The simplest example is a system of two equations in two unknowns.The solution will be the point at which the graphs of the equations intersect.

Example 39x+ y = 4 (i)4x− y = 1 (ii)

44

Page 46: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

We can solve these equations by substitution

x = 4 − y from (i). Substitute for x in (ii)

4(4 − y) − y = 1 ⇒ 16 − 5y = 1 ⇒ y = 3 ⇒ x = 1.

Alternatively by adding equations (i) and (ii) we can eliminate y

5x = 5 =⇒ x = 1 =⇒ y = 3

We see this on the following plot.

Number of solutions of a system of linear equations

In two dimensions straight lines either cross or are parallel. We saw in the previousexample that there was a unique solution where the two lines intersected.

Example 40

Solve the following system of equations:

y = x− 1y = x+ 2

It is clear that these equations are inconsistent, attempting to solve them leads to theabsurdity that −1 = 2. The graphs of these two equations are parallel, there are nosolutions to this system.

45

Page 47: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Example 41

Solve the following system of equations:

y = x− 12y = 2x− 2

In this case the solution is y = x− 1, the two equations are the same. We could write thesolution as y = t, x = t − 1 where t is a parameter that can take any value, thus thereare infinitely many solutions to this system.. The value of t defines the point on the linewhere a particular solution lies.

3.2 Making a given variable the subject of an equa-

tion or a formula

We can think of an equation as a sentence with a subject, a verb (equals) and an object.We make a variable the subject of an equation

Example 42

Make x the subject of y =3x− 1

3x+ 1.

Solution

(3x− 1)y = 3x+ 1 =⇒ 3xy − y = 3x+ 1=⇒ 3xy − 3x = 1 + y=⇒ (3y − 3)x = 1 + y

=⇒ x =y + 1

3(y − 1)

Example 43

Make y the subject of x =y2 + 2

y2 − 2.

46

Page 48: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

xy2 − 2x = y2 + 2 =⇒ (x− 1)y2 = 2 + 2x=⇒ y2 = 2+2x

x−1

=⇒ y =

√2(1 + x)

x− 1

3.3 Quadratic equations

Quadratic functions are of the general form

y = ax2 + bx+ c,

where a, c, c are constants. As the next graph shows, they may have two roots, one rootor no roots.

To solve a quadratic equation we attempt first to factorise it, thus x2 − 5x − 14 = 0 ⇒(x − 7)(x + 2) = 0 so that either x = −2 or x = 7. If we cannot factor the equation wecan solve by completing the square.

Example 44

x2 − 5x− 15 = 0.

Solution

x2 − 5x− 15 = 0 ⇒(x− 5

2

)− 25

4− 15 = 0(

x− 52

)2 − 854

= 0 ⇒ x− 52

= 854

x− 52

= ±√

854

x = 52±

√852.

47

Page 49: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Alternatively we use the quadratic equation formula which is derived as follows:

ax2 + bx+ c = 0 ⇒ x2 +b

ax+

c

a= 0

(x+

b

2a

)2

− b2

4a2+c

a(x+

b

2a

)2

=b2 − 4ac

4a2⇒ x+

b

2a= ±

√b2 − 4ac

2a

x =−b±

√b2 − 4ac

2a.

The quantity b2 − 4ac is known as the discriminant of the equation and determines thenumber of roots of the equation, thus:

• b2 − 4ac > 0 −→ two distinct roots

• b2 − 4ac = 0 −→ one (double) root

• b2 − 4ac < 0 −→ no real roots .

Example 45

Solve x2 + x− 1 = 0.

Solution

x =−1 ±

√1 + 4

2= −1

√5

2

3.3.1 Concealed quadratics

We can apply the technique of solving quadratic equations to other types of equation byconverting them to a quadratic.

Example 46

x4 − 4x2 − 1 = 0

Solution

Put u = x2, then u2 − 4u− 1 = 0 so that, using the formula u = 2 ±√

5.

Since we must have u ≥ 0 we take the positive root, so the solution is x = ±√

2 +√

5.

Example 47

Solve 2ex + 2e−x = 5.

48

Page 50: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

Multiply both sides by ex

2to give e2x − 5

2ex + 1 = 0.

Put u = ex then u2 − 52u + 1 = 0 which we factorise to give (u − 2)(u − 1

2) = 0, so

that either u = 2 or u = 12

Then either ex = 2 so x = ln 2 or ex = 12

so x = − ln 2.

Example 48

The roots of f(x) = x2+4x+3 are −3,−1. Write down the roots of f(x+1), f(x−1), f(2x).

Solution

Recalling the earlier section on transformation of graphs, the roots of f(x−1) are −4,−2;those of f(x− 1) are 0, 2 and those of f(2x) are −3

2,−1

2.

3.4 Inequalities

In the real world inequalities are extremely important, we usually have constraints onthe availability of resources for example. We have ≥, >, ≤, < signifying greater than orequal to, greater than, less than or equal to and less than. It is important to distinguishthese.

We can manipulate inequalities in the same way as equations with two key differences.

Multiplying/dividing by a negative quantity reverses the order of the inequal-ity

The easiest way to see this is

8 > 5, multiplying both sides by −2 give us −16 < −10.

Reciprocation reverses the order of the inequality

Thus

8 > 5, taking reciprocals gives us 18< 1

5.

3.4.1 Solving inequalities

Example 49

Solve 3x+ 4 < 2.

49

Page 51: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

3x < 2 − 4 = −2 ⇒ x < −2

3

Example 50

Solve 1 +1

x≤ 3.

Solution

1

x≤ 2 ⇒ x ≥ 1

2

It is almost always a good idea to sketch the problem, as illustrated in the followingexample,;

Example 51

Solve (x− 2)2 ≤ 4.

Solution

We show the inequality on the graph, plotting y = (x− 2)2 and the line y = 4

If (x − 2)2 ≤ 4 then either x − 2 ≤ 2, taking the positive root, so x ≤ 4, or x − 2 ≥ 2,taking the negative root, so x ≥ 0. Thus the solution is 0 ≤ x ≤ 4 or x ∈ [0, 4].

Example 52

Solve |x− 2| ≤ 4.

50

Page 52: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

If |x− 2| ≤ 4 then either x− 2 ≤ 4 ⇒ x ≤ 6 or −(x− 2) ≤ 4 so x− 2 ≥ −4 and x ≥ −2.The solution is thus −2 ≤ x ≤ 6 0r x ∈ [−2, 6].

Example 53

Solve cos2 x < 12

x ∈ [−π, π]

We have either

cos x <1√2

or cos x > − 1√2.

Drawing the graph

We see that we have two intervals; either x ∈(−3π

4,−π

4

)or x ∈

(π4, 3π

4

).

3.4.2 Graphing inequalities

Whereas a graph of a linear equation is a straight line, the graph of a linear inequality isan area of the graph bounded by a straight line. If the inequality is strict (> or <) the lineitself is excluded from the area represented by the inequality. Above the line corresponds

51

Page 53: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

to a “greater than” inequality, below the line to a “less than” inequality. Hence we canshow the regions of space represented by x+ y < 1, x+ y = 1 and x+ y > 1.

Exercise 2 Draw the area of the graph which represents 3 < x < 5, 1 < y < 2

Solution

In the graph the dashed line means that the boundary is not included in the area repre-sented by the inequality.

A typical application of graphing inequalities

Consider a machine that can produce either product A or product B and is available 20hours per day. It takes 10 minutes to produce one item of A and 15 minutes to produceone item of B.

Let xA and xB be the numbers of items of A and B manufactured each day. Thenwe have the inequalities:

xA ≥ 0, xB ≥ 0, 10xA + 15xB ≤ 1200 ⇒ 2xA + 3xB ≤ 240.

52

Page 54: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

We represent these inequalities as the shaded area on the graph, this area is called thefeasible region and all production schedules must lie within it.

3.5 Other equations

We will encounter equations which cannot be solved algebraically, when we will use nu-merical methods (see the section on the Newton Raphson method) or Maple.

Higher order polynomial equations can be solved algebraically, provided we are able tofactorise them. To do so we make use of the factor theorem:

Theorem 1 If f(x) is a polynomial and f(a) = 0 then x − a is a factor of f(x) andf(x) = (x− a)g(x) where g(x) is another polynomial.

Example 54

Find the roots of f(x) = x3 − 9x2 + 26x− 24.

Solution

We first attempt to spot a root of f(x) using some obvious guesses.

f(0) = −24, f(1) = −6, f(2) = 0

So x−2 is a factor and thus f(x) = (x−2)g(x). To find g(x) we could either use algebraiclong division or the following procedure

1. g(x) must be a quadratic factor since f(x) is cubic.

2. g(x) must contain x2 and +12 since we need them to get x3 and −24 in f(x).

3. The only other term to be found in g(x) is the term in x. Now the −2 in x − 2multiplied by x2 in g(x) gives us −2x2, but f(x) has −9x2 so we must have a −7xterm in g(x) to multiply the x in (1 − x) to produce this. We can check this byequivalent reasoning for the x term in f(x).

53

Page 55: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Thus g(x) = x2 − 7x+ 12 which factorises to give (x− 3)(x− 4). Then

f(x) = (x− 2)(x− 3(x− 4) ⇒ the roots are {2, 3, 4}.

54

Page 56: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Exercises for Chapter 3

1. Solve the following pairs of simultaneous equations:

(a) 3x+ y = 7, 2x− 3y = 1

(b) 5x+ 10y = 18, 2x− 4y = 6

(c) 2x+ 3y = 16, x− y = 10

2. make x the subject of the following equations

(a) y =3x+ 4

4x+ 3, (b) y =

x2 − 4

x2 + 4

3. Solve the following quadratic equations

(a) x2 − 11x = 10 = 0

(b) x2 + x− 3 = 0

(c) 5x− 6x2 − 1 = −0

(d) x2 − 3x− 1 = 0

(e) x4 + 3x2 − 4 = 0

4. Solve the following inequalities

(a) x− 3 ≤ 4 − x

2(b) 3x+ 1 < −2 − x

(c) x2 − 16 < 0

(d) x2 + 4x+ 3 > 0 Hint: factorise and sketch a graph.

5. Sketch the region of the x, y plane corresponding to

(a) y > x+ 2 (ii) x+ y ≤ 5 (iii) y ≤ x2

6. For what range of values of c do (a) 3x2 − 4x− c = 0 and (b) 2x2 + cx+ 8 = 0 haveat least one real root?

7. Make x the subject of the following equations:

(a) y =2x2 + 1

4x+ 3

(b) y =ex2

+ 1

ex2 − 1

8. Solve the following equations

(a) ex + 21e−x = 10

(b) 32x + 5 × 3x+1 + 36 = 0

55

Page 57: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

9. *Sketch the area on the graph represented by x2 + y2 > 9

10. *The hyperbolic cosine (cosh) and hyperbolic sine (sinh - pronounced “shine”) aredefined by

coshx =1

2

(ex + e−x

), sinh x =

1

2

(ex − e−x

).

(a) Are coshx and sinh x odd, even or neither?

(b) Simplify the following expressions as far as possible:

(i) 2 cosh(lnx) (ii) cosh 5x+ sinh 5x (ii) cosh2 x− sinh2 x.

(c) Solve coshx = 2.

11. Solve x3 − 6x2 + 11x− 6 = 0

12. *Solve 4 sin3 x− 2 sin2 x− 6 sin x+ 3 = 0, x ∈ [0, 2π]

13. *Solve the following inequalities for x ∈ [0, 2π])

(i) tanx < 1 (ii) sin2 x ≤ 1

2(iii)

1

2< cosx <

√3

2.

56

Page 58: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Chapter 4

Introduction to linear algebra

4.1 Vectors

So far we have deal with quantities like 2, π, x which have magnitude only. These areknown as scalar quantities. We have seen how points in the x, y plane can be representedas an ordered pair of numbers - the x co-ordinate, followed by the y coordinate - e.g (2, 3).We could also describe the point (2, 3) as the position vector (2, 3) or the line vector fromthe origin to (2, 3).

x

y

(2,3)

A vector is an ordered set of numbers that has both magnitude and direction. Thusthe vector v = (2, 3) is not the same as u = (3, 2).

In three dimensions a vector will have three components, thus w = (2, 3, 4) for ex-ample.

The vector from (x1, y1) to (x2, y2) is (x2 − x1, y2 − y1). (Note the direction)

We describe (a, b, c) as a row vector, while

abc

or (a, b, c)T as a column vector, T means

transposed.

Vector notation is thus a compact and convenient method of expressing information.

57

Page 59: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

We write vectors as bold letters v in print, otherwise v or ~v.

A typical vector is wind velocity e.g. 20 m.p.h. from the east.

4.1.1 Equality of vectors

Vectors a = (a1, a2, a3) and b = (b1, b2, b3) are equal only if each of the correspondingcomponents are equal, i.e.

a1 = b1, a2 = b2, a3 = b3.

4.1.2 Vectors have magnitude

The length (of a line vector) or more generally the magnitude of a vector is called thenorm of the vector and is defined as the square root of the sum of the squares of thecomponents and written as ‖v‖.

Example 55

Find the norms of (i) v = (2, 3), (ii) w = (2, 3, 4).

Solution

• ‖v‖ =√

22 + 32 =√

13

• ‖w‖ =√

22 + 32 + 42 =√

29

4.1.3 Vectors have direction

2

3

1 2 3 x

y

v

1

θ

0

Here v = (3, 2), its direction is θ, where tan θ = 32, so θ = 56.3o and its length is

‖v‖ =√

13.

Example 56

What is the direction of the directed line vector (5, 3)?

58

Page 60: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

Both x and y are positive so this is a vector from the origin pointing into the first quadrant.The tangent of the angle between the x axis and the vector is 3

5, so the angle is 30.96o.

4.1.4 Vector arithmetic

We can add vectors provided that they have the same number of components,thus, ifa = (a1, a2, a3) and b = (b1, b2, b3) then:

a + b = (a1 + b1, a2 + b2, a3 + b3), a − b = (a1 − b1, a2 − b2, a3 − b3).

A vector in the opposite direction but with the same magnitude as a is -a = (−a1,−a2,−a3).We can multiply a vector by a scalar, k, to obtain another vector in the same directionbut stretched (k > 1) or compressed (k < 1):

ka = (ka1, ka2, ka3), ‖ka‖ = k‖a‖

The product of two vectors is a scalar quantity, known as the dot or scalar product

a · b = a1b1 + a2b2 + a3b3.

We can also express the dot product in the form

a · b =‖ a ‖‖ b ‖ cos θ where θ is the angle between a and b.

Let a = (2, 3, 1), b = (1,−2, 0) c = (−4, 2, 1). Then

• a + b = (3,−1,−1)

• a − b = (1, 5,−1)

• −3b = (−3, 6, 0)

• ‖a‖ =√

4 + 9 + 1 =√

14

• ‖b‖ =√

1, 4, 0 =√

5

• ‖c − b‖ = ‖(−5, 0, 1)‖ =√

25 + 0 + 1 =√

26

• a · b = 3 − 6 + 0 = −3

• a · c = −8 − 6 − 1 = −15

• b · c = −4 + 4 + 0 = 0

59

Page 61: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

If u ·v = 0 and neither u nor v is zero, then we say that u and v are orthogonal, in twoand three dimensions this is the same as saying they are at right angles to one another.

The angle between two vectors is given by cos−1 θ (cos−1 θ means the angle whose co-sine is θ and is pronounced either “arccos” or “inverse cos” where

cos θ =a · b

‖ a ‖‖ b‖

Thus

Example 57

Find the angles between (a) a = (2, 3, 1) and b = (1,−2, 0) and (b) a = (2, 3, 1) andc = (−4, 2, 1).

• The cosine of the angle between a and b is −3√14

√5

= −0.3586. The angle is 111.01o

to 2 d.p.s.

• The cosine of the angle between a and c is −15√14

√26

= 0.7862. The angle is 141.83o to2 d.p.s.

Example 58

Find values of α and β such that (i) (2, 1, 0) = α(−2, 0, 2) + β(1, 1, 1), (ii) (−3, 1, 2) =α(−2, 0, 2) + β(1, 1, 1).

Solution

• We equate corresponding components, thus

2 = −2α+ β x component1 = β y component0 = 2α+ β z component

The solution is β = 1, α = −12

which satisfy all three equations.

•−3 = −2α+ β x component1 = β y component2 = 2α+ β z component

The three equations are inconsistent since while β = 1, α = −12

satisfy the first twoequations they give 2 = 0 for the third. Thus no solutions exist.

Example 59

Given that a = (1, 0, 1),b = (0, 1, 0) find the dot product and interpret the result.

60

Page 62: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

a · b = 0. Thus a andb are at right angles. a is a vector in the (x, z) plane while b is avector along the y axis.

4.1.5 The vector equation of a straight line

Consider a line with general point r which passes through a point with vector u and hasdirection parallel to a vector v. Then the vector u − r is parallel to v so that

u − r = λv =⇒ r = u + λv λ ∈ R.

A particular value of λ indicates a specific point on the line (negative values of λ indicatethat the line points in the opposite direction).

Example 60

Find the vector equation of the line through (−2, 3) and (3,−4).

Solution

The line is parallel to v = (3 − (−2),−4 − 3) = (5,−7) so the equation is

r = (−2, 3) + λ(5,−7).

Example 61

Find the vector equation of the line through (−2, 3, 8) and (3,−4, 11).

Solution

The line is parallel to v = (3 − (−2),−4 − 3, 11 − 8) = (5,−7, 3) so the equation is

r = (−2, 3, 8) + λ(5,−7, 3)

in three dimensions.

Comparison with the Cartesian form of the straight line equation

We can write the equation r = (−2, 3) + λ(5,−7). in the form(xy

)=

(23

)+ λ

(5−7

).

Equating the corresponding components gives the two equations

x = −2 + 5λ, y = 3 − 7λ

61

Page 63: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

We eliminate λ from these two equations, thus

x+ 2

5=

3 − y

7=⇒ 5y + 7x+ 29 = 0.

This is of course the same result had we applied the standard formula to the line joining(−2, 3) and (3,−4) :

y − 3 =−4 − 3

3 − (−2)(x+ 2) =⇒ 5y + 7x+ 29 = 0.

Exercises on vectors

1. Let u = (2, 3, 4), v = (1, 5, 8), w = (2,−1 − 4)

(a) Find (i) v − w (ii) 3w + 2u − v (iii) (6w + 2v) − u)

(b) Find (i) ||u|| (ii) ||w+v|| (iii) ||u-v||(c) Find (i) u · v (ii) w · x (iii) ‖u · (v-w)‖(d) Find a vector y such that 5y − 2v = 2(w − 5u)

(e) Find the value of all scalars k such that ||ku|| = 14

(f) Find the angles between (i) u and v and (ii) v and w

(g) Find the vector equation of the line joining u and w

2. Find the vector equation and the Cartesian equation of the line joining (i) (1, 3) and(5, 6) (ii) (−1, 2) and (4,−3).

3. Find the vector equation and the Cartesian equation of the line passing through(4, 2) parallel to the vector (4,−3).

4. Find scalars c1, c2, c3 such that

c1(1, 2, 0) + c2(2, 1, 1) + c3(0, 3, 1) = (0, 5, 4).

5. Show that there do not exist non-zero scalars k1, k2, k3 such that

k1(−2, 9, 6) + k2(−3, 2, 1) + k3(1, 7, 5) = (0, 0, 0.)

6. Show that v = (a, b) and w = (−b, a) are orthogonal. Use this result to find twovectors orthogonal to (2,−3).

4.2 Matrices

Suppose that a furniture manufacturer has factories F1, F2 supplying warehousesW1,W2,W3

with the following numbers of armchairs each week:

62

Page 64: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

W1 W2 W3

F1 3 2 4F2 5 1 2

We can write this information in the form of a matrix:

A =

(3 2 45 1 2

)A matrix is simply a rectangular array of numbers with particular properties.

Terminology

We refer to the entry aij of the matrix A as the entry in the ith row and the jth column,so a13 = 4. The dimension of the matrix is number of rows × number of columns sodim(A) = 2 × 3. We also describe A as a (2, 3) matrix. A row in a matrix is also knownas a row vector, a column as a column vector.

Matrices are given certain important properties by mathematicians.

4.2.1 Matrix addition and subtraction

Suppose that the factories also supply the warehouse with dining chairs

W1 W2 W3

F1 4 3 1F2 5 3 6

Then we can define another matrix

B =

(4 3 15 3 6

).

The total amount of furniture supplied to each location from each factory is then

A+B =

(3 2 45 1 2

)+

(4 3 15 3 6

)=

(7 5 510 4 8

)More generally if A and B have the same dimensions only,

A+B = C −→ cij = aij + bij.

In a similar way we can subtract matrices:

A−B =

(3 2 45 1 2

)−(

4 3 15 3 6

)=

(−1 −1 30 −2 −4

)so that

A−B = D −→ dij = aij − bij.

The following rules apply to matrices A,B and C, all of the same dimension:

63

Page 65: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

• (A+B) + C = A+ (B + C)

• k(A+B) = kA+ kB where b is a scalar and the (i, j) entry in kA is kaij.

• A− A = 0. In this case by 0 we mean the zero matrix e.g

(0 0 00 0 0

).

• A+ 0 = A

4.2.2 Matrix multiplication

Suppose that armchairs cost the three warehouses £30, £40 and £50 respectively. Wecould represent this information by the vector (30, 40, 50). The income to factory F1 willbe the dot product of the vector representing the number of armchairs it supplies and thecost vector:

(3, 2, 4) · (30, 40, 50) = 370,

while the income to factory F2 will be

(5, 1, 2) · (30, 40, 50) = 290.

If we put all this information together we have

(3 2 45 1 2

)304050

=

(370290

).

If the three warehouses sell their armchairs to the public for £40, £45 and £52 re-spectively., then the revenue vector is (40, 45, 52) and so the sales revenue for factoryF1 = (3, 2, 4) · (40, 45, 52) = 418 and that for factory F2 = (5, 1, 2) · (40, 45, 52) = 349.This gives the following statement for sales revenue

(3 2 45 1 2

)404552

=

(418349

).

We can now express the entire set of information as

(3 2 45 1 2

)307 4040 4550 52

=

(370 418290 349

).

In general if A is a m,n matrix and B is an n, p matrix then the matrix AB existsand has dimension (m, p). If the number of columns of matrix A is not equalto the number of rows of matrix B then the matrix AB does not exist. Themultiplication is as follows for a (2, 3) matrix A and a (3, 2) matrix B:

(a11 a12 a13

a21 a22 a23

)b11 b12

b21 b22

b31 b32

=

(a11b11 + a12b21 + a13b31 a11b12 + a12b22 + a13b32a21b11 + a22b21 + a23b31 a21b12 + a22b22 + a23b32

)

64

Page 66: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

• Unless A and B are specific matrices with that property, in general AB 6= BA.

• If m = n then A is a square matrix and A2, A3 . . . etc. exist.

• The identity matrix I such that AI = A = IA is a square matrix with each diagonalentry 1 and zero elsewhere, thus

I3 =

1 0 00 1 00 0 1

.

• A(BC) = (AB).C

• A(B + C) = AB + AC (premultiply by A).

• (A+B)C = AB +BC (postmultiply by C).

Example 62

If

A =

1 4 32 1 83 1 4

B =

4 −1 5−2 6 13 2 7

find AB,BA,A2, B2

Solution

AB =

5 29 30

30 20 67

26 −1 42

BA =

17 10 24

13 −3 46

28 7 53

A2 =

18 5 47

28 1 46

13 7 17

B2 =

33 0 54

−17 40 3

29 23 66

.

Transposing a matrix

We transpose a matrix by exchanging its row and columns, leaving the diagonal entriesunaffected.

A =

1 4 32 1 83 −1 4

AT =

1 2 34 1 −13 8 4

65

Page 67: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

4.2.3 Inverses

Matrix division does not exist. However, for certain square matrices only we can definean inverse matrix as follows

AA−1 = I = A−1A.

Suppose that

A =

(a bc d

),

what is A−1 such that

AA−1 =

(1 00 1

)?

Let

A−1 =

(w xy z

)then

(a bc d

)(w xy z

)=

(1 00 1

)We can write the following four equations in four unknowns from this matrix multiplica-tion:

aw + by = 1 cw + dy = 0ax+ bz = 0 dcx+ dz = 1.

Solving, we obtain

w =d

ad− bc, x = − b

ad− bc, y = − c

ad− bc, z =

a

ad− bc.

The quantity ad − bc is the determinant of A, written as |A|. If we write our solutionfor A−1 we can see the manipulation required to obtain the inverse of a (2, 2) matrix.

A−1 =1

ad− bc

(d −b−c a

).

The procedure to find the inverse of a (2 × 2) matrix (aij) is as follows:

1. calculate the determinant,

2. swap entries a11 and a22,

3. reverse the signs of a12 and a21,

4. multiply the resulting matrix by the reciprocal of the determinant.

It should be clear that if the determinant is zero the inverse does not exist. In this casethe matrix is said to be singular.

Example 63

Find the inverse of the matrices

(i)

(3 −14 −7

)(ii)

(2 46 8

)

66

Page 68: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

(i) − 1

15

(−7 1−4 3

)(ii)

1

10

(8 −4−6 2

)

Using matrix inverses to solve systems of linear equations

We can write the system of equations

3x− 2y = 15x− 4y = 3

in the form (3 −25 −4

)(xy

)=

(13

)If we let

A =

(3 −25 −4

), x =

(xy

), b =

(13

)Then

Ax = b =⇒ A−1Ax = A−1b =⇒ Ix = A−1b =⇒ x = A−1b

Now

det(A) = −12 + 10 = −2, A−1 = −1

2

(−4 2−5 3

)Thus (

xy

)= −1

2

(−4 2−5 3

)(13

)=

(−1−2

)Finding the inverses of larger matrices manually is more complicated but is very straight-forward using Maple. Thus, in principle we have a method for solving any linear systemof equations. However, a more practical approach is to use what is called Gaussian Elim-ination.

4.2.4 Gaussian Elimination

Consider the system of equations

x+ y + z = 63x+ 2y − z = 43x+ y + 2z = 11.

(4.1)

We can write this system in the form:1 1 13 2 −13 1 2

xyz

=

6411

.

We use row operations to transform the 3, 3 matrix into the form1 m12 m13

0 1 m23

0 0 1

This is called row-echelon form.

67

Page 69: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Row operations

We can

• add or subtract any non-zero multiple of any one row to or from any other

• multiply any row by a non-zero scalar

• swap any two rows

of a matrix to produce an equivalent matrix.

Using row operations to solve a system of equations

We first write down the augmented matrix corresponding to equation 4.1 1 1 1 63 2 −1 43 1 2 11

the vertical line signifies the = sign. We then carry out row operations as follows, firstwe get two zeros, in column 1, row 2 and row 3. 1 1 1 6

0 −1 −4 −140 −2 −1 −7

r1 := r1r2 := r2 − 3r1r3 := r3 − 3r1

Then we get the leading element in row 2 =1. 1 1 1 60 1 4 140 −2 −1 −7

r2 := −r2

We get a zero in row 2 column 2 1 1 1 60 1 4 140 0 7 21

r3 := r3 + 2r2

Finally we get a 1 in row 3 column 3 1 1 1 60 1 4 140 0 1 3

r3 := r3

7

We are now in a position to use back-elimination:

z = 3y+ 4z = 14 =⇒ y = 2

x+ y+ z = 6 =⇒ x = 1

68

Page 70: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Alternatively we could continue with row operations to solve the system (this is calledGauss-Jordan elimination) producing a matrix in reduced row echelon form (rref). 1 1 0 3

0 1 0 20 0 1 3

r1 := r1 − r3r2 := r2 − 4r3

1 0 0 10 1 0 20 0 1 3

r1 := r1 − r2

Exercise 3 Solve the following system of equations using Gaussian Eliminations:

4x+ 3y − 6z = 122x− 5y + 3z = 52x− 6y + 4z = 4

Solution

With row operations we get 1 34

−32

30 1 −12

13213

0 0 1 −11

By back substitution (x, y, z) = (−6,−10,−11).

4.2.5 The rank of a matrix

The column rank of a matrix A is the number of linearly independent columns of A(Section 4.3.2 explains linear independence). Likewise, the row rank is the number oflinearly independent rows of A. Since the column rank and the row rank are always equal,they are simply called the rank of A with symbol ρ. If the rank of a matrix is k then,after row operations, there will be k rows which contain non-zero values.

This is an important property in allowing us to understand how many solutions existto a system of linear equations.

Example 64

Find the rank of the matrix A where

A =

1 −1 2 22 −3 2 13 −5 2 −3−4 12 8 10

69

Page 71: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

We apply row operations1 −1 2 20 −1 −2 −30 −2 −4 −90 8 16 18

r2 := r2 − 2r1r3 := r3 − 3r1r4 := r4 + 4r1

1 −1 2 20 1 2 30 −2 −4 −90 8 16 18

r2 := −r2−

1 −1 2 20 1 2 30 0 0 −30 0 0 −6

r3 := r3 + 2r2r4 := r4 − 8r2

1 −1 2 20 1 2 30 0 0 10 0 0 0

r3 := − r3

3

r4 := r4 + 6r3

Hence ρ(A) = 3

4.2.6 Number of solutions of a set of linear equations

We saw in section 4.1 the conditions for a pair of equations in two unknowns to have one,no or an infinite number of solutions. Suppose that Ax = b when A is an (n, n) matrix.Then if

ρ(A) = n there is a unique solutionρ(A) < n there are an infinite number of solutionsρ(A) 6= ρ(A|b) there is no solution, the equations are inconsistent

Example 65

How many solutions are there to the following system?

w + 3x+ 5y + z = 2 (i)2w + 3x+ 4y + 2z = 1 (ii)w + 2x+ 3y + z = 1 (iii)

Solution

A =

1 3 5 12 3 4 21 2 3 1

A|b =

1 3 5 1 22 3 4 2 11 2 3 1 1

70

Page 72: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

We now carry out row operations on A|b 1 3 5 1 20 −3 −6 0 −30 −1 −2 0 −1

r2 := r2 − 2r1r3 := r3 − r1 1 3 5 1 2

0 1 2 0 10 0 0 0 0

r2 := r2

−3

r3 := r3 + r2

Thus ρ(A|b) = 2, by inspection ρ(A) = 2 and we have n = 2,thus we expect an infinitenumber of solutions. We find these solutions in the following way:

The last row gives that 0z = 0 so we put z = α. The second row gives x + 2y = 1,let y = β so x = 1 − 2β. The first row is w + 3x+ 5y − z = 2 so w = −1 − α− β. Boththe parameters α ∈ R, β ∈ R.

We can write the solution in the vector form:wxyz

=

−1100

+ α

−1001

+ β

1−210

.

The parameters α and β show us that we have an infinite set of solutions, with particularsolutions given by specific values of α and β..

If we have m equations in n unknowns (m < n), then we will have n− ρ(A|b) parametersin the set of solutions.

To see why we obtained the result we did in this case we first demonstrate that weonly have two independent equations:

equation (i)

3

w

3+ x+

5y

3+z

3=

2

3

equation (ii)

3

2w

3+ x+

4y

3+

2z

3=

1

3

equation (i)+equation (ii)

3= w + 2x+ 3y + z = 1 = equation (iii)

To understand why there are no solutions if ρ(A) 6= ρ(A|b) we first reduce the last matrixwith r1 := r1 − 3r2 to 1 0 −1 1 2

0 1 2 0 10 0 0 0 0

Now, suppose that equation (iii) was w + 2x + 3y + z = 2, then the rref form of (A|b)would be 1 0 −1 1 2

0 1 2 0 10 0 0 0 1

71

Page 73: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

The last row means 0w + 0x + 0y + 0z = 1 −→ 0 = 1 which is nonsense. Thus ifρ(A) 6= ρ(A|b) the system of equations is inconsistent.

Geometrical considerations

In two dimensions the equation ax + by = c is a straight line. Straight lines in twodimensions either intersect or are parallel. In three dimensions the equation ax+by+cz =d represents a plane. Two planes either intersect in a line or are parallel. Three planesmay mutually intersect at a point (unique solution), a line (infinite number of solutions)or not at all (no solutions).

4.2.7 Matrices as operators

Multiplication of a vector by a matrix in general produces another vector with differentmagnitude and direction. Thus, consider the effect of some simple matrices on the vector(1, 2):

Reflection in the y axis. (−1 00 1

)(12

)=

(−12

)

y

x

Reflection in the x axis. (1 00 −1

)(12

)=

(1−2

)

72

Page 74: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

y

x

Reflection about the line y = x. (0 11 0

)(12

)=

(21

)

y

x

Reversing the direction of a vector(−1 00 −1

)(12

)=

(−1−2

)

y

x

Rotating a vector by an angle θ in an anticlockwise direction(cos θ − sin θsin θ cos θ

)(12

)=

(cos θ − 2 sin θsin θ + 2 cos θ

)

73

Page 75: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

y

x

θ

Stretching a vector and changing its direction(3 00 1

)(12

)=

(32

)

y

x

Stretching a vector but not changing its direction(4 12 3

)(12

)=

(24

)

x

θ θ

yy

x

74

Page 76: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

4.2.8 Eigenvectors and eigenvalues

Suppose, as in the last case, the action of the matrix A on the vector v is to multiply itsmagnitude by a scalar λ but leave the direction unchanged, i.e:

Av = λv.

If A is a square matrix and v 6= 0 then we call v an eigenvector and λ an eigenvalue. Wefind eigenvectors and eigenvalues as follows:

Finding eigenvalues

Rearranging the previous equation:

Av − λv = 0 =⇒ v(A− λI) = 0 =⇒ A− λI = 0.

The matrix A− λI is a11 − λ a12 a13 . . . a1n

a21 a22 − λ a23 . . . a2n...

......

...an1 an2 an3 . . . ann − λ

.

If the matrix is equal to the zero matrix then the determinant of the matrix is zero. Thus,for a (2, 2) matrix:

|A− λI| =

∣∣∣∣ a11 − λ a12

a21 a22 − λ

∣∣∣∣ = 0

So (a11 − λ)(a22 − λ) − a12a21 = 0, which, on multiplying out gives us the characteristicequation of the matrix

λ2 − (a11 + a22)λ+ a11a22 − a12a21 = 0.

The coefficient of λ,−(a11 +a22) is the negative of the sum of the diagonal elements of thematrix, this sum is known as the trace of the matrix. The constant term, a11a22−a12a21,is the determinant of the matrix. Solving the characteristic equation gives the eigenvaluesof the matrix.

Example 66

Find the eigenvalues of B =

(3 32 4

).

Solution

The characteristic equation of B is

λ2 − (3 + 4)λ+ (12 − 6) = 0 =⇒ λ2 − 7λ+ 6 = 0,

thus the eigenvalues are {1, 6}.

75

Page 77: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Finding eigenvectors

We substitute for λ = 1 in the equation v(B − λI) = 0(2 32 3

)(xy

)=

(00

)We solve 2x+ 3y = 0. This has two unknowns and one equation so we need a parameter.Let x = α, then y = −2

3α so the eigenvector corresponding to the eigenvalue λ = 1 is

α

(1−2

3

)or α

(−32

).

We now substitute for λ = 6 in the equation v(B − λI) = 0(−3 32 −2

)(xy

)=

(00

)We use Gaussian elimination to solve the system of equations(

−3 3 02 −2 0

)=⇒

(1 −1 00 0 0

)So that we have y = β, x = β and the eigenvector associated with the eigenvalue 6 is

β

(11

).

4.2.9 Determinants of (3, 3) matrices

The determinant of a (3, 3) matrix is evaluated as follows∣∣∣∣∣∣a11 a12 a13

a21 a22 a23

a31 a32 a33

∣∣∣∣∣∣ = a11

∣∣∣∣ a22 a23

a32 a33

∣∣∣∣− a21

∣∣∣∣ a21 a23

a31 a33

∣∣∣∣+ a31

∣∣∣∣ a21 a22

a31 a32

∣∣∣∣ .It is important to note the patterns of positive and negative signs. Each (2, 2) determinantcan then be evaluated.

Eigenvectors and eigenvalues of (3, 3) and matrices

Finding eigenvalues of (3, 3) matrices requires us to solve a cubic equation which may ormay not be factorisable. In practice for large matrices we use Maple.

Exercises on matrices

1. One student bought 2 CD’s and 3 DVD’s for £65 while another student bought 4CD’s and 1 DVD for £55. How much does a CD and a DVD cost?

76

Page 78: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

2. Solve the following systems of linear equations:

(a) x+ 3y = −1 (b) 2x− 5y = −8

4x− 2y = 10 4x+ y = 6

(c) x+ 2y + z = −3 (d) x+ 2y + 5z = 5x+ 3y + 3z = −9 2x+ y + 3z = 8

−x+ 3y − 2z = 17 3x+ 2y + z = 10

3. For the two matrices

A =

1 2 13 −1 4

−2 5 1

, B =

4 −2 31 0 3

−1 −2 3

,

find (i) B − 3A, (ii) AB and (ii) BA.

4. For the matrix

A =

1 3 1−2 5 3−3 0 1

,

show that the matrix

A−1 =

−5 3 −47 −4 5

−15 9 −11

is the inverse of A and hence find the solution of the following system of linearequations: 1 3 1

−2 5 3−3 0 1

x1

x2

x3

=

6111

.

5. Show that the following linear system of equations does not have a solution: [Hint:Use Gaussian elimination]

x+ 2y + z = 4

2x+ 5y − 2z = 6

x+ 4y − 7z = 6

6. Solve the following system of equations

2u+ v − 2w + 3x = 2

v + 3w − 3x = 1

2u+ 3v + 2w − x = 0

−4u− 3v + 5w − 4x = 0

7. Find the inverse of the matrix (3 4

−2 5

),

and hence solve the system

3x+ 4y = 13, −2x+ 5y = −1.

77

Page 79: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

8. Find the eigenvalues and eigenvectors of the following matrices

(i)

(2 61 3

), (ii)

(3 41 6

), (iii)

(4 16 3

])

9. Find two non-zero 2×2 matrices A and B such that their product is the zero matrix

10. *Is (A + B)(A − B) = A2 − B2 for matrices A and B? if it is not true in generalcan you find a pair of matrices for which the result is true.

11. Let

A =

(1 10 1

),

Find A2, A3 and A4. What is An for positive integer n?

12. *Find the eigenvalues and eigenvectors of the following matrices

(i)

4 0 1−2 1 0−2 0 1

, (ii)

5 6 20 −1 −81 0 −2

)

4.3 Elementary vector spaces

We are familiar with vectors in two and three dimensional spaces. We can extend theproperties to n dimensional spaces such as Rn, which is called a Euclidean space, whichcan provide many useful mathematical tools even if we cannot visualise more dimensionsthan three.

A vector in n dimensions is the ordered ntuple v = (v1, v2 . . . , vn) - we can think ofv as point in n-space or a directed line vector.

Vector arithmetic in n dimensions

Thus, if u = (u1, u2 . . . , un) and v = (v1, v2 . . . , vn) are two vectors in Rn then thefollowing properties are the natural extension form two and three demensional space.

• u = v −→ u1 = v1, u2 = v2 . . . un = vn

• u ± v = (u1 ± v1, u2 ± v2 . . . un ± vn)

• ku = (ku1, ku2 . . . kun)

• 0 = (0, 0, . . . 0) - n components

• −u = (−u1,−u2 . . . ,−un)

• u · v = u1v1 + u2v2 + . . .+ unvn, the scalar or dot product

78

Page 80: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

• ‖ u ‖=√u2

1 + u22 . . . u

2n, the norm

• ‖ u-v ‖=√

(u1 − v1)2 + (u2 − v2)2 . . . (un − vn)2 a metric

The latter quantity is the distance between u and v, known as the Euclidean distanced(u,v);

d(u,v) =√

(u1 − v1)2 + (u2 − v2)2 . . . (un − vn)2

If u ·v = 0 and neither u nor v are identically zero then u and v are said to be orthogonal.

Example 67

Given u = (3,−2, 7),v = (7, 2, 2), find ‖ u ‖, d(u,v),u · v

Solution

‖ u ‖=√

9 + 4 + 49 =√

62

d(u,v) =√

(3 − 7)2 + (−2 − 2)2 + (7 − 2)2 =√

57

u · v = 3 × 7 + −2 ×−2 + 7 × 2 = 39.

Unit vectors

if u = (u1, u2 . . . , un) then

u =u

‖ u ‖is a unit vector in the direction of u. We can express any vector in the direction of u asλu.

Example 68

Find a unit vector in the direction of x = (2, 4,−2, 1)

Solution

||x|| =√

4 + 16 + 4 + 1 = 5, thus a unit vector in the direction of x is 15(2, 4,−2, 1).

Basis vectors in R3

Any point in R3 can be written (x, y, z). If we denote

i = (1, 0, 0) unit vector in x directionj = (0, 1, 0) unit vector in y directionk = (0, 0, 1) unit vector in z direction

79

Page 81: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

then any vector v = (a, b, c) can also be written as

v = ai + bj + ck.

This is linear combination of i, j,k. i, j,k are called basis vectors for R3 and any vectorin R3 can be expressed as a linear combination of these basis vectors.

x y

z

i j

k

From the graph we see that

i · j = j · k = i · k = 0 mutually orthogonal

‖ i ‖=‖ j ‖=‖ k ‖= 1 unit vectors

4.3.1 Linear combinations of vectors in Rn

We say thatw = k1v1 + k2v2 . . . knvn,

where k1, k2, . . . kn are scalars, is a linear combination of vectors v1,v2, . . .vn

Example 69

If u = (1, 2,−1),v = (6, 4, 2) in R3, is w = (9, 2, 7) a linear combination of u and v?

Solution

Let w = k1u + k2v thenk1 + 6k2 = 92k1 + 4k2 = 2−k1 + 2k2 = 7.

We find that k1 = −3, k2 = 2 is the solution to this system of equations, so w is a linearcombination of u and v.

Example 70

If u = (1, 2,−1), v = (6, 4, 2) in R3, is z = (4,−1, 8) a linear combination of u and v?

80

Page 82: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

Let z = c1u + kc2v thenc1 + 6c2 = 42k1 + 4k2 = −1−k1 + 2k2 = 8.

There is no solution to this system of equations - they are inconsistent, so z is not a linearcombination of u and v.

4.3.2 Linearly independent vectors

Vectors v1,v2, . . .vn are said to be linearly independent if

k1v1 + k2v2 . . . knvn = 0

only if k1, k2, . . . kn are all zero.

Example 71

Are v1 = (2,−1, 0, 3),v2 = (1, 2, 5,−1) and v3 = (7,−1, 5, 8) linearly independent?

Solution

We have to solve k1v1 + k2v2 + k3v3 = 0. Thus

2k1+ k2+ 7k3 = 0−k1+ 2k2− k3 = 0

5k2+ 5k3 = 03k1− k2+ 8k3 = 0

We write the system in matrix form and solve using Gaussian Elimination:2 1 7 0−1 2 −1 00 5 5 03 −1 8 0

−→

1 1

272

00 5

252

00 5 5 00 −5

2−5

20

r1 := r1

2

r2 := r2 + r1r3 := r3r4 := r4 − 3r1

−→

1 1

272

00 1 1 00 0 0 00 0 0 0

r1 := r1r2 := r2

52

r3 := r3 − 5r2r4 := r4 + 5

2r2

The solution is k3 = α, k2 = −α and k1 = 3α or

k1

k2

k3

= α

311

. Thus we conclude that

v1,v2 and v3 are not linearly independent.

81

Page 83: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

On the other hand, if we consider (i, j,k) we have to solve1 0 00 1 00 0 0

k1

k2

k3

=

000

.

This has only one solution, k1 = k2 = k3 = 0 demonstrating that i, j and k are linearlyindependent.

Remark 3 Linear independence in R2

Two vectors in R2 are independent if, when placed with their initial points at the origin,they are not on the same line - i.e. they are not parallel.

Remark 4 Linear independence in R3

Three vectors in R2 are independent if, when placed with their initial points at the origin,they are not in the same plane

4.3.3 Basis vectors in Rn

In R2, i and j are basis vectors, every vector in R2 can be expressed as a linear combinationof them. Any other pair of linearly independent vectors will also form a basis for R2. Wecall i, j standard basis vectors for R2 and i, j, k standard basis vectors for R3.

In Rn we say that if v1,v2, . . .vn are linearly independent then the set

{v1,v2, . . .vn}spans Rn. A spanning set S in Rn must contain n linearly independent vectors. Wealso say that if S = {v1,v2, . . .vn} is a spanning set it is also a basis for Rn and everyvector in Rn can be expressed as a linear combination of the vectors in S.

To show that a set is a basis for Rn we have to show that there are n linearly inde-pendent vectors in the set or, equivalently, that any vector in Rn can be expressed as alinear combination of the vectors in the set.

Example 72

Is {u = (1, 2, 1),v = (2, 9, 0),w = (3, 3, 4)} a basis for Rn?

Solution

Let c1u+ c2v + c3w = 0. Then solving for c1, c2, c3 with Gaussian Elimination we have 1 2 3 02 9 3 01 0 4 0

−→

1 2 3 00 5 −3 00 −2 1 0

−→

1 2 3 00 1 −3

50

0 0 −15

0

The rank of the matrix is 3. The only solution is c1 = 0, c2 = 0, c3 = 0. Thus u, v, w arelinearly independent and they form a basis for Rn

82

Page 84: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Exercises on vector spaces

1. Let u = (−3, 2, 1, 0), v = (4, 7,−3, 2), w = (5,−2, 8, 1), x = (1, 2, 3, 4)

(a) Find (i) v − w (ii) 3w + 2x − u (iii) (6w + 2v) − (4x − u)

(b) Find (i) ||u|| (ii) ||w+x|| (iii) ||x-u|| (iv) w (v) 2v − x

(c) Find (i) u · v (ii) w · x (iii) d(w,v) (iv) d(u,x)

(d) Find a vector y such that 5y − 2v = 2(w − 5x)

(e) Find the value of all scalars k such that ||ku|| = 14

(f) Are u,v,w,x linearly independent?

2. Which of the following pairs of vectors are orthogonal?

(a) u = (−1, 3, 2) v = (4, 2,−1)

(b) u = (−2,−2,−2) v = (1, 1, 1)

(c) u = (−4, 6, 10, 2) v = (2, 1,−2, 11)

3. For what value of k are u and v orthogonal?

(a) u = (2, 1, 3) v = (1, 7, k)

(b) u = (k, k, 1) v = (k, 5, 6)

4. Which of the following are linear combinations of u = (1,−2, 3) and v = (2,−1, 4)

(a) (−4,−1, 6)

(b) (0,−3, 2)

(c) (4,−3, 8)

(d) (3 − 5, 9)

5. Express the following as linear combinations ofu = (2, 1, 4),v = (1,−1, 3) and w = (3, 2, 5)

(a) (−9,−7,−15)

(b) (6, 11, 6)

(c) (1, 1, 1)

(d) (7, 8, 9)

6. Determine whether or not these sets of vectors span R3:

(a) (2, 2, 2), (0, 0, 3), (0, 1, 1)

(b) (2,−1, 3), (4, 1, 2), (8,−1, 8)

(c) (3, 1, 4), (2,−3, 5), (5,−2, 9)

7. Show that the following sets of vectors are linearly independent.

83

Page 85: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

(a) (3, 8, 7,−3), (1, 5, 3,−1), (2,−1, 2, 6), (1, 4, 0, 3)

(b) (0, 0, 2, 2), (3, 3, 0, 0), (1, 1, 0, 1), (2, 3, 1, 4)

(c) (0, 3,−3,−6), (−2, 0, 0, 6), (0,−4,−2,−2), (0,−8, 4,−4)

(d) (3, 0,−3,−6), (0, 2, 3, 1), (0,−2,−2, 0), (−2, 1, 2, 1)

8. Prove that for any vectors u,v,w the vectors u − v, v − w and w − u form alinearly dependent set.

9. Find the values of λ such that the following vectors form an independent set in R3

v1 =

(λ,−1

2,−1

2

), v2 =

(−1

2, λ,−1

2

), v3 =

(−1

2,−1

2, λ

)10. Determine whether the two lines

r = (3, 2, 3,−1) + t(4, 6, 4,−2), r = (0, 3, 4, 5) + t(1,−3,−4,−2)

intersect in R4

84

Page 86: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Chapter 5

Differential calculus

Suppose that an object moves in a straight line with constant speed v. We can plot theposition of the object, x(t), at any time t to give a straight line with equation x(t) = x0+vt.At time t+ a we have x(t+ a) = x0 + v(t+ a).

The rate of change of position with time =corresponding change in position

change in time.

Thus between time t and t+a we have rate of change of position with time =v(t+ a) − vt

a=

v. The speed, v, is the slope or gradient of the line and is constant.

If, however, we want to measure the rate of change of position when the object movesat variable speed - say x(t) = x0 + αt + βt2, we need to be able to measure the rate ofchange instantaneously as

instantaneous speed =corresponding change in position

very small change in time.

85

Page 87: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

5.1 The general case

If, for y = f(x) we move from x to x + ∆x then y moves from f(x) to f(x + ∆x). Thuswe can define the slope of the chord in the graph below as

slope of chord =f(x+ ∆x) − f(x)

(x+ ∆x) − x,

or∆y

δx=f(x+ ∆x) − f(x)

∆x.

∆x

∆x

∆x

x

f(x+ )

∆y

chord

xx+

f(x)

y= f(x)

We can see that, as ∆x gets smaller, so does ∆y, and the chord approaches a tangent,i.e. just touching the curve, at the point (x, f(x)). As both ∆x and ∆y approach zero wedefine the limit of the left hand side as

lim∆x→0

∆y

∆x=dy

dx.

dydx

is the slope or gradient at the point (x, y), it is the differential of y with respect to xand may also be written as f ′(x) or y′.

The question arises as to what is

lim∆x→0

f(x+ ∆x) − f(x)

∆x.

86

Page 88: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Suppose that f(x) = cx3 where c ∈ R is a constant. Then

f(x+ ∆x) − f(x) = c(x+ ∆x)3 = cx3

= c(x3 + 3x2∆x+ 3x∆x2 + ∆x3) − cx3

∆y

∆x=c(3x2∆x+ 3x∆x2 + ∆x3)

∆x

= c(3x2 + 3x∆x+ ∆x2).

Then as ∆x,∆y → 0 we have

dy

dx= lim

∆x→0c(3x2 + 3x∆x+ ∆x2) = 3cx2 + lim

∆x→0c(3x∆x+ ∆x2) = 3cx2.

In general we can show that if y = axn where (a, n ∈ R) then

dy

dx= anxn−1.

Example 73

y = 6x3 dy

dx= 18x2.

y =4

x2

dy

dx= − 8

x3.

y = 2√x

dy

dx=

1

2√x.

y = x13

dy

dx=

1

3x−

23 =

1

3x23

.

5.1.1 Common differentials

Here is a list of the differentials of some common functions:

f(x) f ′(x)eax aeax

ln(ax+ b) aax+b

cos ax -a sin axsin ax a cos axtan ax a sec2 x

Note that we always express angles in radian measure in calculus.

87

Page 89: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

5.2 Key properties of differentials

The table of common differentials can be used to evaluate the differentials of many muchmore complicated functions by using the following rules:

5.2.1 Sum of derivatives

The derivative of a sum of functions is the sum of the derivatives of the functions.

d

dx(f(x) ± g(x)) = f ′(x) ± g′(x)

Example 74

d

dx

(x4 + 4x2 − 2

x

)= 3x2 + 8x+

2

x2

5.2.2 Second derivatives

We define the second derivative of f with respect to x as

d2y

dx2=

d

dx

dy

dx.

Example 75

d2

dx2(x4) =

d

dx4x3 = 12x2.

If x(t) is position we have seen that dxdt

(often written as x) is speed. Then d2xdxt or x is the

rate of change of speed with time or acceleration. In the same way we can have third,fourth and higher derivatives.

5.2.3 The product rule

If we want to differentiate a product of two functions u(x) and v(x) the rule is

d

dxuv = u

dv

dx+ v

du

dx.

Example 76

y = x2 cosx −→ u = x2, v = cosxdy

dx= x2 sinx+ 2x cos x.

y = ex sin x −→ u = ex, v = sin xdy

dx= ex(sin x+ cosx).

y = x3e−x −→ u = x3, v = ex dy

dx= 3x2e−x − x3e−x = x2ex(3 − x).

88

Page 90: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

5.2.4 The quotient rule

If we want to differentiate a quotient of two functions u(x) and v(x) we have

d

dx

u

v=udv

dx− v

du

dxv2

.

Example 77

y =sinx

x2−→ u = sin x, v = x2 dy

dx=x2 cos x− 2x sinx

x4.

y =ex + x

lnx−→ u = ex + x, v = lnx

dy

dx=

lnx(ex + 1) − 1x(ex + x)

(lnx)2.

=ex + 1

ln x− ex + x

x(lnx)2

y = tanx −→ u = sin x, v = cos xdy

dx=

cosx cosx− (− sinx) sinx

cos2 x.

=cos2 x+ sin2

cos2 x=

1

cos2 x= sec2 x.

5.2.5 The chain rule

This rule is also known as “function of a function’. Consider a function such as y = g(f(x))then the chain rule is that if u = f(x) and so y = g(u) then

dy

dx=dy

du

du

dx= g′(u)f ′(x) = g′(f(x))f ′(x).

The first differential is the change in y due to a change in u, the second is the change inu due to a change in x.

Example 78

y = ln(sin x) −→ u = sin x, y = lnudy

dx=

1

ucosx =

cosx

sinx= cotx.

y = sec x =1

cos x−→ u = cos x, y =

1

u

dy

dx= (− sin x)

(− 1

u2

)=

sinx

cos2 x= sec x tanx.

y = e4x2 −→ u = 4x2, y = eu dy

dx= u · 8x = 8xe4x2

.

Example 79

Find the second derivatives of (i) y = ex sinx (ii) y = tanx

89

Page 91: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

We use the product rule twice in the first case and the quotient rule in the second casesince we recognise the differential of tan x as a standard form.

d2y

dx2=

d

dx(ex sinx+ ex cos x) = ex sin x− ex sinx+ ex sin x+ ex cos x = 2e2 cosx

•d2y

dx2=

d

dx

(sec2 x

)=

d

dx

(1

cos2 x

)= −2 cos x sin x

cos4 x= −2 sec2 x tanx.

Remark 5

The process of differentiation is essentially an algorithm, following these standard rules.

5.3 Applications of differentiation

There are many applications of differential calculus - we look at some of the most impor-tant here.

5.3.1 Finding local maxima and minima

If we consider the curve below, we see that at a local maximum or minimum the gradientof the curve is zero.

Local maxima and minima are also known as turning points as the gradient moves formpositive to negative or vice versa.

Example 80

Find the local maxima and minima of y = x3 − 6x2 + 9x+ 21

90

Page 92: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

We differentiate to get y′ = 3x2 − 12x+ 9 and then solve y′ = 0. Thus x2 − 4x+ 3 = 0 →(x− 1)(x− 3) = 0 and x = 1 and x = 3. We find that y(1) = 25 and y(3) = 19.

In oder to find whether these are maxima or minima we could of course sketch the graph,however we can use the properties of the first and second differentials to characterise thesepoints.

The graph below shows the position for a general f(x), f ′(x) and f ′′(x) on the sameplot. There are two equivalent tests:

• EitherAt a minimum the second derivative is positive and a maximum it is negative. Inthe example y′′ = 6x− 12 and thus y′′

∣∣1

= −6 so x = 1 is a maximum and y′′∣∣3

= 6so x = 3 is a minimum.

• OrAt a minimum the first derivative is passing from negative to positive and at amaximum the first derivative is passing from positive to negative. In the examplewe have

y′∣∣x<1

> 0 y′∣∣x>1

< 0 y′∣∣x<3

>< 0 y′∣∣x>3

> 0

so we have shown as before that x = 1 is a maximum and x = 3 is a minimum.

If the second derivative is zero at a point (at which the first derivative may or may not bezero) then the point is known as a point of inflection. There is one in the plot aboveat x = 0.5. A point of inflection in this example shows that the slope is moving fromincreasing to decreasing or vice versa.

When both the first and second derivatives are zero the point of inflection looks likethat shown in the graph below.

91

Page 93: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Procedure for finding and characterising turning points and points of inflectionof y = f(x)

1. compute f ′(x),

2. solve f ′(x) = 0,

3. compute f ′′(x),

4. evaluate f ′′(x) at each solution of f ′(x) = 0 and use

(a) f ′′(x) < 0 maximum

(b) f ′′(x) < 0 minimum

(c) f ′′(x) = 0 point of inflection,

5. solve f ′′(x) = 0 to find any other points of inflection.

Example 81 Find and characterise the turning points and points of inflection of g(x) =x5 − 5x3.

Solution

g′(x) = 5x4 − 15x3 = 5x2(x2 − 3). The solutions to g′(x) = 0 are x = 0 and x = ±√

3.

g′′(x) = 20x3 − 30x = 10x(2x2 − 3) then

• g′′(0) = 0 point of inflection,

• g′′(−√

3) = −60√

3 + 30√

3 < 0 maximum,

• g′′(√

3) = 60√

3 + −30√

3 > 0 minimum.

fg′′(x) = 0 for x = 0,±√

32. The function and its derivatives are plotted below:

92

Page 94: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Finding absolute maxima and minima

Consider y = x2 − 3x + 2. Thus function has a local minimum at 2x− 3 = 0, x = 32

andfrom the graph we can see that it is also an absolute or global minimum. It is clear thatthere is no maximum, local or global since limx→±∞ y = ∞. However if the domain ofx is constrained, e.g. x ∈ [0, 2] then y has an absolute maximum at x = 0, y(0) = 2. Inmodeling the real world domains are typically constrained - thus prices and quantities arealways non-negative.

Hence if the domain is constrained the maxima and minima are to be found either wherethe gradient is zero or at the end of the interval.

Remark 6

Linear functions only have maxima or minima if their domain is constrained.

93

Page 95: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

5.3.2 Tangents and normals

If y = f(x) then the gradient of the graph at x0 is f ′(x0). Thus if y0 = f(x0) then theequation of the tangent at (x0, y0) is

y − y0 = f ′(x0)(x− x0).

The normal is at 90o to the tangent. The product of the gradients of two lines at rightangles is −1. Thus the equation of the normal at (x0, y0) is

y − y0 = − 1

f ′(x0)(x− x0).

Example 82

Find the equation of the tangent and the normal to y =√

5 − x2 at x = 1.

Solution

dy

dx= − x√

5 − x2=⇒ dy

dx

∣∣∣∣x=1

= −1

2

We have y(1) = 2 so that the equation of the tangent is

y − 2 = −1

2(x− 1) =⇒ 2y + 3x− 3 = 0,

while the equation of the normal is

y − 2 = 2(x− 1) =⇒ y − 2x = 0.

This is the graph of the curve with the tangent and normal shown.

94

Page 96: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

5.3.3 Approximating small changes

We had for y = f(x) that

∆y = f(x+ ∆x) − f(x) =∆y

∆x∆x.

Thus, for very small ∆x,∆y

∆y =dy

dx∆x.

Example 83

By what % does the area of a circle increase if the radius is increased by 2%?

Solution

Let the area be A and the radius r. Then A = πr2 and

∆A =dA

dr∆r = 2πr∆r.

We need∆A

Athus

∆A

A=

2πr∆r

πr2=

2∆r

r.

We are told that∆r

r= 0.02 so

∆A

A= 0.04.

The area is expanding by 4%.

Example 84

By what % does the volume of a sphere increase if the radius is increased by 2%?

Solution

Let the volume be V , then V =4

3πr3 so that we have

dV

dr= 4πr2, thus

∆V

V=

4πr2

43πr3

∆r =3∆r

r= 0.06.

The volume is expanding by 6%.

5.3.4 Related rates of change

Example 85

95

Page 97: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Air is pumped into a spherical balloon. The volume is increasing at 20 cm3 per secondwhen the radius is 30 cm. How fast is the radius increasing?

Both the volume, V and the radius r are functions of time, t. If V = 43πr3 then

dV

dt=

d

dt

4

3πr3.

On the right hand side we put u = r3 sodu

dr= 3r2 and, using the chain rule,

du

dt=du

dr

dr

dtso we obtain

dV

dt= 4πr2dr

dt.

Substituting the given values we have

dr

dt=

20

4π(30)2= 0.0018cm/second.

Example 86

How fast is the area of a rectangle changing if one side is 10cm long and is increasing at arate of 2 cm/second and the other is 8cm long and is decreasing at a rate of 3cm/second

Solution

Let the sides be x, y and the area A. Then

A = xy =⇒ dA

dt= x

dy

dt+ y

dx

dt= 10(−3) + 8(2) = −14cm2 per second.

5.4 The Newton Raphson method

The Newton Raphson method is a powerful technique for the numerical solution of equa-tions that cannot be solved arithmetically. Numerical methods generally use algorithmswhich require an initial estimate as a starting point.

Finding an initial estimate

Consider the function f(x) = cos x− x. We cannot solve f(x) = 0 by algebraic methods.If we draw the graph we see that there is a root, x0.

96

Page 98: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

We see that, close to x0 that for x < x0, f(x) > 0 while for x > x0, f(x) < 0. Thuswe know that in an interval where the function changes sign there must be at leastone root.(This is known as the Intermediate Value Theorem.) We have f(0) = 1 andf(

π2

)= −π

2, so we can be sure that there is a root x0 ∈

(0, π

2

). Thus a reasonable first

estimate might be x0 = π4.

The Newton Raphson method has the following steps, illustrated on the graph that follows

1. Sketch the graph of the function f(x)

2. Find an interval (a, b) such that f(a) and f(b) are of different signs

3. Find the equation of the tangent at x0

4. Compute the intercept of the tangent line with the x axis, this is x1

5. Repeat steps 3 and 4 until the required degree of accuracy has been reached.

y= f(x)

xxx xx x0123

f(x )

f(x )0

f(x )1

f(x )2

3

We know that the equation of the tangent at (x0, f(x0) to y=f(x) is

y − f(x0) = f ′(x0)(x− x0).

97

Page 99: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Suppose that at x1 we have y = 0 then

f(x0) + f ′(x0)(x− x1) = 0 =⇒ x− 1 − x0 = −f(x0)

f ′(x0

.

Thus

x1 = x0 −f(x0)

f ′(x0

and in general we have the iteration formula:

xn+1 = xn − f(xn)

f ′(xn

.

Thus if f(x) = cosx− x then f ′(x) = − sinx− 1 and

xn+1 = xn − cosxn + xx

sinxn + 1.

n xn f(xn) f ′(xn) xn − f(xn)

f ′(xn

0 0 1 −1 11 1 −0.459698 −1.841471 0.7503642 0.750364 −0.018923 −1.681905 0.7391133 0.739113 −0.000047 −1.673633 0.739085

Thus to four decimal places the solution is 0.7391. Maple gives 0.7390851322.

In general the Newton Raphson method gives rapid convergence to the desired approxi-mation.

98

Page 100: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

5.5 Exercises for chapter 5

1. Work through as many of the examples and exercises in the Differentiation Work-book as you can.

2. Find the derivativedy

dxin each of the following cases, simplifying your answers as

much as possible:

(a) y = 3x4, (b) y = 12x

83 , (c) y = 5x4+x3+

2

x, (d) y = cos 6x, (e) y = 2e−3x,

(f) y =√x+ lnx2, (g) y = x4e2x, (h) y =

1 − cos x

x, (i) y =

cosx

sinx,

(j) y = e−2x(2x2 + 2x− 1), (k) y = ln(1 + 2x2), (l) y = esin x.

3. For each of the following functions, find the co-ordinates of all the local maximaand minima:

(a) −3x2+4x+5, (b) y = 2x3−5x2+4x−1 (c) y = x4−2x2, (d) y = x2+250

x.

4. Find the coordinates of the points of inflection of the curve y = x4 − 6x3 + 12x2 +5x− 3.

5. Find the equations of the tangent and the normal to the curve y = e3x(1−x) at thepoint where x = 0.

6. Find the second derivatived2y

dx2of (a) y = ln(1 + x2), (b) y = ex cos x

7. Find and characterise the turning points of y = e−x2. Sketch the graph.

8. Find√

3 by solving x2 − 3 = 0 using the Newton-Raphson method to 3 d.p.s

9. The equation x3 + x + 1 has one real root. (How would you show this?) Use theNewton Raphson method to find this root correct to 2 d.p.s

10. *The binomial expansion of (x+ h)n is

(x+ h)n = xn + nxn−1h+n(n− 1)

2xn−2h2 . . .

Using these first three terms show that when y = xn, then dydx

= nxn−1, from firstprinciples.

11. *Find the first and second derivatives of y = e−2x sin 5x and hence show that thisfunction satisfies the differential equation

d2y

dx2+ 4

dy

dx+ 29y = 0.

12. *Find and characterise all the turning points of y = x3e−x. Sketch the graph.

99

Page 101: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

13. *Find the root of x3 +2x− 1 = 0 that lies between 0 and 1 by the Newton-Raphsonmethod to 3 d.p.s.

Exercises using differentiation in modeling to find the optimalsolution

1. *An orchard plants 24 trees per acre and gets 600 apples per tree. They know thatfor each additional tree planted per acre in excess of 24 the number of apples pertree falls by 12 per year. What is the optimal number of trees to plant per acreand what is the corresponding number of apples per tree? (Hint: let the number ofapples per tree be n and find an expression for N , the total number of apples in theorchard as a function of n. Then find the value of n that maximises N).

2. *A property company has 180 holiday apartment which will be fully occupied whenthe rent is £300 per week. For each additional £10 per week five apartments willbecome unoccupied. What is the optimal rent? (Hint: let the weekly rent perapartment be r and find an expression for R, the total rent from all the apartments.Then find the value of r that maximises R.)

3. *The maximum size of parcel that may be sent through the post is such that thesum of the perimeter of the base and the length is less than 96 inches. If the baseis square, what are the dimensions of the largest box that can be sent through thepost.(Hint: label the edges as shown and find an expression for the volume V interms of x, having eliminated h. Then find the value of x that maximises V .)

xx

h

4. *The picture shows a semicircular arch. What are the proportions which maximisethe amount of light passing through the window if the perimeter is fixed at 4 metres?Can you find a solution if the perimeter is p? (Hint: express the perimeter and thearea in terms of x and h, eliminate h and then find the value of x that maximisesthe area.)

x

h

100

Page 102: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Chapter 6

Introduction to MathematicalEconomics

6.1 Supply and demand

In general if the price P of an item increases, then the demand QD for the item decreaseswhile the supply QS increases. We would expect that QD is a decreasing function of P ,while QS is an increasing function of P.

Where the two lines intersect, in the first quadrant (since we have P,Q ≥ 0). we have anequilibrium, where supply = demand.

We will assume that supply and demand are linear functions of price only, thus

supply function QS = a+ bP, demand function QD = c+ dP

and c > 0, a < c, b > 0, d < 0.

At equilibrium

a+ bP = c+ dP −→ PE =c− a

b− d, QE =

bc− ad

b− d. (6.1)

101

Page 103: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Example 87

Find the equilibrium if QD = 8 − 4P,QS = 4 + 5P.

Solution

8 − 4P = 4 + 5P −→ 9P = 4 −→ PE =4

9, QE =

56

9.

6.2 Excise tax

This is a fixed monetary amount of tax paid for each unit sold to the government by thesupplier, (such as the tax on a bottle of spirits in the U.K.) Thus the buyer pays P andthe supplier receives P − t where t is the amount of the tax. Thus

QS = a+ b(P − t) and QD = c+ dP.

The values of PE and QE are as in equation 6.1. With excise tax t the new equilibriumis found from the solution of a+ b(P − t) = c+ dP, that is

Q?E =

bc− ad+ dbt

b− dP ?

E =c− a− bt

b− d. (6.2)

Straightforward algebra shows that P ?E > PE and Q?

E < QE.

The price increase paid by the consumer at equilibrium as a result of the tax is P ?E −PE =

bt

b− d. while the amount received by the supplier is P ?

E − t or − dt

b− d. Thus the cost of

the excise tax is split between the supplier and the consumer in the ratio |d| : b.

The graph shows what has happened to supply and demand. The supply curve is shiftedin the direction of negative Q with the slope unchanged as a result of the impositionof an excise tax.

102

Page 104: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Example 88

The demand function is QD = 120 − 8P , the supply function QS = −6 + 4P . An excisetax of £4.5 is applied. Find the equilibria before and after tax and the proportions of thetax paid by the buyer and the seller.

Solution

Without the tax we have the equilibrium price at the solution of 120−8P = −6+4P −→PE = £10.5, QE = 36.

With the tax the equilibrium price is the solution of 120 − 8P = −6 + 4(O − 4.5) −→P ?

E = £12, Q?E = 24.

The buyer pays an extra £1.5 and the seller receives £3 less so the tax burden is split 1:2between the buyer and seller.

6.2.1 Maximising the yield from excise tax

If the equilibrium price increases and the equilibrium quantity decreases with the appli-cation of an excise tax we might suppose that there was a value of the tax t at which theyield Y = Q?

Et is maximised.

Y = Q?Et =

(bc− ad+ dbt

b− d

)t −→ dY

dt=bc− ad

b− d+ 2

dbt

b− d.

We havedY

dx= 0 if t =

ad− bc

2dband also that at this value of t,

dY

dt2=

2db

b− d< 0 so the

point is indeed a maximum.

Example 89

If the demand function is QD = 100 − 10P , the supply function QS = 10 + 5P , find thevalue of the excise tax which maximises the tax yield.

103

Page 105: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

The pre-tax equilibrium we find in the usual way to be PE = £6, QE = 40. Now let thetax be t per unit, then the new supply function is QS = 10+5(P − t) and the equilibrium

post-tax is P ?E = £6 +

t

3, Q?

E = 40 − 10t

3. Thus the tax yield is

Y (t) = t

(40 − 10t

3

)= 40t− 10t2

3.

Differentiating and solving for Y ′(t) = 0 we have t = 6. The graph of Y is as follows:

6.3 Sales tax

A sales tax is paid by the supplier and is a given percentage of the sales price of the item.Thus if the pre-tax supply and demand functions were

supply function QS = a+ bP, demand function QD = c+ dP,

then after a sales tax at a rate τ they are

QS = a+ bP (1 − τ), QD = c+ dP.

We found the pre-tax equilibrium in equation 6.1. The post-tax equilibrium price is foundby solving a+ bP (1 − τ) = c+ dP, thus

P ?E =

c− a

b(1 − τ) − d, Q?

E =bc(1 − τ) − ad

b(1 − τ) − d.

Example 90

Show that P ?E > PE and that Q?

E < QE.

104

Page 106: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

To show P ?E > PE is straightforward, for τ > 0, b(1−τ)−d < b−d so

c− a

b(1 − τ) − d>c− a

b− d.

Now

Q?E −QE =

cb(1 − τ) − ad

b(1 − τ) − d− bc− ad

b− d

=(b− d)(cb(1 − τ) − ad) − (bc− ad)(b(1 − τ) − d)

(b− d)(b(1 − τ) − d)

=bdt(a+ c)

(b− d)(b(1 − τ) − d)< 0

Example 91

The demand function is QD = 80 − 5P , the supply function QS = 10 + 2P , and a salestax of τ is applied. Find the equilibria before and after tax.

Solution

The equilibrium pre tax is PE = 10, QE = 30. With the tax rate τ the post-tax equilibriumprice is found by solving 10 + 2P (1 − τ) = 80 − 5P to give

P ?E =

70

7 − 2τQ?

E =210 − 160τ

7 − 2τ.

Thus if τ = 10% then P ?E = £10.29 and Q? = 28.53.

The equilibrium price has increased and the equilibrium quantity has decreased. Theslope of the supply curve has been reduced by the imposition of a sales tax.

105

Page 107: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

6.3.1 Maximising the yield from a sales tax

The tax yield from the sales tax τ is

Y (τ) = τ · P ?E ·Q? =

70τ(210 − 160τ)

(7 − 2τ)3.

If we differentiate Y with respect to τ we obtain (using both the product rule and quotientrule):

dY

dτ=

4900(21 − 26τ)

(7 − 2τ)3.

When τ − 2126

= 80.8% the tax yield is maximised, we can check by computingd2Y

dτ 2=

−392007 + 13 τ

(−7 + 2τ)4 .

The graph of Y is as follows:

While this appears to be a very high rate, tax on tobacco and fuel can frequently reachthis level.

6.3.2 Non-linear supply and demand functions

Consider the following supply and demand functions:

QS = P 2 + 2P + 12QD = 68 − 4P − P 2.

At the equilibriumP 2 + 2P + 12 = 68 − 4P − P 2

P 2 + 3P − 28 = 0(P + 7)(P − 4) = 0

We select the positive value, thus PE = 4, QE = 36 We note thatdQS

dP> 0 and

dQD

dP< 0,

as in the linear case the supply function is increasing and the demand function is decreas-ing.

106

Page 108: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

In principle, the same calculations on excise and sales taxes could be carried out on thismodel. Although the results will be much more complicated, they will show the sameprincipal of reduction in equilibrium quantity and increase in equilibrium price.

6.4 Revenue, costs and profit

We can also express a demand function with Q as the independent variable, in the formP = γ+ δQ, (γ > 0, δ < 0) and a supply function as P = α+βQ, β > 0. In the usualway we solve α+ βQ = γ + δQ to get the equilibrium values

PE =βγ − αδ

β − δ, QE =

γ − α

β − δ

The total revenue TR at the equilibrium is TRE = PEQE, thus, at equilibrium, for allsuppliers in the market:

TRE =(βγ − αδ)(γ − α)

(β − δ)2.

More generally, for one supplier, if the demand for his product is q then his total revenueis TR = q(γ + δq).

This function has a maximum when q = qmax = − γ

2δat which the supplier’s total revenue

is TRmax = −γ2

Suppose that the seller’s total costs TC can be expressed as TC = F + vq where Fis fixed costs (like rent which do not very with demand) and vq is variable cost (which isrelated to demand, such as cost of materials or machine time). Then the average cost perunit of the product is

TC

q=F

q+ v.

As q gets small TC gets very large and as q gets very large, TC tends to v.

107

Page 109: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Maximising total revenue

Clearly if the demand function for a company’s product is given by P = f(q) thenTR = qf(q) and total revenue is maximised when f(q) + qf ′(q) = 0.

Example 92

Find the value of q which maximises total revenue when (i) P = 3−2q, (ii) P = 68−4q−q2.

Solution

• TR = q(3 − 2q) −→ dTR

dq= 3 − 4q. Thus qmax = 3

4, TRmax = 3

4.

• TR = 68q− 4q2 − q3 −→ dTR

dq= 68− 8q− 3q2. We have to solve 3q2 +8q− 68 = 0,

using the quadratic formula we obtain qmax = −43

+ 23

√55 = 3.6 to 1 d.p. Then

TRmax = 146.3.

Profit

Profit π is the difference between total revenue and total costs. π is given by π = TR−TC.The graph below shows that q1 is the break-even point, q? is the production when profitis maximized and q2 is the maximum production that can be profitably produced,

108

Page 110: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Now, π(q) = qγ+ δq2 −F − vq, so we can find q1 and q2 by solving δq2 + q(γ− v)−F = 0to get

q1 =v − γ

2δ+

√(v − γ)2 − 4δF

2δ, q2 =

v − γ

2δ−√

(v − γ)2 − 4δF

2δ.

We find q? as usual:dπ

dq= γ + 2δq − v so q? =

v − γ

2δwhich is a maximum since

d2π

dq2= 2δ < 0, hence we have

πmax =−(v − γ)2

4δ− F.

Example 93

Find the value of q which maximises profit when (i) TR = q(3 − 2q), TC = 0.3 + q2, (ii)

TR = 68q − 4q2 − q3, TC = 40 + 8q.

Solution

(i) We find the profit, differentiate the result, set the differential equal to zero and solveto find q.

π =5

2q − 2q2 − 0.3 so we have

dq=

5

2− 4q

and profit is maximised when q = qmax = 58.

(ii)

π = 60q − 4q2 − q3 − 40,dπ

dq= 60 − 8q − q2

We solvedπ

dq= 0,

3q2 + 8q − 10 = 0 −→ (3q − 10)(q + 6) = 0,

so profit is maximised when q = 3.33 disregarding the negative root.

109

Page 111: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Example 6.4 (i) Example 6.4 (ii)

6.4.1 Marginal revenue and marginal cost

We define marginal revenue, MR as MR =dTR

dq, in effect the revenue from the last item

sold. We define marginal cost MC as MC =dTC

dq, the cost of the last item made. With

the expressions we derived in this section we have

MR =d

dqγq + δq2 = γ + 2δq, MC =

d

dqF + vq = v.

Now, if γ + 2δq = v then dπdq

= 0. Thus we have found that profit is maximised when

marginal revenue = marginal cost.

This is a key idea in economics.

110

Page 112: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Exercises for Chapter 6

When answering these questions, work through the calculations involved rather thansimply substituting numbers into the formulas developed in the lectures.

1. The supply (QS) and demand (QD) for a product are related to its price (P ) by

QD = 8 − 2P

QS = 1 + P.

(a) Find the equilibrium price PE and quantity QE.

(b) An excise tax t is applied to this product.State the new supply equation which includes the tax t.Find the equilibrium price PE(t) and quantity E(t) as functions of t.

(c) Find the value of the tax t which will result in the maximum tax yield beinggenerated.

2. The demand and supply functions of a product are given by

P = −4QD + 120

P =1

3QS + 29.

(a) Calculate the equilibrium price and quantity

(b) Calculate the new equilibrium price and quantity after the imposition of a fixedexcise tax of £13 per item. Who pays this tax?

3. The supply and demand functions for a product are

P = 2QS + 10

P = −5QD + 80

(a) Find the equilibrium price and quantity.

(b) If the government deducts as tax, 15% of the market price of each product,determine the new equilibrium price and quantity.

4. Given the total revenue and total cost functions

TR = 4350Q− 13Q2

TC = Q3 − 5.5Q2 + 150Q+ 25000

Using Maple, find the breakeven points, the value of Q which maximises total rev-enue and the value of Q which maximises the profit function. On the same graphplot the total revenue, total cost and profit functions.

5. The supply (QS) and demand (QD) for a product are related to its price (P ) by

QD = 7 − P 2

QS = 1 + P.

111

Page 113: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

(a) Sketch the supply and demand curves.

(b) Find the equilibrium price PE and quantity E.

(c) An excise tax t is applied to this product.State the new supply equation which includes the tax t.Find the equilibrium price PE(t) and quantity E(t) as functions of t.

(d) Find the value of the tax t which will result in the maximum tax yield beinggenerated. (You will need to use Maple to find this value).

112

Page 114: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Chapter 7

Series

7.1 Arithmetic series

A series is a sum of a finite or infinite number of terms which are each described by somegiven rule. Consider the series

2 + 5 + 8 + 11 . . . .

We can write this series in the form

2 + (2 + 3) + (2 + 3 + 3) + (2 + 3 = 3 + 3) . . . .

The series is an arithmetic series (or progression) with first term 2 and common dif-ference 3.

In general an arithmetic series can be written as

Sn = a+ (a+ d) + (a+ 2d) + (a+ 3d) . . .+ (a+ (n− 1)d).

Here Sn is the sum to n terms, the first term is a, the common difference is d and the nth

term is (a+ (n− 1)d). Another way of writing this is

Sn =n∑

i=1

ui,

where ui is the ith term given by ui = a+ (i− 1)d.

Suppose that the last term is L, then

Sn = a+ (a+ d) + (a+ 2d) . . .+ (L− 2d) + (L− d) + L

Sn = L+ (L+ d) + (L+ 2d) . . .+ (a+ 2d) + (a+ d) + a

2Sn = (a+ L) + (a+ L) + . . .+ (a+ L) + (a+ L) + (a+ L) = n(a+ L)

Sn =n

2(a+ L).

113

Page 115: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

The sum of the arithmetic series is half the sum of the first and last terms times thenumber of terms. Alternatively,

Sn =n

2(2a+ (n− 1)d) .

Example 94

Find the sum of the first 1000 natural numbers.

Solution

Sn = 1 + 2 + 3 + 4 . . . 1000.

We have a = 1, d = 1 and n = 1000, thus

S1000 = 500(2 + 999) = 500, 500.

Example 95

The 3rd and 7th terms of an arithmetic progression are 71 and 55. Find the sum of thefirst 45 terms.

We haveu3 = a+ 2d = 71u7 = a+ 6d = 55

4d = −16.

Thus d = −4 and a = 79. Hence

S45 =45

12(79 × 2 − 44 × 4) = −405.

The terms of an arithmetic series grow linearly, the sum grows as the square of thenumber of terms.

7.2 Geometric series

Suppose we have a series3 + 6 + 12 + 24 + 48 . . .

which we can also write as

3 × 20 + 3 × 21 + 3 × 22 + 3 × 23 + . . .

The nth term is 3 × 2n−1, the common ratio is 3.

In general if the first term is a and the common ratio r;

Sn = a+ ar + ar2 + ar3 . . .+ arn−1

rSn = ar + ar2 + ar + 3 + ar4 . . .+ arn

Sn − rSn = a− arn.

114

Page 116: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Thus

Sn =n−1∑i=0

=a (1 − rn)

1 − r.

The sum of a geometric series grows exponentially with the number of terms.

Example 96

Find the sum of the first 11 terms of the geometric series whose first term is 5 and secondterm is 6.

We have a = 5, ar = 6 so r = 65

thus

S11 =5(1 −

(65

)11)

1 − 65

= 161 to 3 s.f..

7.2.1 Convergent series

A geometric series may be finite, thus

1 + x+ x2 + x3 =1 − x4

1 − x.

or infinite, e.g.S∞ = 1 + x+ x2 + x3 + x4 . . .+ xn . . .

Provided that the terms get small sufficiently quickly we might expect an infinite geometricseries to have a finite sum.

limn−→∞

Sn = limn−→∞

a (1 − rn)

1 − r=

a

1 − r− lim

n−→∞

arn

1 − r.

If we consider arn we see that for positive n, if r < 1 then as n → ∞, arn → 0, while ifr > 1 the terms are continuously increasing. If r = 1 the terms are constant.

115

Page 117: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Hence, for r < 1 we have the sum of an infinite geometric series:

S∞ =a

1 − r.

If r < 0 we have terms of alternating signs so that the terms oscillate either to zero forr ∈ (−1, 0), to infinity for r < −1 and remain absolutely constant, oscillating in sign ifr = −1.

and thus we have∞∑i=0

ari =a

1 − rfor |x| < 1.

Thus suppose that a = 1, r = 12, then

Sn = 1 +1

2+

1

4+

1

8. . .

1

2n−1.

and

S1 = 1, S2 =3

2, S3 =

7

4, S4 =

15

8, S3 =

31

16S4 =

63

32. . .

The sum rapidly approaches 2. in fact∞∑i=0

2i =1

1 − 12

= 2.

Example 97

Findn=11∑n=5

3n.

n=11∑n=5

3n =n=11∑n=0

3n −n=4∑n=0

3n

=1 − 312

1 − 3− 1 − 35

1 − 3=

312 − 35

2

= 265, 559

116

Page 118: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Remark 7 Note the identity

b∑n=a

xn ≡b∑

n=0

xn −a−1∑n=0

xn

Exercise 4

Find8∑

n=o

(1

3

)n

.

Solution

8∑n=o

(1

3

)n

=1(1 −

(13

)9)1 − 1

3

= 1.4999.

7.3 The binomial expansion

If we consider the expansion of (1 + x)n for different values of n we have

(x+ 1)2 ≡ x2 + 2x+ 1(x+ 1)3 ≡ x3 + 3x2 + 3x+ 1(x+ 1)4 ≡ x4 + 4x3 + 6x2 + 4x+ 1.

The pattern of the coefficients in (1 + x)n for n ∈ N is given by the appropriate row inPascal’s triangle:

n = 0 1n = 1 1 1n = 2 1 2 1n = 3 1 3 3 1n = 4 1 4 6 4 1n = 5 1 5 10 10 5 1

Each entry is the sum of the entries above to the left and to the right.

In the nth row the entries are

1, n,n(n− 1)

1 · 2,

n(n− 1)(n− 2)

1 · 2 · 3. . .

Thus the coefficient of xr in the expansion of (1 + x)n is

n(n− 1)(n− 2)(n− 3) . . . (n− r + 1)

1 · 2 · 3 · 4 . . . r

=n(n− 1)(n− 2)(n− 3) . . . (n− r + 1) [(n− r)(n− r − 1)(n− r − 2) . . . 3 · 2 · 1]

1 · 2 · 3 · 4 . . . r [(n− r)(n− r − 1)(n− r − 2) . . . 3 · 2 · 1]

=n!

r!(n− r)!

117

Page 119: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

We can write the last expression equivalently as nCr or

(nr

). The expression

(nr

)is the

number of different ways in which we could choose r objects from a group of n objects

where the order of the objects is not important. We call

(nr

)“n choose r”.

Properties of the binomial coefficients

1. In the expansion of (1 + x)n the sum of the coefficients is 2n.

2.

(n0

)=

n!

0!(n− 0)!= 1, note that we define 0! = 1.

3.

(nn

)=

n!

n!(n− n)!= 1

4.

(nr

)=

(n

n− r

).

Example 98

(i)

(53

)=

5!

3!(5 − 3)!=

5 · 4 · 3 · 2 · 1(1 · 2 · 3)(1 · 2)

= 10

(ii)

(95

)=

9!

5!4!=

9 · 8 · 7 · 61 · 2 · 3 · 4

= 126

In general, for n ∈ N we have

(x+ y)n =n∑

r=0

(nr

)xn−ryr

= xn + nxn−1y +n(n− 1)

2!xn−2y2 +

n(n− 1)(n− 2)

3!xn−3y3 . . .+ yn

Example 99

Find (i) the fifth term in the expansion of (x+2y)7, (ii) the fourth term in the expansionof (2x− y)9

Solution

(i) The required term has n = 7 and r = 4:(74

)x7−4(2y)4 =

7!

4!(7 − 4)!x3y4 = 560x3y4

118

Page 120: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

(ii) Here n = 9, r = 3:(93

)(2x)9−3(−y)3 = − 9!

3!6!26x6y3 = −84 × 64x6y3 = −5376x6y3

Example 100

Expand (1 + x)14 and hence find 0.99714.

Solution

(1 + x)14 = 1 + 14x+14 · 13

1 · 2x2 +

14 · 13 · 12

1 · 2 · 3x3 . . . = 1 + 14x+ 91x2 + 364x3 . . . .

We now put x = −0.003 so

0.99714 = 1 + 14 × (−0.003) + 91 × (0.003)2 + 364 × (0.003)3 . . . = 0.95881.

7.4 The binomial series

We can generalise the binomial expansion to cases where n is negative or fractional.

(1 + x)n = 1 + nx+n(n− 1)

2!x2 +

n(n− 1)(n− 2)

3!x3 . . .

=∞∑

r=0

n(n− 1)(n− 2) . . . (n− r + 1)

r!xn

(7.1)

• The series converges only for |x| < 1.

• If n ∈ N the series terminates after n+ 1 terms - it is the binomial series.

• More generally the expression must be in the form (1 + argument)n and we musthave |argument| < 1. If the argument is f(x) then, provided that |f(x)| < 1, theright hand side of the equation 7.1 is simply another function, say F (f(x)),

(1 + f(x))n =∞∑

r=0

n(n− 1)(n− 2) . . . (n− r + 1)

r!(f(x))n = F (f(x))

Example 101

119

Page 121: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

(i)1

1 + x= (1 + x)−1 = 1 + (−1)x+

(−1)(−2)

2!x2 +

(−1)(−2)(−3)

3!x3 . . . = 1 − x+ x2 − x3 . . .

(ii)1

1 − x= (1 + x)−1 = 1 + (−1)(−x) +

(−1)(−2)

2!(−x)2 +

(−1)(−2)(−3)

3!−x3 . . .

= 1 + x+ x2 + x3 . . .

We recognise this as a geometric series with the first term 1 and common ratio x.

(iii)1

(1 − x)2= 1 + 2x+ 3x2 + 4x3 . . .

In each case we must have |x| < 1. We obtained this expansion in (iii) by differentiating

the left and right hand sides of the expansion for1

1 − x.

Remark 8

Provided that series converge we can treat the right and left hand sides like an equation.Thus in particular we can differentiate both sides.

We can also add and subtract convergent series and multiply series together, thus;

1

1 + x= 1 − x+ x2 − x3 + x4 . . .

1

1 − x= 1 + x+ x2 + x3 + x4 . . .

1

1 + x

1

1 − x=

1

1 − x2= (1 − x+ x2 − x3 + x4 . . .) (1 + x+ x2 + x3 + x4 . . .)

= 1 +x +x2 +x3 +x4 . . .

−x −x2 −x3 −x4 . . .

+x2 +x3 +x4 . . .

−x3 −x4 . . .

+x4 . . .

1

1 − x2= 1 + x2 + x4 . . .

This is of course the same result as we would have obtained had we expanded1

1 − x2

directly.

120

Page 122: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

(ii)1√

1 − 3x= (1 − 3x)−

12

= 1 +

(−1

2

)(−3x) +

(−1

2

)(−3

2

)2!

(−3x)2 +

(−1

2

)(−3

2

)(−5

2

)3!

(−3x)3 . . .

= 1 +3x

2+

27

8x2 +

135

16x3 . . .

This series converges provided that | − 3x| < 1 −→ |x| < 13.

It is very important that we only use the binomial series in the interval for which itconverges, outside that interval the series is not valid as the following graph shows for

1

1 − x. The dashed line is the binomial expansion of

1

1 − xto ten terms.

As we take more terms the better the approximation. The approximation is best near tox = 0 and worst near to x = ±1.

Example 102

Expand1√

4 − x2and hence find an approximation to

1√3.

121

Page 123: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Solution

1√4 − x2

= (4 − x)−12 = 4−

12

(1 − x

4

)− 12

=1

2

[1 +

(−1

2

)(−x

4

)+

(−1

2

)(−3

2

)2!

(−x

4

)2

+

(−1

2

)(−3

2

)(−5

2

)3!

(−x

4

)3

. . .

]

=1

2+

x

16+

3x2

128+

5x3

2048. . .

The series converges provided that∣∣∣x4

∣∣∣ < 1 −→ |x| < 1

4.

If x = 1 we immediately see that

1√3

=1

2+

1

16+

3

128+

51

2048. . .

= 0.5 + 0.0625 + 0.01172 + 0.0024 = 0.5776.

In fact to four d.p.s we have from Maple1√3

= 0.5774.

7.5 Maclaurin Series

This is a method of approximating a function by an infinite power series of the formf(x) = a0 + a1x+ a2x

2 + . . .. We obtain the coefficients in this series as follows:

Letf(x) = a0 + a1x+ a2x

2 + a3x43 . . . anx

n . . . ,

122

Page 124: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

assuming that the series converges and all the derivatives of f(x) exist at x = 0.Then

f(0) = a0

f ′(x) = a1 + 2a2x+ 3a3x2 . . . nanx

n−1 . . .

f ′(0) = a1

f ′′(x) = 2a2 + 6a3x . . . n(n− 1)anxn−2 . . .

f ′(0) = 2a2 −→ a2 =f ′(0)

2

f ′′′(x) = 6a3 . . . n(n− 1)(n− 2)anxn−3 . . .

f ′′′(0) = 6a3 −→ a2 =f ′′′(0)

3!

...

f [n](0) = n!an −→ an =f [n](0)

n!

Thus we have the Maclaurin series for f(x)

f(x) = f(0) + f ′(0)x+f ′′(0)

2!x2 +

f ′′′(0)

3!x3 . . .

provided that x lies in the interval for which the series converges. This interval is knownas the radius of convergence and can be calculated for each series by methods we will notcover here.

Two important Maclaurin series

1. If f(x) = ex we have f [n](x) = ex for all x and f [n](0) = 1 for all x so

ex = 1 = x+x2

2!+x3

3!· · · + xn

n!. . . for all x ∈ R

2. For f(x) = cosx we have

f ′(x) = − sin x, f ′′(x) = − cosx, f ′′′(x) = sinx, f [iv](x) = cosx and sof ′(0) = 0, f ′′(0) = −1, f ′′′(0) = 0, f [iv](0) = 1 and so forth. Thus

cosx = 1 − x2

2!+x4

4!. . .+

(−1)nx2n

(2n)!. . . for all x ∈ R

123

Page 125: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

We have the following useful approximations for small values of x:

ex ≈ 1 + xsin x ≈ x

cos x ≈ 1 − x2

2tanx ≈ x.

124

Page 126: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Exercises for Chapter 8

1. Find the value of

(a)23∑

r=1

r (b)13∑

r=7

(3r − 2).

2. Find the sum of all even positive integers less than 2000.

3. The boring of a well costs £5 for the first metre depth, £11 for the second and £17for the third. The costs for each successive metre continue in the same arithmeticseries. Find the cost of boring a well of (a) 50 metres and (b) 100 metres.

4. Find the 10th term and the sum of the first ten terms of the following geometricseries:

a+ ar + ar2 + ar3 . . .

when(i) a = 10, r = 2, (ii) a = 10, r = −2, (iii) a = 10, r = −1

2,

(iv) a = 3, r = 6, (v) a = 3, r = −6.

5. Find the sum to n terms and the sum to infinity (where the series converges) of thefollowing series:

(i) 310

+ 3100

+ 31000

+ . . . (ii) 16 − 8 + 4 − . . . (iii) 8 − 12 + 18 − . . .

6. Find the first 3 terms in the expansion of the following in ascending powers of x

(a) (1 − x)23 (b) (1 + x)15.

7. Find the first three terms in descending powers of x of (5x− 3)7.

8. Expand (1 + x)10, in ascending powers of x obtaining the first four terms. Henceobtain an approximation of 0.99810.

9. Expand the following in series in ascending powers of x up to and including theterm in x3, simplifying as much as possible and stating the range of values of x forwhich the series is valid:

(a)1

(1 + x)2(b)

1

(1 − x)3(c)

2(1 − x

2

)2 (d) (4 + 3x)12

(e) (1 − x)34 (f)

1

(100 + x)12

(g) (1 − 3x)13 .

10. Find the sum of all the integers between 0 and 200 that are not divisible by 4.

11. The first and third term of an arithmetic series are 23

and 32

respectively. Find thecommon difference and the sum of the first twelve terms.

125

Page 127: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

12. Find the value of

(a)9∑

n=4

(1.5)n (b)10∑

n=2

4

(3

4

)n−1

.

13. Suppose that the price of a house increases at a constant 3% per annum. At thestart of 1994 it was worth £45, 000. What was the value at the start of 1980? Whatwould the value be at the start of 2020? 2200?

14. The coefficients of x, x2 and x3 in the expansion of (1 + x)n form the first threeterms of an arithmetic series. Show that n = 7.

15. Find the coefficient of x12 in the expansion of (x+ y)18. Evaluate this term withx = 2, y = 1

3.

16. Given that |x| < 1, expand

(1 + x

1 − x

) 13

up to and including the term in x2.

17. Expand each of the following using the binomial series and state the range of valuesof x for which the series is convergent

(i)1√

1 − 5x, (ii)

1

(1 + 4x)4, (iii)

1

(16 − 3x)2.

18. The coefficients of x and x2 in the expansion of (1+px+qx2)−2 in ascending powersof x are 4 and 14. Find p and q.

19. A theatre has 24 seats in the front row, 28 in the second, 32 in the third and soforth. There are 32 rows of seats. How many seats are there in the theatre?

20. A rubber ball is dropped vertically from a height of 16ft. Each time it is dropped itrebounds to 80% of the previous height. How far does it travel in (a) 15 bounces,(b) until it comes to rest.

21. Find the Maclaurin series for the following functions

(i) e−3x, (ii) ln(1 − x), (iii) cos 3x (iv) tanx

126

Page 128: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Chapter 8

Introduction to FinancialMathematics

8.1 Simple interest

Suppose that an amount of money P (the principal) is invested for n years at an annualinterest rate of r (i.e. the annual percentage is 100r%), paid at the end of each year,then at the end of the period the interest paid will be I where I = Prn.

Thus the interest on £4000 invested at 8.5% annual interest for 5 months will be

I = 4000 × 8.5

100× 512 = £141.67.

If the money is accumulated in the account then the amount in the account after n yearswill be An = A0(1 + rn), where A0 = P .

8.2 Compound interest

In practice we would want to have interest earned on any interest accumulated in theaccount. This is known as compound interest.

Suppose that we invest an amount A0 = P at an annual interest rate of r, accumu-lated in the account, then the amount in the account at the end of each year will be asfollows:

A0 = PA1 = P +Rr = P (1 + r)A2 = P (1 + r) + P (1 + r)r = P (1 + r)(1 + r) = P (1 + r)2

A3 = P (1 + r)2 + P (1 + r)2r = P (1 + r)2(1 + r) = P (1 + r)3

...An = P (1 + r)n

127

Page 129: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Example 103

What is the value of £300 invested for 5 years at annual interest of 6% compoundedannually?

Solution

A5 = 300

(1 +

6

100

)= £401.47.

Example 104

What is the annual rate of compound interest if the initial investment doubles in 10 years?

Solution

If the initial investment is P and the interest rate r, then

2P = P (1 + r)10 −→ (1 + r)10 = 2 −→ r = 2110 − 1 = 0.0718.

The annual compound interest is 7.18%.

Example 105

How many years at annual compound interest of 5% does it take for an initial investmentof £1000 to reach a value of £1500

Solution

Let the number of years be n, then

1500 = 1000(1 + 0.05)n −→ 1.05n = 1.5 −→ n ln 1.05 = ln 1.5

n =ln 1.15

ln 1.05=

0.4055

0.0488= 8.3 years.

These examples illustrate the concept of the time value of money. Suppose we are toreceive An in n years time while the annual interest rate is r. What is the present value(PV) of this money?

An = A0(1 + r)n −→ A0 =An

(1 + r)n.

The present value is the future value discounted at a rate r, which we term the discountrate.

Thus if we expect to receive £1000 in 5 years time and interest is 5% per annum thepresent value is

A0 =1000

(1 + 0.05)5= £783.55.

128

Page 130: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

In other words, investing £783.55 at compound 5% interest per annum for 5 years wouldhave a future value of £1000.

The following illustrates this time value property of money.

The higher the discount rate the less valuable is money received in the future. The longerthe time period before the money is received, the lower its present value.

Remark 9

The time value of money is not the same as inflation, as the following example shows.

Let the rate of annual inflation in consumer prices be i. Then the purchasing power of£1000 in a years time will be Π1, where

1000

1 + i,

so the purchasing power of £1000 in n years time will therefore be

Πn =1000

(1 + i)n.

Thus to have the same purchasing power as £1000 today would require £1000(1 + i)n inn years time.

Hence if £1000 is invested at annual compound interest rate r and with annual infla-tion rate i, then the purchasing power after n years will be

Πn = £1000 × (1 + r)n

(1 + i)n.

If we expand the expression for Πn using the binomial series and multiplication of twoinfinite series which converge in each case since i and r are both small we have

Πn ≈ 1 + n(r − i)

129

Page 131: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

if we ignore any non-linear terms. This clearly demonstrates the importance of takingaccount of expected inflation in investment planning.

However, in this module we will choose to ignore inflation for the sake of simplicity.

8.2.1 Compounding over other periods than one year

Consider an investment of £300 invested at annual interest of 6% for 4 years.

• annual compounding

A4 = 300 × 1.064 = £378.74.

• quarterly compoundingThe quarterly interest rate is 0.06

4= 0.015. The number of periods is 4 × 4 = 16.

Thus

A4 = 300 × 1.01516 = £380.70 £1.96 more than annual compounding.

• daily compoundingThe interest rate is 0.06

365, the number of periods is 365 × 4 = 1460. Hence

A4 = 300 ×(

1 +0.06

365

)1460

= £381.36 £2.53 more than annual compounding.

While the differences may be small, on investments of billions of pounds they are ex-tremely important.

We call the annual interest of 6% the nominal rate.

8.2.2 Continuous compounding

In general, if r is the nominal rate and interest is compounded m times per year thenafter n years

An = A0

(1 +

r

m

)mn

Suppose that m→ ∞, i.e. the compounding is done continuously, we have

limm→∞

An = A0 limm→∞

(1 +

r

m

)mn

= A0 limm→∞

[(1 +

r

m

)m]n

We have already seen that

limm→∞

(1 +

r

m

)m

= er

so we must havelim

m→∞An = A0 (er)n = A0e

rn.

130

Page 132: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

If the length of time for which the money has been invested is t years then

A(t) = A(0)ert

and the present value of money received at some time t in the future is A(0) = A(t)e−rt.

The value of £300 compounded continuously for 4 years at 6% nominal rate is £381.37,almost identical to daily compounding.

The great advantage of continuous compounding is that A(t) is a smooth (continu-ous) function of time - periodic compounding is a discontinuous function and much lesstractable mathematically.

8.2.3 Annual percentage rate (APR)

Suppose that three banks offered the following interest rates

A 4.75% compounded annuallyB 4.65% compounded quarterlyC 4.60% compounded continuously.

If £1000 were to be invested in each case the value of the investment in 1 year would be

A 1000 × 1.0475 = £1047.5 APR = 4.75%,

B 1000 ×(

1 +0.0465

4

)4

= £1048.35 APR = 4.835,%

C 1000 × e0.046 = £1047.07 APR = 4.707.%

The APR takes account of the different compounding regimes to allow a direct comparisonbetween savings accounts.

Example 106

How long will it take to quadruple an investment of £1000 at (i) 5% (ii) 7% (iii)10%,compounded annually?

Solution

If the interest rate is r then the time to quadruple the investment, n years, is given bythe solution of

4000 = 1000(1 + r)n −→ (1 + r)n = 4 −→ n ln(1 + r) = ln 4 −→ n =ln 4

ln(1 + r)

131

Page 133: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Thus,

at 4% n =ln 4

ln 1.05≈ 41 years

at 7% n =ln 4

ln 1.07≈ 20.5 years

at 10% n =ln 4

ln 1.1≈ 14 years

This clearly illustrates the power of compounding. In general, to find the number ofperiods it takes to for an investment of A0 to reach a given value An we have

n =lnAn − lnA0

ln(1 + r).

8.3 Investment appraisal

We know that the present value of An in n years time is given by

A0 = An(1 + r)−n.

In a project the revenue and the costs typically come at different times. We discount allof the positive and negative cash flows to present values and then we compute the NPV,net present value of an investment.

Example 107 An investment offers a return of £20,000 in three years time for an initialinvestment of £15,000. The market rate of interest is 5%. Is this a good investment?

Solution

The present value of £20,000 in three years time at 5% is £20, 000×1.05−3 = £17, 276.75.Thus the net present value is

NPV = 17, 276.75 − 15, 000 = £2, 276.75

This process is known as discounted cash flow (DCF).

The calculation suggests it is a good investment. We can check this result by findingr, the internal rate of return, IRR, the annual percentage interest at which £15,000produces £20,000 in three years time.

20, 000 = 15, 000(1 + r)3 −→ (1 + r)3 =4

3−→ r =

3

√4

3− 1 = 0.1006.

This is more than twice the market rate, suggesting a good investment.

132

Page 134: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

However, suppose that market rate were 12%, then the present value of £20,000 in threeyears time at 12% is £20, 000 × 1.12−3 = £14, 3336.6 and so

NPV = 14, 3336.6 − 15, 000 = −£764.4

and the investment would be a poor one.

The attractiveness of an investment therefore depends on assumptions about interestrates and the pattern of cash flows over time.

Example 108

Investing £5000 produces cash flows of £1000 at the end of year 1, £2000 at the end ofyear 2 and £3000 at the end of year 3. The discount rate is 5%. Is this a good investment?

Solution

To find the net present value we use

NPV =1000

1.05+

2000

(1.05)2+

3000

(1.05)3− 5000 = £318.

To find the internal rate of return we solve for r in the equation;

1000

1 + r+

2000

(1 + r)2+

3000

(1 + r)3= 5000,

multiplying this out we have the cubic equation

1000 − 11000 r − 14000 r2 − 5000 r3 = 0,

which can be solved by Maple to give the IRR as 8.21%.

Both the internal rate of return and the net present value can be important as the nextexample shows

Example 109

Project A returns £1,000 at the end of year 1 and year 2 for an initial investment of£1,600. Project B returns £2,100 at the end of year 2 for the same initial investment.The discount rate is 5%.

Solution

Project A

PV =1000

1.05+

1000

(1.05)2= £1, 859.41 NPV = £259.41

IRR1000

1 + r+

1000

(1 + r)2= 1 r = 16.26%

133

Page 135: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Project B

PV =2100

(1.05)2= £1, 904.76 NPV = £304.76

IRR1000

(1 + r)2= 1600 r = 14.56%

Project B has a higher NPV than Project A but a lower IRR reflecting the later receipt ofreturns. In addition to the time value of money the later the return the more likely it isthat unforeseen problems will occur and the greater the uncertainty about interest rates.Thus we might conclude that while both investment are attractive, project B carries ahigher risk.

8.3.1 Comparing investments

Example 110

Project A returns £12,000 at the end of year 4 for an initial investment of £10,000. ProjectB returns £11,500 at the end of year 3 for the same initial investment. The discount rateis 3%.

Solution

We compute the net present value for each project:

NPVA = 12, 000 × (1.03)−4 − 10, 000 = £661.84

NPVB = 11, 5000 × (1.03)−3 − 10, 000 = £524.13

All other things equal we would might choose project A. with the higher NPV, the IRRsare very similar (4.66% for A and 4.76% for B).

Example 111

Project X returns £12,000 at the end of year 4 for an initial investment of £10,000.Project B returns £35,000 at the end of year 5 for an initial investment of £30,000. Thediscount rate is 3%.

Solution

We compute the present value for each project:

PVX = 12, 000 × (1.03)−4 = £10, 661.84

PVY = 35, 000 × (1.03)−5 = £30, 191.31

134

Page 136: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

We must add to the present value of project X the present value of £20 000 invested atthe market rate, which is of course £20,000. Thus we see that the NPV for project X is£661.84 and the NPV of project Y is £191,31.

Example 112

Which investment would you choose and why?

Solution

There are two reasons to prefer project X.

1. The IRR of Project X is 4.37%, that of Project Y is 1.27%. The NPV of Project Xis higher than Project Y.

2. The entire investment in Project Y is in a single project, in the case of Project Xthere is the opportunity to spread the risk

On the other hand then returns in project X come one year later than Project Y so thatthe risk is higher.

8.4 Annuities

An annuity is a stream of income paid for either a fixed number of years (the term) orfor the lifetime of the individual to whom it is paid. Suppose that the income is A, paidannually and the discount rate is r. then the present value of n years annuity is

PV =A

1 + r+

A

(1 + r)2+

A

(1 + r)3. . .+

A

(1 + r)n.

This is a geometric series with common ratio1

1 + rand first term

A

1 + r, hence

PV =n∑

i=1

A

(1 + r)n=

A

1 + r

1 −(

1

1 + r

)n

1 − 1

1 + r

.

Simplifying we have

PV =A

r

(1 −

(1

1 + r

)n)Example 113

Thus a payment of £1000 per year for 20 years at a discount rate of 5% has a presentvalue of

PV =1000

0.05

(1 − 1

1.0520

)= £12, 462.21.

135

Page 137: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

This is the amount we would need to purchase such an annuity.

If an annuity were to be paid for ever (a perpetuity), the present value would be

PV = limn→∞

A

r

(1 −

(1

1 + r

)n)=A

r.

so in this example we would have to pay1000

0.05= £20, 000 for the perpetuity.

Example 114

Suppose we have £100,000 and we wish to purchase an annuity for 20 years with thediscount rate of 5%. What will be the amount of the annuity?

We solveA

0.05

(1 − 1

1.0520

)= 100, 000 −→ A = £8, 024.

The amount of annuity that can be bought with a pension lump sum for example dependson the annuity company’s estimation of life expectancy. The average life expectancy inthe U.K. for a man aged 50 is 28.5 years, aged 60 is 20.4 years and age 70 13.3 yearsgiving expected ages at death of 78.5, 80.4 and 83.3 respectively.

8.5 Savings accounts

Let us suppose that at the start of every period a fixed amount P is paid into a savingsaccount and that compound interest is paid at r at the end of every period. Then

Period (n) Amount in account Amount in the accountat the start of the period at the end of the period

1 P P (1 + r)2 P + P (1 + r) P (1 + (1 + r))(1 + r)

= P (1 + (1 + r))3 P + P (1 + (1 + r))(1 + r) P (1 + (1 + r) + (1 + r)2)(1 + r)

= P (1 + (1 + r) + (1 + r)2)...

......

n P (1 + (1 + r) + . . . (1 + r)n−1) P (1 + (1 + r) + . . . (1 + r)n−1) (1 + r)

The amount at the end of the nth period is

An = P

[1 + (1 + r) + . . . (1 + r)n−1

](1 + r),

where the term in square brackets is a geometric series with common ratio (1 + r) andfirst term 1. Hence

An = P

[1 − (1 + r)n

1 − (1 + r)

](1 + r) = P

((1 + r)n − 1

r

)(1 + r).

We term this the savings account formula.

136

Page 138: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Example 115

£15 per month is paid into a savings account at a nominal rate of 6%. How much will bein the account at the end of 5 years?

Solution

Here r = 0.0612

= 0.005 per month. For a total period of 60 months the savings accountformula gives

A5 = 15 × 1.005 ×(

1.00560 − 1

0.005

)= £1052 rounded to whole numbers.

A total of 60 × 15 = £900 was invested, so interest earned was £152.

Example 116

£15 per month is paid into a savings account and at the end of 5 years the account holds£1100. What was the interest rate?

Solution

We use the savings account formula

1100 = 15 × (1 + r) ×(

(1 + r)60 − 1

0.005

).

We solve this equation with Maple or by the Newton Raphson method to give r =0.006681 −→ 6.68% per annum.

8.6 Mortgages and loans

A mortgage is simply a loan secured by property. We suppose that a debt of D is paidoff in n periodic payments of size P with an interest rate of r per period. then

Period (n) Amount of debt at the end of the period1 D(1 + r) − P2 (D(1 + r) − P )(1 + r) − P = D(1 + r)2 − P (1 + (1 + r))3 (D(1 + r)2 − P (1 + (1 + r))) (1 + r) = D(1 + r)3 − P (1 + (1 + r) + (1 + r)2)...

...n D(1 + r)n − P [1 + (1 + r) + (1 + r)2 . . . (1 + r)n−1]

The square bracketed term is a geometric series with first term 1 and common ratio (1+r)so, at the end of the period the size of the loan outstanding is

Vn = D(1 + r)n − P

[(1 + r)n − 1

r

].

137

Page 139: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

At the end of the mortgage the amount outstanding is zero. Thus

D(1 + r)n − P

((1 + r)n − 1

r

)= 0

and solving for P we have the mortgage formula,

P =rD(1 + r)n

(1 + r)n − 1.

Example 117

£90,000 is borrowed on a 25 year mortgage at a fixed annual interest of 6.8%. What isthe monthly payment?

Solution

In this example r = 0.06812

= 0.00567 per month, n = 25 × 12 = 300 and D = 90, 000.making these substitutions in the mortgage formula we have

P =90, 000 × 0.00567 × 1.00567300

1.00567300 − 1= £625 per month.

The total amount paid will be 300× 625 = £187, 500 which includes interest of £97, 500.

The cost of borrowing could be reduced by paying a higher deposit, i.e. borrowing less,or by paying the mortgage off over a shorter term.

Suppose only £80,000 is borrowed in this case, then the debt is reduced by 19

and fromthe mortgage formula we see that the monthly payment is also reduced by the same pro-portion. The total paid is now 8

9× 187, 500 = £166, 800, of which interest is £86,800.

The saving in interest is thus £10,700.

Now suppose that the mortgage were paid off over only 20 years. Then there are 240periods so

P =90, 000 × 0.00567 × 1.00567240

1.00567240 − 1= £687 per month.

The total amount repaid is now 240 × 687 = £164, 880 which represents a saving of£12,620 in interest over the life of the mortgage.

Remark 10

The monthly payment is very sensitively related to the mortgage interest as the followinggraph shows

138

Page 140: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

8.6.1 Equity

The equity in a property is the difference between the market value of the property andthe amount of any outstanding mortgage.

Example 118

A house costs £150,000. It is purchased with a 25 year £120,000 mortgage at a fixedinterest of 6%. House prices rise by 10% per year. How much equity is there is in thehouse after 15 years?

Solution

We first calculate the monthly payment with r = 0.005, D = 120, 000 to be

P =120, 000 × 0.0005 × 1.005300

1.005300 − 1= £773 per month.

Now we find the loan outstanding after 15 years from

Vn = D(1 + r)n − P

((1 + r)m − 1

r

).

Here r = 0.005, D = 120, 000 and n = 180, so we have the amount of the mortgageoutstanding as

V180 = 120 × 1.005180 − 773(1.005180 − 1)

0.005= £69, 641.

The price of the house will be

150, 000 × 1.115 = £626, 587,

so the amount of equity is

626, 587 − 69, 641 = £556, 964.

139

Page 141: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

This is the return that has been produced from an initial investment of the £30,000deposit. The investment has produced an annual return of ρ where

556, 964 = 30, 000(1 + ρ)15 −→ ρ =

(556, 964

30, 000

) 115

− 1 = 0.215.

This is a 21.5% annual return.

140

Page 142: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

Exercises for Chapter 8

1. (a) A sum of £10,000 is invested in an account that pays 5% per annum simpleinterest. How much money is in the account after 10 years?

(b) A sum of £10,000 is invested in an account that pays 5% per annum compoundinterest. How much money is in the account after 10 years?

(c) A sum of £10,000 is invested in an account that pays simple interest. Whatinterest rate is required so that the money in the account after 10 years is thesame as if the money were invested with 5% compound interest (as in part(b)).

2. A sum of £25 per month is paid into a savings account which offers a return of 3%per annum, compounded monthly.

(a) How much money will be in the account after 10 years?

(b) What sum should be invested each month in order to accumulate a total of£4000 in the account after 10 years?

(c) If the account balance is £4250 after 10 years what was the interest rate?

3. In order to buy a house costing £140,000, a person takes out a mortgage of £110,000.The interest rate is fixed at 8% per annum for the lifetime of the mortgage.

(a) Calculate the monthly payments if the mortgage is to be paid off in 25 years.

(b) Calculate the total amount of interest paid by the person over the 25 year loanperiod.

(c) If the original £110,000 mortgage was paid over a period of 20 years, how muchinterest would have been saved compared with paying over a 25 year period?

(d) If the price of house were to rise by 6% per annum, how much equity wouldthe person have in the house after 15 years. What would this represent as aneffective rate of interest on the initial deposit?

(e) If the interest rate on the mortgage was 10% per annum what would be thetotal amount of interest paid over the 25 year period.

4. *A 25 year mortgage with a fixed 8% interest rate is taken out. After 10 years,interest rates have fallen substantially and the borrower wants to re mortgage totake advantage of the lower rate. However the current mortgage requires that apenalty of four months interest on the loan outstanding at the time is paid if themortgage is terminated early. Assuming that the new mortgage is for a period of15 years, what would the maximum interest rate be for it to be worthwhile for theborrower to take out this new mortgage?

5. How long will it take for an investment to triple in value if invested at an annualrate of 3% compounded (a) annually and (b) continuously?

6. What is the APR if the nominal rate of 7% is compounded (a) quarterly and (b)continuously?

141

Page 143: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

7. What is the annual percentage rate if the nominal rate is 12% compounded weekly?

8. How much will it cost to purchase an annuity for 20 years paying £12,000 per yearwhen interest rates are at 4.3% per annum? What annuity over 15 years could bepurchased with this same lump sum at the same interest rate..

9. *An individual saves 10% of his salary by way of a monthly payment into an in-vestment account which pays 6% interest compounded monthly. Suppose that hecontinues to do this over a period of 40 years. His starting salary is £15,000 andduring his career his salary increases each year by 8% (assumed to be in the form ofan increase after the completion of each full year except the 40th). On his retirementhis life expectancy is assessed at 23 years and interest rates ar at 5.5%. What isthe amount of annuity he can purchase for his retirement pension, expressed as aproportion of his final salary? (ignore tax and inflation). Hint: use excel.

10. Project A requires an initial investment of £20,000 and yields the following returns:

year income1 £5, 00027 £5, 0003 £8, 0004 £7, 0005 £3, 000

Project B also requires an initial investment of £20,000 and in addition a furtherinvestment of £1000 at the end of year 3 and £1000 at the end of year 4. In thiscase the returns are the following

year income1 £3, 00027 £4, 0003 £8, 0004 £12, 0005 £3, 000

(a) Calculate the NPV of each project at a discount rate of 4%.

(b) Calculate the IRR of each project.

(c) Calcualte the NPV of each project at a discount rate of 8%.

(d) Comment on your results

H int: use Excel or Maple.

11. *A prize fund is set up with a single investment of £5000 to provide an annualprize of £500. The fund is invested to earn 7% interest compounded annually. Ifthe first time the prize is awarded is one year after the initial investment is madeand subsequent prizes are awarded each year on the same date, for how many yearscan the prize be awarded before the fund falls below £500?

142

Page 144: COM 1021 Mathematical Methods for Computing I …personal.maths.surrey.ac.uk/st/G.Derks/COM2023/COM1021.pdfMathematical methods for Computing I Spring Semester 2010-2011 The module

12. *A retired person lives on savings that earn r% interest. Her expenses are £Nincurred uniformly throughout the year. She makes x equal withdrawals of £N

xat

equal intervals throughout the year. There is a transaction cost for weak withdrawalof £t. What is the optimal frequency of withdrawals.

143