0% found this document useful (0 votes)
14 views32 pages

Handout - 20 Numerical Methods ALL

Uploaded by

suhail.z6191
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views32 pages

Handout - 20 Numerical Methods ALL

Uploaded by

suhail.z6191
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Handout 20 – Numerical Methods

NUMERICAL SOLUTIONS OF EQUATIONS


Objectives: I can solve equations efficiently, to any required level of accuracy, using numerical methods.
Aims: solving equations by the following two methods.
• Systematic search for change of sign using a decimal search.
• Fixed point iteration after rearranging the equation f(x) = 0 into the form x = g(x)
CHANGE OF SIGN.
Example 1: Suppose we wish to solve the equation x5 – 5x + 3 = 0.
A) Use calculator to find solutions.

B) It is not possible to factorise the LHS, so a numerical method of solution is appropriate.

Use your calculator to draw the graph of y = x5 – 5x + 3, use values of x from -3 to +3 and values of y from
-2 to + 8. (Alter the axes using V-window) Sketch the graph below.

How many solutions are there to the equation


x5 – 5x + 3 = 0 ? ________
For each solution write down the two whole
numbers between which it lies.
___________________________________
___________________________________
___________________________________
The problem now is to find the roots to any
degree of accuracy.

C) Complete the table below to show values of x and y for the equation y = x5 – 5x + 3

x y Describe how this table supports your answers above.


-3
-2
-1
0
1
2
3

1
Handout 20 – Numerical Methods
D) Can we be more accurate?
• Zoom in on this solution on your calculator, by altering the x axis (use V-Window) to min 0, max 1.
• Sketch the graph below, and complete the table, again you may wish to use the table function.

x y
0
0.1
0.2
0.3
0.4
0.5
1 0.6
0.7
0.8
0.9
The function is __________________ in __________________ 1.0
• Write down a new interval for the root, of width 0.1

Repeat the above procedure until you can write down the root to 2 decimal places.
x y Write down a new x y Write down a new interval for
interval for the root, of the root, of width 0.001.
width 0.01. _________________________
So, the root is _____________
to 2 decimal places.

Example 2: Solve x – 2 sin x = 0 (x in rads)

x -1.5 -1 -0.5 0 0.5 1 1.5 2

2
Handout 20 – Numerical Methods
If we select x-values and find f(x), we should be able to
pick x-values so that f(x) heads towards zero.
E.g. x = 1, 1 – 2 sin (1) = –0·68 (negative)
x = 2, 2 – 2 sin (2) = 0·18 (positive)
From 1 to 2, f(x) passes from negative (through zero) to
positive. Because the function is continuous (no breaks
in it), then f(x) must have passed through zero in the
interval (1, 2).
The change in sign of f(x) indicates the location of the
root.

Exercise 1: Show that x3 = 3x2 – 2 has a root between x = 2 and x = 3

Decimal Search: Knowing the interval in which the root lies, we can use decimal search to find the root to
a greater degree of accuracy.
Exercise 1: Find to 2 decimal places, the root located in the interval (2, 3) to the equation x3 – 3x2 + 2 = 0.

3
Handout 20 – Numerical Methods
Exercises: Ex. 17.1 A q.1 ad, 3b, 7 ac

4
Handout 20 – Numerical Methods
ITERATION
We can solve equations by drawing graphs and finding where they cross.
Show that the equation x5 – 5x +3 = 0 𝑥 5 +3
Sketch the graphs of 𝑦 = 5 and y = x, clearly showing
x5 + 3
can be rearranged as x = all points of intersection of the two lines
5

𝑥𝑛 5 +3
The rearrangement above provides us with the iterative formula 𝑥𝑛+1 = we know that there is a
5
root in the interval [0, 1] so we will take a starting value for x0 of 1

We work each value out in turn. • use the ANS function.


x0 = 1 1. RUN
2. Put in the starting value, (x0) of 1 and EXE.
𝑥0 5 + 3 15 + 3 3. Build up the equation pressing ANS instead of x:
𝑥1 = = = 0.8
5 5 𝐴𝑛𝑠 5 + 3
𝑥2 = 5
4. Now each time you press the EXE key you will get
𝑥3 = the next value of x.
𝑥4 =
𝑥5 =
𝑥6 =
OR:
𝑥7 = 𝑎𝑛 5 +3
• RECURSION the enter formula: 𝑎𝑛+1 = 5
So the root is _________ to 3 decimal places.

5
Handout 20 – Numerical Methods
Cobweb and Staircase Diagrams
𝑥 5 +3
The diagram shows the graphs of y = x and 𝑦 = 5

What you do. What it looks like on the graph


