I have already solved the Lorenz transformation in terms of x and t, by Cramers rule on paper. I was wondering if there is a way to compute matrix operations in terms of variables, such as the inverse of some matrix. If I could take the inverse of M above and dot it with k (the solution matrix). I could solve for x and t. I have tried computing inverses of matrices of variables with no luck on python. Any help would be appreciated!
Summary: I need help computing inverses of matrices containing variables. Here is one of my attempts.
import numpy as np
from IPython.display import display
import sympy as sp
sp.init_printing() # LaTeX like pretty printing for IPython
γ, xp, tp, x, t, v, c = sp.symbols('γ, xp, tp, x, t, v, c')
k = sp.Matrix( [ xp, tp ] )
M = sp.Matrix([ [ γ , -γ*v],
[-γ*v/c**2 , γ ] ])
Minv = np.linalg.inv(M)
NumPy only operates on numeric types, not symbols. Try the sympy method directly. Either M.inv() if you don't have a specific method in mind, or M.inverse_{METHOD} if you do have a specific method in mind.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.