function [ctanresult,z]=ctan(z);
ctanresult=[];
persistent den firstCall sn2x sqeps x2 y2 ; if isempty(firstCall),firstCall=1;end;
;
if isempty(den), den=0; end;
if isempty(sn2x), sn2x=0; end;
if isempty(sqeps), sqeps=0; end;
if isempty(x2), x2=0; end;
if isempty(y2), y2=0; end;
%***BEGIN PROLOGUE CTAN
%***PURPOSE Compute the complex tangent.
%***LIBRARY SLATEC (FNLIB)
%***CATEGORY C4A
%***TYPE COMPLEX (CTAN-C)
%***KEYWORDS ELEMENTARY FUNCTIONS, FNLIB, TANGENT, TRIGONOMETRIC
%***AUTHOR Fullerton, W., (LANL)
%***DESCRIPTION
%
% CTAN(Z) calculates the complex trigonometric tangent of complex
% argument Z. Z is in units of radians.
%
%***REFERENCES (NONE)
%***ROUTINES CALLED R1MACH, XERCLR, XERMSG
%***REVISION HISTORY (YYMMDD)
% 770401 DATE WRITTEN
% 890531 Changed all specific intrinsics to generic. (WRB)
% 890531 REVISION DATE from Version 3.2
% 891214 Prologue converted to Version 4.0 format. (BAB)
% 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
%***end PROLOGUE CTAN
if firstCall, sqeps=[0.]; end;
firstCall=0;
%***FIRST EXECUTABLE STATEMENT CTAN
if( sqeps==0. )
sqeps = sqrt(r1mach(4));
end;
%
x2 = 2.0.*real(z);
y2 = 2.0.*imag(z);
%
sn2x = sin(x2);
xerclr;
%
den = cos(x2) + cosh(y2);
if( den==0. )
xermsg('SLATEC','CTAN','TAN IS SINGULAR FOR INPUT Z (X IS PI/2 OR 3*PI/2 AND Y IS 0)',2,2);
end;
%
if( abs(den)<=max(abs(x2),1.).*sqeps )
xerclr;
xermsg('SLATEC','CTAN',['ANSWER LT HALF PRECISION, ABS(X) TOO BIG OR X TOO NEAR ','PI/2 OR 3*PI/2'],1,1);
end;
%
ctanresult = complex(sn2x./den,sinh(y2)./den);
%
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',z); evalin('caller',[inputname(1),'=FUntemp;']); end
end
%DECK CTANH