function y=aranymetszes(t0,t1,t2,k) 
				# aranymetszes(t0,t1,t2,k) k lepesben
				#keresi f minimumat. t0<t1<t2,
				#f(t0)>f(t1)<f(t2).
f0=f(t0);f1=f(t1);f2=f(t2);A=(3-sqrt(5))/2;
for i=1:k if abs(t1-t0)>abs(t2-t1) T=t0;Y=t2;fT=f0;fY=f2;
          else T=t2;Y=t0;fT=f2;fY=f0;
          end;
          y=(1-A)*t1+A*T;fy=f(y);
          if fy<f1 t0=t1;f0=f1;t1=y;f1=fy;t2=T;f2=fT;
          else t0=Y;t2=y;f0=fY;f2=fy;
          end;
end;