[Math] Differentiate the squared dot product

derivativeslinear algebravectors

I am new to Mathematics stack exchange community and has no experience in asking question so please bear with me. I am watching deep learning course from Coursera and encounter a question during the video.
$$\left|\frac d{d\vec x}(\vec x\cdot\vec x)^2\right|=?$$
$$\vec x=\begin{bmatrix}x_1\\x_2\end{bmatrix}=\begin{bmatrix}3\\4\end{bmatrix}$$
I am not sure how to perform dot product on 2 vectors since they are 2×1 and 2×1 dimension. Please guide me! Thanks

Note:
After some try and error, I got the answer, but I don't understand the solution.

enter image description here

Best Answer

Note that

$$(\vec x \cdot \vec x)^2=|\vec x|^4=(x_1^2+x_2^2)^2$$

Thus: $$\frac{d(\vec x \cdot \vec x)^2}{d\vec x} =\left(\frac{\partial(\vec x \cdot \vec x)^2}{\partial x_1},\frac{\partial(\vec x \cdot \vec x)^2}{\partial x_2}\right) =(4x_1(x_1^2+x_2^2),4x_2(x_1^2+x_2^2))$$

$$\left|\frac{d(\vec x \cdot \vec x)^2}{d\vec x} \right|=\sqrt{16x_1^2(x_1^2+x_2^2)^2+16x_2^2(x_1^2+x_2^2)^2}=4(x_1^2+x_2^2)^{\frac32}=4|\vec x|^3$$

You can also apply the ordinary rules using the product rule:

$$\frac{d(\vec x \cdot \vec x)^2}{d\vec x} =2(\vec x \cdot \vec x)\vec x+2(\vec x \cdot \vec x)\vec x=4\vec x|\vec x|^2$$