Hi,
I have a written the code for Newton's method by using the Pseudocode from my professor. The problem is I can't see why it doesn't provide the output.
I see your point and you're totally right. I guess I want to define n as the maximum number of the iterations that Newton's method can take. I didn't know how to do that, so I just included n as an integer. n=0 is because my program said it should be initialized, which is the same reason for r=0.0.
So you need to initialise variables to sensible values. :+)
And be careful with unnecessary redefining with new values.
Check out using a debugger, one can see what values are and how they change as one executes the program 1 line at a time. There should be one in your IDE.
But how can debugging omit the use of initialised values?
Does there exist a counter for sequence iterations? I tried to do this with intmax_t, but that would be the maximum of the width of the data type, not the iterations, even though n is actually an integer.
debugging just shows you what is happening. it does not omit anything.
i is the number of iterations. you can look at i in your debugger.
you can also change the code to limit it. Newtons will converge on an answer that is good enough to test with in just a few iterations if you put in a decent guess; Sir Issac didn't run 20k iterations by hand.. pass in like 10 or 20 for the number of iterations and see what pops out.
do you know what the roots are? Start by finding them by hand. Then plug in something near them. Then test it that way with a few iterations.