epsilon0=8.854184817*1e-12;
g=9.80665;
m=1e-3;
l=0.12;
Q=2.5*1e-8;
k=Q^2/(16*pi*epsilon0*m*g*l^2);
fs='u^3-k*u^2-k';
dfs='3*u^2-2*k*u';
alpha=20*pi/180;
eps=1e-8;
u=tan(alpha/2);
for i=1:100,
	u1=u-eval(fs)/eval(dfs);
	if abs(u1-u)<eps, break, end;
	u=u1;
end;
printf('iter=%0d, alfa= %0.8f stopinj\n',i,2*atan(u1)/pi*180);
%%
%% druga naloga 
v=[2,4]; beta=2; g=9.80665;
x='v(1)/beta*(1-exp(-beta*t))';
y='1/beta^2*(g-beta*g*t+beta*v(2)-exp(-beta*t)*(g+beta*v(2)))';
t=[0.5,0.7];
eps=1e-8;
for i=1:100,
        ff=eval(y);
        tt=t(2)-ff(2)*diff(t)/diff(ff);
        t(1)=t(2); t(2)=tt;
        if abs(diff(t))<eps, break, end;
end;
printf('cas=%0.8f, domet=%0.8f\n',mean(t), mean(eval(x)));

%% tretja naloga

tarca=4;
cas=[0.5,1];
smodnik=[4,4.5];
eps=1e-8;
for i=1:100
	kiks=[strel(smodnik(1),cas)-tarca,strel(smodnik(2),cas)-tarca];
	s=smodnik(2)-kiks(2)*diff(smodnik)/diff(kiks);
	smodnik(1)=smodnik(2); smodnik(2)=s;
	if abs(diff(smodnik))<eps, break, end;
end;
printf('polnjenje=%0.8f\n',mean(smodnik));
