function [ra,k]=newton(fu,x0,tol,nmax)
k=0;x=x0';virhe=100;
while ((k<nmax) & (virhe>tol)) 
    [f,df]=fu(x);
    v=-df\f';
    y=x+v;
    virhe=norm(y-x)/norm(y);
    k=k+1;
    x=y;
end     
ra=x;    
