# Functions Coursework - A2 Maths

Extracts from this document...

Introduction

C3 Coursework: Numerical Analysis

Change of sign method

I want to find the roots of the equation x3-3x-1=0 to five decimal places.

Consider the function f(x)=x3-3x-1; hence I want to find the roots of the equation f(x)=0.

If the function is continuous in the interval [a,b], where a and b are values x could take, and either:

f(a)<0 and f(b)>0

or:

f(a)>0 and f(b)<0

then there must be at least one root of the equation f(x)=0 in the interval [a,b]. Therefore we are looking for a change of sign, which will then indicate the interval in which there lies a root of the equation f(x)=0.

The table shows values of f(x) at integer values of x from -5 to 5.

x | -5 | -4 | -3 | -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5 |

f(x) | -111 | -53 | -19 | -3 | 1 | -1 | -3 | 1 | 17 | 51 | 109 |

We can identify 3 intervals which have a change of sign:

[-2,-1],[-1,0] and [1,2]

If we sketch the graph of the function, i.e. y=f(x), the x values at the point where y=0 are the roots to the equation f(x)=0, since y=f(x). Three roots are confirmed in these intervals i.e. each interval contains one root.

The gradient formula can be calculated: f′(x)=3x2-3

f′(5)=72, and after x=5, the gradient formula shows that the gradient just continues to increase with increasing x therefore the curve y=f(x) never crosses the x-axis after x=5.

f′(-5)=72, and for any x value lower than x=-5, the gradient formula shows that the gradient just continues to increase with decreasing x, therefore the curve y=f(x) never crosses the x-axis before x=-5.

Therefore there are no roots of the equation f(x)

Middle

As one can see, x1 which equals 2, is more accurate than x2 which equals four. The root the iteration converges to is 2.8951065. This occurs because the absolute value of the gradient formed at the curve is very small, i.e. it is very shallow, therefore the tangent touches the x-axis further away. However, this method still works because the tangent formed at (2,-10) leads the iteration to (4,0), allowing tangent sliding from the right side of the curve, which brings us back to a similar situation.

I can confirm earlier that I had found the roots using this method to seven decimal places. I had claimed that the roots to the equation x3-7x-4=0 are:

x= 2.8951065, -0.6027049, -2.2924016 (all to seven decimal places)

Primarily Excel gave 8 figures after the decimal point, so I could confirm that there would not be a rounding error when giving the roots to seven decimal places. I therefore rounded the values of x to seven decimal places. I can confirm that these are correct to seven decimal places using the decimal search method.

I therefore wish to confirm that x=2.8951065 to seven decimal places is a root of the equation x3-7x-4=0.

x | f(x) | x | f(x) | x | f(x) | X | f(x) |

-5 | -94 | 2.0 | -10 | 2.80 | -1.648 | 2.890 | -0.09243 |

-4 | -40 | 2.1 | -9.439 | 2.81 | -1.48196 | 2.891 | -0.07437 |

-3 | -10 | 2.2 | -8.752 | 2.82 | -1.31423 | 2.892 | -0.05628 |

-2 | 2 | 2.3 | -7.933 | 2.83 | -1.14481 | 2.893 | -0.03818 |

-1 | 2 | 2.4 | -6.976 | 2.84 | -0.9737 | 2.894 | -0.02007 |

0 | -4 | 2.5 | -5.875 | 2.85 | -0.80087 | 2.895 | -0.00193 |

1 | -10 | 2.6 | -4.624 | 2.86 | -0.62634 | 2.896 | 0.016219 |

2 | -10 | 2.7 | -3.217 | 2.87 | -0.4501 | 2.897 | 0.034388 |

3 | 2 | 2.8 | -1.648 | 2.88 | -0.27213 | 2.898 | 0.052575 |

4 | 32 | 2.9 | 0.089 | 2.89 | -0.09243 | 2.899 | 0.070779 |

5 | 86 | 3.0 | 2 | 2.90 | 0.089 | 2.90 | 0.089 |

x | f(x) | x | f(x) | X | f(x) | x | f(x) |

2.8950 | -0.00193 | 2.8951 | -0.00012 | 2.89510 | -0.00012 | 2.8951060 | -9.4E-06 |

2.8951 | -0.00012 | 2.89511 | 6.32E-05 | 2.895101 | -0.0001 | 2.8951061 | -7.5E-06 |

2.8952 | 0.001696 | 2.89512 | 0.000245 | 2.895102 | -8.2E-05 | 2.8951062 | -5.7E-06 |

2.8953 | 0.003511 | 2.89513 | 0.000426 | 2.895103 | -6.4E-05 | 2.8951063 | -3.9E-06 |

2.8954 | 0.005326 | 2.89514 | 0.000608 | 2.895104 | -4.6E-05 | 2.8951064 | -2.1E-06 |

2.8955 | 0.007141 | 2.89515 | 0.000789 | 2.895105 | -2.8E-05 | 2.8951065 | -2.9E-07 |

2.8956 | 0.008956 | 2.89516 | 0.00097 | 2.895106 | -9.4E-06 | 2.8951066 | 1.53E-06 |

