sympy / sympy

A computer algebra system written in pure Python
https://sympy.org/
Other
13.01k stars 4.45k forks source link

Implement MatrixFunction #5855

Open asmeurer opened 13 years ago

asmeurer commented 13 years ago
We need a class MatrixFunction, like MatrixSymbol that contains arguments, so, e.g., we can differentiate with respect to them.

Also, when you do MatrixSymbol()(t), it creates a commutative Function (see issue 3539 ).  

In [54]: A = MatrixSymbol('A', n, n)(t)

In [55]: x = MatrixSymbol('x', m, n)

In [56]: x*A
Out[56]: A(t)⋅x

In [57]: A*x
Out[57]: A(t)⋅x

In [58]: type(A)
Out[58]: sympy.core.function.A

This should either raise TypeError or create a MatrixFunction.

Original issue for #5855: http://code.google.com/p/sympy/issues/detail?id=2756 Original author: https://code.google.com/u/asmeurer@gmail.com/ Referenced issues: #3539 Original owner: https://code.google.com/u/asmeurer@gmail.com/

mrocklin commented 13 years ago
Hrm, the Symbol(...)(t) syntax is new to me. 
A temporary fix might be to disable this syntax for MatrixSymbols until someone builds a MatrixFunction class. I may get to this but its not likely to be in the immediate future. 

More long term is the goal here to have matrix valued functions? What are some compelling use cases? Most of the time when I think of derivatives and matrices I think more of gradients of vector valued functions, not differentiating w.r.t. a matrix symbol (although this happens too of course).

Original comment: http://code.google.com/p/sympy/issues/detail?id=2756#c1 Original author: https://code.google.com/u/109882876523836932473/

asmeurer commented 13 years ago
So actually we would want to support functions of matrices as well as functions of real (or complex) parameters.  I guess we could just have one MatrixFunction and it could be inferred from the type of the argument.

Symbol()(t) converts to Function()(t) because this allows the parser to just convert all unknown names into Symbols, without having to check if they really should be Functions. Since the parser won't handle MatrixSymbol, I think just disabling this for now is a good fix.

Original comment: http://code.google.com/p/sympy/issues/detail?id=2756#c2 Original author: https://code.google.com/u/asmeurer@gmail.com/

asmeurer commented 13 years ago
See also issue 5858 (which is a much more important issue to fix, btw, as our computed derivatives with respect to matrices are simply wrong).

Referenced issues: #5858 Original comment: http://code.google.com/p/sympy/issues/detail?id=2756#c3 Original author: https://code.google.com/u/asmeurer@gmail.com/

asmeurer commented 12 years ago
**Status:** Valid  

Original comment: http://code.google.com/p/sympy/issues/detail?id=2756#c4 Original author: https://code.google.com/u/asmeurer@gmail.com/

zouhairm commented 2 years ago

Is this still worked on, if not, is there an alternative to being able to to define vectors/matrices that are "dynamic symbols" (i.e. functions of t) for use with kinematics/dynamics package?