A Number Theory

Any integer can be expressed as the difference of two squared integers, unless it is divisible by 2 and not by 4.

Call the two integers to be squared p and q. We can also express q as p+n, where n is an integer.

Let f(p,n= (p+n)² − p²
= 2np + n²
= n × (2p + n)

Let xn = f(p,n)

Then, x1 = 2p + 1
⇒ {x1} ≡ {..., -5, -3, -1, 1, 3, 5, ...}
And x2 = 4p + 4
⇒ {x2} ≡ {..., -12, -8, -4, 0, 4, 8, 12, ...}

For any integer α, we have:
x2α+1 = (4α+2)p + (4α²+4α+1)
⇒ {x2α+1} ⊆ {x1}
x2α = 4αp + 4α²
⇒ {x2α} ⊆ {x2}

So every number that can be expressed as the difference between two squared integers is contained either within the set of odd integers or the set of integer multiples of 4. It follows that any other integer cannot be expressed as the difference of two squared integers, and that all of these must be divisible by 2 (since they are not odd) but not by 4. So three-quarters of the integers can be expressed as this difference in at least one way, and depending on its factors, in more than one way.

Factorising Numbers

Each number that can be expressed as the difference of two squares, can be so expressed in more than one way. Representing the number in terms of its factors can give every way this can be done. We can achieve this by using the following equality (to show this is an equality, expand the brackets and cancel like terms):

   x = a × b
= (a/2 + b/2)² − (a/2 − b/2)²
= q² − p²

So if the two factors a and b are either both odd or both even, then this gives integer values for p and q as required from above. Note that this also shows that to be expressed as a difference of two squared integers, a number must either be odd (giving it only odd factors) or divisible by 4 (giving it the possibility of two even factors that can be multiplied to give the number).

This gives us then;
p = ½(ab)
q = ½(a + b)
a = 2p + n
b = n

For a pair of positive integer factors a and b (ab) we can in fact represent x in four ways:

  1. x = [½(a + b)]² − [½(ab)]²
  2. x = [−½(a + b)]² − [½(ab)]²
  3. x = [½(a + b)]² − [−½(ab)]²
  4. x = [−½(a + b)]² − [−½(ab)]²

And if we have x which is a square number, with a positive integer root of n, we have two ways to represent x:

  1. x = n² − 0²
  2. x = (−n)² − 0²

Summary

Summing up, a positive integer x may be represented as the difference of the squares of two integers. The number of ways in which this can be done (ie the number of unique pairs of integers that can be squared and subtracted to give x) is equal to four times the number of unique pairs of positive integer factors a, b (such that a×b=x) where a and b are either both odd or both even, less two if x is a square number.

If a number has no such pair of factors, then it cannot be so represented. This will only be the case if the number is divisible by 2 but not by 4. This is because in any pair of factors a, b (such that a×b=x) one of the pair must be even and one must be odd.

1 and 4 can each be represented in two ways only:
 1 = 1² − 0²
= (−1)² − 0²
 4 = 2² − 0²
= (−2)² − 0²

Prime numbers can each be represented in four ways only (they can only be factorised as x×1):
 x = (½x + ½)² − (½x − ½)²
= (−½x − ½)² − (½x − ½)²
= (½x + ½)² − (−½x + ½)²
= (−½x − ½)² − (−½x + ½)²

Also, numbers that are 4 times a prime number can each be represented in four ways only:
 x = (¼x + 1)² − (¼x − 1)²
= (−¼x − 1)² − (¼x − 1)²
= (¼x + 1)² − (−¼x + 1)²
= (−¼x − 1)² − (−¼x + 1)²

Any other positive integers (ie non-prime odd numbers, and numbers that are divisible by 4 and are not 4 times a prime number) can be represented in more than four ways (in fact, at least six ways) as the difference of two squared integers.

Negative integers can be represented in the same number of ways as their positive complements (x = q² − p² gives −x = p² − q²).

Zero can be represented in an infinite number of ways (0 = n² − n²...).

Help! Maths!