mei c3 coursework (2)

31
Alexander White MEI C3 Coursework Introduction During this coursework I will be using 3 different numerical methods to solve a range of polynomials, for each method I will be giving a brief explanation, an example of a root being found successfully and then an example of the method failing. Once I have demonstrated the methods I will then be comparing each method against each other. Change of Sign When using a change of sign method you would first find the intervals that the roots lie in, either graphically or by substituting values of x into the equation and looking for a change in sign of the y value. Once you have your intervals you would then split this interval down again looking for a change of sign, and then repeat this process until the root is found to the required accuracy. I will be using decimal search; in this method once I have found my first interval for a root I would then go up in the interval in increments finding another change of sign, which would then give me a new smaller interval, which I will then take smaller increments of finding another change of sign, I will be repeating this method until I find the root to a required accuracy. I will be finding one root of the equation x 3 5 x 2 +2=0 to 5 decimal places using the decimal search method −2 2 4 −15 −10 −5 5 x y y=x³−5x²+2 This is the graph of the function y=x 3 5 x 2 + 2 1

Upload: wubberduck

Post on 22-Nov-2015

285 views

Category:

Documents


5 download

TRANSCRIPT

Alexander White

MEI C3 CourseworkIntroduction

During this coursework I will be using 3 different numerical methods to solve a range of polynomials, for each method I will be giving a brief explanation, an example of a root being found successfully and then an example of the method failing. Once I have demonstrated the methods I will then be comparing each method against each other.

Change of Sign

When using a change of sign method you would first find the intervals that the roots lie in, either graphically or by substituting values of into the equation and looking for a change in sign of the value. Once you have your intervals you would then split this interval down again looking for a change of sign, and then repeat this process until the root is found to the required accuracy.

I will be using decimal search; in this method once I have found my first interval for a root I would then go up in the interval in increments finding another change of sign, which would then give me a new smaller interval, which I will then take smaller increments of finding another change of sign, I will be repeating this method until I find the root to a required accuracy.

I will be finding one root of the equation to 5 decimal places using the decimal search method

This is the graph of the function

The graph of the function shows that the roots lie in the intervals [-1, 0] [0, 1] and [4, 5]

I will find the root that lies in the interval [0,1] to 5 decimal places

First I will show that there is a change of sign at the interval by calculating when and

= 2

= -2

There is a change in sign of and which means that the root does lie in the interval [0,1], I will now take increments of 0.1 to look for another change of sign

= 1.951

= 1.808

I will continue these calculations in Microsoft Excel

xf(x)

02

0.11.951

0.21.808

0.31.577

0.41.264

0.50.875

0.60.416

0.7-0.107

0.8-0.688

0.9-1.321

1-2

From these calculations I can see there is a change of sign between and this gives me a new interval of [0.6, 0.7]

I will now take increments of 0.01 to look for another change of sign

= 0.366481

= 0.316328

I will continue these calculations in Microsoft Excel

Xf(x)

0.60.416

0.610.366481

0.620.316328

0.630.265547

0.640.214144

0.650.162125

0.660.109496

0.670.056263

0.680.002432

0.69-0.05199

0.7-0.107

From the calculations I can see there is a change of sign between and this gives me a new interval of [0.68, 0.69]

I will now take increments of 0.001 to look for another change of sign

= -0.002432

= -0.00841

I will now continue these calculations using Microsoft Excel

Xf(x)

0.680.002432

0.681-0.00298

0.682-0.00841

0.683-0.01383

0.684-0.01927

0.685-0.02471

0.686-0.03015

0.687-0.0356

0.688-0.04106

0.689-0.04652

0.69-0.05199

From the calculations I can see there is a change of sign between and this gives me a new interval of [0.680, 0.681]

I will now take increments of 0.0001 to look for another change of sign

=0.001891

=0.001349

I will now continue these calculations using Microsoft Excel

Xf(x)

0.680.002432

0.68010.001891

0.68020.001349

