function [casinresult,zinp]=casin(zinp);
casinresult=[];
persistent ci first firstCall i nterms pi pi2 r rmin sqzp1 twoi z z2 ; if isempty(firstCall),firstCall=1;end;
;
if isempty(i), i=0; end;
if isempty(nterms), nterms=0; end;
if isempty(pi), pi=0; end;
if isempty(pi2), pi2=0; end;
if isempty(r), r=0; end;
if isempty(rmin), rmin=0; end;
if isempty(twoi), twoi=0; end;
%***BEGIN PROLOGUE CASIN
%***PURPOSE Compute the complex arc sine.
%***LIBRARY SLATEC (FNLIB)
%***CATEGORY C4A
%***TYPE COMPLEX (CASIN-C)
%***KEYWORDS ARC SINE, ELEMENTARY FUNCTIONS, FNLIB, TRIGONOMETRIC
%***AUTHOR Fullerton, W., (LANL)
%***DESCRIPTION
%
% CASIN(ZINP) calculates the complex trigonometric arc sine of ZINP.
% The result is in units of radians, and the real part is in the first
% or fourth quadrant.
%
%***REFERENCES (NONE)
%***ROUTINES CALLED R1MACH
%***REVISION HISTORY (YYMMDD)
% 770701 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)
%***end PROLOGUE CASIN
if isempty(z), z=0; end;
if isempty(z2), z2=0; end;
if isempty(sqzp1), sqzp1=0; end;
if isempty(ci), ci=0; end;
if isempty(first), first=false; end;
if firstCall, pi2=[1.57079632679489661923e0]; end;
if firstCall, pi=[3.14159265358979324e0]; end;
if firstCall, ci=[complex(0.,1.)]; end;
if firstCall, first=[true]; end;
firstCall=0;
%***FIRST EXECUTABLE STATEMENT CASIN
if( first )
% NTERMS = LOG(EPS)/LOG(RMAX) WHERE RMAX = 0.1
nterms = fix(-0.4343.*log(r1mach(3)));
rmin = sqrt(6.0.*r1mach(3));
end;
first = false;
%
z = zinp;
r = abs(z);
if( r>0.1 )
%
if( real(zinp)<0.0 )
z = -zinp;
end;
%
sqzp1 = sqrt(z+1.0);
if( imag(sqzp1)<0. )
sqzp1 = -sqzp1;
end;
casinresult = pi2 - ci.*log(z+sqzp1.*sqrt(z-1.0));
%
if( real(casinresult)>pi2 )
casinresult = pi - casinresult;
end;
if( real(casinresult)<=(-pi2) )
casinresult = -pi - casinresult;
end;
if( real(zinp)<0. )
casinresult = -casinresult;
end;
else;
%
casinresult = z;
if( r<rmin )
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',zinp); evalin('caller',[inputname(1),'=FUntemp;']); end
return;
end;
%
casinresult =complex(0.0,0.0);
z2 = z.*z;
for i = 1 : nterms;
twoi = 2.*(nterms-i) + 1;
casinresult = 1.0./twoi + twoi.*casinresult.*z2./(twoi+1.0);
end; i = fix(nterms+1);
casinresult = z.*casinresult;
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',zinp); evalin('caller',[inputname(1),'=FUntemp;']); end
return;
end;
%
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',zinp); evalin('caller',[inputname(1),'=FUntemp;']); end
end
%DECK CASINH