C3.7 Numerical methods
Download
Report
Transcript C3.7 Numerical methods
A-Level Maths:
Core 3
for Edexcel
C3.7 Numerical
methods
This icon indicates the slide contains activities created in Flash. These activities are not editable.
For more detailed instructions, see the Getting Started presentation.
1 of 35
© Boardworks Ltd 2006
Contents
Using graphs to solve equations
Using graphs to solve equations
The change-of-sign rule
Solving equations by iteration
Examination-style question
2 of 35
© Boardworks Ltd 2006
Using graphs to solve equations
Most of the equations we have looked at so far have had exact
solutions (or roots) that could be found using a series of
algebraic manipulations.
However, this is not true of all equations. For example:
x3 + 5x – 3 = 0,
ex = x – 2,
sin x = ln x + 1
cannot be solved exactly by any obvious algebraic method.
The first step in solving most equations of this type is to sketch
a graph.
The graph will tell us how many roots there are and their
approximate locations.
3 of 35
© Boardworks Ltd 2006
Using graphs to solve equations
By sketching an appropriate graph find approximate roots to
the equation x3 = 3x + 1.
There are two ways to approach this.
The first is to consider the left-hand side and the right-hand
side of the equation as two separate functions.
x3 = 3x + 1
y = x3
y = 3x + 1
The points where these two functions intersect will give us the
roots to the equation x3 = 3x + 1.
4 of 35
© Boardworks Ltd 2006
Using graphs to solve equations
10
y = x3
8
The graphs of
y = x3 and y = 3x + 1
y = 3x + 1 intersect at three points.
6
This means that the
equation x3 = 3x + 1 has
three solutions.
4
2
–4
–3
–2
–1 0
–2
–4
–6
5 of 35
1
2
3
4
The graph shows that
these solutions are
approximately:
x = –1.5
x = –0.3
x = 1.9
© Boardworks Ltd 2006
Using graphs to solve equations
The second approach is to rearrange the equation so that all
the terms are on the left-hand side:
x3 – 3x – 1 = 0
y = x3 – 3x – 1
y=0
The line y = 0 is the x-axis. This means that the roots to the
equation x3 – 3x – 1 = 0 are given by the x-coordinates of the
points where the function y = x3 – 3x – 1 crosses the x-axis.
6 of 35
© Boardworks Ltd 2006
Using graphs to solve equations
10
8
6
x = –1.5
4
x = –0.3
2
–4
–3
–2
–1 0
–2
–4
–6
7 of 35
Again, the roots are to be
found approximately:
x = 1.9
These roots can be found
1
2
3
4 to a greater degree of
accuracy by using a
graphical calculator or
y = x3 – 3x – 1
graph-plotting program to
‘zoom in’ on them.
© Boardworks Ltd 2006
Using graphs to solve equations
8 of 35
© Boardworks Ltd 2006
Contents
The change-of-sign rule
Using graphs to solve equations
The change-of-sign rule
Solving equations by iteration
Examination-style question
9 of 35
© Boardworks Ltd 2006
The change-of-sign rule
Suppose a function f(x) is continuous. In other words it has no
breaks in it.
The solution (or solutions) to f(x) = 0 are given by the x-values
of the points where y = f(x) crosses the x–axis.
The change-of-sign rule states that:
If two values of x, a and b, can be found such that f(a) and
f(b) are of different sign then f(x) = 0 must have at least one
root in the interval [a, b].
10 of 35
© Boardworks Ltd 2006
The change-of-sign rule
To see how this works in practice consider the equation
x – cos x = 0
We can start by sketching a graph to see how many roots there
are and their approximate locations.
Rather than try to sketch the graph of y = x – cos x we can
sketch the graphs of y = x and y = cos x.
y
1
2
0
–1
11 of 35
y=x
2
y = cos x
x
We can see from this
graph that there is one
root about half-way
between x = 0 and x = 2
That is, around
4
≈ 0.8.
© Boardworks Ltd 2006
The change-of-sign rule
Now, let f(x) = x – cos x.
When x = 0.8,
f(0.8) = 0.8 – cos 0.8 ≈ 0.1
So f(0.8) is positive.
Let’s try x = 0.7 next.
f(0.7) = 0.7 – cos 0.7 ≈ –0.06
So f(0.7) is negative.
The sign changes from positive to negative and so f(x) must
equal 0 somewhere between x = 0.7 and x = 0.8.
We can therefore conclude that the equation x – cos x = 0
has a root between 0.7 and 0.8.
12 of 35
© Boardworks Ltd 2006
The change-of-sign rule
Show that the equation x3 + 2 = 4x has a root between x = 1
and x = 2.
Start by rearranging the equation into the form f(x) = 0.
x3 – 4x + 2 = 0
Now let f(x) = x3 – 4x + 2.
f(1) = (1)3 – 4(1) + 2 = –1
f(2) = (2)3 – 4(2) + 2 = 2
Since f(1) < 0 and f(2) > 0, there must be a root to the equation
f(x) = 0 between x = 1 and x = 2.
13 of 35
© Boardworks Ltd 2006
Decimal search
The change-of-sign-rule can be used to find the roots to any
required degree of accuracy.
However, a large number of calculations is required to
progressively narrow down the interval.
Using a decimal search is the traditional method of doing this.
14 of 35
© Boardworks Ltd 2006
Problems with the change-of-sign rule
There are some potential problems with using the change-ofsign method to locate roots. These include cases where:
y = f(x) has a repeated root
In this situation the graph of y = f(x) touches the x-axis without
crossing it:
a
b
y = f(x)
15 of 35
Here we can see that f(a) and f(b)
have the same sign even though there
is a root between x = a and x = b.
We would therefore have to find this
root using an alternative method.
© Boardworks Ltd 2006
Problems with the change-of-sign rule
There is more than one root in a given interval
In some cases there may be several
roots close together.
In this example there are three roots
between x = a and x = b.
b
a
y = f(x)
There is a discontinuity in a given interval
If there is a discontinuity in a given
interval then f(a) and f(b) may have
different signs even though there
isn’t a root between a and b.
16 of 35
b
y = f(x)
a
© Boardworks Ltd 2006
Contents
Solving equations by iteration
Using graphs to solve equations
The change-of-sign rule
Solving equations by iteration
Examination-style question
17 of 35
© Boardworks Ltd 2006
Solving equations by iteration
This method works by using a recurrence relation to generate
a sequence of approximations that get closer to the root each
time.
The first step is to write the equation we are trying to solve in
the form x = f(x).
We then write this as an iterative formula of the form:
x n +1 = f ( x n )
If the resulting sequence converges then this limiting value
will be a root of x = f(x).
Note that several different formulae are usually possible.
Some may produce convergent sequences and some may not.
18 of 35
© Boardworks Ltd 2006
Solving equations by iteration
For example, suppose we want to solve the equation
5x – ex = 0
One way to write this equation in the form x = f(x) is:
x=
e
x
5
This gives us the iterative formula:
x n +1 =
e
xn
5
Now we can substitute an initial value for x0 into this formula in
the hope of generating a sequence that converges towards the
root of the original equation.
19 of 35
© Boardworks Ltd 2006
Solving equations by iteration
Let’s try an initial value of x0 = 1:
x0 = 1
x1 =
x2 =
x3 =
x4 =
x5 =
20 of 35
e
1
= 0 .5 4 3 6 5 . . .
5
e
0 .5 4 3 6 5 ...
= 0 .3 4 4 4 5 . ..
5
e
0 .3 4 4 4 5 ...
= 0 .2 8 2 2 4 . ..
5
e
0 .2 8 2 2 4 ...
= 0 .2 6 5 2 2 . ..
5
e
0 .2 6 5 2 2 ...
= 0 .2 6 0 7 4 . ..
5
© Boardworks Ltd 2006
Solving equations by iteration
Continuing this process gives:
x6 = 0.25957…, x7 = 0.25927…, x8 = 0.25919…, x8 = 0.25917…
The values are converging towards 0.259 (to 3 d.p.).
We can conclude that this is a root of our original equation.
To prove that this is a root of 5x – ex = 0 we can show that if
f(x) = 5x – ex there is a change of sign between f(0.2585)
and f(0.2595):
f(0.2585) = 5(0.2585) – e0.2585 ≈ –0.002
negative
f(0.2595) = 5(0.2595) – e0.2595 ≈ 0.001
positive
There is a change of sign and so 0.259 (to 3 d.p.) is a root of
5x – ex = 0.
21 of 35
© Boardworks Ltd 2006
Solving equations by iteration
If you have a calculator with an ANS key then the iterative
process can be made much quicker.
In this example you would start by keying in the initial value 1,
followed by the = key.
You then key in the formula as: eANS ÷ 5
Now, each time you press the equals key you will be given the
next value in the sequence.
To see why these values are converging towards the root,
consider the equation again in the form:
x=
e
x
5
e
x
Plotting the graphs of y = x and y =
will show that there are
5
two points of intersection.
22 of 35
© Boardworks Ltd 2006
Solving equations by iteration
Using the starting value of x = 1 we get progressively closer to
the first intersection point. We can demonstrate this graphically:
23 of 35
© Boardworks Ltd 2006
Looking a different arrangements
Suppose we had arranged our original equation, 5x – ex = 0,
in another form. For example:
5x e = 0
x
x
e =5x
x = ln(5 x )
This leads to the iterative formula:
x n +1 = ln(5 x n )
If we use the same start value of x0 = 1 we get:
x1 = 1.6064…, x2 = 2.0853…, x3 = 2.3443…, x4 = 2.4614…,
x5 = 2.5101…, x6 = 2.5297…, x7 = 2.5375…, x8 = 2.5406…,
x9 = 2.5418…, x10 = 2.5423…, x11 = 2.5425…
This time, using the same start value but a different formula,
the sequence converges towards 2.542 (to 3 d.p.).
24 of 35
© Boardworks Ltd 2006
Solving equations by iteration
We can illustrate this convergence graphically using different
starting points.
25 of 35
© Boardworks Ltd 2006
Staircase diagrams
Some iterative processes may result in a staircase diagram:
26 of 35
© Boardworks Ltd 2006
Cobweb diagrams
Other iterative processes may result in a cobweb diagram:
27 of 35
© Boardworks Ltd 2006
Solving equations by iteration
In most cases you will be told what starting value and
rearrangement to use.
a) Show that the equation x3 + 5x – 2 = 0 can be rearranged in
the form
3
x=
2 x
5
b) Use the iterative formula
x n +1 =
2 xn
3
5
with x0 = 1 to find a root of the equation to 5 decimal places.
a) Rearrange the equation:
x + 5x 2 = 0
3
28 of 35
5x = 2 x
3
x=
2 x
3
5
© Boardworks Ltd 2006
Solving equations by iteration
b) The start value is x0 = 1. Therefore:
x1 = 0.2
x2 = 0.3984
x3 = 0.387352…
x4 = 0.388376…
x5 = 0.388283…
x6 = 0.388292…
x7 = 0.388291…
The sequence converges towards 0.38829 (to 5 d.p.).
29 of 35
© Boardworks Ltd 2006
Problems with iterative methods
Not all iterations will converge towards a root. Here are some
examples:
30 of 35
© Boardworks Ltd 2006
Contents
Examination-style question
Using graphs to solve equations
The change-of-sign rule
Solving equations by iteration
Examination-style question
31 of 35
© Boardworks Ltd 2006
Examination-style question
a) Show that the equation
ex + x = 8
has a root between and 1 and 2.
b) Show that this equation can be arranged to give the
iterative formula
xn + 1 = ln(8 – xn)
c) Use the iterative formula found in part b) with x0 = 2 to find
the value of x1, x2, x3, x4 and x5 to 5 decimal places.
d) Prove that the value found for x5 is a root of ex + x = 8
correct to 4 decimal places.
32 of 35
© Boardworks Ltd 2006
Examination-style question
a) Rearrange the equation in the form f(x) = 0:
ex + x – 8 = 0
If f(x) = ex + x – 8 then
f(1) = e1 + 1 – 8 ≈ –4.3
f(2) = e2 + 2 – 8 ≈ 1.4
Since f(1) < 0 and f(2) > 0 there must be a root to the equation
f(x) = 0 between x = 1 and x = 2.
b) Rearrange ex + x = 8 in the form x = f(x):
ex = 8 – x
x = ln(8 – x)
33 of 35
© Boardworks Ltd 2006
Examination-style question
Now write this as an iterative formula of the form xn + 1 = f(xn):
xn + 1 = ln(8 – xn)
c) The starting value is x0 = 2, therefore:
x1 = 1.79176
x2 = 1.82588
x3 = 1.82037
x4 = 1.82126
x5 = 1.82111
34 of 35
© Boardworks Ltd 2006
Examination-style question
d) x5 = 1.8211 is a root of ex + x = 8 correct to 4 decimal places
if f(1.82115) and f(1.82105) are of different sign where f(x)
= ex + x – 8.
f(1.82115) = e1.82115 + 1.82115 – 8 ≈ 0.0001
f(1.82105) = e1.82105 + 1.82105 – 8 ≈ –0.0006
f(1.82115) > 0 and f(1.82105) < 0 and so x5 is a root of the
equation to 4 decimal places.
35 of 35
© Boardworks Ltd 2006