function k=deriv2(x,y,d)

% DERIV2      High order partial derivatives of the Normal kernel.
%
%             Example: k42=deriv2(0,0,'42')
%
%             DERIV2(X,Y,D) finds the partial derivatives of the kernel K 
%             at the point (X,Y).  D defines the derivative. 
%
%             Christian C. Beardah 1995

k=zeros(size(x));

xd=str2num(d(1));
yd=str2num(d(2));

if xd==0,
  xterm=1;
  elseif xd==2,
    xterm=x.^2-1;  
    elseif xd==4,
      xterm=x.^4-6*x.^2+3;
      elseif xd==6,
        xterm=x.^6-15*x.^4+45*x.^2-15;
        elseif xd==8,
          xterm=x.^8-28*x.^6+210*x.^4-420*x.^2+105;
end;

if yd==0,
  yterm=1;
  elseif yd==2,
    yterm=y.^2-1;  
    elseif yd==4,
      yterm=y.^4-6*y.^2+3;
      elseif yd==6,
        yterm=y.^6-15*y.^4+45*y.^2-15;
        elseif yd==8,
          yterm=y.^8-28*y.^6+210*y.^4-420*y.^2+105;
end;

k=xterm.*yterm.*knorm(x,y);