# How do I use numerical methods to find the root of the equation F(x) = 0?

Generally you will be asked to find the root of an equation of the form F(x) = 0. In my answer below I will only touch on graphical methods, but will go into deeper detail on showing that a root lays in a given interval (a,b), and using iteration to find an approximation to a root.

Firstly it is important to note here that in your course F(x) will always be chosen specifically so that this kind of process works. By this I mean that F(x) will always be a “continuous” function – this essentially means it can be drawn as a graph of y=F(x) without taking your pen off the paper (this will be important later). The notion of using graphs here is important for an intuitive understanding of what is happening. If y = F(x) = 0 for some x then the graph is crossing the line y = 0, i.e. the x-axis. It is therefore often asked of students to draw a sketch of the function before trying to find a root, because this will show you whereabouts to expect to find such a root.

We will use the same example throughout this explanation. The questions, written in exam format, will be written in Italics, my answers in bold, and explanations will be in plain text.

__Example__

*(a) **By sketching the curves y _{1} = x^{2}+1 and y_{2} = 4x on the same axes show that x^{2} – 4x +1 = 0 has 2 roots.*

It’s not possible to sketch these graphs in this text box but they are straightforward to sketch yourself: the first equation is a parabola that crosses the y-axis at 1, and the second equation is a straight line through the origin of gradient 4. If you would like a more accurate picture than that you can draw by hand or you want to verify your answer, nip over to ‘Wolfram Alpha’ and type these equations separated by a semi-colon. From viewing these graphs you can see that there are two points where the graphs cross, this is no coincidence. That means there are two points at which y_{1} = y_{2} and thus there are two points at which x^{2} + 1 = 4x. This equation is equivalent to x^{2} – 4x +1 = 0, and therefore there are two values of x that satisfy this equation, these are the values that we call ‘roots’. When answering this question your explanation is more important than the graph itself and should look something like this:

**Let y _{1} = x^{2}+1, y_{2}= 4x. **

(Then draw the graphs)

**By the graphs above, there are two points at which y _{1} = y_{2} – therefore two values of x satisfy x^{2} + 1 = 4x <=>**

**two values of x satisfy x**

^{2}– 4x +1 = 0 <=>**x**

^{2}– 4x +1 = 0 has two roots.The symbol <=> should be used only if the two statements either side of the symbol are equivalent, but it is not necessary that you use it and it will not gain you marks, but it saves you having to write more in an exam. I recommend asking your teachers (or myself) about its use if you want to learn more, especially if they’ve studied Mathematics at degree level.

*(b) **Verify that x ^{2 }-4x + 1 =0 has a root in the interval [3,4].*

For neatness and mathematical rigour, I would recommend the following approach (this will be justified in the following discussion).

**Let F(x) = x ^{2} -4x +1. **

**Then F(3) = -2 < 0, and F(4) = 1 > 0.**

**Since F is continuous on [3,4] , F(3) < 0, F(4) > 0, there is a point x in the interval [3,4] such that F(x) = 0, i.e. there is a root of F(x) = x ^{2} -4x +1 = 0 in the interval [3,4].**

Firstly, let me explain why this answer is correct. The kernel of the argument is this: if a function F(x) can be drawn without lifting your pen from the paper, and it goes from being below the x-axis at one point x_{1} to above the x-axis at a point x_{2} (or, alternatively, from above to below) then it __must__ cross the axis between these two points, i.e. have a point x in the interval [x_{1},x_{2}] where F(x) = 0. Now, since a function is positive if it is above the x-axis and negative if it is below the x-axis then we only need to check the whether the function goes from being positive to negative (or negative to positive).

This approach to this particular question (most papers have a question almost exactly like this) is likely to maximise your marks for several reasons. Firstly, by defining the function F(x) = x^{2} -4x +1, we save time writing F(x) out in full, furthermore we make our argument clear to the examiner – they now know we understand the link between a ‘change of sign’ of y = F(x) on an interval, and the existence of a root. We then only need to ‘plug- in’ x=3 and x=4 to F(x) and show that this sign change has happened, and then justify ourselves by stating that a ‘change of sign’ occurred and the function is continuous.

