Numerical_Solutions_of_Equations docx

advertisement
Chris Hayward
Maths
C/W
Numerical Solutions of Equations
Numerical Solutions are used to find the roots of equations when
algebraic methods may fail to do so. In this coursework three
different methods will be demonstrated and compared to find
which can be used to most effectively find the roots of equations.
Decimal Search
Success
The decimal search method relies on using an estimation of the interval that the root is in.
We shall be using the following equation for the Decimal Search:
X3 –x2 +15x – 9= f(x)
600
500
400
300
200
f(x)>0
100
0
-2
-100
-1
0
f(x)<0
1
2
3
4
5
6
7
X3 –x2 +15x – 9= f(x)
x
f(x)
-2
-51
-1
-26
0
-9
1
6
2
25
3
54
4
99
5
166
6
261
This search, with integer values, shows that a root is located between X=0 and X=1.
Following this realising; a search to 1d.p is carried out, to further locate the root.
1|Page
7
390
Chris Hayward
Maths
C/W
x
f(x)
0
-9
0.1
-7.509
0.2
-6.032
0.3
-4.563
0.4
-3.096
0.5
-1.625
0.6
-0.144
0.7
1.353
0.8
2.872
0.9
4.419
Carrying out the further search we can see that the root is located between 0.6 and 0.7.
8
6
4
2
0
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
-2
-4
-6
-8
-10
A search to 2d.p is then carried out.
x
F(x)
0.6
-0.144
0.61
0.62
0.63
0.64
0.65
0.66
0.67
0.68
0.69
0.004881 0.153938 0.303147 0.452544 0.602125 0.751896 0.901863 1.052032 1.1202409
The results are placed in a table and then plotted on a lane graph with axis with smaller
intervals.
The graph (along with the table) shows that the line crosses the X axis between 0.6 and 0.61
2|Page
Chris Hayward
Maths
C/W
1.6
1.4
1.2
1
0.8
0.6
0.4
0.2
0
0.6
0.61
0.62
0.63
0.64
0.65
0.66
0.67
0.68
0.69
0.7
-0.2
-0.4
Once again going to a smaller interval allows us to see where the change in sign is. We can
see that the change occurs between X=0.609 X=0.610
x
F(x)
0.6
0.144
3|Page
0.601
0.129
119
0.602
0.114
237
0.603
0.099
353
0.604
0.084
467
0.605
0.069
58
0.606
0.054
691
0.607
0.039
8
0.608
0.024
908
0.609
0.010
014
0.610
0.004
881
Chris Hayward
Maths
C/W
0.02
0
0.6
0.601
0.602
0.603
0.604
0.605
0.606
0.607
0.608
0.609
0.61
-0.02
-0.04
-0.06
-0.08
-0.1
-0.12
-0.14
-0.16
This penultimate table and graph shows that the root is between 0.609 and 0.610. To be
accurate to 3dp we need to work it out for a 4thdp to know whether we round it up or down.
0.006
0.004
0.002
0
0.609
-0.002
0.6091 0.6092 0.6093 0.6094 0.6095 0.6096 0.6097 0.6098 0.6099
0.61
-0.004
-0.006
-0.008
-0.01
-0.012
To 4dp we can see that the root occurs between X=0.6096 and X=0.6097. As the final
decimal place on either side of the root is a 6 or a 7, we round the lower estimate for 3dp
up.
This gives us a final value of X= 0.610 to three decimal places. This is accurate to ±0.00005
4|Page
Chris Hayward
Maths
C/W
Failure
One situation that this method of decimal searching fails will occur on the following graph.
F(x) = (X2+7X-3)/(2X2-5X-6)
To gain an estimate for a root we can do an integer search; which yields the following
results.
x
F(x)
-2
-1.0833
-1
-9
0
0.5
1
-0.5555
2
-1.875
This would lead us to believe that a root lies between -1 and 0; however, when we consult
the graph of the function, we
can see this:
That between -1 and 0 is, in
fact, not a root but an
asymptote. Due to the fact
asymptotes lead to the sign
changing, along with roots,
this method can identify them as roots. This however, is not good as asymptotes are not
roots. Due to this functions with asymptotes are failed by this method.
Fixed Point Iteration (Re-Arrangement) Method
Failure
We shall be using the following equation for this method:
f(x) = X3-X2+4X-17
This method relies on rearranging the formula into an ‘X=’ form.
One rearrangement for our equation in an ‘x=’ for is x= ((x2-x3+17)/4)
5|Page
Chris Hayward
Maths
C/W
Firstly, we plot the original formula, to gain an estimate for the root.
200
150
100
f(x)>0
50
0
-5
-4
-3
f(x)<0
-2
-1
0
1
2
3
4
5
-50
-100
-150
-200
This graph shows that a root is located between -2 and -1.
Now we sub one of our estimates for a root into the re-arranged formula (x= ((x2-x3+17)/4)).
We can see that -2 is closer to the point that the equation cuts the x axis, so we’ll use this as
our estimate.
So, for X1 =-2. This then gives X2 = +7.25. We now sub X2 into the formula; and so on until we
find the root.
X3 =-77.879
X4 = 119606
At this point we can see that the results are diverging (moving further apart) so this method
has failed to find the root situated between -2 and -1.
We can see this graphically by plotting the graphs y=x and y= (x2-x3+17)/4 on the same axis.
6|Page
Chris Hayward
Maths
C/W
6
4
2
0
-3
-2
-1
0
1
2
-2
-4
-6
The graph makes it clear that the value’s we receive will continue to diverge; which means
that the we are not moving closer to the root, but instead moving further away from it.
Success
Although this method failed to find a root to this equation once that does not mean that it
will always fail.
When I use a different re-arrangement of the original equation; it can be successful.
This time I shall be using the rearrangement: (x2-4x+17)1/3
We can use the same X1 as before; -2. We then put the next ‘X’ value in the equation and
see what the answer converges on.
We end up with the results as follows:
X1 = -2
X2= -1.70998
X3= -1.93420
X4= -1.89507
This continues until the value finally converges on:
X42= -1.84140
7|Page
Chris Hayward
Maths
C/W
This shows that X=-1.84140 is a root of the equation.
We can also show this graphically by plotting Y=X and Y=(x2-4x-17)1/3 on the same graph.
6
4
2
0
-5
-4
-3
-2
-1
0
1
2
3
-2
-4
-6
Newton-Raphson – Tangent Sliding
Success
In this method we can find f(x) = 0 by using the arrangement Xn+1= Xn- f(xn)/f'(xn).
f(x) = 2x2 + 5x3-2
Therefore: f'(x) = 4X + 15X2
8|Page
4
5
Chris Hayward
Maths
C/W
This function can be plotted to gain an approximation for a root.
y
f(x)=2X^2 + 5X^3 -2
10
8
6
4
2
x
-12
-11
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
1
2
3
4
5
6
7
8
9
10
11
12
13
-2
-4
-6
-8
-10
-12
-14
We can see that the root is located between 0 and 1.
We can then use the formula to get closer to the root. Each time we gather a new answer with the
formula, we use that answer in the formula, continuing until we have converged on the root.
X1=1
x2 = 1 - ( 2(1)2 + 5(1)3 - 2 ) / ( 4(1) + 15(1)2 ) = 14/19
X3= 0.63891
X4= 0.62053
X5= 0.62476
X7= 0.62476
X6= 0.62476
The method has converged on 0.62476; meaning that the root, to four decimal places is
0.6248 ± 0.00005. To ensure the root is within these bound I'll check 0.62475 and 0.62785 in the
original f(x).
Inputting 0.62475 gives -0.00014. As this bound is below zero, and the graph shows the line having a
positive gradient, this helps confirm the root.
Inputting 0.62485 gives 0.000699. As this bound is above zero, with the graph showing a positive
gradient, we know the root is below this point.
Inputting the bounds shows the root to be between the bounds and the method to have converged
on a root.
Failure
This method can be seen failing when we’re using the function f(x) =x3 - 8x2 + 5.
This gives us f’(x) = 3X2 – 16X.
An integer search is used to gain an estimate of the root.
9|Page
Chris Hayward
Maths
C/W
X
F(x)
-2
-35
-1
-4
0
5
We can see a change of sign between x=-1 and x=0. Using X1=0 we shall try to gauge a root.
X2 = f(x) / f’(x) = (03- 8(0)2 +5)/ (3(0)2 – 16(0) = N/A
Using X1=0 makes the denominator ‘0’. As we must divide by the derivative this fails; as we
cannot divide by ‘0’, and the derivative does not have a constant term.
.
This shows a time that using this numerical method cannot work.
Comparison
To compare the three methods I shall use the function from the original Decimal Search.
X3 –x2 +15x – 9= f(x)
The Decimal Search method; although not particularly quick does make it very easy to find a
root (assuming you are closing on a root, not an asymptote). The process is very simple to
complete; repeating the same procedure over and over.
For the Fixed Point Iteration method we shall use the re-arrangement:
9 − 𝑥3 + 𝑥2
𝑥 =
15
For Newton-Raphson f’(x) = 3X2 -2X + 15
Xn+1 = Xn – ( X3 +x2 +15x -9) / (3x2 -2X+15 )
The other two methods are compared in the following table.
10 | P a g e
Chris Hayward
Maths
C/W
X0 = 0
Newton-Raphson
n
0
1
2
3
4
5
6
Xn
0
0.6
0.6096
0.609672
0.609672
0.609672
0.609672
Fixed Point Iteration
Xn
0
-0.6
-1.075
-1.33497
-1.44183
-1.48023
-1.49337
Using the function that was used for the decimal search shows a huge variation in the
usefulness of each equation.
Newton-Raphson converges on the root at only X3; meaning this method is both very fast
and very accurate finding the root of the equation. Comparing the speed of this to the
decimal search we can see that it is much faster. Newton-Raphsons accuracy is limited to
the display of whatever hardware you are using; with a calculator this will be limited to 9d.p,
Decimal search is also limited by this. If you use Microsoft Excel with either of these
methods it is possible for you to be accurate to many more decimal places as Excel will
display as many places as can fit in the box.
Fixed Point Iteration has not worked for this equation. From the results it is clear to see that
the value is moving away from the root found in the other two methods.
Although Newton-Raphson was the fastest method, faster than the Decimal Search, it is still
not necessarily the best method. It does require a larger ‘set-up’ than a decimal search.
Decimal search only requires the ability to spot signs changing, as well as inputting a large
amount of values into your equation. Newton-Raphson, however, requires differentiation
and a more complex final equation to use. Once the final equation is set up; it is easier to
use N-R as you can store the Answer in your calculator and continue without having to reinput.
This means that when you want to go to more decimal places; N-R is faster. To less decimal
places, decimal search is faster.
Hardware that can do all the computing automatically, such as a computer, makes it more
sensible to use the methods with harder set-ups as they are able to become more accurate.
The location of the root; the value of the derivative and the amount of decimal places you
want to go to are what must determine what method you use.
11 | P a g e
Download