Hi Hugh!
I'm not a 100% sure that I understand what problem you are trying to solve using your for-loop. Are you trying to iteratively solve for a Real x such that f(x)/f'(x) = 0?
If that is the case, you could always use Solve or NSolve:
a = 6;
b = 3;
c = 2;
d = 1;
e = 3.2;
f[x_] := 2 a x^6 + b x^3 + c x^2 + d x + e x^3;
NSolve[f[x]/f'[x] == 0, x]
This will give you the following six solutions:
{{x -> 0.531951 + 0.688517 I}, {x ->
0.531951 - 0.688517 I}, {x -> -0.76146}, {x -> -0.151221 +
0.34885 I}, {x -> -0.151221 - 0.34885 I}, {x -> 0.}}
If you absolutely necessarily want to do it with a loop you could write it like this:
maximumIterations = 100;
pr = prnew = -1;
i = 1;
While[i < maximumIterations,
prnew = pr - f[pr]/f'[pr]; i++; If[Abs[prnew - pr] < 10^-3, Break[]];
pr = prnew]
prnew
Which will give you one solution, depending on your start-value for pr:
-0.76146
Hope that helps Hugh. And if not, if you could put your problem in context, I would gladly help you more.
Have a nice day!
Patrik
Attachments: