/TRIGONOMETRY ROUTINES                         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 5 HAS PATCH FOR IMPROVED ACCURACY AT LARGE ARGS
/	INSERTED NOP INSTRUCTIONS AT PATCH1 AND PATCH2/C. STOLZ
/
/
/
/
/
/
/
/
/
/
/	VERSION 6A
/	VERSION NUMBER IS AVAILABLE AT ENTRY POINTS
	ENTRY	SIN
	ENTRY	COS
	ENTRY	TAN

QUAD,	0	/CONTAINS ONE LESS THAN THE QUADRANT OF THE ARGUMENT
Y,	BLOCK	3	/TEMPORARY STORAGE FOR ARG
	CPAGE	22
COEF,	5476		/-2.39E-8	CONSTANTS FOR SIN
	3246
	2500		/2.7526E-6
	1565
	6134
	5170		/-1.98409E-4
	5646
	4006
	0026		/8.3333315E-3
	1724
	2104
	2065		/-1.6666667E-1
	5765
	2525
	2525		/1.0
	2014
	0000
	0000
	CPAGE	3
HALFPI,	2016		/1.5707963
	2207
	7324
	CPAGE	3
QTRPI,	2006		/7.8539815E-1
	2207
	7324
	CPAGE	25
TOEF,	1724		/9.5168091E-3
	6766
	1440		/2.9005250E-3
	1705
	7413
	2741		/2.4565090E-2
	1736
	2236
	2720		/5.3374060E-2
	1746
	6517
	3023		/1.3339240E-1
	1764
	2114
	0042		/3.3333140E-1
	1775
	2525
	1517		/1.0
	2014
	0000
	0000
TAN,	BLOCK	1
	6
	DCA	QUAD	/SET QUADRANT OFFSET SWITCH
	TAD I	TAN	/PICK-UP CDF
	DCA	TARG
	INC	TAN#	/POINT TO NEXT WORD
	TAD I	TAN	/PICK-UP ADDRESS
	DCA	TARG#
	INC	TAN#	/POINT TO RETURN
	CALL	1,FAD	/GET ARG IN FP-ACC
TARG,	ARG	0
BAC,	TAD	ACH	/LOOK AT HIGH ORDER WORD
	SPA CLA		/IF NEGATIVE
	JMP	OVT	/GO OM
	CALL	1,FSB	/OTHERWISE SUBTRACT
	ARG	QTRPI	/PI/2
	ISZ	QUAD	/AND INCREMENT QUADRANT COUNTER
PATCH1,	NOP		/ALLOW FOR SKIP
	JMP	BAC	/UNTIL ARG IS NEGATIVE
OVT,	CALL	1,FAD	/ADD PI/2 TO ARG UNTIL IT IS IN 
	ARG	QTRPI	/THE FIRST QUADRANT
	CLA CMA
	TAD	QUAD	/BUT KEEP TRACK OF WHICH QUADRANT IT WAS IN
	DCA	QUAD
	TAD	ACH	/GET HI ORDER WORD
	SPA CLA
	JMP	OVT	/IF NEGATIVE REPEAT
	TAD	QUAD	/FIND OUT WHAT QUAD IT WAS IN
	RTR	
	SMA CLA
	JMP	OM
	CALL	0,CHS	/SUBTRACT FROM PI/2 IF QUAD 2 OR 4
	CALL	1,FAD
	ARG	QTRPI
OM,	TAD	(7	/USE A 7 TERM SERIES
	CPAGE	3
	JMS	POL
	TOEF		/ADRESS OF COEFICIENTS FOR THE SERIES
	CLA CMA
	TAD	QUAD
	RTR
	SZL CLA
	JMP	OM3
	CALL	1,STO
	ARG	Y
	TAD	(2014
	DCA	ACH
	CALL	1,FDV
	ARG	Y
OM3,	RETRN	TAN
/	INTERNAL SUBROUTINE POL
/
/	COMPUTES N TERMS OF POLYNOMIAL 
/	N IN AC ... X IN FLOATING AC
/	COEFFICIENTS START IN LOCATION WHOSE ADDRESS FOLLOWS JMS TO POL
/
POL2,	BLOCK	1
POL,	BLOCK	1
	CIA
	DCA	POL2
	CALL	1,STO	/STORE ADJUSTED ARGUMENT
	ARG	Y	/IN A TEMPORARY
	CALL	1,FAD
	ARG	Y	/RESTORE FP AC
	CALL	1,FMP
	ARG	Y	/SQUARE IT
	CALL	1,STO
	ARG	X
	TAD I	POL
	INC	POL
ARG2,	DCA	ARG1#
	CALL	1,FAD
ARG1,	ARG	COEF	/     ADDRESS STORED HERE
	ISZ	POL2
	JMP	POL1
	CALL	1,FMP	/MULTIPLY AGAIN TO COMPLETE SERIES
	ARG	Y
	TAD	QUAD
	RTR
	SNL CLA		/FIND OUT WHICH QUADRANT
	JMP	POLEX
	CALL	0,CHS	/IF IN QUADRANT 3 OR 4 SET NEGATIVE
POLEX,	JMP I	POL
POL1,	CALL	1,FMP
	ARG	X
	TAD	ARG1#
	TAD	(3
	JMP	ARG2
/
X,	BLOCK	3	/TEMPORARY FOR POL
/
/
/ 8K FORTRAN TRIGNOMETRY ROUTINES
/
/
COS,	BLOCK	1
	6
	TAD	COS
	DCA	SIN
	TAD	COS#
	DCA	SIN#	/IT NOW APPEARS THAT SIN WAS CALLED
	CLA IAC		/WITH QUADRANT OFFSET BY ONE
	JMP	COSE
SIN,	BLOCK	1
	6
COSE,	DCA	QUAD	/SET QUADRANT OFFSET SWITCH
	TAD I	SIN	/PICK-UP CDF
	DCA	SARG
	INC	SIN#	/POINT TO NEXT WORD
	TAD I	SIN	/PICK-UP ADDRESS
	DCA	SARG#
	INC	SIN#	/POINT TO RETURN
	CALL	1,FAD	/GET ARG IN FP-ACC
SARG,	ARG	0
BACK,	TAD	ACH	/LOOK AT HIGH ORDER WORD
	SPA CLA		/IF NEGATIVE
	JMP	OVR	/GO ON
	CALL	1,FSB	/OTHERWISE SUBTRACT
	ARG	HALFPI	/PI/2
	ISZ	QUAD	/AND INCREMENT QUADRANT COUNTER
PATCH2,	NOP		/ALLOW FOR SKIP
	JMP	BACK	/UNTIL ARG IS NEGATIVE
OVR,	CALL	1,FAD	/ADD PI/2 TO ARG UNTIL IT IS IN 
	ARG	HALFPI	/THE FIRST QUADRANT
	CLA CMA
	TAD	QUAD	/BUT KEEP TRACK OF WHICH QUADRANT IT WAS IN
	DCA	QUAD
	TAD	ACH	/GET HI ORDER WORD
	SPA CLA
	JMP	OVR	/IF NEGATIVE REPEAT
	TAD	QUAD	/FIND OUT WHAT QUAD IT WAS IN
	RTR	
	SMA CLA
	JMP	ON
	CALL	0,CHS	/SUBTRACT FROM PI/2 IF QUAD 2 OR 4
	CALL	1,FAD
	ARG	HALFPI
ON,	TAD	(6	/USE A 6 TERM SERIES
	CPAGE	3
	JMS	POL
	COEF		/ADRESS OF COEFICIENTS FOR THE SERIES
	RETRN	SIN
	END

