function K = besselk(nu,Z)
%BESSELK Symbolic Bessel function, K(nu,z).

%   Copyright (c) 1993-98 by The MathWorks, Inc.
%   $Revision: 1.6 $  $Date: 1997/11/29 01:05:18 $

nu = sym(nu);
Z = sym(Z);

if all(size(nu) == 1)
   [K,stat] = maple('map2','besselk',nu,Z);
elseif all(size(Z) == 1)
   [K,stat] = maple('map','besselk',nu,Z);
else
   error('One argument must be a scalar.')
end


if stat
   % Singularity encountered.
   if all(size(nu) == 1)
      nu = nu(ones(size(Z)));
   else
      Z = Z(ones(size(nu)));
   end
   K = Z;
   for k = 1:prod(size(Z));
      [K(k),stat] = maple('besselk',nu(k),Z(k));
      if stat
         K(k) = inf;
      end
   end
end
