function [ni,x]=maxcorr(ni,x,res,tol)
disp('corr')
h=x(2:ni+1)-x(1:ni);
%
%computing new mesh size
%
h
res
hnew=sqrt(tol*ones(size(h))./(res+eps*ones(size(res))));
%
%computing new mesh points
%
sons=max(ones(size(h)),ceil(h./hnew));
hnew=h./sons;
xnew=[x(1):hnew(1):x(2)];
for j=2:ni;
add=[x(j)+hnew(j):hnew(j):x(j+1)];
xnew=[xnew,add];
end
x=xnew;
ni=length(x)-1;


