26
Introduction: When analytical method can not be used, this is when numerical methods come in handy as it helps to provide roots where y=0. In my coursework I will be using 3 different types of numerical methods and they are: 1) Change of sign method (Decimal search) 2) Newton Raphson Iteration 3) Rearranging f ( x )=0 In the form x=g ( x) Change of sign (decimal search) The change of sign method is used to find the roots of a function which crosses the x-axis on the graph. If there is a change of sign from the roots extracted then the interval between these two x values will be taken and the search will be narrow down to 5 decimal places. The root will be established when the value of y=0. The reason for this is because the root will only be seen when the graph passes the x axis, which is when the equation is y=0 Change of sign method- Success The equation that I will be using for my success will be f ( x)=x 3 3 x+4 The graph for the equation is shown as below:

Math Couesework

Embed Size (px)

Citation preview

Introduction:

When analytical method can not be used, this is when numerical methods come in handy as it helps to provide roots where y=0. In my coursework I will be using 3 different types of numerical methodsand they are:

1) Change of sign method (Decimal search)

2) Newton Raphson Iteration

3) Rearranging f (x )=0 In the form x=g(x)

Change of sign (decimal search)

The change of sign method is used to find the roots of a function which crosses the x-axis on the graph. If there is a change of signfrom the roots extracted then the interval between these two x values will be taken and the search will be narrow down to 5 decimalplaces. The root will be established when the value ofy=0. The reason for this is because the root will only be seen when the graphpasses the x axis, which is when the equation is y=0

Change of sign method- Success

The equation that I will be using for my success will bef(x)=x3−3x+4

The graph for the equation is shown as below:

I will now, narrow the search to 1 decimal place

The table confirms that there is a root between -3 and -2, as there is a

From the graph, we can see that there is a root between -3 and -2x y

change ofsign

-4 -48 negative-3 -14 negative-2 2 positive-1 6 positive0 4 positive1 2 positive2 6 positive3 22 positive4 56 positive

Then, I will narrow the search to 2decimal place

After that, I will narrow the search again to 3decimal place

x ychange of sign

-3 -14 negative

-2.9 -11.689 negative

-2.8 -9.552 negative

-2.7 -7.583 negative

-2.6 -5.776 negative

-2.5 -4.125 negative

-2.4 -2.624 negative

-2.3 -1.267 negative

-2.2 -0.048 negative

-2.1 1.039 positive

-2 2 positivex y

change ofsign

-2.2 -0.048 negative

-2.19

0.066541 positive

-2.18

0.179768 positive

-2.17

0.291687 positive

-2.16

0.402304 positive

-2.15

0.511625 positive

-2.14

0.619656 positive

-2.13

0.726403 positive

-2.12

0.831872 positive

-2.11

0.936069 positive

-2.1 1.039 positive

My search is then narrow to 4 decimal place

x ychange of sign

-2.2 -0.048 negative

-2.199-

0.036486599 negative

-2.198-

0.024986392 negative

-2.197-

0.013499373 negative

-2.196-

0.002025536 negative

-2.195 0.009435125 positive

-2.194 0.020882616 positive

-2.193 0.032316943 positive

-2.192 0.043738112 positive

-2.191 0.055146129 positive

-2.19 0.066541 positive

x ychange of sign

-2.196

-0.00202553

6 negative

-2.1959

-0.00087887

7 negative

-2.1958 0.00026765 positive

-2.1957

0.001414046 positive

-2.1956

0.002560309 positive

-2.1955

0.003706441 positive

-2.1954

0.004852441 positive

-2.1953 0.00599831 positive

-2.1952

0.007144047 positive

-2.1951

0.008289652 positive

-2.1950.00943512

5 positive

I will finish the search by narrowing it to 5decimal place

The error bound for my equation is−2.19582+−2.19581

2 = -2.195815

Therefore the error is -2.195815 ± 0.000005

To test that my error is correct, I wilcalculate it as shown below:

Lower bound: -2.195815 – 0.000005 = -2.19582

Upper bound: -2.195815 + 0.000005 = -2.19581

x ychange of sign

-2.1959

-0.000878877 negative

-2.1958

9-

