-reference:System.Numerics.dll
".
Alternatively, you can use a simpler,
home-made, implementation of complex numbers, complex.cs
,
and the corresponding complex functions, cmath.cs
. You can
build the library, say "cmath.dll
", like this:
cmath.dll : cmath.cs complex.cs mcs -target:library -out:./cmath.dll $^You can then link your "cmath.dll" library when compiling your
main.cs
like this,
main.exe : main.cs cmath.dll mcs -reference:cmath.dll -target:exe -out:main.exe main.cs
Calculate √-1, √i, ei, eiπ, ii, ln(i), sin(iπ) and compare (using our "approx" function) with manually calculated results (check them please before using):
√-1 = ±i, ln(i) = ln(eiπ/2) = iπ/2, √i = e½ln(i) = eiπ/4 = cos(π/4)+i sin(π/4) = 1/√2+i/√2 (and where is the second branch you think?) ii = ei ln(i) = e-π/2 ≈ 0.208, (ii is actually real – magic, isn't it?)
Extra: add to our cmath-class the hyperbolic functions sinh, cosh of complex argument—and calculate sinh(i), cosh(i). Check that the results are correct.