# Taking the Dot Product

How can I take the dot product for this problem: $||w +z-\hat w||^2$?

Solution: $||w - \hat w||^2 + 2\langle w - \hat w , z \rangle + ||z||^2$

-

First recall that $\Vert x \Vert^2 = \langle x,x \rangle$. Denoting $w - \hat{w}$ as $x$, we get that, $$\Vert w + z - \hat{w} \Vert^2 = \Vert x+z \Vert^2 = \langle x+z, x+z \rangle$$ Now recall that for the inner product, we have $$\langle a+b, c+d \rangle = \langle a+b,c \rangle + \langle a+b, d \rangle = \langle a,c \rangle +\langle b,c \rangle + \langle a, d \rangle + \langle b, d \rangle$$ Hence, we get that $$\langle x+z, x+z \rangle = \langle x,x \rangle + \langle x,z \rangle + \langle z,x \rangle + \langle z,z \rangle$$ Assuming your vectors are in $\mathbb{R}^n$, we have that $$\langle a,b \rangle = \langle b,a \rangle$$ Hence, we get that $$\langle x+z, x+z \rangle = \langle x,x \rangle + 2 \langle x,z \rangle + \langle z,z \rangle$$ Hence, $$\Vert w + z - \hat{w} \Vert^2 = \langle w-\hat{w},w-\hat{w} \rangle + 2 \langle w-\hat{w},z \rangle + \langle z,z \rangle = \Vert w-\hat{w} \Vert^2 + 2 \langle w-\hat{w},z \rangle + \Vert z \Vert^2$$

-
Beautiful, thank you very much, Marvis! –  diimension Nov 28 '12 at 9:03

$||x+y||_2^2=(x+y)^T(x+y)=||x||_2^2+2x^Ty+||y||_2^2$. Now put $x=w-\hat{w}$ and $y=z$.

-
Thanks, dineshdileep! –  diimension Nov 28 '12 at 9:04