Considering the following simple problem:
Given $A$ an n x n matrix, $B$ an n-dimensional column vector, find the gradient:
$$\nabla _B((A B) . (A B))$$
The solution is obviously $2(A + A^T) B$, but Mathematica seems to have a hard time finding the close form solution:
In[17]:= TensorExpand[v, Element[A,Matrices[{d,d},Reals]]&&Element[B,Vectors[{d},Reals]]]
Out[17]= TensorExpand[(A B).(A B),A\[Element]Matrices[{d,d},Reals,{}]&&B\[Element]Vectors[d,Reals]]
In[14]:= Grad[v,A]
Out[14]= \!\(\*
SubscriptBox["\[Del]",
TemplateArgBox["A"]]\*
TemplateArgBox[
RowBox[{"(",
RowBox[{
RowBox[{"(",
RowBox[{"A", " ", "B"}], ")"}], ".",
RowBox[{"(",
RowBox[{"A", " ", "B"}], ")"}]}], ")"}]]\)
What function should I use to solve this simple problem? Thanks a lot for any help!
UPDATE Now I know that such facet of symbolic computing is not very aligned with the scope of Mathematica, is there a reason why it is considered too trivial or too hard to be implemented?
Yours Peng