/ARCTANGENT ROUTINE                       OS8 FORTRAN II LIBRARY
/
/
/
/
/
/
/
/
/
/COPYRIGHT  (C)  1974,1977 BY DIGITAL EQUIPMENT CORPORATION
/
/
/
/
/
/
/
/
/
/
/THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE
/AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT
/CORPORATION.  DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/FOR ANY ERRORS THAT MAY APPEAR IN THIS MANUAL.
/
/THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FURNISHED TO THE PURCHASER
/UNDER A LICENSE FOR USE ON A SINGLE COMPUTER SYSTEM AND CAN BE COPIED
/(WITH INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR USE IN SUCH
/SYSTEM, EXCEPT AS MAY OTHERWISE BE PROVIDED IN WRITING BY DIGITAL.
/
/DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY FOR THE USE
/OR RELIABILITY OF ITS SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY
/DIGITAL.
/
/
/
/
/
/
/
/
/
/
/	VERSION 11A
/	VERSION NUMBER IS AVAILABLE AT ENTRY POINTS
	ENTRY	ATAN

ATAN,	BLOCK	1
	11
	TAD	ATAN
	DCA	L4
	TAD	ATAN#
	DCA	L4#
	INC	ATAN#
	INC	ATAN#
	CALL	1,IFAD
L4,	ARG	0
	CLL
	TAD	ACH
	SNA
	JMP	EXIT
	SPA
	TAD	(4000
	DCA	ACH		/TAKE ABSVAL OF ARGUMENT
	RAR
	DCA	SIGN		/AND REMEMBER SIGN
	TAD	ACH
	TAD	(-2014
	SPA CLA
	JMP	LSTN45		/IF ARG>1,
	JMS	INVRS		/INVERT ARG - SUBTRACT RESULT FROM PI/2
	CLA CMA
LSTN45,	DCA	L4#		/L4# IS THE "PI/2-RESULT" SWITCH
	TAD	ACH
	TAD	(-1774		/THIS IS AN APPROXIMATE TEST TO SEE
	SPA CLA			/IF THE NEW ARG IS <2-SQRT(3)
	JMP	LSTN15		/IF IT IS,
	CALL	1,FAD		/PERFORM A "DIFFERENCE OF TANGENTS"
	ARG	SQRT3		/TRANSFORMATION TO SUBTRACT PI/6
	TAD	(20
	JMS	INVRS		/FROM THE RESULT. THE ARG IS TRANSFORMED
	CALL	0,CHS		/INTO SQRT(3)-4/(ARG+SQRT(3))
	CALL	1,FAD
SQT3,	ARG	SQRT3
	CLA CMA
LSTN15,	DCA	INVRS		/USE INVRS AS A SWITCH TO INDICATE THIS
	CALL	1,STO		/TRANSFORMATION OCCURRED
	ARG	T
	TAD	(-4
	DCA	L4
	TAD	SQT3#
	DCA	L3#
ATLOOP,	INC	L3#		/NOW PERFORM A STANDARD TAYLOR SERIES
	INC	L3#		/EXPANSION (WITH TRUNCATED COEFFICIENTS)
	INC	L3#
	CALL	1,FAD		/CONVERGENCE WILL BE GOOD SINCE WE
L3,	ARG	SQRT3		/HAVE MADE THE ARGUMENT BE <.3
	JMS	FMPT
	JMS	FMPT
	ISZ	L4
	JMP	ATLOOP
	JMS	FMPT
	CALL	1,FAD
	ARG	T		/FINISH UP THE SERIES
	ISZ	INVRS
	JMP	NOPI6
	CALL	1,FAD		/ADD PI/6 IF NECESSARY
	ARG	PIOVR6
NOPI6,	ISZ	L4#
	JMP	NOPI2
	CALL	0,CHS		/SUBTRACT FROM PI/2 IF NECESSARY
	CALL	1,FAD
	ARG	PIOVR2
NOPI2,	TAD	SIGN
	TAD	ACH		/SET SIGN OF RESULT = SIGN OF ARGUMENT
	DCA	ACH
EXIT,	RETRN	ATAN

INVRS,	0		/INVERSION SUBROUTINE
	TAD	(2014	/ENTERED WITH AC=0 OR 20
	DCA	L4	/AC=0 MEANS 1/FAC, AC=20 MEANS 4/FAC
	CALL	1,STO
	ARG	T
	TAD	L4
	DCA	ACH	/ACM AND ACL WERE CLEARED BY STORE
	CALL	1,FDV
	ARG	T
	JMP I	INVRS

FMPT,	0		/SUBROUTINE TO MULTIPLY BY T
	CALL	1,FMP	/SAVES A FEW MEASLY LOCATIONS
	ARG	T
	JMP I	FMPT

SIGN,	0		/CELL FOR HOLDING SIGN OF ARG
T,	BLOCK	3	/FLOATING TEMPORARY

	PAGE

PIOVR6,	2004;1405;2216	/PI/6
PIOVR2,	2016;2207;7325
SQRT3,	2016;7331;7272	/SQRT(3)
/THE NEXT 4 NUMBERS MUST IMMEDIATELY FOLLOW SQRT3
	1756;0462;4562	/APPROXIMATELY 1/9
	5764;4221;3403	/APPROXIMATELY -1/7
	1766;3141;6672	/APPROXIMATELY 1/5
	5775;2525;2337	/APPROXIMATELY -1/3

	END