0.000764218 negative

-2.1958

8-

0.000649561 negative

-2.1958

7-

0.000534905 negative

-2.1958

6 -0.00042025 negative

-2.1958

5-

0.000305597 negative

-2.1958

4-

0.000190945 negative

-2.1958

3

-0.0000762942 negative

-2.1958

2

-0.00000383552 negative

-2.1958

1 0.000153003 positive

-2.1958 0.00026765 positive

To test this even further I am going to input these values into the original equation.

Lower bound:

f(x)=x3−3x+4

f(x) = −2.195823−3 (−2.19582 )+4

f(x)=−10.58742164+6.58746+4

f(x)=3.836×10−05

Upper bound:

f(x)=x3−3x+4

f(x) = −2.195813−3 (−2.19581 )+4

f(x)=−10.587277+6.58743+4

f(x)=1.53×10−04

Now, a comparison can be made with the values on the table

From testing the error bound, I have proved that my error bound is correct as the upper and lower bound shows similar values to the values on my table after narrowing to 5 decimal searches. Moreover this proves that there is a root from the equation f(x)=x3−3x+4 due to the change of sign.

Change of sign method- Failure

There is a failure in this method when having two roots that are very close together. When this happens, the change of sign method will not work as there will be no apparent changes in sign.

The equation that I will be using for my failure is y=x4−8x+7.545

Firstly, an integer search must be done of all the values of f(x) shows that there are no changes in sign which means that there are no root presents from the equation. However, the graph shows that there are roots; between 1 and 2

x ychange ofsign

1 0.545 positive2 7.545 positive

Now, I’m going to narrow the search to 1 decimal place

I will be focusing on the two roots between 1 and 2

Newton – RaphsonIteration Method

Newton-Raphson Iteration is when a tangent of a point is drawn on the graph and where the line meets the x-axis that will be next point that should be used into the equation.

The Newton-Raphson Iteration equation is

xn+1=xn−f(x)

f'(x) where xn+1 is the next

value of x, xn is the value of x that is being used, f(x)is the value at the x value, and f'(x) is the value of the differential at that value of x

A change in sign is also not present. However a close view ofthe two roots, prove that there are roots present however the

X yChange of signs

1 0.545 Positive

1.10.209

1 Positive

1.20.018

6 Positive

1.30.001

1 Positive

1.40.186

6 Positive

1.50.607

5 Positive

1.61.298

6 Positive

1.72.297

1 Positive

1.83.642

6 Positive

1.95.377

1 Positive2 7.545 Positive

This method works for finding roots because of the tangent being drawn at a point. Where the tangent touches the x-axis that will become the new value for x, which is then inserted to the graph and another tangent will be drawn at the new value of x. This method will continue to step inwards towards the root.

Newton-Raphson method (Success)

I will be using the function f (x ) = x5-x4-4.55x2+4

The graph shows that there are 3 roots present in the intervals; [-1, 0], [0, 1] and [1, 2]

First of all, I will find the roots between 1 and 2.

My initial value (x0) will be 2. Therefore this should give an x value closer to the root by inputting the initial value into the function, which isf (x )=x5−x4−4.55x2+4.

The differential of the function is f' (x)=5x4−4x3−9.1x

The iterative formula is xn+1=xn−f(x)f'(x)

therefore the iterative formula for my search will be:

x1=x0−(x0)5−(x¿¿0)4− 4.55(x¿¿0)2+4

5(x¿¿0)4−4(x¿¿0)3−9.1(x¿¿0)¿¿¿¿¿

Letx0be2

x1=2−(2)5−(2)4−4.55(2)2+45(2)4−4 (2 )3−9.1(2)

x1=2−32−16−18.2+480−32−18.2

x1=2−1.829.8

x1=1.939597315

Fr0m the above graph above it is evident that using the value of 2 as x0, the Newton Raphson Iteration converges towards the roof in the interval [1, 2]

We can now do this for the rest of the values and put them into a table.

x1 x0

We do this until the value of xn+1=xn

The root is 1.93193 (5 decimal place)

The error is therefore ±0.00005

Lower limit is 1.93193 – 0.00005= 1.93188

