0

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

tribbloid
  • 167
  • 4
  • 3
    Despite people asking questions like this now and then, you are likely to find that there is almost no support in MMA for "abstract" matricies or "abstract" vectors or sums or products, etc. I don't think anyone has written a package for MMA to do this in the last 30 years and I assume that means there are likely deep insurmountable reasons for this. – Bill Aug 25 '17 at 04:27
  • @Bill, thanks a lot for sharing your exp! I'm still curious about the reason, so I updated the question. – tribbloid Aug 25 '17 at 19:45

0 Answers0