I would like to differentiate this matrix A with respect to a vector x: $$A = x^tBxy^tx$$
where B is a known matrix. y is a vector with the same dimension with x. I tried to google but only found the result for quadratic form, not cubic like this
I would like to differentiate this matrix A with respect to a vector x: $$A = x^tBxy^tx$$
where B is a known matrix. y is a vector with the same dimension with x. I tried to google but only found the result for quadratic form, not cubic like this
On
The quantity in question is a scalar, not a matrix.
Let's find its differential and gradient. $$\eqalign{ \alpha &= x^TBxy^Tx \cr&= Bxy^T:xx^T \cr d\alpha &= Bxy^T:d(xx^T) + B\,dx\,y^T:xx^T \cr &= Bxy^T:(dx\,x^T+x\,dx^T) + xx^T:B\,dx\,y^T \cr &= (Bxy^Tx+yx^TB^Tx + B^Txx^Ty):dx \cr \frac{\partial\alpha}{\partial x} &= Bxy^Tx+yx^TB^Tx + B^Txx^Ty \cr }$$ where a colon denotes the trace/Frobenius product $$A:B={\rm tr}(A^TB)$$ And the cyclic properties of the trace allow for a number of ways to rearrange the terms in the product. For example, all of the following products are equal $$\eqalign{ A:BC &= BC:A \cr &= A^T:(BC)^T \cr &= B^TA:C \cr &= AC^T:B \cr &= etc \cr }$$
You can notice that you can separate your product into two scalars $A = (x^TBx)(y^Tx)$. $$ \nabla_x A = \left[\nabla_x(x^TBx)\right](y^Tx) + (x^TBx)\left[\nabla_x (y^Tx)\right] = y^Tx(B+B^T)x + x^TBxy. $$
If you are aware of tensor notation, it is straightforward: $$ A_{,i} = \partial_i\left(x_jB_{jk}x_ky_lx_l\right) = B_{jk}y_l \ \partial_i\left(x_jx_kx_l\right) = B_{jk}y_l\left(x_{j,i}x_kx_l+x_{j}x_{k,i}x_l+x_{j}x_kx_{l,i}\right) = \\ B_{jk}y_l\left(\delta_{ji}x_kx_l+x_{j}\delta_{ki}x_l+x_{j}x_k\delta_{li}\right)=(B_{ik}+B_{ki})x_ky_lx_l+B_{jk}x_jx_ky_i $$