Skip to content
Advertisement

Solving linear equation of complex matrices

I have a linear equation of a form ax=b where b is a complex matrix, and a is a real matrix. I’m expecting solution x to be a complex vector. When trying the numpy.linalg.solve(a,b) function, I’m getting this warning:

ComplexWarning: Casting complex values to real discards the imaginary part

How do I solve this equation to preserve the complex numbers?

Advertisement

Answer

Split b into its real and imaginary components and solve the real/imaginary parts separately
Ax = b = A(xr+xi) = br + bi
A @ xr = br, A @ xi = bi

JavaScript

EDIT The way you want to do it:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement