# Please explain this unexpected code snippet behavior [duplicate]

Consider a function that maps a complex function z->f(z) to it's multivariable counterpart (x,y)->f(x,y)

complex2multivar[z_] := ComplexExpand[Through[{Re, Im}[z]]]


Here are some results:

As expected:

complex2multivar[2 #^2 &[x + I y]]
{2 x^2 - 2 y^2, 4 x y}


As expected:

t1[z_] := 2 z^2
complex2multivar[t1[x + I y]]
{2 x^2 - 2 y^2, 4 x y}


NOT as expected:

t2[z_] := 2. z^2
complex2multivar[t2[x + I y]]
{(0. + 0. I) + 2. x^2 - 2. y^2, (0. + 0. I) + 4. x y}


How can this be fixed such that I can use pure functions like

(a # + b) / (c # + d) &


where the a,b,c,d are of type

Real + Real I


for example

a = 1.4 + .7 I


## marked as duplicate by J. M. will be back soon♦Jul 5 '15 at 18:15

• Yes, it was the inexact numbers that did it. Use Chop[]. – J. M. will be back soon Jul 5 '15 at 17:47