Académique Documents
Professionnel Documents
Culture Documents
C3 Coursework
In this coursework I will be using three different methods to solve an
equation. These are the:
Change of sign method which involves a decimal search
Newton-Raphson method
Rearrangement of f(x) = 0 to x = g(x)
I will use each of these methods to find a success and a failure and at the
end will identify the practicalities of each method in different situations
compared to each other.
Example
I will use this method to solve the equation 0.5x+2x30x+24.2 = 0.
To do this I will find the values of f(x) = 0.5x+2x30x+24.2 and detail
where the value of the f(x) changes from a positive value to a negative. As
seen in the graph plotted in autograph, there are three roots for this
equation. I will be searching for the second root.
Consecutive integers take the place of x in the function. If the function of
0 is used we arrive at the answer 24.2:
f(0) = 0.5x0+2x030x0+24.2 = 24.2
Equation 1
1
Joseph Wheatland
With the function of 1 we can see that the answer is now negative
(Equation 2). This means there is a root in this interval. We can now
narrow down this search to locate the root in the 0-1 range.
f(1) = 0.5x1+2x130x1+24.2 = -3.3
Equation 2
f(0) =
f(1) = -3.3
As the f(0) is positive and f(1) is negative this tells us the graph must
cross the x axis between 0 and 1. We can now narrow down one of the
roots to being in the range (0, 1)
Figure 1: f(x) = 0.5x+2x30x+24.2
It is now possible to do a decimal search in which I will split the interval
into ten and will again calculate the values of f(x) for the values of x in the
0-1 interval until a change in sign occurs. This step is repeated until the
accuracy comes to four decimal places and the number can be accurately
rounded to 3 decimal places.
Joseph Wheatland
Step 1
Step 2
x
f(x)
f(x)
1
-3.3
160.7
168.2
0.9
0.815
161.7
5
144.2
f(x)
Root in interval
0.8
118.7
1.736
1.736 (0.8,0.9)
88.2
1.4779
21
55.7
1.2204
24.2
84-3.3
0.9636
Root in interval (0,1)
-23.8
94
as there is a change of
-34.3
0.7075
sign
-31.8
52
where the line crosses
-13.3
0.4520
x
63
0.1972 Root in interval
0.86
28
(0.86,0.87)
0.87
Step 4
x
f(x)
Step 0.0569
5
0.1972
3
0.86
28
0.1717
0.861
81
0.1463
0.862
4
0.1209
0.863
06
0.0954
0.864
78
0.0700
0.865
57
0.0446
0.866
43
0.0192 Root in interval
0.867
35
(0.867,0.868)
0.0061
0.868
7
x
-7
-6
-5
X -4
0.8 -3
-2
0.81
-1
0.820
1
0.832
3
0.844
5
0.85
Joseph Wheatland
x
0.867
0.8671
0.8672
0.8673
Step 5
0.8674
0.8675
0.8676
0.8677
0.8678
f(x)
0.0192
35
0.0166
95
0.0141
54
0.0116
14
0.0090
74
0.0065
34
0.0039
94
0.0014
54
0.0010
9
Root in interval
(0.8677,0.8678)
This data has split the values of x into equal intervals so as to get the
degree of accuracy as desired (4 decimal places). We can now diagnose
that f(x) = 0 for 0.8677 < x < 0.8678. This means that the value of the
root is 0.868 (3 d.p) and the former value of f(x) describes the error
bounds of the answer. If we were to again search for a change of sign
between 0.8677 and 0.8678 then it would yield us a more accurate
answer. Our error bound proves our answer is not the definitive one.
Joseph Wheatland
Interval (0.8677, 0.8678)
f(0.8677)
is
POSITIVE
f(0.8678)
is
NEGATIVE
[0.8677,0.8678]
The decimal search method I undertook was a success as the function
crosses the x axis between the values of 0.8677 and 0.8678 (figure 2).
When the x axis is intersected, f(x) = 0. Therefore, as the value of
f(0.8677) is positive and the value of f(0.8678) is negative, we know that
there is an intersection trapped between these two points and hence a
root.
31.5
11
0.5
3
21.5
Joseph Wheatland
(figure 3). But as we can see on the graph between three and four there
are two roots. It is not picked up by this method as the sign changes back
to positive in the same interval.
Figure 3: f(x) = 0.5x+2x30x+59
As the two roots havent been picked up with the decimal search and a
success is only a success when all the roots can be found with the
Integer search
doesnt pick up
these two roots
f(x)
198.6
87.6
18.6
-2.4
30.6
123.6
Joseph Wheatland
X 1 = x0 -
f ( x0 )
f ' ( x 0)
= Xn+1 = xn -
x 30 +27 x 20 +5 x0 2.4
3 x 20+ 54 x 0+5
x 3n +27 x 2n +5 xn 2.4
3 x 2n+ 54 x n+5
0327 02+ 5 02.4
3 0 2+54 0+5
=0-
= 0.48
Now that we have a value for x1 this can be substituted into the iterative
formula again to give out another answer closer to that of the root.
Instead of x0 we now substitute it with x1, and the x1 at the beginning of
the formula becomes an x2 as it will find the second iteration.
3
x2 = x1 -
x 1 +27 x 1+ 5 x 12.4
2
3 x 1+54 x1 +5
= 0.48 -
0.277
While this process can be repeated to achieve a greater accuracy it is
much easier to use software to calculate the values of x3 etc. as it will find
better values quickly with much less rounding error.
Joseph Wheatland
xn
0
0.4799
9
0.2797
1
0.2240
12
0.2190
14
0.2189
73
0.2189
73
0.2189
73
0.2189
73
change in
xn
0.479999
982
0.200289
505
0.055698
736
0.004997
567
Figure 5:
Newton
Raphson
tangent
x+27x+5x2.4
X
X
X
0
3
1
2
Joseph Wheatland
F(0.218965) = -0.000143453025
F(0.218965) = 2.62292106E-005
0.21897 0.000005
The change of sign means there is definitely a root in between the values
and both of these numbers round to 0.21897 so we can say for certain this
is the answer to this root to five significant figures.
There is one more root that lies between [-1,0] that still needs to be found.
Again the same method will be used as before but the value of x0 will be
changed to -1 as it is closer to this root and will find it in fewer iterations.
We can see that the method has found the root with ease in only five
Curve of
y=x+27x+5x2.4
X
0
iterations once
root as -0.40881 to five
again.
Xn
0.59565217
4
0.44278177
5
0.41042812
6
0.40881290
9
0.40880885
3
0.40880885
3
failure
newton Raphson
either the line
closest root from the
different root is found
Joseph Wheatland
than the one we are searching for. This could happen due to the gradient of the
tangent being very close to zero and not reaching the x axis for a long time as it
has a steep crossing point or the function is discontinuous and the tangent is
formed but the new value of xn doesnt hit the curve again.
Let f(x) = (2x3-4x2+1)1/3 (Figure 5.1) I will attempt to find the root on the far right
in the interval [1,2] in this example for the equation f(x) = 0.
X4
X3
X1
X0
X2
Figure
The line first goes onto the other
side of the root we are looking for.
5.2
x
change
10
Joseph Wheatland
1.6250
01
2.6593
33
1.1952
28
2.7405
8
in xn
0.37499
909
1.03433
18
1.46410
49
3.93580
32
X = g(x) method
This third method is known at the x = g(x) method which involves
rearranging the equation f(x) = 0 to x= g(x). This new function can then
be used as an iterative formula. When using this method, the function y =
g(x) is plotted against y=x and the points at which these points intersect
will now satisfy the equation f(x) = 0.
I am going to use the x = g(x) method to solve 2x -3x-2x +0.7=0 so let
f(x) = 2x -3x-2x +0.7=0 (figure 6).
Joseph Wheatland
An integer search can be used now to see which number to use for the
starting value of this formula (x0). In figure 7 there are three turning
points which signifies there are three roots. I am going to focus on the root
between [0,1] so I will make x0 = 0
x
-1
0
1
2
3
f(x)
-2.3
0.7
-2.3
0.7
21.7
Figure
7
This method
Raphson
be found by
X1 = (2x03-
Y=
x
Y=
g(x)
Y=
f(x)
functions
each
Figure 8:
g(x) =
are
just rearrangements of
other.
y = f(x) = 2x -3x-2x +0.7, y =
(2x3-3x2+0.7)/2, y = x
12
Joseph Wheatland
x
0.35
0.209125
0.293545821
0.24604087
0.274090192
0.257902994
0.267383216
0.261875561
0.2650909
0.263219004
0.264310564
0.263674645
0.264045323
0.263829323
0.263955213
0.26388185
0.263924605
0.263899688
0.26391421
0.263905747
0.263910679
0.263907805
0.26390948
0.263908504
0.263909072
0.263908741
0.263908934
change in xn
0.35
0.140875
0.084420821
0.047504951
0.028049322
0.016187198
0.009480222
0.005507655
0.003215338
0.001871896
0.001091559
0.000635919
0.000370678
0.000215999
0.000125889
7.34E-05
4.28E-05
2.49E-05
1.45E-05
8.46E-06
4.93E-06
2.87E-06
1.68E-06
9.76E-07
5.69E-07
3.32E-07
1.93E-07
13
Joseph Wheatland
Root of f(x) =
0
X1
X3
X2
Y = x has
gradient of 1
Fig
X0
Y=g(x) line
steeper than y
=x
ure 9
The
reason
for the
cobweb like shape is due to the
magnitude of the root for g(x) when calculated at the root.
When the value of g(x) lies in the bounds -1 < g'(x) <0, the
line
will converge on the root with the cobweb effect. If the root
was higher than zero a staircase pattern would occur instead. Anything
below -1 or above 1 will lead to a failure. In the case of this graph the line
y = x has a gradient of one. The blue line is steeper than the red line
which means that the g(x) lies within the bounds -1<g(x)<0 and forms
the cobweb effect.
Failure of the x = g(x) method
Normally the line used to visualise this method will converge in either a
staircase or cobweb towards an intersection between the equation y = x
and y = g(x) if it is successful. However a failure will do the exact
opposite. It would diverge away from the point of intersection and shoot
off into infinity as it cant reach a point on a curve. Failure would also
constitute finding the wrong root which is not the closest root to the
starting integer.
I am going to once again rearrange my equation f(x) = 0 into the form x =
g(x).
14
Joseph Wheatland
3
1/2
equation is xn+1 = (xn xn +0.35) .
I will choose a different root to work on this time between the integers [2,-1]. The intersection is nearest to the integer -2 so I will make the value
of x0 equal -2. At first glance (figure 10) it is clear to see that the gradient
of the equation y = g(x) is much higher than that of y = x which has a
gradient of 1. This means that g(x)>1; we would expect the line to
diverge away from the intersection in a staircase like pattern. This isnt
too clear to see however as after the line hits y = x for the second time, it
tries to go vertical but shoots to infinity. The line visualising x = g(x) is
very steep so the line created will not reach it. The graph does in fact
diverge away from the intersection as expected (in a staircase pattern)
therefore. The table below shows that the graph is not converging at all
towards the desired too and is in fact moving further away with each
iteration in the interval [-2,-1].
X0
Y=x
X1
X2
Y=
g(x)
Figure 10
2x -3x2x +0.7
x
0
1
2
-2
-2.825
9.685
-449.2
-23.3
-62.682
1516.82
181884169.
8
found earlier.
15
Y=f(
x)
Joseph Wheatland
3(0.26391)21
g(x) =
7
30
The value of g(x) is below -1 so a cobweb diverging pattern is formed as
we expected.
2
(0.26391)3(0.26391)+
n
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
x
0
0.1
0.2
0.3
0.21
0.22
0.23
0.24
0.25
0.26
0.27
0.261
0.262
0.263
0.264
0.2631
0.2632
0.2633
0.2634
0.2635
0.2636
0.2637
0.2638
0.2639
0.264
0.2639
1
f(x) = 2x -3x-2x
+0.7
0.7
0.472
0.196
-0.116
0.166222
0.136096
0.105634
0.074848
0.04375
0.012352
-0.019334
0.009196162
0.006037456
0.002875894
-0.000288512
0.002559581
0.00224324
0.00192687
0.001610472
0.001294046
0.000977591
0.000661108
0.000344596
2.80562E-05
-0.000288512
-3.59931E-06
16
Joseph Wheatland
0.2639
01
0.2639
02
0.2639
03
0.2639
04
0.2639
05
0.2639
06
0.2639
07
0.2639
08
0.2639
09
26
27
28
29
30
31
32
33
34
2.48907E-05
2.17252E-05
1.85596E-05
1.53941E-05
1.22285E-05
9.06294E-06
5.89738E-06
2.73182E-06
-4.33743E-07
Newton Raphson
n
x
0
1
2
0
0.35
0.26627
0.26391
1
0.26390
9
0.26390
9
3
4
5
n
0
1
2
3
0.35
0.2091
25
0.2935
46
0.2460
41
change in
xn
0.35
0.140875
0.084420
821
0.047504
951
17
Joseph Wheatland
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
0.2740
9
0.2579
03
0.2673
83
0.2618
76
0.2650
91
0.2632
19
0.2643
11
0.2636
75
0.2640
45
0.2638
29
0.2639
55
0.2638
82
0.2639
25
0.2639
0.2639
14
0.2639
06
0.2639
11
0.2639
08
0.2639
09
0.2639
09
0.028049
322
0.016187
198
0.009480
222
0.005507
655
0.003215
338
0.001871
896
0.001091
559
0.000635
919
0.000370
678
0.000215
999
0.000125
889
7.34E-05
4.28E-05
2.49E-05
1.45E-05
8.46E-06
4.93E-06
2.87E-06
1.68E-06
9.76E-07
Joseph Wheatland
19
Joseph Wheatland
20