function [ok,globalerr,res]=etest(ni,x,u,d,Dd,c,r,f,tol)
disp('test')
h=x(2:ni+1)-x(1:ni);
%
for i=1:ni;
res(i)=f(i)+(Dd(i)-c(i))*(u(i+1)-u(i))/h(i)-r(i)*(u(i+1)+u(i))/2;
res(i)=abs(res(i))/sqrt(d(i));
end
%
cint=1/sqrt(10); %interpolation error constant in ||z-zi||<c||z'|| (where z=e)
%
%testing energy norm error
%
res=cint*res;
globalerr=sqrt(sum(h.*h.*res.*res));
%
if globalerr<tol
ok=1;
else
ok=-1;
end
