/
FP1: Chapter 2 FP1: Chapter 2

FP1: Chapter 2 - PowerPoint Presentation

tawny-fly
tawny-fly . @tawny-fly
Follow
367 views
Uploaded On 2015-10-27

FP1: Chapter 2 - PPT Presentation

Numerical Solutions of Equations Dr J Frost jfrosttiffinkingstonschuk Last modified 2 nd January 2014 y x y cos x Iterative Methods Suppose we wanted to find solutions to ID: 174215

interval root linear cos root interval cos linear method approach find methods interpolation process newton convergence bisection approximation converge

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "FP1: Chapter 2" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

FP1: Chapter 2 Numerical Solutions of Equations

Dr J Frost (jfrost@tiffin.kingston.sch.uk)

Last modified: 2

nd

January 2014Slide2

y

= x

y =

cos(x)

Iterative Methods

Suppose we wanted to find solutions to

x =

cos

(x)

.

There is in fact no way to express the solution in an ‘exact’ way, i.e. involving sums, divisions, roots, logs, trigonometric function, etc.

We instead have to use numerical methods to approximate the solution.Slide3

Iterative Methods

The principle of iterative methods is that we start with some initial approximation of the solution, and ‘iteratively’ repeat some process to gradually get closer to the true solution.

This is a method you will see in C3:

Suppose we start (by observing the graph) with an approximation of

x

0

= 0.5

We could use the iterative formula:

x

n+1

= cos(

xn)

y

= x

y =

cos

(x)

You could do this on a calculator using:

[0.5] [=]

[

cos

] [ANS][=] [=] [=] [=] [=] ...

x = 0.739085...

?Slide4

Iterative Methods

There are different numerical methods we could use.

Why have different methods?

Some converge to the solution more

quickly

than others.

Some methods

may not converge at all

for certain equations/initial choice of x, either diverging, or oscillating between values.

1

2

For FP1 we will be exploring 3

root-finding algorithms

:

Interval Bisection

Linear Interpolation

Newton-

Rhapson

Process

These will all be used to find the roots of functions, i.e. the x for which f(x) = 0.Slide5

f(x) = 0

Root-finding algorithms find the root of a function!

Just simply put your equation into the form f(x) = 0 if not already so.

We want to solve...

x =

cos

(x)

Use f(x) =

f(x) = x –

cos

(x)

x

2

= 2

f(x) = x

2

– 2

x

= x

3

+ 3

f(x) = x

3

– x + 3

x

2

= 2x – 6

f(x) = x

2

– 2x + 6

?

?

?

?Slide6

Approach 1: Interval Bisection

This approach starts with an interval for which f(x) changes sign, then halves this interval at each iteration. This is loosely an approach you used at GCSE.

x

a

b

Suppose we know the root lies in the interval [a, b]

We want to narrow this interval.

a + b

2

So try halfway. We find f((

a+b

)/2) is positive, so we replace b with (

a+b

)/2.

And repeat...

a + b

2

a + b

2Slide7

Example

Using the initial interval [2,3], find the positive root to the equation x

2

= 7 to 2dp.

a

b

(

a+b

)/2

f((

a+b

)/2)232.5

-0.75

2.5

3

2.75

0.5625

2.5

2.75

2.625

-0.109

2.6252.752.68750.2232.6252.68752.65625

0.0557...

2.64453125

2.646484375

2.645507813

f(x) = x

2

- 7

We can stop at this point because:

Both the new bounds will be 2.65 to 2dp, so we know the solution must be 2.65 to 2dp.

?

?

Bro Tip:

Keeping a table like this helps you easily keep track of your bounds.

?Slide8

Exam Question

f(2) = -1, f(2.5) = 3.4062

(M1)

Sign change (and f(x) is continuous), therefore a root

α

exists between x = 2 and x = 2.5

(A1)

f(2.25) = 0.673828125

(B1)

f(2.125) = -0.27526855

(M1)Therefore 2.125 

α  2.25 (A1)

a

b

?

?

Bro Tip:

This is an incredibly common question, so know your mark scheme here!Slide9

Exercises

To DoSlide10

Analysis of Interval Bisection

Failure Analysis:

Guaranteed to converge to a root provided that for the initial interval [

a,b

], f(a) and f(b) have opposite signs, and f(x) is continuous.

Other Comments:

Another advantage: Simple to carry out.

Rate of Convergence:

H

orribly slow in terms of crawling very slowly towards the root. The error

halves each time

– we say this is

linear convergence

.

Therefore in practice Interval Bisection tends not to be used.

(Note that none of this bit will be in an exam)Slide11

Approach 2: Linear Interpolation

Linear Interpolation builds on the method of Interval Bisection by choosing a point (generally) better than the midpoint of the bounds.

x

a

b

α

c

Initially the bound for our root is [

a,b

].

We establish c using linear interpolation, see that f(c) is +

ve

, and hence adjust our interval to [

a,c

] and repeat.Slide12

Approach 2: Linear Interpolation

x

1

2

α

1

Show that the equation x

3

+ 5x – 10 = 0 has a root in the interval [1,2]. Using linear interpolation, find this root to 1 decimal place.

(Hint: use similar triangles)

f(1) = -4, f(2) = 8

(2 –

α

1

)/(

α

1

– 1) = 8/4

Solving a1 = 1.33333

f(1.333...) = -0.96296. Since negative,

Make new interval [1.333..., 2]

Eventually we find a3 = 1.4196.

We can check 1.4 is correct to 1dp by looking at f(1.35) and f(1.45). Change of sign means root

