# Square of Sum and Difference

## Related Calculator: Polynomial Calculator

**Square of sum and difference**:

`huge color(purple)((a+-b)^2=a^2+-2ab+b^2)`

Let's see how to derive it.

Recall, that exponent is just repeating multiplication.

Thus, we can write that `(a+b)^2=(a+b)(a+b)`.

Now, apply FOIL: `(a+b)(a+b)=a*a+a*b+b*a+b*b=a^2+2ab+b^2`.

Similarly, it can be shown, that `(a-b)^2=a^2-2ab+b^2`.

Or, more shortly: `(a+-b)^2=a^2+-2ab+b^2`.

Geometrically `(a+b)^2` represents an area of the square with side `a+b`.

But, as shown on picture, this square consist of four smaller squares with areas `a^2`, `ab`, `ab`, `b^2`.

Thus, `(a+b)^2=a^2+ab+ab+b^2=a^2+2ab+b^2`.

**Example 1**. Multiply `(2x+3y)^2`.

Here `a=2x` and `b=3y`.

Just use above formula: `(2x+3y)^2=(2x)^2+2*(2x)*(3y)+(3y)^2=4x^2+12xy+9y^2`.

Let's see how to handle minus sign.

**Example 2**. Multiply `(8/3ab-3cd)^2`.

Here `a=8/3ab` and `b=3cd`.

Now, use formula for difference: `(8/3ab-3cd)^2=(8/3ab)^2-2*(8/3ab)*(3cd)+(3cd)^2=64/9a^2b^2-16abcd+9c^2d^2`.

Finally, let's do a slightly harder example.

**Example 3**. Multiply the following: `(-xyz-5x^2)^2`.

Till now, we didn't see two minus signs, but this case can be handled easily.

There are two options:

- `a=-xyz` and `b=-5x^2`; apply sum formula.
- `a=-xyz` and `b=5x^2`; apply difference formula.

I choose second option: `(-xyz-5x^2)^2=(-xyz)^2-2*(-xyz)*(5x^2)+(5x^2)^2=x^2y^2z^2+10x^3yz+25x^4`.

From last example we see, that `color(purple)((-a-b)^2=(a+b)^2)`.

Another nice application of square of sum formula is to calculate square of a number. In many cases you can perform calculations mentally without calculator (or pen and paper).

**Example 4**. Calculate `24^2`.

We could use calculator or multiply vertically, but there is simpler way.

We know, that `20^2=400`.

Thus, `24^2=(20+4)^2=20^2+2*20*4+4^2=400+160+16=576`.

Alternatively `24^2=(30-6)^2=30^2-2*30*6+6^2=900-360+36=576`.

Note, that this method is not always the simplest.

Now, it is time to exercise.

**Exercise 1**. Multiply `(5z+3y)^2`.

**Answer**: `25z^2+30zy+9y^2`.

**Exercise 2**. Multiply `(-1/3xy^2+2x)^2`.

**Answer**: `1/9x^2y^4-4/3x^2y^2+4x^2`.

Hint: either swap summands (`(-1/3xy^2+2x)^2=(2x-1/3xy^2)^2`: commutative property of addition) or proceed as always.

**Exercise 3**. Multiply the following: `(-3x-2)^2`.

**Answer**: `9x^2+12x+4`.

**Exercise 4**. Calculate `31^2` using square of sum/difference formula.

**Answer**: `961`. Hint: `31^2=(30+1)^2` or `31^2=(40-9)^2` (however, first option is easier).