2.8957 | 0.010772 | 2.89517 | 0.001152 | 2.895107 | 8.78E-06 | 2.8951067 | 3.34E-06 |

2.8958 | 0.012587 | 2.89518 | 0.001333 | 2.895108 | 2.69E-05 | 2.8951068 | 5.15E-06 |

2.8959 | 0.014403 | 2.89519 | 0.001515 | 2.895109 | 4.51E-05 | 2.8951069 | 6.97E-06 |

2.8960 | 0.016219 | 2.89520 | 0.001696 | 2.895110 | 6.32E-05 | 2.8951070 | 8.78E-06 |

x | f(x) |

2.89510650 | -2.9E-07 |

2.89510651 | -1.1E-07 |

2.89510652 | 7.39E-08 |

2.89510653 | 2.55E-07 |

2.89510654 | 4.37E-07 |

2.89510655 | 6.18E-07 |

2.89510656 | 8E-07 |

2.89510657 | 9.81E-07 |

2.89510658 | 1.16E-06 |

2.89510659 | 1.34E-06 |

2.89510660 | 1.53E-06 |

Therefore using the decimal search method, the root lies in the interval [2.89510651,2.89510652], therefore to 7 decimal places, it is equal to 2.8951065. Therefore I have confirmed the accuracy to one of the roots the Newton-Raphson method produced.

An example of a failure of this method is as follows:

Suppose I want to find a particular root of the equation x3-4x+1=0. Let f(x)= x3-4x+1 and a graph of y=f(x) is drawn below.

I want to find the root of the equation in the interval [0,1]. 1 is a decent first approximation, as it is closer to the root near 0, than the root at 2.

However if one uses 1 in the iteration the following occurs:

x1 | 1.00000000 |

x2 | -1.00000000 |

x3 | 3.00000000 |

x4 | 2.30434783 |

x5 | 1.96748948 |

x6 | 1.86947047 |

x7 | 1.86087068 |

x8 | 1.86080586 |

x9 | 1.86080585 |

x10 | 1.86080585 |

i.e. it does not converge at the required root.

To illustrate this graphically (the pink line represents the iteration):

This happens because the gradient of the curve at x=1 is very shallow, therefore the tangent touches the x-axis ‘too far’ to the left. The gradient is shallow at this value for x as well, therefore the new tangent touches the x-axis ‘too far’ to the right, causing convergence at the root furthest to the right (the root with the biggest value), 2.8951065. Therefore the method fails to find the particular root I wanted it to find despite taking a starting value close to it.

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

I want to find the roots of the equation x3-3x+1=0 to seven decimal places.

Consider the function f(x)=x3-3x+1; hence I want to find the roots of the equation f(x)=0.

One way to rearrange this equation is:

x3+1=3x

therefore x=(x3+1)/3

Therefore one possible iteration that emerges from the original equation is:

xn+1=(xn3+1)/3

Let g(x)=(x3+1)/3

A graph of the curves y=g(x) and y=x is shown:

The points at which these two curves meet have the same x-values as the roots to the equation x3-3x+1=0.

This is because:

At the intersection points, y=g(x) equals y=x

therefore, (x3+1)/3 = x

therefore, x3+1 = 3x

therefore, x3-3x+1 = 0, which is the equation to which the roots we are trying to find.

Therefore the roots of the equation have the same x-values as these intersection points.

Using the formula generated at the beginning,

xn+1=(xn3+1)/3

one can obtain values for the roots. I want to find the root in the interval [0,1]. The table below shows the iteration being generated, using an initial approximation of the root. e.g. x2 was generated using (x13+1)/3, x3 was generated using (x23+1)/3, and so on.

n | xn |

1 | 1.00000000 |

2 | 0.66666667 |

3 | 0.43209877 |

4 | 0.36022563 |

5 | 0.34891459 |

6 | 0.34749245 |

7 | 0.34732002 |

8 | 0.34729921 |

9 | 0.34729670 |

10 | 0.34729640 |

11 | 0.34729636 |

12 | 0.34729636 |

13 | 0.34729636 |

14 | 0.34729636 |

15 | 0.34729636 |

16 | 0.34729636 |

17 | 0.34729636 |

18 | 0.34729636 |

Conclusion

I used Microsoft Excel to do all of these tables and graphs. In terms of ease of use, the rearrangement method required the least steps as all I had to do was fill the formula in one cell, using cell above as the xn value, and ‘drag down’. This was the quickest and easiest method to produce a table for. The Newton-Raphson method was much the same, however it required the input of a much longer formula, and therefore was slightly more tedious. The decimal search method required the input of a lot of data, even after entering the formula into one of the cells. It requires n+1 tables if I want to find a root to n decimal places. Therefore this was by far the slowest method to use.

In terms of failure, the rearrangement method only gives one root for one rearrangement. In this respect the Newton-Raphson method is better, since it converges to all roots given a suitable starting value. However it has the potential to diverge which is unhelpful. In this respect, the decimal search method is the best, given small enough intervals, as it hardly ever fails once a root is identified in a particular interval.

- -

This student written piece of work is one of many that can be found in our AS and A Level Core & Pure Mathematics section.

## Found what you're looking for?

- Start learning 29% faster today
- 150,000+ documents available
- Just £6.99 a month