# How is this algebra derived?

In Gilbert Strang's linear algebra book, question 29 in section 1.2 gives:

$x + y + z = 0$

It then asks why, given that vector v = (x, y, z) and w = (z, x, y), that the value of $\frac{v\cdot w}{||v|| ||w||}$ is always $-\frac12$.

I began solving it on my own but got stuck at xz + yz + xy. When I looked at the solution it gave me this:

$x⋅y = xz+yz+xy=\frac 12(x+y+z)^2−\frac12(x^2+y^2+z^2)$

My question is how is this done? How did they get the right hand side?

The solution ends by going from the algebra above to stating $v\cdot w = 0 - \frac 12 ||v||||w||.$ Then $cos\theta = -\frac 12$. This part I understand just fine.

Similar question was asked here: Converting dot producto to set of arithmetic mean differences?, and it gives me a clue with the arithmetic mean difference, but that I don't understand.

• $(x+y+z)^2=x^2+y^2+z^2+2xy+2xz+2zy$ May 15, 2018 at 12:58

Vasya's comment is correct. We start by expanding the square as follows...

$$(x+y+z)^2 = x^2+y^2+z^2+2xy+2yz+2zx$$

From this expression we can derive the formula you want in 3 steps.

1. Factor out the 2 $$(x+y+z)^2 = x^2+y^2+z^2+2(xy+yz+zx)$$

2. Subtract the squares $$(x+y+z)^2 - (x^2+y^2+z^2) = 2(xy+yz+zx)$$

3. Divide by 2 $$\frac{1}{2}(x+y+z)^2 - \frac{1}{2}(x^2+y^2+z^2) = xy+yz+zx$$

Now we just notice that the RHS is the inner product of your two vectors $$v$$ and $$w$$ and we're done.

$$\frac{1}{2}(x+y+z)^2 - \frac{1}{2}(x^2+y^2+z^2) = xy+yz+zx = v\cdot w$$