In an exam, the next step would be something like:

*(c) **Show that x ^{2}-4x + 1= 0 can be written in the form x = 4 -1/x.*

You can then re-arrange the formula to get the desired result. Beware: this sometimes takes a bit of practice, I recommend doing exercises until you are confident that you can breeze this in an exam. It is totally okay to take your time and practice as long as you are ready before the exam. Try it now and check your answer against mine below.

**X ^{2} - 4x + 1 = 0 <=>**

**x**

^{2}= 4x -1 <=>**x = 4 – 1/x**

Moving from equation 1 to equation 2 involves adding (4x -1) to both sides, and moving from 2 to 3 we divide through by x. A quick note: this isn’t a particularly legal move especially since x can be 0, but on the interval [3,4] this doesn’t matter, because x is not 0 on this interval. Phew. The last part of the question of course, will ask you to use iteration to find an approximation to the root:

*(d) **Use the iteration formula x _{n+1} = 4 – 1/x_{n} to find, to 3d.p. , a root of the equation x^{2}-4x + 1= 0. Start with x_{0} = 3.5*

Now, just handing the solution to you here will make no sense until I have explained what is going on. You won’t be asked to do any iterative numerical calculations unless it’s a calculator paper as these methods are generally used to find roots using a computer. So, I’ll talk you through how I would approach this question and why.

Firstly, type x_{0} – in this case 3.5 – into your calculator and press ‘=’. Now your calculator will have saved this value as ‘Ans’ – for ‘answer’. This will save you time in an exam as typing values into formulae is an unnecessary burden. Then type ‘4 – 1/Ans’ and press ‘=’. This will give you x_{1 }and will automatically set ‘Ans’ = x_{1}. Now the next time you press ‘=’ you have x_{2} and so on. Each time you press ‘=’ write down the value on the calculator. You should see that the values are ‘converging’, which means that they are getting closer and closer to a particular value. The chances are, this value is something horrible and irrational and you will never reach it, but you can reach any degree of accuracy you wish, and in this example, we want an answer to 3.d.p. So what we shall do is find an approximation to the root using iteration, and then for rigour, verify that it is correct using the ‘change of sign’ method described above. Therefore, follow the steps above and you should achieve a list of results like below:

**Let x _{0} = 3.5**

**Then, using the iterative formula, we get:**

**x _{1} = 3.714 to 3.d.p
x_{2 } = 3.731 to 3.d.p
x_{3 } = 3.732 to 3.d.p
x_{4 } = 3.732 to 3.d.p**

**Since x _{3} = x_{4} = 3.732, we will try the interval [3.7315,3.7325]:**

**Let F(x) = x ^{2} – 4x + 1. Then F(3.7315) = -0.0019 to 4.d.p and F(3.7325) = 0.0016 to 4d.p. – since F(x) changes sign on the interval [3.7315,3.7325] the root must lay in this interval and is therefore equal to 3.732 to 3.d.p.**

The last point on here relies on the fact that any value in the interval [3.7315,3.7325] __must__ round to 3.732 if rounded to 3.d.p – that is why we used this interval. So to recap:

- Use iteration until you get the same answer twice (up to the number of decimal points specified),

- Take an interval around this answer so that all values in this interval round to the value you have found by iteration,

- Use the ‘change of sign’ method to verify the root is in this interval, and;

- Finally, justify yourself by saying that if the root is in this interval, then it is equal to the value you found via iteration to the number of decimal points you were asked.

Thank you for reading my tutorial on numerical methods. It would be fantastic if you dropped me a message on here to let me know if you found it helpful, or if any part of the tutorial is unclear. I hope to hear from you in the future.