There are two more roots to be found [-1, 0] and [0, 1]

To test this we can use these values as x into the function and if there is a change in sign than the root is truly between these two values.

f (x )=x5−x4−4.55x2+4

f (1.93188 )=(1.93188)5−(1.93188 )4−4.55(1.93188 )2+4

f (1.93188 )=26.90919663−13.92902076−16.98132952+4

f (1.93188 )=−1.15365×10−0.3f (x )=x5−x4−4.55x2+4

f (1.93198 )=(1.93198)5−(1.93198 )4−4.55(1.93198 )2+4

f (1.93198 )=26.91616186−13.93190502−16.98308758+4

f (1.93198 )=1.16926×10−0.3

Newton-Raphson method (Failure)

There are many ways that Newton- Raphson can fail in. For example, when the graph does not intercept with the x-axis or the root is a turning point.

The equation that I will be using is y=√(x¿¿3+3.345x2−2.45)¿

−10 −5 5 10

−6

−4

−2

2

4

6

8

x

y

First of all I will be explaining why the Newton-Raphson Method fails in finding the root that I’m focusing on which isthe root between 0 and 1.

The value of x0will become 1 as it is the closer integer to theroot.

My function is y=+√(x¿¿3+3.345x2−2.45)¿

The differential of my function is

√3x2+6.69x√x3+3.345x2−2.45

The iterative formula is xn+1=xn−f(x)f'(x)

xn+1=x0−√(x0)3+3.345(x¿¿0)2−2.45

√3(x¿¿0)2+6.69(x¿¿0)√(x¿¿0)3+3.345(x¿¿0)2−2.45¿¿¿¿¿

xn+1=1− √(1)3+3.345(1)2−2.45√3(1)2+6.69(1)√(1)3+3.345(1)2−2.45

xn+1=1− √1.895√9.69 √1.895

xn+1=1− √1.895√13.339157

xn+1=0.623087609

We take the value of xn+1 and substitute it into the iterative formula.

The above equation shows that the Newton-Raphson method is a failurebecause when you square root a negative number the answer will become undefined. The graph even shows the same result as the squareroot of a negative figure is undefined therefore the function for the equation does not exist.

0.6 0.7 0.8 0.9 10

0.2

0.4

0.6

0.8

1

1.2

1.4

x

y

The graph shows a failure because the graph did not continue to pass through the linen x=0. In order for the Newton-Raphsonmethod to success, it requires the graph to cross the x axis

xn+1=0.623087609− √(0.623087609)3+3.345(0.623087609)2−2.45√3(0.623087609)2+6.69 (0.623087609)√(0.623087609)3+3.345(0.623087609)2−2.45

xn+1=0.623087609− √−0.909436934√5.333170609√−0.909436934

xn+1=undefined

x0

so that we can find the root as the tangent will then be takenfrom the graph. The function of the graph above makes it seems as if after the line x=0, the value of y does not exists.

−4 −3 −2 −1

−1

0

1

2

3

x

y

In addition, the other two roots show that it is a failure. However, it also shows that the domain of the function does not all the Newton-Raphson iteration to find roots as it states that it is ‘overflow’ because no tangent can be drawn from the root as at -1 or -2 the function dost not exist.

Rearranging f (x )=0 to the form x=g(x)

The rearrangement method helps to find roots because by rearranging the original formula, we are able to form two moredifferent functions (one being f (x )=x and the other one being a curve). These two functions are then graphed onto the same graph and then the roots are identified by looking on the graph where the functions intersect with each other.

An intial guess is now possible to be made ( ) and similar toNewton-Raphson method, the function may either diverge from the intersection points or converge towards them.

I am going to use the function :

f (x )=x5−6.5x2+4.32

The graph is shown below:

−10 −5 5 10

−8

−6

−4

−2

2

4

6

x

y

The following function can be rearranged in two ways:

1.) Bringing the over to the other side and then taking the fifth root of both sides.

f (x )=x5−6.5x2+4.32

−x5=4.32−6.5x2

−x=(4.32−6.5x¿¿2)1 /5 ¿

g (x)=−(4.32−6.5x2)1/5

2.) By bringing the −7x to the other side then dividing bothsides by 7

