function [u,us,dw,zo]=der(u0,z,x,Lx,Lz)
k=0.4;
zoo=2e-5;
y=1;
am=.8;
az=.5;
[a,b]=size(x);
[aa,bb]=size(z);
us=am*sin(2*pi*x/.8);

dus=am*2*pi*cos(2*pi*x/.8)/Lx;

uns=find(x>.4);  
if ~isempty(uns);
      us(uns)=0;
      dus(uns)=0;    
end;
xb=.10;
sg=.025;
gs=0.1*az/sqrt(2*pi)/sg./exp((x-xb).*(x-xb)/2/sg/sg);
%gs=0;
zo=zoo*((1-az*sin(2*pi*x))+gs);
dzo=-zoo*(az*2*pi*cos(2*pi*x)+gs.*(x-xb)/sg/sg)/Lx;
dlg=dzo./zo;
for j=1:bb
	up(j,:)=us+(u0-us).*log(z(j)./zo)/log(10/zoo);
	upp(j)=u0/log(10/zoo).*log(z(j)/zoo);
	u(j,:)=upp(j).*(1-exp(-z(j)/Lz))+up(j,:)./exp(z(j)/Lz);
	dw(j,:)=-dus.*(1-log(z(j)./zo)/log(10/zoo))+(u0-us)/log(10/zoo).*dlg;
	dw(j,:)=dw(j,:)./exp(z(j)/Lz);
end;

   
   
   