Metoda obliczania pierwiastków kwadratowych

szukaj[F_,a_,{x0_,kroki_,cyfryznacz_}]:=Module[{list=NestList[F[#,a] &,x0,kroki]},
Column[{TraditionalForm@Text@Style[
Row[{HoldForm[(Subscript[{(Subscript[x, k])}, k=0]^n)]," = ", N[list,cyfryznacz]}],24]}]];

sprawdź[F_,a_,{x0_,kroki_,cyfryznacz_}]:=Module[{list=NestList[F[#,a] &,x0,kroki]},
Column[{TraditionalForm@Text@Style[
Row[{HoldForm[(Subscript[{((Subscript[x, k]))^2}, k=0]^n)]," = ", N[list,cyfryznacz]^2}],24]}]];

Pierwiastek[x_,a_]:=(x^2+a)/(2x);

szukaj[Pierwiastek,2,{2,5,25}]

sprawdź[Pierwiastek,2,{2,5,25}]

Geometria tego algorytmu -  metoda stycznych

f1[x_]:= x^2 -2  ;            (* drop down menu function definitions *)

f21[x_]:= Cos[x]-0.8+1.9Cos[x/Sqrt[2]]+.3*Exp[-3(x-11)^2];

f21a[x_]:= Cos[x];

f21b[x_]:= Cos[x]-0.8+1.9Cos[x/Sqrt[2]]+.3*Exp[-3(x-11)^2]-.6*Exp[-4x^2];

f3[x_]:=x^3 -100;

f5[x_]:=x^3 -3x^2 + x -1;

newton2[f_,x0_,A_,B_,n_]:=Module[{list=NestList[#-((f[#])/(f'[#])) &,x0,n]},Column[{TraditionalForm@Text@Style[Row[{HoldForm[(Subscript[{(Subscript[x, k])}, k=0]^n)]," = ", list}],24],Plot[f[x],{x,A,B},PlotRange-> All,PlotStyle-> {Black,Thickness[0.007]},Ticks->None,AxesOrigin->{0,0},AxesLabel->None,
Epilog->{
{Red,Thickness[.004],Arrowheads[.003],Arrow[Most[Flatten[Map[{{#,0},{#,f[#]}} &,list],1]]]},
{PointSize[0.015],Point[{x0,0}]}
},AspectRatio->0.66,ImageSize->{900,430}]},Center]]

Manipulate[newton2[d,N[x0],lewy,prawy,n],
{{d,f21,"funkcja"},{f1-> TraditionalForm[x^2 -2], f21-> TraditionalForm[Cos[x]-0.8+1.9Cos[x/Sqrt[2]]+.3*Exp[-3(x-11)^2]],
f21b->TraditionalForm[Cos[x]-0.8+1.9Cos[x/Sqrt[2]]+.3*Exp[-3(x-11)^2]-.6*Exp[-4x^2]],f3-> TraditionalForm[x^3 -100],f5-> TraditionalForm[x^3 -3x^2 + x -1]},ControlType-> PopupMenu},
{{n,1,"n"},{0,1,2,3,4,5,6,7,8,10,12},ControlType->SetterBar},
{{x0,.6,Subscript["x","0"]},0.001,20,Appearance->"Labeled" },
{{lewy,-4,"lewy koniec"},-4,0.5,Appearance->"Labeled" },
{{prawy,17,"prawy koniec"},17,4,Appearance->"Labeled" },
SaveDefinitions->True]