f (x )=x5−6.5x2+4.32

6.5x2=x5+4.32

x2=x5+4.326.5

g (x)=√x5+4.326.5

The graph of the first rearrangement, g (x)=−(4.32−6.5x2)1/5 along with the line y=x is shown below:

−4 −2 2 4 6

−2

2

4

x

y

As seen from the graph of the rearrangement, the line y=x also intersects the rearranged function three times. The roots that are present in the interval are [-1, 0], [0, 1] and [1, 2]

I will be focusing on the root in the interval [0, 1]. An initial value (x0¿ can be 0

g(x¿¿1)=¿¿

g(x¿¿1)=[4.32−6.5(0)2]1/5 ¿

g(x¿¿1)=[4.32−0]1 /5 ¿

g(x¿¿1)=4.321 /5¿

g(x¿¿1)=1.339975165¿

The result is then substituted into the equation again until a valueis consistent ,then the root will lie close to this value.

From the graph below; f (x )=x5−6.5x2+4.32 we can see that the root does lie between 1 and 1.5

1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 2.1

−0.5

0

0.5

1

x

y

The graph above shows the function f (x )=x5−6.5x2+4.32 tofind the root between 1.5 and 2

1.68 1.7 1.72 1.74

−0.1

0

0.1

0.2

x

y

The graph above shows the function f (x )=x5−6.5x2+4.32 tofind the root between 1.5 and 2

1.68 1.7 1.72 1.74

−0.1

0

0.1

0.2

x

y

It is now evident that this reaarangement works for the root 1.7131719 to 7 decimal places. However thisis not the root that we wanted to obtain. Therefore to make sure that the failure was not due to choosingan initial value that was inappropriate to find the other roots, below are the tables to show that I havechosen all the integer values closest to the roots, and the the only root that it manages to find is 1.7131719.

Rearrangement Method (failure)

This method fails because this method depends on the gradient of the rearranged function. If it is more than one, then it will diverge away to a root that has a gradient that is one. For negativegradients, anything less than 1 will also diverge away as well. Therefore this method will only work in the range .

Therefore finding the gradients at the points of intersection will give a reason why the rearrangement can only find one root.

Firstly we must differentiate the rearranged function of

f (x )=−¿¿

f (x )=−15

¿¿

f (x )=13x5

¿¿

Once we have the differential, we can now substitute in 0 as x.

f' (x)=13 (0)5

¿¿

f' (x)=0¿

f' (x)=0

This rearrangement works because the gradient than -1 however less that 1 therefore this value x will converge towards a root.

The gradient of the other initial values ()

However there is another rearrangement from the function that may find the remaining two roots.

g(x)√x5+4.326.5

The graphs is shown below

f (x )=−¿¿

f (x )=−15

¿¿

f (x )=13x5

¿¿

−10 −5 5 10

−8

−6

−4

−2

2

4

6

x

y

From observation, this rearrangement will not find the root between 0 and -1, therefore the failure can be explained by the rearranged function being a square root, therefore any negative value of will give an answer that is undefined therefore the y-value will not exist.

Once we have the differential, we can now substitute in 0 as x.

This rearrangement works because the gradient it greater than -1 however less that 1 therefore this value of x will converge towards a root.

The gradient of the other initial values (-1,1 and 2) are 0.819197066,0.819197066 and -0.3723153503 respectively.Ho

wever there is another rearrangement from the function that may findthe remaining two roots.

f (x )=x5+47

xn+1=xn

5+47

x2=x1

5+47

x2=1+47

x2=0.7

x3=x2

5+47

This formula will notfind roots near

-1.7 & 1.4 because thoseroots are not

Failure of rearrangement method

xn xn+1

10.7142

860.7142

860.5979

910.5979

910.5823

520.5823

520.5809

970.5809

970.5808

860.5808

860.5808

770.5808

770.5808

760.5808

760.5808

76

The graph of the second rearrangement, f (x )=¿ along with the liney=x is shown below:

Comparison

Comparisons of Methods

Speed of convergence

Ease of Use with Available Software

Conclusions

To really compare these methods fully I think that I would need to test out the different methods.