function [det,G,GC,GD] = sismo_Stoneley_det_cof(k,sigma,rhow,rhos,alphaw,alphas,h,betas)
% det is the determinant of the 3 by 3 matrix that gives the amplitudes of the 
% water and crust potentials 
% for a one layer of water over an infinite half-space (crust)
% and G in the transfer function from surface pressure to crust potential amplitude 

l=sqrt(sigma.^2./alphaw.^2-k.^2);
coslh=cos(l.*h);
sinlh=sin(l.*h);
m=sqrt(k.^2-sigma.^2./alphas.^2);
n=sqrt(k.^2-sigma.^2./betas.^2);
fac1=(sigma^2-2*k.^2.*betas^2);
%fac2=4*betas^4.*k.^2.*m.*n-(sigma^2-2*k^2*betas^2)^2;
fac2=(4.*betas.^4.*k.^2.*(m.*n)./fac1-fac1);
left=2./(sigma).*(l.*rhos.*coslh.*fac2);
right=2.*rhow.*m.*sinlh.*sigma.^3./fac1; 
det=(left-right);
%
% tranferfunctions for delta, C and D
%
G=2.*l.*m.*(k.^2-n.^2)./((k.^2+n.^2).*sigma.*det);
rp=l.*rhos.*fac2./sigma;
qp=rhow.*m.*sigma.^3./fac1; 
denom=(rp.*coslh-qp.*sinlh).*rhow.*sigma.*2;
GC=(sqrt(-1).*rp-qp)./denom;
GD=(sqrt(-1).*rp+qp)./denom;
end



%function [det,G,GC,GD] = sismo_Stoneley_det_cof(k,sigma,g,rhow,rhos,alphaw,alphas,h,betas)
% det is the determinant of the 3 by 3 matrix that gives the amplitudes of the 
% water and crust potentials 
% for a one layer of water over an infinite half-space (crust)
% and G in the transfer function from surface pressure to crust potential amplitude 

%Q=g/(2*alphaw);
%R=g/(2*betas);
%S=g/(2*alphas);


%l=sqrt(-1)*Q+sqrt(sigma.^2./alphaw.^2-k.^2);
%m=S+sqrt(k.^2-sigma.^2./alphas.^2);
%n=R+sqrt(k.^2-sigma.^2./betas.^2);


