complex matrix in sympy using python

pangpangwang

I was using Sympy in Python to conduct some Matrix operations. I have found that Matrix in Sympy cannot process complex automatically. For an easy example

Matrix([[-3007.52907429211/(2898092.62249243 - 706897.569072986*I) -      1/(-138.749949129781 - 2.9947535188934*I) + 5926.32998065723*I/(2898092.62249243 - 706897.569072986*I), 69.4741898294738/(-20767.5225629041 + 5543.00153023887*I) - 42.6513068752839*I/(-20767.5225629041 + 5543.00153023887*I)], [69.4741898294738/(-20767.5225629041 + 5543.00153023887*I) - 42.6513068752839*I/(-20767.5225629041 + 5543.00153023887*I), -1/(148.74433463588 - 43.1600457323684*I)]])

I have tried .expand and it doesn't work. I think there must be a way to let Matrix compute complex I automatically. Please let me know. Thank you!

J Richard Snape

I'm assuming you have imported I as you aren't reporting stack trace type errors.

In which case, you need to add the complex=True argument to .expand()

m = <Your matrix values from above>
simplified_m = m.expand(complex=True)

I am not 100% sure why this is necessary - if the reason behind it is important to you, I can research further.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Partial fraction decomposition using SymPy / Python

From Dev

Python Sympy Pretty Output of Matrix

From Dev

merge complex matrix with python

From Dev

Sympy Complex Matrix Inversion/Operations

From Dev

Factor to complex roots using sympy

From Dev

Sympy absolute value of complex exponential

From Dev

Matlab complex matrix magnitude

From Dev

Solve ode in python with complex matrix as initial value

From Dev

complex matrix in sympy using python

From Dev

Tridiagonal Matrix using Python

From Dev

Complex Matrix Multiplication using gsl

From Dev

How to simplify an expression for a complex constant using sympy?

From Dev

Substitute a Sympy matrix into a polynomial

From Dev

Finding roots with a SymPy Matrix

From Dev

Python Sympy angle of a complex number?

From Dev

Convert symbolic expressions to Python functions using SymPy

From Dev

python complex_ode pass matrix-valued parameters

From Dev

Generating an image of a fraction with python using SymPy

From Dev

Difficulty in using sympy solver in python

From Dev

How to transpose a sympy matrix

From Dev

Sympy Complex Expression To Python Function

From Dev

Solving polynomials with complex coefficients using sympy

From Dev

Derivatives of a matrix using Sympy

From Dev

Differentiation in python using Sympy

From Dev

Complex Matrix Multiplication using gsl

From Dev

sum over matrix entries in sympy 1.0 with python 3.5

From Dev

Format specifier for a complex matrix

From Dev

Creat symbol matrix using numpy, sympy in function?

From Dev

Error: requires numeric/complex matrix/vector arguments when using matrix times vector multiplication