For many calculation algorithms (division of "BigInts", division of polynomials, division of power series, ...) it is desirable to compute efficiently the (multiplicative) inverse of an element b of some ring R. Here's a fairly general method, that works in many real problems. Like the Babylonian square root algorithm, it can be derived from the Newton-Raphson method; also like it, you don't have to use the iteration.


We assume we have some norm |.|:RQ+ (or sometimes to the real numbers), i.e. just a function satisfying


Now, if you've glanced at the Newton-Raphson method, you'll know that it requires division. How can we use an algorithm which requires division in order to implement division? We'll arrange matters so all divisions in the algorithm cancel out, leaving us with just multiplications and additions.

Let b∈R; we shall compute 1/b. We decide to solve the equation 1/x-b=0. Dumbly applying the rules for deriving the Newton-Raphson iteration (after all, derivatives might not mean anything in our ring R!), we see:


So our desired iteration will be
xn+1 = xn - f(xn)/f'(xn) = 2xn-bxn2.

Why does it work?

We shall prove that this iteration converges (and rapidly, at a quadratic pace!). So we can ignore the fact that we used the Newton-Raphson method (with somewhat shaky justification) to derive our iteration -- we shall just prove ``it works''.

When can we guarantee convergence?

|xn+1-1/b| = |2xn-bxn2-1/b| = |b*(xn-1/b)2| ≤ |b|*|xn-1/b|2
So we're guaranteed quadratic convergence if |x0-1/b|<|b|.


Power series

Let R=Q((Z)) be the Laurent field of formal power series with rational coefficients. A good choice of "norm" is

v(p(Z)) = the lowest power of Z appearing in p(Z)
|p(Z)| = 2-v(p(Z))
"Convergence" in this norm means agreement of increasing numbers of low-order terms.

We show how to compute the inverse of a power series of norm 1. For general p(Z), just note that we can express the inverse based on the inverse of such a power series:

1/p(Z) = Zv(p(Z))*1/(Z-v(p(Z))p(Z)).
And if v(p(Z))=1, it turns out that a good initial guess is p(0), the coefficient of the 1's term in p(Z).

Let us compute the inverse of Z2+1. The first few iterations:

  1. a0(Z) = 1 (the coefficient of the 1's term).
  2. a1(Z) = 2a0(Z)-(Z2+1)a0(Z)2 = 1-Z2
  3. a2(Z) = 2a1(Z)-(Z2+1)a1(Z)2 = 1-Z2+Z4-Z6
Indeed, every iteration doubles the number of correct terms! (The correct answer is 1-Z2+Z4-Z6+Z8-...).

Polynomials mod ZN

A more practical setting is used when dividing polynomials. We want to find the multiplicative inverse of a polynomial b(Z) modulo ZN (for more information, see the full algorithm under polynomial division). This exists (when working over a field; for polynomials over a ring we require b(0) invertible...) iff b(0)≠0.

We proceed exactly as in the power series case. Except that now there cannot be norms smaller than 2-N. So we may conclude our iteration after log2(N) iterations (rounded up), knowing we hold the precise answer.

Integers mod 2N

Suppose you're trying to divide huuuge numbers. Computer arithmetic is usually performed modulo 2N, so we shall do so here, too. The 2-adic norm will be our norm; we can invert any odd number.

For instance, to invert 13 modulo 2^16:

  1. a0=1 (≥1 bit of accuracy)
  2. a1=-11≡65525 (mod 2^16)=11111111111101012 (≥2 bits of accuracy; in fact, 4 bits!)
  3. a2=-1595≡63941 (mod 2^16)=11111001110001012
  4. a3≡20165=1001110110001012 is the correct answer.


Some square matrices have an inverse. We can compute it rapidly. Suppose we want to invert a matrix of real or complex numbers B. If the matrix norm |I-B-1|<1, then by the argument above the algorithm, started from A0=I, will converge.

But many ("most"!) nonsingular matrices B are not of this form. Still, this is the basis for a very strong method of inverting a matrix.

Log in or register to write something here or to contact authors.