1

I am solving a linear system of few equations (6 equations that has complex coefficients) with numpy.linalg.solve(A, b), where the arrays have type="complex128". The system is solved for a big range of frequencies and from a certain frequency on, the system becomes very much ill-conditioned. When the condition number is in my case over 1E+19 the system becomes unstable so I do not get right solutions. I have tried to use "clongdouble" type but it is not supported in numpy.linalg.

Are there ideas which is the best workaround to increase the precision or to get the system stable in numpy?

Simon Hänisch
  • 4,740
  • 2
  • 30
  • 42
Dan Turm
  • 11
  • 3
  • Use [Wolfram|Alpha](http://wolframalpha.com/). – Kenny Lau Aug 16 '16 at 13:35
  • Do you really need more accuracy? Maybe you can solve the problem by downsizing the magnitude of your numbers? I have not worked with it myself but the `bigfloat` package provides numbers with arbitrary precision. I don't think it is compatible with `numpy` though... You could also look into `mpmath` which is referred to by this post: http://stackoverflow.com/questions/13442531/increasing-float-point-numbers-accuracy – meetaig Aug 16 '16 at 13:40
  • I have scaled down the coefficients but it did not help, because the ratio between some coefficients in same equations is very high, what causes the high condition numbers. Besides I cannot scale the coefficients by normalizing input data, because there is not at all linear dependencies of them with the coefficients of the equations. I think the only way is to increase the accuracy. Thanks for suggesting mpmath, I will look it. – Dan Turm Aug 16 '16 at 15:08
  • I have just looked in WolframAlpha and is not a practical solution, because I have to solve the system of equations for a large range o frequencies (from 1. to 20000. Hz), besides the coefficients are complex (I mentioned it) and I did not see WolframAlpha includes complex arithmetic for linear systems of equations. So I should twice (once for real part, once for imaginary part) solve the system, lets say with frequency step 10 Hz, i.e. 4000 times by typing the coefficients there. – Dan Turm Aug 17 '16 at 07:13
  • With mpmath by defining the required precision with mp.dps I could solve my problem. – Dan Turm Aug 21 '16 at 13:10

0 Answers0