複素数(2)

指数関数

これはやさしい。
オイラーの公式

 e^{iy} = \cos{y} + i\sin{y}

より、

 e^{x + iy} = e^x(\cos{y} + i\sin{y})


import std.cstream;
import std.math;

void main(char[][] args) {
cdouble c = 1 + 0.1i;
dout.writefln(exp(c)); // 2.7047+0.271375i
}

cdouble exp(cdouble c) {
double im = c.im;
return std.math.exp(c.re) * (cos(im) + 1i * sin(im));
}

虚部を取るところが、
http://www.kmonos.net/alang/d/1.0/float.html
の動作と違う。どうなってるの?