root

lies in [1.35, 1.45], i.e. 1.4 is correct to 1dp.

?Slide13

Exam Question

?Slide14

Exercises

To DoSlide15

Analysis of

Linear Interpolation

Failure Analysis:

As with Interval Bisection, guaranteed

to converge to a root provided that for the initial interval [

a,b

], f(a) and f(b) have opposite signs, and f(x) is continuous.

Rate of Convergence:

The error of the approximation after each iteration is dependent on ‘curvy’ the line is: as you might expect, the flatter the curve is, the more it approximates a straight line, and hence the better linear interpolation will be (which assumes a straight line in the region).

The rate of convergence is high when the second derivative at the root is small (i.e. the gradient is not changing very much).

(Note that none of this bit will be in an exam)Slide16

Approach 3: The Newton-

Raphson

Process

x

y

y = f(x)

x

0

Suppose we start with an approximation of the root, x

0

. Clearly this is well off the mark.

A seemingly sensible thing to do is to follow the direction of the line, i.e. use the gradient of the tangent.

x

1

x

2

We can keep repeating this process to (hopefully) get increasingly accurate approximations.

Can you come up with a formula for x

n+1

in terms of

x

n

?

(also known as Newton’s method)Slide17

Approach 3: The Newton-

Raphson

Process

x

y

y = f(x)

x

n

x

n+1

Formula:

Using C1 coordinate geometry:

y – f(

x

n

) = f’(

x

n

)(x –

x

n

)

But we’re interested when

x = x

n+1

and y = 0

-f(

x

n

) = f’(

x

n

)(x

n+1

x

n

)

which gives:

Newton-

Raphson

Process:

x

n+1

=

x

n

- f(

x

n

)/f’(

x

n

)

?Slide18

Approach 3: The Newton-

Raphson

Process

Demo

(Courtesy of Wikipedia)Slide19

Example

Returning to our original example:

x =

cos

(x)

,

say letting x

0

= 0.5Let f(x) = x – cos(x)f’(x) = 1 + sin(x)

f(0.5) = 0.5 – cos(0.5) = -0.3775825f’(0.5) = 1 + sin(0.5) = 1.4794255

x1 = 0.5 – (-0.3775825 / 1.4794255) = 0.7552224171x2 = 0.7391412x3 = 0.7390851

After merely three iterations, our approximation is accurate to 7 decimal places. Holy smokes Batman!

Bro Tip: To perform iterations quickly, do the following on your calculator:

[0.5] [=]

[ANS] – (ANS –

cos

(ANS))/(1 + sin(ANS))

Then spam [=].

?Slide20

Quickfire

Questions

Using Newton’s method, state the recurrence relation for the following functions.

f

(x) = x

3

- 2

x

n+1

=

xn – (x

n3 – 2)/3xn2

f

(x) =

x + x - 2

x

n+1

=

x

n – (√xn

+ xn - 2)/(0.5xn-0.5 + 1)

f(x) = x2 – x – 1

x

n+1

=

x

n

– (x

n

2

x

n

– 1

)/(2x

n

– 1)

?

?Slide21

Exam Question

June 2013 (Retracted)

f

’(x) = 2x

3

– 3x

2

+ 1

f

’(-1.5) = -12.5

f(-1.5) = 1.40625

1 = -1.5 – 1.40625/(-12.5)

= -1.3875

?Slide22

Exercises

To do.Slide23

Really Nice Application #1

Find the square root of 3.

Using the C3 method of putting equation in form x = f(x), then using x

n+1

= f(

x

n

)

We want solutions to x

2

= 3.

This gives xn+1 = 3/xn

This method fails to converge, because it will oscillate between two values regardless of the starting value.

Using Newton’s method

We want solutions to

x

2

– 3 = 0

f

(x) = x

2

– 3f’(x) = 2xUsing xn+1 = xn – (xn2 – 3)/2xn

x0 = 1x1 = 2x

2

= 7/4 = 1.75

x

3

= 97/56 = 1.73214

x

4

= 1.73205

x

5

= 1.73205

...

?

?Slide24

Really Nice Application #2

Approximate

.

Identify a function which has

as a root (Hint: think trig functions!)

Using Newton’s method (letting x

0

= 3)

Note that

cos

(

) = -1, so a root of

f(x) = 1 +

cos

(x)

is

.We could have also used f(x) = tan(x), provided we started between /2 and 3/2

xn+1 = xn + (1 + cos(xn))/sin(xn)

x0 = 3 (a sensible starting place!)x1 = 3.070914844 x

6

= 3.139385197 x

11

= 3.141523671

x

2

= 3.106268467 x

7

= 3.140488926 x

12

= 3.141558162

x

3

= 3.123932397 x

8

= 3.141040790 x

13

= 3.141575408

x

4

= 3.132762755 x

9

= 3.141316722 x

14 = 3.141584031x5 = 3.137177733 x

10 = 3.141454688 x15 = 3.141588342

?

?Slide25

Analysis of

Newton-

Raphson

Method

Failure Analysis:

Approximations may diverge (and hence fail!).

Consider what happens in the following scenario on the right:

Rate of Convergence:

The Newton-

Raphson’s

rate of convergence is

‘quadratic’

:

that is, as we converge on the root, on each

iteration

the difference between the approximation and the root is

squared (squaring a value less than 1 makes it smaller).

That’s rather good

(and is considerably better than Interval Bisection’s linear convergence).

(Note that none of this bit will be in an exam)

x

0