1. Choose a starting value x0=1 1. Start at x = 1 on the x axis
x5 + 3
2. Find the corresponding value of 2. Move vertically to the curve.
5
3. Take this value as the value for x1 3. Move horizontally to y = x
x5 + 3 4. Move vertically to the curve.
4. Find the new value of
5
5. Move horizontally to y = x
5. Take this as the value for x2 and so on……..

𝑥5 + 3
𝑦= y=
5 x Remember to go
up (or down) to
the curve and
across to the
line.

x x x

Another rearrangement of the original equation is x = 5 5 x − 3

a. Show how x5 – 5x + 3 = 0 can be rearranged as x = 5 5 x − 3

b. Beginning with x0 = 1 and using xn +1 = 5 5 xn − 3 find the value of the root between 1 and 2 to three
decimal places. Draw a diagram to show how the process converges on the root.
c. Change the starting value so that x0 = 0 and using xn +1 = 5 5 xn − 3 find the value of the other root to
three decimal places.

6
Handout 20 – Numerical Methods

Ex. 17.2A, q.4

7
Handout 20 – Numerical Methods
The Intersection of Graphs
By sketching the curves 𝑦 = √𝑥 and 𝑦 = 3𝑥 2 – 1 find
the number of roots of the equation 3𝑥 2 – 1 = √𝑥
The graph shows _____solution (approximately_____),
which we can find to a greater degree of accuracy using
decimal search.

Note: Sometimes a question may be worded as follows


“Show that the curves y = 3x2 – 1 and y = √x intersect between x = 0·5 and x = 1”
Put the curves equal to each other:
Rearrange:

Now put x = 0·5 and x = 1 in and look for the change of sign:

Iteration
3
Suppose we have a sequence defined iteratively by 𝑥𝑛+1 = √(3𝑥𝑛2 − 2)
Try 𝑥1 = 2.5, 𝑡ℎ𝑒𝑛
.
𝑥2 =
.
𝑥3 = .
𝑥4 = 𝑥13 = The sequence seems to be “settling down” – i.e.
𝑥5 = converging. This means that the values of xn+1
𝑥14 =
and xn are getting closer.
𝑥6 = 𝑥15 =
8
Handout 20 – Numerical Methods
As it converges, 𝑥 𝑛+1 ≈ 𝑥𝑛
3
Hence: 𝑥𝑛+1 = √(3𝑥𝑛2 − 2)
3
becomes: 𝑥𝑛 = √(3𝑥𝑛2 − 2)

so,
finally, the iteration solves

What is the method?


We are trying to solve: f(x) = 0. To do this we rearrange this equation to solve: x = g(x)

Example: Find an iteration to solve: x2 + 3x – 4 = 0

We need to rearrange this in the form : 𝑥 = 𝑔(𝑥)

• One arrangement could be : 𝑥 = √(4 – 3𝑥)


4 – 𝑥2
• Another could be : 𝑥 = 3

How does it work?


x2 + 3x – 4 = 0 and 𝑥 = √(4 – 3𝑥) will have the same roots (solutions)
• x2 + 3x – 4 = 0 has roots where _____________________________________________

𝑥 = √(4 – 3𝑥) is where the __________________meet____________________________

• x = 1 is a solution. This is also the solution to the equation x2 + 3x – 4 = 0.

What about the other solution?

We can see the other rearrangement provides us with both solutions.

9
Handout 20 – Numerical Methods

Not all Iterations Converge


Rearranging an equation into an iteration does not always give a convergent sequence.
1
Suppose we wish to solve x3 – 3x – 5 = 0 which can rearrange to 𝑥 = (𝑥 3 – 5)
3

using the iteration 𝑥𝑛+1 = 13 (𝑥3𝑛 – 5)) starting with 𝑥1 = 2


𝑥2 =
𝑥3 =
𝑥4 =
𝑥5 =
𝑥6 =
𝑥7 =
Spec Questions
a) The equation 𝑒 −𝑥 − 2 + √𝑥 = 0 has a single root α. Show that α lies between 3 and 4.
b) Use the recurrence relation:
𝑥𝑛+1 = (2 − 𝑒 −𝑥𝑛 )2
with 𝑥1 = 3.5, to find 𝑥2 and 𝑥3 giving your answers to three decimal places.

10
Handout 20 – Numerical Methods

11
Handout 20 – Numerical Methods

12
Handout 20 – Numerical Methods

13
Handout 20 – Numerical Methods

14
Handout 20 – Numerical Methods

15
Handout 20 – Numerical Methods
THE NEWTON-RAPHSON METHOD

• The Newton-Raphson method


finds roots of equations in the
form f(x) = 0
• It works by finding the x-
intercept of tangents to f(x) to get
closer and closer to a root.

The gradient of a tangent =