0.68030.000808

0.68040.000266

0.6805-0.00028

0.6806-0.00082

0.6807-0.00136

0.6808-0.0019

0.6809-0.00244

0.681-0.00298

From the calculations I can see there is a change of sign between and this gives me a new interval of [0.6804, 0.6805]

I will now take increments of 0.00001 to look for another change of sign

+2 =0.000266

= 0.000158

I will continue these calculations in Microsoft Excel

Xf(x)

0.68040.000266

0.680410.000212

0.680420.000158

0.680430.000104

0.680444.98E-05

0.68045-4.4E-06

0.68046-5.9E-05

0.68047-0.00011

0.68048-0.00017

0.68049-0.00022

0.6805-0.00028

From the calculations I can see there is a change of sign between and this gives me a new interval of [0.68044, 0.68045]

I will now take increments of 0.000001 to look for another change of sign

= 4.44x10-5

=3.9x10-5

Xf(x)

0.680444.98E-05

0.6804414.44E-05

0.6804423.9E-05

0.6804433.35E-05

0.6804442.81E-05

0.6804452.27E-05

0.6804461.73E-05

0.6804471.19E-05

0.6804486.47E-06

0.6804491.06E-06

0.68045-4.4E-06

From these calculations I can see there is a change of sign between and giving me a new interval of [0.680449, 0.68045]

As both of these numbers round up to 0.68045 to 5 decimal places

To 5 decimal places

This is a zoomed in picture of my graph showing that the root does lie in the first interval [0,1], the decimal search method then works by finding a smaller interval that the root lies in, for this root the next interval was [0.6,0.7]

This shows that the next interval for this root is [0.6, 0.7]

Failures of Change of sign methods

Under certain situations the change of sign methods will not work, for example the equation Root

The graph of shows that it has a repeated root in the interval [-1, 0], this will cause problems with the change of sign methods as at a repeated root there is no change of sign, which means that a new interval will not be found.

xf(x)

-1-2.10938

-0.9-1.54213

-0.8-1.07388

-0.7-0.69863

-0.6-0.41038

-0.5-0.20313

-0.4-0.07088

-0.3-0.00762

-0.2-0.00738

-0.1-0.06413

0-0.17188

Taking increments of 0.1 in the interval [-1, 0] shows that there is no change of sign

A zoomed in graph of the repeated root shows that there is no change of sign; this means that a change of sign method will fail as I will not generate a second interval to continue the process with.

Newton-Raphson method

