On 10 January 2012 10:26, John B <[email protected]> wrote: > On Jan 9, 6:42 am, Matthew <[email protected]> wrote: > > You could do the above by explicitly making a scalar symbol for each > > of x[0], x[1], ... > > > Hello Matthew. I realize I could use a scalar for each x[i], but I > was looking for a way to use only the vector symbol x[i]. It makes > the results of differentiation much more tidy, especially when f has > many terms. You can do this in Mathematica and it is a nice feature. > In my example, f = Sum(5*x[i]**2, (i,0,n)), x[i] is a vector. In > Mathematica you can also symbolically differentiate with matrices. > For example, you can take the derivative of f = Sum(5*x[i,j]**2, (i, > 0,n)) and obtain the symbolic result: > df/dx = Sum(10*x[i,j], (i,0,n)) > I don't understand that last result. I looked up the definition of matrix derivative in wikipedia but the article is disputed and the definition is not complete. Could you show me some resource where the definition and usecases are shown?
Back to your question. I don't think there is a direct way to do this with sympy at the moment. But... There is DeferredVector that with some work can be extended to do this. But I don't think that the idea behind it was to do that. (The others should correct me if I'm wrong) On the other hand there was the demand for a MatrixSymbol class. I suppose that is the way to do what you want but this is not yet implemented. If you think that it covers what you want to do you may add to the discussion on the wiki page https://github.com/sympy/sympy/wiki/Matrix-Expressions I also saw that the tensor analysis is supposed to do the same thing (according to wikipedia). There is a tensor module (but it's actually just objects with index, not real tensors (please correct me if I'm wrong on this)). It seems to me it's used mainly for code generation so I'm not sure if it's the best tool for this problem. Finally there is the GA module that is frequently mentioned in this type of discussions. But the formalism presented by it is quite different even if it is equivalent. > John > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sympy?hl=en. > > -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