⇒ at 𝑥0 𝑔𝑟𝑎𝑑𝑖𝑒𝑛𝑡 𝑓′(𝑥0 ) = and 𝑦0 = 𝑓(𝑥0 )

⇒ 𝑓 ′ (𝑥0 ) =

Rearrange for 𝑥1 :

SUMMARY:
To use the Newton-Raphson method to estimate a root of an equation:
• rearrange the equation into the form f(x) = 0
• differentiate 𝑓(𝑥) to find 𝑓 ′ (𝑥)

• substitute 𝑓(𝑥) and 𝑓 ′ (𝑥) into the formula:


𝑓(𝑥𝑛 )
𝑥𝑛+1 = 𝑥𝑛 −
𝑓 / (𝑥𝑛 )

16
Handout 20 – Numerical Methods

17
Handout 20 – Numerical Methods

18
Handout 20 – Numerical Methods
Can the Newton-Raphson method fail?
The Newton-Raphson method can fail when:

the starting value x0 is too far the tangent gradient is too the tangent is horizontal, where
away from the root leading to small, where f’(x) close to 0 f’(x) = 0 so the tangent will never
a divergent sequence or leading to a divergent sequence meet the x-axis
a different root. or one which converges very
slowly.

OR the equation cannot be differentiated (or is awkward and time-consuming to do)


Exam question:

19
Handout 20 – Numerical Methods

20
Handout 20 – Numerical Methods

21
Handout 20 – Numerical Methods
The Trapezium Rule for Estimating the Area under a Curve
Objective: I understand and use numerical integration of functions using the trapezium rule to estimate
the area under a curve
Aims: I should be able to:
• Understand and use the term ‘ordinate’.
• Use graphical determination to find whether an approximation over- or under- estimates the area
• Improve approximation by increasing the number of strips.
Estimating the Area under a Curve
Suppose we wish to find the area under a curve y = f(x) between x = a and x = b.

The area can be divided into 4 trapezia of


equal width h.
The parallel sides of the 4 trapezia are
given by the five ordinates
𝑦0 , 𝑦1 , 𝑦2 , 𝑦3 , 𝑦4 .
In general, if there are n trapezia there
will be n + 1 ordinates.

Formula booklet:

𝑢𝑝𝑝𝑒𝑟 𝑙𝑖𝑚𝑖𝑡−𝑙𝑜𝑤𝑒𝑟 𝑙𝑖𝑚𝑖𝑡


Where h is a width of trapeziums ℎ = 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑠𝑡𝑟𝑖𝑝𝑠

Example1: Calculate the exact value of the integral for 𝑓(𝑥) = 𝑥 2 + 1, between x=0 and x=3. Check your
answer on calculator.

22
Handout 20 – Numerical Methods

• Use 3 strips to estimate the area between x = 0 and x = 3

Step 1: write the formula.

𝐴𝑟𝑒𝑎 ≅

Step 2: Work out the width of the strip.

upper limit lower limit

𝑏−𝑎
ℎ=
𝑛

number of strips

Step 3: Prepare a table of values (use table mode on your calculator).

x 0 3
𝑦 = 𝑥2 + 1
Step 4: Substitute all values in the formula.

𝐴𝑟𝑒𝑎 ≅

𝑝𝑟𝑒𝑑𝑖𝑐𝑒𝑑−𝑎𝑐𝑡𝑢𝑎𝑙
%error = × 100
𝑎𝑐𝑡𝑢𝑎𝑙

The calculated area is an_________________________________________________________________


_____________________________________________________________________________________
_____________________________________________________________________________________
_____________________________________________________________________________________

23
Handout 20 – Numerical Methods
• Use 4 strips to estimate the area between x = 0 and x = 3

h=

x 0 3
𝑦

Formula:

𝐴𝑟𝑒𝑎 ≅

% error =

• Use 6 strips to estimate the area between x = 0 and x = 3

h=
x 0 3
𝑦

Formula:

𝐴𝑟𝑒𝑎 ≅

% error =

24
Handout 20 – Numerical Methods
• Use 8 strips to estimate the area between x = 0 and x = 3

h=

x 0 0.75 1.875 3
𝑦 1.5625 4.515625

Formula:

𝐴𝑟𝑒𝑎 ≅

Overestimates and underestimates

In general, when the slanting line is


above the curve the area given by
the trapezium rule will be an
OVERESTIMATE of the actual area.

When the slanting line is below the


curve the area given by the
trapezium rule will be an
UNDERESTIMATE of the actual area.

25
Handout 20 – Numerical Methods
Exam type questions:

26
Handout 20 – Numerical Methods

27
Handout 20 – Numerical Methods

28
Handout 20 – Numerical Methods

29
Handout 20 – Numerical Methods

30
Handout 20 – Numerical Methods

31
Handout 20 – Numerical Methods

32

You might also like