A matlab prog which produces 20 steps for the intuitive ...



A matlab prog which produces 20 steps for N-R iteration :

format long;

x=1.8

for i=1:20

i;

x=x-((x-2*sin(x))/(1-2*cos(x))) ;

fprintf('x%d = %.17g\n',i,x)

end

results: ( starting x0=1.8)

x =

1.80000000000000

x1 = 1.9015503550073825

x2 = 1.8955153109517944

x3 = 1.8954942672901975

x4 = 1.8954942670339809

x5 = 1.8954942670339809

x6 = 1.8954942670339809

x7 = 1.8954942670339809

x8 = 1.8954942670339809

x9 = 1.8954942670339809

x10 = 1.8954942670339809

x11 = 1.8954942670339809

x12 = 1.8954942670339809

x13 = 1.8954942670339809

x14 = 1.8954942670339809

x15 = 1.8954942670339809

x16 = 1.8954942670339809

x17 = 1.8954942670339809

x18 = 1.8954942670339809

x19 = 1.8954942670339809

x20 = 1.8954942670339809

we can see the convergence through the digits after the dot , which are not variable .

The best guess for x is x20 = 1.8954942670339809

We also can see the digits after the dot are invariable after the 4th step!

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download