0

Having troubles with C# and its square root computation. Math.sqrt doesn't support negative arguments.

using System.Numerics;

and consiquently,

Complex

class, works only under .Net 4.0 and higher. Due to project restrictions I can use only .Net 3.5

Is there any workaround available for this problem? Any suggestions how to get complex square root in .Net 3.5?

Amphyby
  • 73
  • 1
  • 11
  • Related : http://stackoverflow.com/questions/18923247/square-root-of-negative-numbers –  Jul 01 '16 at 10:29
  • 1
    a simple reading of this post leads to use Complex.Sqrt only available in .Net 4.0 – Amphyby Jul 01 '16 at 10:29
  • 1
    [Download the source code.](https://github.com/dotnet/corefx/blob/d0dc5fc099946adc1035b34a8b1f6042eddb0c75/src/System.Runtime.Numerics/src/System/Numerics/Complex.cs) – Patrick Hofman Jul 01 '16 at 10:30
  • 1
    You'll need a library for complex arithmetic that works on .NET 3.5. Supplying such a library is out of scope for SO. – Jeroen Mostert Jul 01 '16 at 10:33
  • @PatrickHofman , so I am supposed to copy whole class from github? Erm, if you meant this solution, - I will try, but not sure mentioned `using System.Globalization; using System.Diagnostics.CodeAnalysis;` are usable in .Net 3.5 – Amphyby Jul 01 '16 at 10:34
  • Have you try this one: http://numerics.mathdotnet.com/ ? – currarpickt Jul 01 '16 at 10:34
  • Then remove all that you don't need and see if you get it working. – Patrick Hofman Jul 01 '16 at 10:35
  • @currarpickt, will try your solution, and Patrick's one. Thanks everyone for help! – Amphyby Jul 01 '16 at 10:40

0 Answers0