%
clear
%
load -ascii data7.txt
td=data7(:,1);
yd=data7(:,2);
%
a=4;
b=6;
tol=1.0e-10;
n=0;
%
g=(sqrt(5)-1)/2;
r1=a+(b-a)*(1-g);
f1=dd(r1,td,yd);
r2=a+(b-a)*g;
f2=dd(r2,td,yd);
%
while (b-a) > tol,
  n=n+1;
  if f1 < f2,
    b=r2;
    r2=r1;
    f2=f1;
    r1=a+(b-a)*(1-g);
    f1=dd(r1,td,yd);
  else
    a=r1;
    r1=r2;
    f1=f2;
    r2=a+(b-a)*g;
    f2=dd(r2,td,yd);
  end
end
T=(a+b)/2
%
figure(3)
clf reset
axes('position',[0.15,0.13,0.75,0.75])
%
plot(td,yd,'b-','linewidth',2.0)
hold on
plot(td-T,yd,'r--','linewidth',2.0)
axis([0,20,-2.5,2.5])
set(gca,'fontsize',14)
set(gca,'xtick',[0:5:20])
set(gca,'ytick',[-2.0:1:2.0])
xlabel('t')
ylabel('y')
%
%
