its been 3+ hours of trying. i do not understand ComputeRoot and the connection to the other functions.
1. I cant figure out how to do this with a 'for' loop and not a while loop. 2. the math is above my head. the closest I have come is reading the posts on this site and I still dont get correct answers
1. As far as I know, you can't do the problem with a for loop as you need to keep a count of how many iterations you loop through to find your answer. 2. A root for the polynomial is basically finding some number, x, that, when input into the polynomial, gives 0. Since Newton's method is basically a guess and check, we keep guessing the value of x. This number, when input into the polynomial, must be as close to 0 as possible. How do we get this number? x1=x0−f(x0)/f′(x0) So every time we are too far from 0, we utilize this equation. To get the answers for these equations we plug our guesses back into the first two functions that we programmed. Once we resolve x1=x0−f(x0)/f′(x0), we get this new guess and check if it's close enough to 0. By close enough, it means that whatever your answer is has to be within "epsilon" distance of 0. So for example, if epsilon was 5, our guess, x, has to be within 5 of 0. That is to say, x must be < 5.
Join our real-time social learning platform and learn together with your friends!