clear;
f=inline('sqrt(x)','x');
T=[0.5,2;2,0.5];
c=[1,0.3];
eps=1e-8;
t=inline('norm(T(1,:)-[x,f(x)])/c(1)+norm([x,f(x)]-T(2,:))/c(2)','x');
dt=inline('(t(x+eps)-t(x-eps))/2/eps','x');
x1=1; x2=2;
for i=1:100
        xi=x2-dt(x2)*(x2-x1)/(dt(x2)-dt(x1));
        x1=x2; x2=xi;
	if abs(x1-x2)<eps, break, end;
end;
printf('Tx=(%0.6f,%0.6f)\n',x1,f(xi));

r=[20,30,40,25,10,15,34,20];
U=[-35; 0; 0; 0; -40];
R=[-r(7),0,-r(6),r(6)+r(7),0;...
r(1)+r(5)+r(7),r(5),0,-r(7),0;...
-r(5),r(2)+r(3)+r(5)+r(8),-r(8),0,-r(3);...
0,-r(8),r(4)+r(6)+r(8),-r(6),0;...
0,-r(3),0,0,r(3)]
I=R\U;
printf('i=%0.6f\n',I(3)-I(2)); 





