I have here a complex function in which z =x+ I y must be filled in

f[z_] := E^(-z^2)

By hand : (-E^(-x^2))*E^y^2*(Cos[2*x*y]-I*Sin[2*x*y]) Can this be derived in MMA ?

I tried to use z= x+Iy and the formula of Euler, but don't get the manual outcome?

By hand inference the answer should come out listed here. Unfortunately, I am not yet getting to this manual derivation.

I wonder if this is really so important now because there are further calculations to be made.

But yes I am trying to follow a math text.

  • 1
    $\begingroup$ Simplify@ComplexExpand@f[x + I y]? $\endgroup$
    – kglr
    Mar 28 at 21:16
  • $\begingroup$ @kglr, how easy can it be :) ComplexExpand command was not present by me $\endgroup$
    – janhardo
    Mar 28 at 21:37
  • $\begingroup$ @janhardo please have a look at the edit. I am hoping that now is clear that there's a loose sign in your expression. $\endgroup$
    – bmf
    Mar 28 at 21:43
  • 1
    $\begingroup$ You haven't accept many, if any, answers. It's polite to thank people by doing so. Please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – Michael E2
    Mar 29 at 19:53
  • 1
    $\begingroup$ @bmf no problem. For that matter, I like to comment in terms of politeness because it tends to get the attention of new users that they are participants in a community that has norms. I think it helps the community if answerers feel appreciated, whatever other benefits there are too accepting answers. And I think become better community members as they figure out how to participate in better ways. $\endgroup$
    – Michael E2
    Mar 29 at 22:03

1 Answer 1


The following works if I am not mistaken

E^(-z^2) /. z -> x + I y // ComplexExpand // Factor

E^(-x^2 + y^2) (Cos[2 x y] - I Sin[2 x y])

Edit: I believe there's a small typo in the OP. An overall sign, i.e this

Just to make it clearer

In the OP this is written

janhardo = (-E^(-x^2))*E^y^2*(Cos[2*x*y] - I*Sin[2*x*y]);

Mathematica gives us this

mma = E^(-z^2) /. z -> x + I y // ComplexExpand // Factor;

If I subtract I should get zero, but I don't.

janhardo - mma // FullSimplify

-2 E^-(x + I y)^2

If I add them

janhardo + mma


hence an overall minus sign missing.

Better understanding, just divide

janhardo/mma // FullSimplify


Edit: final comment. This is not really related to Mathematica, but Maths.

The expression after substitution is

Exp[-x^2 + y^2]

which can be written as Exp[-x^2] Exp[y^2]. Verification:

Exp[-x^2 + y^2]/(Exp[-x^2] Exp[y^2]) // FullSimplify


But in the OP it is written as -Exp[-x^2]*Exp[y^2].

Exp[-x^2 + y^2]/(-Exp[-x^2]*Exp[y^2]) // FullSimplify


  • $\begingroup$ thanks, it was ComplexExpand needed. Unfortunately it was not yet ready with me I'm so used to Expand...i forget ComplexExpand I checked my typed in manually obtained formula, but don't see the typo? $\endgroup$
    – janhardo
    Mar 28 at 21:35
  • $\begingroup$ @janhardo it's easy enough to understand why I suggested it. You gave a formula. I copied, pasted and subtracted from the expression after ComplexExpand//Factor. It should give zero, but it does not. When I sum them, you get a zero, hence there must be an overall minus sign. You can check for yourself $\endgroup$
    – bmf
    Mar 28 at 21:39
  • 1
    $\begingroup$ thanks . Indeed a typo then : a minus sign before the e power manual formula. MMA gives the right answer now: now doubt abou tthis . $\endgroup$
    – janhardo
    Mar 28 at 22:17
  • $\begingroup$ @janhardo glad I was able to help. If you found this answer useful, you can consider accepting it by clicking the checkmark sign :-) $\endgroup$
    – bmf
    Mar 28 at 22:46
  • 1
    $\begingroup$ bmf, i did now choose for your excellent answer for rating: useful and as best answer too (although there is one answer, its a best one ) $\endgroup$
    – janhardo
    Mar 29 at 21:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.