/
/
/ SUBROUTINE DATAN(X)
/
/ VERSION 5A 4-26-77 (MH)
/
/X,THE ARGUMENT, IS REDUCED TO 
/0<X<1/2
/BY THE IDENTITIES:
/ATAN(-X)=-ATAN(X)
/IF X>1.0 THEN ATAN(X)=PI/2 - ATAN(1/X)
/IF .5<X<1.0 THEN ATAN(X)=ATAN(1/2)+ATAN(2*X-(1/(X+2)))
/ATAN(X)=X FOR X<2^(-15)
/
/
/
	SECT	DATAN
	JA	#DATAN
	DPCHK
/
	TEXT	+DATAN +
DATNXR,	SETX 	XRDATN
	SETB	BPDATN
BPDATN,	F 0.0
XRDATN,	F 0.0
DATFP1,	F 1.0
	F 0.0
DATLOW,	-15
	2000
	0000
	0000
	0000
	0000
/
	ORG	10*3+BPDATN
	FNOP
	JA	DATNXR
	0
DATRTN,	JA	.
/
LAMBDA,	0004
	3057
	7537
	4017
	0276
	4536
DATB0,	0005
	3221
	3522
	3121
	3352
	5066
DATA1,	0007
	5372
	4104
	3437
	1766
	6167
DATB1,	0003
	3135
	1757
	0565
	4141
	4270
DATA2,	0001
	5473
	7524
	1112
	4701
	2723
DATB2,	0002
	2065
	4070
	1015
	2710
	3176
DATA3,	7775
	5374
	4326
	3317
	1675
	3124
DATB3,	0001
	2410
	5255
	0370
	2076
	6374
PIS2,	0001
	3110
	3755
	2421
	0264
	3013
ATN1S2,	7777
	3553
	0634
	0530
	3443
	6406
DATP5,	7777
	3777
	7777
	7777
	7777
	7776
X,	F 0.0
	F 0.0
C0,	F 0.0
	F 0.0
DT1,	F 0.0
	F 0.0
DATFP2,	F 2.0
	F 0.0
Z,	F 0.0
	F 0.0
/
/PICK UP RETURN AND ARGUMENT
	BASE	0
#DATAN,	STARTD
	FLDA	10*3
	FSTA	DATRTN
	FLDA	0
	SETX	XRDATN
	SETB	BPDATN
	BASE	BPDATN
	LDX	1,1
	FSTA	BPDATN
	FLDA%	BPDATN,1
	FSTA	BPDATN
	STARTE
	FLDA%	BPDATN	/GET X
	LDX	-1,0	/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