How do I calculate gradient?

51 Views Asked by At

$q(x)=x^TAx+b^Tx+c$ Where A is matrix,

$x,b\in \mathbb{R}^n $

$c\in \mathbb{R}$

So someone in my book wrote that q(x) is the same like $q(x)=a_{11}x_1^2+...a_{nn}x_n^2+2a_{12}x_1x_2...+2a_{ij}x_ix_j+ b_1x_1....b_nx_n + c$

Can someone explain me how they get that and what is that? Thank you

2

There are 2 best solutions below

0
On

Since your $x$ and $b$ are in $\mathbb{R}^n$, then you may write $$x=\begin{bmatrix} x_1 \\ x_2 \\ \vdots \\ x_n\end{bmatrix}, \quad b=\begin{bmatrix} b_1 \\ b_2 \\ \vdots \\ b_n\end{bmatrix} $$

Then your $A$ is surely an $n \times n$ matrix, and it can be also written as $$ A=\begin{bmatrix} a_{11} & a_{12} & \cdots & a_{1n}\\ a_{21} & a_{22} & \cdots & a_{2n}\\ \vdots & \vdots & \vdots & \vdots \\ a_{n1} & a_{n2} & \cdots & a_{nn}\end{bmatrix} $$ Now try expanding your $q(x)$ you will get the desired answer.

0
On

$\nabla q(\boldsymbol{x})= (\boldsymbol{A}+\boldsymbol{A}^{T})\, \boldsymbol{x}+\boldsymbol{b}$