# Symbolic derivatives with vectors and matrices

I'm currently trying to solve some problems using symbolic vectors and matrices of arbitrary size. However, I have some problems with understanding and verifying the results:

I defined the vectors as mentioned here

\$Assumptions = { Element[x, Matrices[{m, 1}, Reals]],
Element[a, Matrices[{m, 1}, Reals]] };


Now I'm trying to compute the gradient (m x 1 matrix) and hessian (m x m matrix) of the function f

f[x_, a_] := Dot[a, x]^2


using

In[144]:= D[f[x, a], x]
Out[144]= 2 a.1 a.x

In[143]:= D[f[x, a], x, Transpose[x]]
Out[143]= 0


What does a.1 mean? is it just a or more like sum[a] ? And why does the second term for the hessian just give 0? Shouldn't it be something like 2*a*Transpose[a] ?

• Derivatives for symbolic tensors are not supported. You would either have to write out components explicitly (which you can't if you don't know m), or use packages that can do this. I would look at NCAlgebra and see if it has support for derivatives. math.ucsd.edu/~ncalg/DOWNLOAD2010/DOCUMENTATION/html/… – Szabolcs Jan 11 '17 at 10:26
• @Szabolcs thanks a lot (also for the sad news ;-) ). I had a look at NCAlgebra but find it very hard to learn/understand the syntax. Do you know further alternatives (even commercial if need be)? – bonanza Jan 11 '17 at 12:38
• No, I am not very familiar with these kinds of packages. Try searching on packagedata.net – Szabolcs Jan 11 '17 at 12:43
• Just wondering if you ever found a solution for this problem? – oracle3001 Mar 16 '17 at 10:35
• @oracle3001 unfortunately no. I suppose its currently not possible with mathematica. – bonanza Mar 16 '17 at 21:39