I'm trying to understand my exam solution from the lecturer, but I got confused over one small thing in the solution.
Problem: Consider $f(x)=\frac{1}{2}x^{T}Ax - b^{T}x$
Where $A=\begin{bmatrix}2&1\\1&4\end{bmatrix}$ , $b=\begin{bmatrix}0\\7\end{bmatrix}$ and $x=\begin{bmatrix}x\\y\end{bmatrix}$
Caclulate $\nabla f(x)$.
Solution: From the theory we know that if $A$ is symmetric, we get
$\nabla f(x)= Ax - b^{T}$
$\nabla f(x)=\begin{bmatrix}2x+y\\x+4y-7\end{bmatrix}$
Is it a typo on the answer, where $Ax-b^{T}$ should've been written as $Ax-b$?
If it should've been written as $b$, then I understand why we have $-7$ in the 2nd row.
Thank you
There is no typo, you need to transpose $b$ if you want to compute its scalar product with $x$ (quick check, treat this as a normal matrix-matrix multiplication: the dimensions would not agree without transposition!).
And yes, $\nabla (b^Tx) = b$.
In this case, since there are only two components, we can compute everything by hand. You can then understand how this generalizes, once you figure out what happens when applying the gradient.
We have:
$$b^Tx = \begin{bmatrix} 0 & 7\end{bmatrix} \cdot \begin{bmatrix} x \\ y \end{bmatrix} = 0x + 7y$$
and since
$$\nabla = \begin{bmatrix} \frac{\partial}{\partial x} \\ \frac{\partial}{\partial y} \end{bmatrix},$$
you can compute
$$\nabla (b^Tx) = \begin{bmatrix} \frac{\partial}{\partial x} (0x + 7y) \\ \frac{\partial}{\partial y} (0x + 7y) \end{bmatrix} = \begin{bmatrix} 0 \\ 7 \end{bmatrix}.$$