Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 beta 3/9/83; site cca.UUCP
Path: utzoo!watmath!clyde!burl!hou3c!hocda!houxm!houxz!vax135!floyd!harpo!decvax!cca!g-rh
From: g-rh@cca.UUCP (Richard Harter)
Newsgroups: net.math
Subject: Calculation of reciprocal without division
Message-ID: <686@cca.UUCP>
Date: Wed, 13-Jun-84 03:02:33 EDT
Article-I.D.: cca.686
Posted: Wed Jun 13 03:02:33 1984
Date-Received: Thu, 14-Jun-84 00:43:36 EDT
Organization: Computer Corp America, Cambridge
Lines: 20

{
	A recent submission asked for a good algorithm for division,
given shift, multiply, and add instructions.  The following is an
efficient and simple algorithm:

	Suppose we have an approximation x to 1/N.  Then we have
xN = 1+e which can be written as 1/N = x/(1+e).  We have

	1/(1+e) = 1-e+e^2-e^3+e-4 ...
	        = (1-e)(1+e^2)(1+e^4)(1+e^8)...

An estimate for x which is correct to the first bit can be found
by shifting N.  This should be done so that xN lies in the range
[1/2,1].  The magnitude of the error term, e, is then bounded by
1/2.  Four terms in the product are required for 16 bit accuracy
and five for 32 bit accuracy.  The powers are formed by successive
squaring.  A number of refinements are possible; the best algorithm
for a particular machine will depend on the exact instruction set
available and their execution times.
}