The Math Forum

Ask Dr. Math - Questions and Answers from our Archives
Associated Topics || Dr. Math Home || Search Dr. Math

An Introduction To P-adic Numbers

Date: 04/29/2004 at 00:27:10
From: Scott
Subject: p-adic numbers

What are p-adic numbers?  What are they used for?

Date: 04/29/2004 at 12:18:52
From: Doctor Vogler
Subject: Re: p-adic numbers

Hi Scott,

Thanks for writing to Dr Math.  That's not an easy question!  It could
lead to a whole semester-long course of math.

There are many ways to think about the p-adic numbers, but this is the
way which seems most enlightening to me.  By the way, the "p" in
p-adic refers to a prime number p, and there are a completely
different set of p-adic numbers for each prime (the 2-adics, the
3-adics, the 5-adics, and so on), but we often speak about them all
together, because most of them are very similar to one another (the
2-adics being an exception to some of the rules).

First think of the integers mod p.  There are p of them, from 0 to
p - 1.  It is a field, so we can add, subtract, multiply, and divide
by anything but the 0.  Now think of the integers mod p^2.  This is no
longer a field, but it is a ring, and it still has some interesting
properties.  Now think of the elements of p^2 being written in the form

  a_0 + p*a_1.

Then you can reduce to mod p by simply dropping the a_1 term.  You can
keep going, too.  You can think of the integers mod p^n as numbers of
the form

  a_0 + p*a_1 + p^2*a_2 + ... + p^(n-1)*a_(n-1)

and you then reduce to a lower power of n by dropping the terms with
higher powers of p.

Now think of the normal integers.  If you look at the integer mod p,
then mod p^2, and p^3, and so on, then a certain digit a_i is going to
come out at each step, until p^n gets bigger than your number, at
which point the coefficients all become zero.  But when we're looking
at a number mod p^10, we can't tell what the next coefficient is going
to be.  We can't even say that it will stop there if the last 8
coefficients were all zero.  We can't say where the number might stop.

So what if it doesn't?  What if your number is an infinite string of
powers of p

  a_0 + p*a_1 + p^2*a_2 + ... + p^i*a_i + ...

and it never ends.  It's sort of like a power series in the number p.
This is what p-adic integers are.  

Think of it in another way:  When you write a number in decimal, you
can only have finitely many digits on the left of the decimal, but you
can have infinitely many on the right of the decimal.  They might
"terminate" (and become all zeros after some point) but they might 
not.  The p-adic integers can be thought of as writing out integers in
base p, but you can have infinitely many digits to the *left* of the
decimal (and none on the right; but the rational p-adic numbers can
have finitely many digits on the right of the decimal).

These numbers are useful for two very important reasons:  They are
surprisingly easy to work with (once you understand them), and they
can tell you things about the (normal) rational numbers.  More on this

Another way to think of these p-adic integers is as an infinite string
of residues mod p^n (for n = 1, 2, 3, ...) such that reducing a higher
residue gives you a lower residue.  In other words, the n'th term in
this string is the integer which is the sum of the first n terms in
the power series form.

They also call this "localizing" the rational number "at the prime p"
whereas the real numbers are what you get if you "localize" at
infinity.  I won't go into that any more, because it gets pretty deep
into algebraic number theory.

Now, if you have a basic idea of what p-adic integers are, I will tell
you how they relate to p-adic rational numbers.  As you would expect,
a rational p-adic number is one p-adic integer divided by another
(nonzero) p-adic integer.  But here's the kicker:  Recall that every
number mod p^n has a multiplicative inverse mod p^n unless the number
is divisible by p (this is part of why the p has to be prime).  Well,
we can write any p-adic integer in the form

  p^k * r

where r is a p-adic integer that is not divisible by p, just by
factoring out p's.  Now r has a multiplicative inverse mod p^n for
every n, so 1/r is a p-adic integer!  That's a very important step. 
So that means that if we divide

  p^m * s


  p^k * r,

then we get the p-adic rational number

  p^(m-k) * (s * 1/r),

which is a p-adic integer times a power of p.  It will be another
p-adic integer if the power of p is nonnegative, but p-adic rationals
can have negative powers of p here, and that is why I said earlier
that p-adic rational numbers can have finitely many (and not
infinitely many) digits to the right of the decimal when you write
them in base p.  For example, a 2-adic number could be written in
binary as something like


which would mean

  2^-7 * (1 + 2^2 + 2^4 + 2^8 + 2^9 + 2^13 + 2^15 + ...).

A search on the internet for "p-adic" yields a link to MathWorld, 
which is always a good math reference: 

and a link to a surprisingly accurate article for a general
encyclopedia on Wikipedia: 

Note their comment, "They have been used to solve several problems in
number theory, many of them using Helmut Hasse's local-global
principle, which roughly states that an equation can be solved over
the rational numbers if and only if it can be solved over the real
numbers and over the p-adic numbers for every prime p."  And this is
the short answer to your second question.  The MathWorld article also
lists several applications of the p-adics.

There are many other internet articles that will tell you more about
p-adics.  But I find that it's always easier to learn from a book, and
many modern graduate-level texts on number theory will have at least a
chapter on p-adic numbers.  If you have access to a university
library, then I would look for a book there.  You might even find a
book exclusively about p-adics.  I learned from Serre, "A Course in
Arithmetic," but I'm sure there are many others.

One nice program that does math with p-adics is GNU Pari, whose home
page is 

You can download the program for free.  (It was made for UNIX, but
there is a Windows version available.)  Pari writes p-adics in the
form I described first, using big-oh notation for the infinite part
that it doesn't calculate (much like any calculator only computes a
certain number of decimal digits).  For example, you can ask it

  log(1 + 2 + O(2^8))

which is the same as

  log(3 + O(2^8))

and it will tell you

  2^2 + 2^4 + 2^5 + 2^6 + 2^7 + O(2^8).

Or you can ask it

  1/(3 + O(2^10))

and it will tell you

  1 + 2 + 2^3 + 2^5 + 2^7 + 2^9 + O(2^10).

Pari is also great for Taylor series, number fields, and elliptic
curves, among other things.

If you have any more questions about this, please write back and I
will try to explain further.

- Doctor Vogler, The Math Forum 

Date: 04/29/2004 at 13:44:33
From: Scott
Subject: Thank you (p-adic numbers)

Thanks for answering my question!

Associated Topics:
College Number Theory

Search the Dr. Math Library:

Find items containing (put spaces between keywords):
Click only once for faster results:

[ Choose "whole words" when searching for a word like age.]

all keywords, in any order at least one, that exact phrase
parts of words whole words

Submit your own question to Dr. Math

[Privacy Policy] [Terms of Use]

Math Forum Home || Math Library || Quick Reference || Math Forum Search

Ask Dr. MathTM
© 1994- The Math Forum at NCTM. All rights reserved.