The Newton-Raphson method is an example of fixed point iteration, unlike change of sign methods I will use an iterative process to converge to the roots. After finding the interval that a root lies in I would take first estimate of the root I would then plot the point ( and draw a tangent to the curve at this point, giving me a second estimate at the point where the tangent crosses the axis (, this process is repeated until my estimates round to a degree of accuracy giving me the root. However since drawing in the tangents would be inaccurate it can be done using an iterative process and achieve the same results.I will solve the equation to 5 decimal places using the Newton-Raphson methodGraph of

From the graph I can see that the roots lie in the intervals [-2,-1] [-1, 0] and [1, 2], I will now use Newton-Raphson to find these roots The general formula Newton-Raphson is

Before I can start finding the roots I need to find for my function

Now that I have this I can generate my iterative formula for this function

Now that I have my iterative formula I can now begin to find the root in the interval [-2,-1], I will use as my first estimate

= -1.6800002

= -1.4795169I will now continue these calculations using Autograph

From these calculations I can see that Autograph has found the root The root is to 5 decimal places To confirm this I will now use error bounds to see if there was change of sign either side of the root -4.089022992x10-5 8.621627124x10-5Since there is a change of sign in my error bounds is a root of

This shows how Autograph found the root using Newton-Raphson, after was imputed it found by drawing a tangent to at the point and found as the point where this tangent crossed the -axis, it then used to find and so on until it found the root. I will now find the other 2 roots of to 5 decimal places using Autograph In the interval [-1, 0] using

The root in the interval [-1, 0] is to 5 decimal places 1.207918099x10-5 -3.598372658x10-5Since there is a change of sign is a root of In the interval [1,2] using

The root in the interval [1, 2] is to 5 decimal places 2.429750662x10-4 -2.023798041x10-5

Since there is a change of sign is a root of

Failures of Newton-Raphson

This method will sometimes fail to find a root, for example the graph of, this shows a root in the interval [0,1]

If I attempt Newton-Raphson on this root starting with I see that the result is divergent, meaning that Newton-Raphson will not find the root

This is because is a turning point of the function and therefore the tangent to the curve at has a gradient of 0 and will never intersect the axis and this means it will never give a value for

The iterative formula for this equation is

Showing this for gives

= Error

This shows that it will fail as it means dividing by 0, and because this fails for it means will not be found as there is no value to put into the iterative formula.

Tangent at

This shows that the tangent will never intersect the axis meaning that the Newton-Raphson method will fail as a value for will never be found.

Rearrangement method

The rearrangement method is another example of a fixed point iteration method, this works by taking an equation and then rearranging it into the form, and then any value of for which will be a root of the original equation.

The equation I will be solving using the rearrangement method is to 5 decimal Places.

Graph of

From the graph I can see that the roots lie in the intervals [-3,-2], [0, 1] and [1, 2]

Now I will rearrange into the form making the subject of my formula.

This means that the iterative formula for my equation is.

Now that I have this I will now plot and on the same axis to find the coordinates of the roots of .

This graph shows that the points of intersection of and have the same coordinate of the roots of , these arent the roots as the coordinate isnt 0, however we can use this to find the roots.

I will now look for the root in the interval [0, 1] to 5 decimal places.

I will take my first estimate to be

= 0.5

=0.28125

I will now continue these calculations using Autograph.

From these calculations I can see that the root in the interval [0, 1] is to 5 decimal places.

-1.2605x10-5

2.9558x10-5

Since there is a change of sign is a root of

This is a graph showing how the root was found using the rearrangement method; the staircase diagram shows that at a line is drawn from the coordinate to the point on where then the coordinate of this point is and this process is then repeated using to find until the root is found.

The rearrangement method was able to find this root as the gradient of satisfies the condition

I can see this from looking at the original graph of against as at the root is less steep than which has a gradient of 1.

Failures of the Rearrangement method

Like all numerical methods there are some situations where this method will fail to find the root, usually one rearrangement of will not find all the roots

The graph shows me trying to find the root in the interval [1,2] using the rearrangement starting with a value when this value is put through the iterative formula a value of is found, this is further away from the root.

This happens because the gradient of at the point is greater than 1, which is the gradient of at that point leading to the failure. For a rearrangement to find a root of it must satisfy the condition below.

From the original graph I can see this as at the root is steeper than meaning its gradient is as the gradient of is 1.

To find the other roots I then must rearrange into a different form of

This then gives me a new iterative formula of

Root

This show and plotted on the same graph and that the value for at the point satisfies the condition meaning that the root will be found.

= 0.3644

Now that I know that this satisfies the condition I can find the root, I will do the calculations using Autograph.

This shows that the root is to 5 decimal places.

5.8429x10-5

-5.4495x10-6

Since there is a change of sign is a root.

Comparison of methods.

After successfully finding roots of equations using the 3 methods I will now compare them, to do this I need to find the same root of an equation using all of the methods to the same accuracy to give a fair comparison.

I will be using the equation to compare the methods.

I will find the root in the interval [0,1] using all three methods.

I have already found the root using the change of sign method to be 0.68045 to 5 decimal places

Newton-Raphson

The iterative formula for this equation is

I will take

This shows that the root is to 5 decimal places.

-3.1467x10-5

2.2718x10-5

Since there is a change of sign is a root.

Rearrangement

I will rearrange into the form

Graph showing and on the same axis and the root as the point where they intersect

This shows that the root is to 5 decimal places.

-3.1467x10-5

2.2718x10-5

Since there is a change of sign is a root.

Now that I have found the root using all 3 methods I can compare them.

Speed of convergence

To find the root using each method required a number of calculations.

Decimal Search required 62 calculations.

Newton-Raphson required 4 calculations.

Rearrangement required 9 calculations.

From this it is clear that decimal search took the most calculations to find the root, 58 more than Newton-Raphson and 53 more than rearrangement, making this the method with the slowest speed of convergence. Rearrangement was the 2nd fastest method requiring 5 more calculations than Newton-Raphson but 53 less than decimal search. Newton-Raphson was the fastest method for acquiring the roots only requiring 4 calculations to find the root to the same degree of accuracy as the other methods looked at.

Method Difficulty.

All of the methods used could be done with a calculator and paper or using computer programs to achieve the same results.

Decimal Search

With decimal search the first step with either equipment would be to find the interval that the root lies in, using a calculator this would require setting up a table of integer values and looking for a change or multiple changes of sign depending on how many roots the equation has. Whereas with a program such as Autograph the graph will be drawn for you providing you with the intervals that the root or roots lie in.

Once the intervals have been found increments will then be taken to find a smaller interval once again looking for a change of sign. Using a calculator this would once again require a table of values going up the interval in increments looking for another change of sign, this would require the input of the equation and the increments into the calculator. With a computer a program could be used such as Microsoft Excel or auto graph, this will also require the input of the equation and the increments, using a program like excel could be difficult if not familiar and due to the way equations are inputted could cause problems with the table of values.

Once a new interval has been found the process will be repeated once again using a table function on a calculator or on a computer program, for each the only thing needed to change is the increments as it requires the same equation. Now this will be repeated a number of times until the root is found, this will require the same number of steps regardless of which equipment is being used.

Newton Raphson

This will require the finding of the intervals to be done in the same way a decimal search first, either by a table of values or a program like Autograph.

Once this is done an iterative formula is needed, a program like Autograph will do this automatically. However if done using a calculator the function requires differentiation which must be done by hand. If done by hand then each new estimate must be calculated individually; however the answer button can be used to speed this up if programed to be the answer on the calculator, and then set up the formula so instead of the next value the ANS symbol visible just pressing equals key will give the next estimate without needing to re-input the equation. Whereas using Autograph all once the Newton-Raphson iteration button is pressed all thats needed is a first estimate and all the calculations including finding will be done by the program, all thats required is the pressing of the equals key on Autograph. Both pieces of equipment will use the same number of estimates to find the root.

Rearrangement

Once the intervals that the roots lie in have been found using the same process as the other methods must be rearranged into the form neither a calculator or computer programs will do this so it must be done by hand.

This also gives you your iterative formula if being done using a calculator, and will also tell Autograph what the iterative formula is. When using a calculator if its set up using the ANS key like with Newton-Raphson it will then just require pressing the equals key until the estimates round to the same value at a given accuracy. When using auto graph the graphs of and must be plotted on the same axis, and when theyre both selected the iteration button must be pressed, and a first estimate imputed and the equals key pressed until the estimates round to the same value. Both pieces of equipment will require the same number of steps to find the root.

Conclusion

After using all the methods and comparing them, I think that when using a computer program the simplest method is Newton-Raphson due to the lack of calculations needed by hand and the speed the root is found. Whereas using a calculator I would use the rearrangement method as the first step would be the same irrespective of the equipment and a calculator is quicker at finding the roots as no additional graphs are needed. The decimal search method is the simplest to understand out of the 3 I used but it also takes the most calculations and longest time to complete, no matter which equipment is used.

-Find one of the roots already found with one method using the other 2-Compare the speed of convergence for each method-Compare ease/difficulty of each method if it was being done using a calculator or a computer

PLAN OUT

Using for Newton-Raphson

Using and for rearrangement with

SHOULD TAKE UP TO with both 1