Factorization of polynomials and simplification of expressions The formula for the difference of two squares can be used for factoring
polynomials that contain the square of a first quantity minus the square of a second quantity. For example, the polynomial x^4 - 1 can be factored as follows: x^4 - 1 = (x^2 + 1)(x^2 - 1) = (x^2 + 1)(x + 1)(x - 1). As a second example, the first two terms of x^2 - y^2 + x - y can be factored as (x + y)(x - y), so we have: x^2 - y^2 + x - y = (x + y)(x - y) + x - y = (x - y)(x + y + 1). Moreover, this formula can also be used for simplifying expressions: (a+b)^2-(a-b)^2=(a+b+a-b)(a+b-a+b)=(2a)(2b)=4ab.
Complex number case: sum of two squares The difference of two squares can be used to find the
linear factors of the
sum of two squares, using
complex number coefficients. For example, the complex roots of z^2 + 4 can be found by introducing a factor of -i^2 = 1, and using the difference of two squares: \begin{align} z^2 + 4 &= z^2 - 4i^2 \\ &= z^2 - (2 i)^2 \\ &= (z + 2 i)(z - 2 i). \\ \end{align} Therefore, the linear factors are (z + 2 i) and (z - 2 i). Since the two factors found by this method are
complex conjugates, we can use this in reverse as a method of multiplying a complex number to get a real number. This is used to get real denominators in complex fractions.
Rationalising denominators The difference of two squares can also be used, in reverse, in the
rationalising of
irrational denominators. This is a method for removing
surds from expressions (or at least moving them), applying to division by some combinations involving
square roots. For example, the denominator of \frac{5}{4 + \sqrt{3}} can be rationalised as follows: \begin{align} \dfrac{5}{4 + \sqrt{3}} &= \dfrac{5}{4 + \sqrt{3}} \times \dfrac{4 - \sqrt{3}}{4 - \sqrt{3}} \\[10mu] &= \dfrac{5\bigl(4 - \sqrt{3}\bigr)}{4^2 - \sqrt{3}^2} = \dfrac{5\bigl(4 - \sqrt{3}\bigr)}{16 - 3} = \frac{5\bigl(4 - \sqrt{3}\bigr)}{13}. \end{align} Here, the irrational denominator 4 + \sqrt{3} has been rationalised to 13.
Mental arithmetic The difference of two squares can also be used as an arithmetical shortcut. If two numbers have an easily squared average, their product can be rewritten as the difference of two squares. For example: 27 \times 33 = (30 - 3)(30 + 3) = 30^2 - 3^2 = 891.
Difference of two consecutive perfect squares The difference of two consecutive
perfect squares is the sum of the two
bases and . This can be seen as follows: \begin{align} (n+1)^2 - n^2 &= ((n+1)+n)((n+1)-n) \\[5mu] &= 2n+1. \end{align} Therefore, the difference of two consecutive perfect squares is an odd number. Similarly, the difference of two arbitrary perfect squares is calculated as follows: \begin{align} (n+k)^2 - n^2 &= ((n+k)+n)((n+k)-n) \\[5mu] &= k(2n+k). \end{align} Therefore, the difference of two even perfect squares is a multiple of and the difference of two odd perfect squares is a multiple of .
Galileo's law of odd numbers A ramification of the difference of consecutive squares,
Galileo's law of odd numbers states that the distance covered by an object falling without resistance in uniform gravity in successive equal time intervals is linearly proportional to the odd numbers. That is, if a body falling from rest covers a certain distance during an arbitrary time interval, it will cover , , , etc. times that distance in the subsequent time intervals of the same length. From the equation for uniform linear acceleration, the distance covered s = u t + \tfrac{1}{2} a t^2 for initial speed u = 0, constant acceleration a (acceleration due to gravity without air resistance), and time elapsed t, it follows that the distance s is proportional to t^2 (in symbols, s \propto t^2), thus the distance from the starting point are consecutive squares for
integer values of time elapsed.
Factorization of integers Several algorithms in
number theory and cryptography use differences of squares to find factors of integers and detect composite numbers. A simple example is the
Fermat factorization method, which considers the sequence of numbers x_i:=a_i^2-N, for a_i:=\left\lceil \sqrt{N}\right\rceil+i. If one of the x_i equals a perfect square b^2, then N=a_i^2-b^2=(a_i+b)(a_i-b) is a (potentially non-trivial) factorization of N. This trick can be generalized as follows. If a^2\equiv b^2 mod N and a\not\equiv \pm b mod N, then N is composite with non-trivial factors \gcd(a-b,N) and \gcd(a+b,N). This forms the basis of several factorization algorithms (such as the
quadratic sieve) and can be combined with the
Fermat primality test to give the stronger
Miller–Rabin primality test. ==Generalizations==