PLEASE help to edit this code to output data on each iteration because it outputs only on the last...
favorite
PLEASE help to edit this code to output data on each iteration because it outputs only on the last...
[b]step[f_,inter_] := Module[{x=Mean@First@(List @@ inter)}, [/b]
[b] IntervalIntersection[inter, x - (f[x])/(f'[inter])]] [/b]
[b] newton[f_, inter0_, eps_] := Module[{iter = 0}, [/b]
[b] Print["X1 = ", N@Mean@First@(List @@ [/b]
[b] NestWhile[(++iter; step[f, #]) &, inter0, [/b]
[b] Abs[Subtract @@ First@(List @@ #)] > eps & ])]; [/b]
[b] Print["iter=", iter]; [/b]
[b] Print["Iteration ",iter,".\n","Interval is: ",inter,"; \nx0_=", [/b]
[b] x= Mean@First@(List @@ inter) ,"; \nf(x0_)=",f[x],"; \nf'(interval)=",f'[inter],";"]]; [/b]
[b]f[x_] := x*x - 8*x + 7; [/b]
[b]inter := Interval[{1,9}]; [/b]
[b]newton[f, inter, 0.00001];[/b]