/SQUARE ROOT SUBROUTINE                          OS8 FORTRAN II LIBRARY 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 4A
/	VERSION NUMBER IS AVAILABLE AT ENTRY POINTS
	ENTRY	SQRT
/
/	SQUARE ROOT ROUTINE
/	IF X0 IS AN APPROXIMATION FOR Y**(1/2)
/	THEN (X0+(Y/X0))/2 IS A BETTER APPROXIMATION
/
X0,	BLOCK	3
Y,	BLOCK	3
CNT,	BLOCK	1
/
/
	CPAGE	4
SQER,	6321		     /"SQRT" ERROR FROM LOC XXXXX
	2224
SQRT,	BLOCK	1
	4	     /ENTRY POINT
	TAD I	SQRT
	DCA	IN
	INC	SQRT#
	TAD I	SQRT
	DCA	IN#
	ISZ	SQRT#
	CALL	1,FAD
IN,	ARG	0
	CALL	1,STO	     /Y=ARGUMENT
	ARG	Y
	CALL	1,FAD
	ARG	Y
	TAD	ACH	     /IF Y NEGATIVE THEN ERROR
	SMA
	JMP	POS
	CALL	1,ERROR
	ARG	SQER
	CLA CLL CMA RAR
	AND	ACH
POS,	SZA		     /IF Y=0 THEN ROOT=0
	JMP	NONZ
	RETRN	SQRT
NONZ,	RAR CLL 	     /FORM INITIAL APPROXIMATION
	TAD	(1004
	DCA	ACH
	TAD	ACM
	RAR
	DCA	ACM
	TAD	ACL
	RAR
	DCA	ACL
	TAD	ACH
	AND	(4
	SNA CLA
	TAD	(2
	TAD	ACH
	DCA	ACH
	TAD	(-3	     /DO 3 ITERATIONS
	DCA	CNT
INIT,	CALL	1,STO
	ARG	X0
	CALL	1,FAD
	ARG	Y
	CALL	1,FDV	     /Y/X0
	ARG	X0
	CALL	1,FAD	     /(Y/X0)+X0
	ARG	X0
	TAD	ACH	     /((Y/X0)+X0)/2
	TAD	(7770
	DCA	ACH
	ISZ	CNT
	JMP	INIT
	RETRN	SQRT
	END

