Hey guys, I am trying to implement the Newton Method with a single variable into R. I think the above code should be correct so far, however I have troubles defining that the variable increase with each iteration. So basically for
I dont know how to write that the 2 new variables should be checked for the while condition.
I hope its kind of clear what I mean. can anyone give me a hint? Thanks in advance
Basically x0 should be kicked out after first Iteration and x1 becomes the new x0 in the equation. Thrn x2 gets Computed with x1 and so on until the while condition is false
I've seen that, however the while function is different. I need the absolute value of | x_n+1 - x_n | there
its basically like this :
x_n+1 = x_n - f.prime(x_n)/f.double.prime(x_n)
then calculate x_n+1 - x_n and check if its smaller than the tolerance, if not calculate
x_n+2 = x_n+1 ....
notice how the other example handles the x_n problem: it doesn't do x_n... it does a calculation and reassigns it to x so that x has a new value. See if you can refactor your code to do that too.