function [datanhresult,x]=datanh(x);
datanhresult=[];
persistent atnhcs dxrel first firstCall nterms sqeps y ; if isempty(firstCall),firstCall=1;end;
;
if isempty(nterms), nterms=0; end;
%***BEGIN PROLOGUE DATANH
%***PURPOSE Compute the arc hyperbolic tangent.
%***LIBRARY SLATEC (FNLIB)
%***CATEGORY C4C
%***TYPE doubleprecision (ATANH-S, DATANH-D, CATANH-C)
%***KEYWORDS ARC HYPERBOLIC TANGENT, ATANH, ELEMENTARY FUNCTIONS,
% FNLIB, INVERSE HYPERBOLIC TANGENT
%***AUTHOR Fullerton, W., (LANL)
%***DESCRIPTION
%
% DATANH(X) calculates the doubleprecision arc hyperbolic
% tangent for doubleprecision argument X.
%
% Series for ATNH on the interval 0. to 2.50000E-01
% with weighted error 6.86E-32
% log weighted error 31.16
% significant figures required 30.00
% decimal places required 31.88
%
%***REFERENCES (NONE)
%***ROUTINES CALLED D1MACH, DCSEVL, INITDS, XERMSG
%***REVISION HISTORY (YYMMDD)
% 770601 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 DATANH
if isempty(atnhcs), atnhcs=zeros(1,27); end;
if isempty(dxrel), dxrel=0; end;
if isempty(sqeps), sqeps=0; end;
if isempty(y), y=0; end;
if isempty(first), first=false; end;
if firstCall, atnhcs(1)=[+.9439510239319549230842892218633d-1]; end;
if firstCall, atnhcs(2)=[+.4919843705578615947200034576668d-1]; end;
if firstCall, atnhcs(3)=[+.2102593522455432763479327331752d-2]; end;
if firstCall, atnhcs(4)=[+.1073554449776116584640731045276d-3]; end;
if firstCall, atnhcs(5)=[+.5978267249293031478642787517872d-5]; end;
if firstCall, atnhcs(6)=[+.3505062030889134845966834886200d-6]; end;
if firstCall, atnhcs(7)=[+.2126374343765340350896219314431d-7]; end;
if firstCall, atnhcs(8)=[+.1321694535715527192129801723055d-8]; end;
if firstCall, atnhcs(9)=[+.8365875501178070364623604052959d-10]; end;
if firstCall, atnhcs(10)=[+.5370503749311002163881434587772d-11]; end;
if firstCall, atnhcs(11)=[+.3486659470157107922971245784290d-12]; end;
if firstCall, atnhcs(12)=[+.2284549509603433015524024119722d-13]; end;
if firstCall, atnhcs(13)=[+.1508407105944793044874229067558d-14]; end;
if firstCall, atnhcs(14)=[+.1002418816804109126136995722837d-15]; end;
if firstCall, atnhcs(15)=[+.6698674738165069539715526882986d-17]; end;
if firstCall, atnhcs(16)=[+.4497954546494931083083327624533d-18]; end;
if firstCall, atnhcs(17)=[+.3032954474279453541682367146666d-19]; end;
if firstCall, atnhcs(18)=[+.2052702064190936826463861418666d-20]; end;
if firstCall, atnhcs(19)=[+.1393848977053837713193014613333d-21]; end;
if firstCall, atnhcs(20)=[+.9492580637224576971958954666666d-23]; end;
if firstCall, atnhcs(21)=[+.6481915448242307604982442666666d-24]; end;
if firstCall, atnhcs(22)=[+.4436730205723615272632320000000d-25]; end;
if firstCall, atnhcs(23)=[+.3043465618543161638912000000000d-26]; end;
if firstCall, atnhcs(24)=[+.2091881298792393474047999999999d-27]; end;
if firstCall, atnhcs(25)=[+.1440445411234050561365333333333d-28]; end;
if firstCall, atnhcs(26)=[+.9935374683141640465066666666666d-30]; end;
if firstCall, atnhcs(27)=[+.6863462444358260053333333333333d-31]; end;
if firstCall, first=[true]; end;
firstCall=0;
%***FIRST EXECUTABLE STATEMENT DATANH
if( first )
[nterms ,atnhcs]=initds(atnhcs,27,0.1.*real(d1mach(3)));
dxrel = sqrt(d1mach(4));
sqeps = sqrt(3.0d0.*d1mach(3));
end;
first = false;
%
y = abs(x);
if( y>=1.0D0 )
xermsg('SLATEC','DATANH','ABS(X) GE 1',2,2);
end;
%
if( 1.0D0-y<dxrel )
xermsg('SLATEC','DATANH','ANSWER LT HALF PRECISION BECAUSE ABS(X) TOO NEAR 1',1,1);
end;
%
datanhresult = x;
if( y>sqeps && y<=0.5d0 )
datanhresult = x.*(1.0d0+dcsevl(8.0d0.*x.*x-1.0d0,atnhcs,nterms));
end;
if( y>0.5d0 )
datanhresult = 0.5d0.*log((1.0d0+x)./(1.0d0-x));
end;
%
csnil=dbstack(1); csnil=csnil(1).name(1)~='@';
if csnil&&~isempty(inputname(1)), assignin('caller','FUntemp',x); evalin('caller',[inputname(1),'=FUntemp;']); end
end
%DECK DAVINT