f[x_]:=3*Sqrt[x]Exp[-x]-1/3;
a=NestList[f,0.02,10];
xy=Flatten[Transpose[{a,a}]];
xx=Drop[xy,-1];
yy=Drop[xy,1];
yy[[1]]=0;
gi=ListPlot[Transpose[{Drop[xy,-1],Drop[xy,1]}],Joined->True,PlotStyle->{Hue[0.4]}];
gf=Plot[{x,f[x]},{x,0,1},PlotStyle->{Hue[0.0],Hue[0.7]}];
f'[x]/.x->Nest[#-(#-f[#])/(1-f'[#])&,{0.02,1.0},4]
gh=Show[gi,gf,PlotRange->All]
Export["negibna_tocka-2.pdf",gh,"PDF"];

f[x_]:=1.5*Sqrt[x]Exp[-x]-1/3;
a=NestList[f[#]+#&,0.2,10];
xy=Flatten[Transpose[{a,a}]];
xx=Drop[xy,-1];
yy=Drop[xy,1];
yy[[1]]=0;
gi=ListPlot[Transpose[{xx,yy}],Joined->True,PlotStyle->{Hue[0.4]}];
gf=Plot[{x,f[x]+x},{x,0,2},PlotStyle->{Hue[0.0],Hue[0.7]}];
NestList[#-(f[#])/(f'[#])&,{0.02,1.0},6]//MatrixForm//TeXForm
f'[x]/.x->Nest[#-(f[#])/(f'[#])&,{0.02,1.0},6]
gh=Show[gi,gf,PlotRange->All]
Export["negibna_tocka-3.pdf",gh,"PDF"];

f[x_]:=-1/2(x^3+3);
a=NestList[f,-1.1,10];
xy=Flatten[Transpose[{a,a}]];
xx=Drop[xy,-1];
yy=Drop[xy,1];
yy[[1]]=0;
gi=ListPlot[Transpose[{xx,yy}],Joined->True,PlotStyle->{Hue[0.4]}];
gf=Plot[{x,f[x]},{x,-1.5,1.1},PlotStyle->{Hue[0.0],Hue[0.7]}];
f'[x]/.x->Nest[#-(#-f[#])/(1-f'[#])&,-1.5,4]
gh=Show[gi,gf,PlotRange->All]
Export["negibna_tocka-1.pdf",gh,"PDF"];

n=2;
sl=Solve[(Table[Table[x[i]^s,{i,0,n}],{s,0,n}]/.Table[x[i]->i/n,{i,0,n}]).Table[w[i],{i,0,n}]==Table[Integrate[x^s/Sqrt[x],{x,0,1}],{s,0,n}],Table[w[i],{i,0,n}]]//Flatten
(Cos[x/2]/.x->Table[i/n,{i,0,n}]).(Table[w[i],{i,0,n}]/.sl)//N
Integrate[Cos[x/2]/Sqrt[x],{x,0,1}]//N
Normal[Series[Cos[x/2],{x,0,7}]]
Integrate[Normal[Series[Cos[x/2],{x,0,5}]]/Sqrt[x],{x,0,1}]//N

h=0.6;
g1=ListPlot[NestList[{#[[1]]+h,#[[2]]-h*#[[2]]+h^2/2*#[[2]]}&,{0,1},12],Joined->True,PlotRange->{0,1},PlotStyle->{Hue[0.0]}];
h=1.2;
g2=ListPlot[NestList[{#[[1]]+h,#[[2]]-h*#[[2]]+h^2/2*#[[2]]}&,{0,1},6],Joined->True,PlotRange->{0,1},PlotStyle->{Hue[0.4]}];
g3=Plot[Exp[-x],{x,0,7.2},PlotRange->{0,1},PlotStyle->{Hue[0.6]}];
h=0.1;
Nest[{#[[1]]+h,#[[2]]-h*#[[2]]+h^2/2*#[[2]]}&,{0,1},10]
gt=Show[g1,g2,g3]
Exp[-1.0]
Export["ode-t.pdf",gt,"PDF"];

h=0.6;
g1=ListPlot[NestList[{#[[1]]+h,#[[2]]-h*#[[2]]}&,{0,1},12],Joined->True,PlotRange->{0,1},PlotStyle->{Hue[0]}];
h=1.2;
g2=ListPlot[NestList[{#[[1]]+h,#[[2]]-h*#[[2]]}&,{0,1},6],Joined->True,PlotRange->{-0.2,1},PlotStyle->{Hue[0.4]}];
g3=Plot[Exp[-x],{x,0,7.2},PlotRange->{0,1},PlotStyle->{Hue[0.6]}];
h=0.1
Nest[{#[[1]]+h,#[[2]]-h*#[[2]]}&,{0,1},10]
Exp[-1.0]
ge=Show[g1,g2,g3,PlotRange->All]
Export["ode-e.pdf",ge,"PDF"];

Directory[]

Clear[x,y]
h=1/4;
x[0]=0;
x[1]=h;
x[2]=2*h;
x[3]=3*h;
x[4]=1;
y[0]=1;
y[4]=0;
s1=Solve[Table[(y[k-1]-2y[k]+y[k+1])+x[k]*y[k]==0,{k,1,3}],{y[1],y[2],y[3]}]
s2=Solve[Table[y[k-1]-2y[k]+y[k+1]== 0,{k,1,3}],{y[1],y[2],y[3]}]
ListPlot[Table[y[k],{k,0,4}]/.s1]

Clear[x,y];
s1=DSolve[{y''[x]==-16x*y[x],y[0]==1,y[1]==0},y[x],x]//FullSimplify
s2=DSolve[{y''[x]==0,y[0]==1,y[1]==0},y[x],x]//FullSimplify
Plot[{y[x]/.s1,y[x]/.s2},{x,0,1}]

Table[(y[k-1]-2y[k]+y[k+1])+x[k]*y[k]==0,{k,1,3}]//Expand
1/h^2

{1-((7 y[1])/4)+y[2]==0,y[1]-((3 y[2])/2)+y[3]==0,y[2]-((5 y[3])/4)==0}//MatrixForm//TeXForm

f=Fit[{{1,3},{2,0},{3,-1},{4,1}},{x^2,x,1},x];
s=Solve[D[f,x]==0,x]
f/.s

Solve[Table[Integrate[x^n,{x,0,1}]==w1*x1^n+w2*x2^n,{n,0,3}],{w1,w2,x1,x2}]

Table[Integrate[x^n,{x,0,1}]==w1*x1^n+w2*x2^n,{n,0,3}]

P={{0,1.14},{1,0.89},{2,0.71},{3,0.67},{4,0.64},{5,0.48}}
b=Log[P[[All,2]]]
A=Table[{i,1},{i,0,5}];
ll=LinearSolve[Transpose[A].A,Transpose[A].b];
a1=ll[[1]];
a2=Exp[ll[[2]]];
g1=ListPlot[P,PlotStyle->{Hue[0],PointSize[0.02]}];
g2=Plot[a2*Exp[a1*x],{x,0,5}];
gg=Show[g1,g2,PlotRange->All]
Export["least_sqr_2.pdf",gg,"PDF"]

Directory[]