New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exponential of MatrixSymbol only has very limited working operator set(undocumented) #16813
Comments
my goal is to do a bit of matrix calculus, e.g. differentiate expresslions like g^T exp(Q) v /||exp(Q) v||. Any chances with sympy? |
I don't think that exponential of matrix symbol is implemented. For numeric matrices, you may use |
Is it possible to define a custom function using the sympy.Function object which returns a matrix? Even this might solve the problem. I am facing the same issue and would like to calculate
where |
There isn't a way to make matrix-valued function right now. It should be possible to add something like that based on the kind system. |
Okay, if that is not possible, then I see another way out. I can define an expression using just symbols, for example
Then I would like to generate a Numpy function using Lambdify, but which can take matrices as input. I have tried this before and it works after replacing all the exp with expm from Scipy. But, the only caveat being that the multiplication is element wise multiplication. This is fine if the matrices are diagonal, but now I have a scenario where I need them to be a general matrix. So, is it possible to use Lambdify such that all the multiplication operators in the expression can be replaced with @ or matrix multiplication? This will be a good workaround for the same issue discussed here, at least for numerical implementation. |
I think there are 2 generic approaches to applying functions to a matrix:
You could write either explicitly |
It looks like there is scipy.linalg.expm to compute nonelementwise matrix exponential. That needs to be implemented with lambdify with the introduction of new sympy function for matrix exponential. |
A few examples in live.sympy.org with sympy 1.4:
leads to:
Trace(exp(A))
The text was updated successfully, but these errors were encountered: