CHAPTER 03.05: SECANT METHOD: Algorithm of Secant Method
In this segment, we're going to talk about secant method, and we'll go through the algorithm of the secant method. Secant method is used to find the roots of nonlinear equations. So we are, again, looking at finding the root of a nonlinear equation f of x equal to 0, and the secant method formula looks like this, x-sub-i-plus-1 is equal to xi minus f of xi times the difference between the two guesses, two estimates, divided by the value of the function at xi and the value of the function at x-sub-i-minus-1. So let's go ahead and see that how we can write down the algorithm for the secant method. So what we're going to do is, if you look at this particular formula here, what we do need is we need two initial guesses, xi and x-sub-i-minus-1, to be able to get x-sub-i-plus-1. And then when we go through this process again, we'll have xi and x-sub-i-plus-1, which you're going to use in this formula by increasing i by 1 and getting x-sub-i-plus-2, and that's how the whole process is going to work. So you always need two estimates of the guess, you're going to start with two initial guesses, but once you have incorporated . . . once you have done the first iteration, then you need two estimates of the root, which are going to come out of using that formula. So let's write that down. So what I'm going to do is I'm going to choose i equal to 1. So I'm going to choose i equal to 1, and then what I'm going to do is I'm going to start with guesses x-sub-i-minus-1 and xi, that's what I'm going to do. So in this case, when i is equal to 1, I'll have x0 and x1 as two initial guesses of the root itself. So I start with the initial guesses, x-sub-i-minus-1 and xi, then what I will do is I will use the formula . . . use the formula. I'm going to use the formula that x-sub-i-plus-1 is equal to xi minus f of xi times xi minus x-sub-i-minus-1, divided by the value of the function at xi minus the value of the function at x-sub-i-minus-1. So I'm going to use this formula, which is the secant method formula. So what I have done is I have found x-sub-i-plus-1, but before I start using now the new estimate of the guess which I have obtained and one of the previous estimates which I have, I've got to figure out what the relative approximate error is. So the fourth step which I need to do is, I'm going to find absolute relative approximate error between the present approximation and the previous approximation, The present approximation is x-sub-i-plus-1, the previous approximation is xi, and divided by x-sub-i-plus-1, times 100. Now once I have calculated my absolute relative approximate error, which is the difference between the current approximation and the previous approximation, so once I have done that, what I'm going to do is I'm going to . . . check, I'm going to check if epsilon-a, which is the absolute relative error, is it less than or equal to the prespecified tolerance, so this is prespecified tolerance. Now prespecified tolerance might be given to you as a percentage, or it might be given in terms of a number of significant digits you want to be at least correct in your answer, and those can be all translated into a percentage prespecified tolerance. So if . . . check if epsilon, the absolute relative approximate error is less than the prespecified tolerance. If true, then you stop, because you have achieved your goal of getting your root within the prespecified tolerance. If false, then where you need to go is you're going to go back . . . you're going to go back to step 2. You're going to go back to step 2 with estimates x-sub-i-plus-1 and xi, that's what you're going to do. You're going to basically go with the estimates of x-sub-i-plus-1 and xi, x-sub-i-plus-1 which you just found, and xi which you . . . which you had from the previous iteration. That basically means that you are going with i is equal to i plus 1, that's what you've got to think about, that you are now going to increment your i by 1, you're going to increment i by i plus 1, and that automatically knows that, hey, it has to take the new estimate which it found, x-sub-i-plus-1 and one of the previous estimates which you had in the right-hand side of the formula. And that's how the algorithm of this particular secant method is going to work. And that's the end of this segment. |