Algoritme: Newton (f,f',x0,e,N)

Opgave 15 i afsnit 18.2

Clear[f]

f[x_]:=Cot[x]-Sin[x]

Plot[f[x],{x,0.5,2}]

df[x_]=Dt[f[x],x]

x0=2;
x1=Table[x0=N[x0-f[x0]/df[x0],15],{i,10}]

TableForm[%]

g1=ListPlot[x1,
PlotStyle->{PointSize[0.025],RGBColor[1,0,0]}]

FindRoot[f[x]==0,{x,1.0},AccuracyGoal->15, 
MaxIterations->25]

N[%,15]

x /. %

x2=%;

g2=Plot[x2,{x,0,10},
PlotStyle->{{Thickness[0.01],RGBColor[0,0,1]}}];

Show[g1,g2, PlotRange ->{0,1.2}];