Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Difference of two squares
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|Mathematical identity of polynomials}} In [[elementary algebra]], a '''difference of two squares''' is one [[square (algebra)|squared]] number (the number multiplied by itself) [[subtraction|subtracted]] from another squared number. Every difference of squares may be [[Factorization|factored]] as the [[Multiplication|product]] of the [[addition|sum]] of the two numbers and the [[Subtraction|difference]] of the two numbers: <math display=block>a^2-b^2 = (a+b)(a-b).</math> In the reverse direction, the product of any two numbers can be expressed as the difference between the square of their [[arithmetic mean|average]] and the square of half their difference: <math display=block>xy = \left(\frac{x + y}{2}\right)^2 - \left(\frac{x - y}{2}\right)^2.</math> ==Proof== === Algebraic proof === The [[mathematical proof|proof]] of the factorization identity is straightforward. Starting from the [[Sides of an equation|right-hand side]], apply the [[distributive law]] to get <math display=block>(a+b)(a-b) = a^2+ba-ab-b^2.</math> By the [[commutative law]], the middle two terms cancel: <math display=block>ba - ab = 0</math> leaving<ref name="bbc-bitesize">{{cite web |title=Difference of two squares - Factorising an algebraic expression - National 5 Maths Revision |url=https://www.bbc.co.uk/bitesize/guides/zmvrd2p/revision/2 |website=BBC Bitesize |access-date=9 April 2025}}</ref> <math display=block>(a+b)(a-b) = a^2-b^2.</math> The resulting identity is one of the most commonly used in mathematics. Among many uses, it gives a simple proof of the [[AM–GM inequality]] in two variables. The proof holds not only for numbers, but for elements of any [[commutative ring]]. Conversely, if this identity holds in a [[ring (mathematics)|ring]] {{mvar|R}} for all pairs of elements {{mvar|a}} and {{mvar|b}}, then {{mvar|R}} is commutative. To see this, apply the distributive law to the right-hand side of the equation and get <math display=block>a^2 + ba - ab - b^2.</math> For this to be equal to {{tmath|\textstyle a^2 - b^2}}, we must have <math display=block>ba - ab = 0</math> for all pairs {{mvar|a}}, {{mvar|b}}, so {{mvar|R}} is commutative. === Geometric proof === [[Image:Difference of two squares.svg|right|170px]] The difference of two squares can also be illustrated geometrically as the difference of two square areas in a [[Plane (mathematics)|plane]]. In the diagram, the shaded part represents the difference between the areas of the two squares, i.e. <math>a^2 - b^2</math>. The area of the shaded part can be found by adding the areas of the two rectangles; <math>a(a-b) + b(a-b)</math>, which can be factorized to <math>(a+b)(a-b)</math>. Therefore, <math>a^2 - b^2 = (a+b)(a-b)</math>. Another geometric proof proceeds as follows. We start with the figure shown in the first diagram below, a large square with a smaller square removed from it. The side of the entire square is a, and the side of the small removed square is b; thus, the area of the shaded region is <math>a^2-b^2</math>. A cut is made, splitting the region into two rectangular pieces, as shown in the second diagram. The larger piece, at the top, has width a and height a-b. The smaller piece, at the bottom, has width a-b and height b. Now the smaller piece can be detached, rotated, and placed to the right of the larger piece. In this new arrangement, shown in the last diagram below, the two pieces together form a rectangle, whose width is <math>a+b</math> and whose height is <math>a-b</math>. This rectangle's area is <math>(a+b)(a-b)</math>. Since this rectangle came from rearranging the original figure, it must have the same area as the original figure. Therefore, <math>a^2-b^2 = (a+b)(a-b)</math>.<ref>{{cite journal |last1=Slavit |first1=David |title=Revisiting a Difference of Squares |journal=Mathematics Teaching in the Middle School |date=2001 |volume=6 |issue=6 |page=381 |url=https://www.jstor.org/stable/41180978 |access-date=10 April 2025 |issn=1072-0839}}</ref> [[Image:Difference of two squares geometric proof.png]] ==Usage== ===Factorization of polynomials and simplification of expressions=== The formula for the difference of two squares can be used for factoring [[polynomial]]s that contain the square of a first quantity minus the square of a second quantity. For example, the polynomial <math>x^4 - 1</math> can be factored as follows: <math display=block>x^4 - 1 = (x^2 + 1)(x^2 - 1) = (x^2 + 1)(x + 1)(x - 1).</math> As a second example, the first two terms of <math>x^2 - y^2 + x - y</math> can be factored as <math>(x + y)(x - y)</math>, so we have: <math display=block> x^2 - y^2 + x - y = (x + y)(x - y) + x - y = (x - y)(x + y + 1). </math> Moreover, this formula can also be used for simplifying expressions: <math display=block> (a+b)^2-(a-b)^2=(a+b+a-b)(a+b-a+b)=(2a)(2b)=4ab. </math> ===Complex number case: sum of two squares=== The difference of two squares is used to find the [[linear factors]] of the ''sum'' of two squares, using [[complex number]] coefficients. For example, the complex roots of <math>z^2 + 4</math> can be found using difference of two squares: <math display=block>\begin{align} z^2 + 4 &= z^2 - 4i^2 \\ &= z^2 - (2 i)^2 \\ &= (z + 2 i)(z - 2 i). \\ \end{align}</math> Therefore, the linear factors are <math>(z + 2 i)</math> and <math>(z - 2 i)</math>. Since the two factors found by this method are [[complex conjugate]]s, 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.<ref>[http://www.themathpage.com/alg/complex-numbers.htm#conjugates Complex or imaginary numbers] TheMathPage.com, retrieved 22 December 2011</ref> ===Rationalising denominators=== The difference of two squares can also be used, in reverse, in the [[Rationalisation (mathematics)|rationalising]] of [[irrational number|irrational]] [[denominator]]s.<ref>[http://www.themathpage.com/alg/multiply-radicals.htm Multiplying Radicals] TheMathPage.com, retrieved 22 December 2011</ref> This is a method for removing [[Nth root|surds]] from expressions (or at least moving them), applying to division by some combinations involving [[square root]]s. For example, the denominator of <math>5 \big/ \bigl(4 + \sqrt{3}\bigr)</math> can be rationalised as follows: <math display=block>\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}</math> Here, the irrational denominator <math>4 + \sqrt{3}</math> has been rationalised to <math>13</math>. ===Mental arithmetic=== {{Main|Multiplication algorithm#Quarter square multiplication}} 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: <math display=block> 27 \times 33 = (30 - 3)(30 + 3) = 30^2 - 3^2 = 891.</math> ===Difference of two consecutive perfect squares=== The difference of two consecutive [[square number|perfect square]]s is the sum of the two [[base (exponentiation)|base]]s {{mvar|n}} and {{math|''n'' + 1}}. This can be seen as follows: <math display=block>\begin{align} (n+1)^2 - n^2 &= ((n+1)+n)((n+1)-n) \\[5mu] &= 2n+1. \end{align}</math> Therefore, the difference of two consecutive perfect squares is an odd number. Similarly, the difference of two arbitrary perfect squares is calculated as follows: <math display=block>\begin{align} (n+k)^2 - n^2 &= ((n+k)+n)((n+k)-n) \\[5mu] &= k(2n+k). \end{align} </math> Therefore, the difference of two even perfect squares is a multiple of {{math|4}} and the difference of two odd perfect squares is a multiple of {{math|8}}. ===Galileo's law of odd numbers=== [[File:Galileo's_law_of_odd_numbers.svg|thumb|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 {{math|3}}, {{math|5}}, {{math|7}}, etc. times that distance in the subsequent time intervals of the same length. From the equation for uniform linear acceleration, the distance covered <math display=block>s = u t + \tfrac{1}{2} a t^2</math> for initial speed <math>u = 0,</math> constant acceleration <math>a</math> (acceleration due to gravity without air resistance), and time elapsed <math>t,</math> it follows that the distance <math>s</math> is proportional to <math>t^2</math> (in symbols, <math>s \propto t^2</math>), thus the distance from the starting point are consecutive squares for integer values of time elapsed.<ref>RP Olenick et al., [https://books.google.com/books?id=xMWwTpn53KsC&pg=PA18 ''The Mechanical Universe: Introduction to Mechanics and Heat'']</ref> ===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 <math>x_i:=a_i^2-N</math>, for <math>a_i:=\left\lceil \sqrt{N}\right\rceil+i</math>. If one of the <math>x_i</math> equals a perfect square <math>b^2</math>, then <math>N=a_i^2-b^2=(a_i+b)(a_i-b)</math> is a (potentially non-trivial) factorization of <math>N</math>. This trick can be generalized as follows. If <math>a^2\equiv b^2</math> mod <math>N</math> and <math>a\not\equiv \pm b</math> mod <math>N</math>, then <math>N</math> is composite with non-trivial factors <math>\gcd(a-b,N)</math> and <math>\gcd(a+b,N)</math>. 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== [[Image:Rhombus understood analytically.svg|thumb|right|Vectors {{math|'''a'''}} (purple), {{math|'''b'''}} (cyan) and {{math|'''a''' + '''b'''}} (blue) are shown with [[arrow (symbol)|arrows]]]] The identity also holds in [[inner product space]]s over the [[field (mathematics)|field]] of [[real numbers]], such as for [[dot product]] of [[Euclidean vector]]s: :<math>{\mathbf a}\cdot{\mathbf a} - {\mathbf b}\cdot{\mathbf b} = ({\mathbf a}+{\mathbf b})\cdot({\mathbf a}-{\mathbf b})</math> The proof is identical. For the special case that {{math|'''a'''}} and {{math|'''b'''}} have equal [[normed vector space|norms]] (which means that their dot squares are equal), this demonstrates [[analytic geometry|analytically]] the fact that two diagonals of a [[rhombus]] are [[right angle|perpendicular]]. This follows from the left side of the equation being equal to zero, requiring the right side to equal zero as well, and so the vector sum of {{math|'''a''' + '''b'''}} (the long diagonal of the rhombus) dotted with the vector difference {{math|'''a''' − '''b'''}} (the short diagonal of the rhombus) must equal zero, which indicates the diagonals are perpendicular. ===Difference of two ''n''th powers=== [[File:Difference_of_squares_and_cubes_visual_proof.svg|thumb|Visual proof of the differences between two squares and two cubes]] If {{mvar|a}} and {{mvar|b}} are two elements of a commutative ring, then<ref>{{cite book |last=Grigorieva |first=Ellina |title=Methods of Solving Nonstandard Problems |isbn=978-3-319-19886-6 |doi=10.1007/978-3-319-19887-3_2 |publisher=Birkhäuser |at=Eq. 2.13, {{pgs|83}} |year=2015 }}</ref> <math display=block>a^n-b^n=(a-b)\biggl(\sum_{k=0}^{n-1} a^{n-1-k}b^k\biggr).</math> The second factor looks similar to the [[binomial theorem|binomial expansion]] of <math>(a+b)^{n-1}</math>, except that it does not include the [[binomial coefficient]]s {{tmath|\tbinom{n-1}{k} }}. ==See also== *[[Sum of two cubes]] *[[Binomial number]] *[[Sophie Germain's identity]] *[[Aurifeuillean factorization]] *[[Congruum]], the shared difference of three squares in arithmetic progression *[[Conjugate (algebra)]] *[[Factorization]] ==Notes== {{reflist}} ==Further reading== *{{cite book |first=James Stuart |last=Stanton |title=Encyclopedia of Mathematics |publisher=Infobase Publishing |year=2005 |isbn=0-8160-5124-0 |page=131 |url=https://books.google.com/books?id=MfKKMSuthacC&pg=PA131 }} *{{cite book |first1=Alan S. |last1=Tussy |first2=Roy David |last2=Gustafson |title=Elementary Algebra |edition=5th |publisher=Cengage Learning |year=2011 |isbn=978-1-111-56766-8 |pages=467–469 |url=https://books.google.com/books?id=xwOrtVKSVpoC&pg=PA467 }} ==External links== *[https://web.archive.org/web/20170215183255/http://themathpage.com/alg/difference-two-squares.htm difference of two squares] at mathpages.com [[Category:Algebraic identities]] [[Category:Commutative algebra]] [[Category:Articles containing proofs]] [[Category:Subtraction]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite book
(
edit
)
Template:Cite journal
(
edit
)
Template:Cite web
(
edit
)
Template:Main
(
edit
)
Template:Math
(
edit
)
Template:Mvar
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Tmath
(
edit
)