Re: Re: Separating real part and imaginary part from

• To: mathgroup at smc.vnet.net
• Subject: [mg101404] Re: [mg101380] Re: Separating real part and imaginary part from
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Sun, 5 Jul 2009 04:47:36 -0400 (EDT)

```f[z_] = (a*z + b)/(c*z + d);

g = f[x + I*y];

g // ComplexExpand // FullSimplify

(a*x + I*a*y + b)/(c*x + I*c*y + d)

The form requested is just

expr = (Re[g] + I*Im[g]) // ComplexExpand

I*((a*d*y)/(c^2*y^2 + (c*x + d)^
2) - (b*c*y)/(c^2*y^2 +
(c*x + d)^2)) +
(a*c*x^2)/(c^2*y^2 +
(c*x + d)^2) + (a*d*x)/
(c^2*y^2 + (c*x + d)^2) +
(a*c*y^2)/(c^2*y^2 +
(c*x + d)^2) + (b*c*x)/
(c^2*y^2 + (c*x + d)^2) +
(b*d)/(c^2*y^2 + (c*x + d)^2)

However, the component parts are not in the simplest form. If we apply Simplify or FullSimplify to this expression then

expr // Simplify

(a*x + I*a*y + b)/(c*x + I*c*y + d)

While correct, it is no longer in the desired form. Consequently, to retain the form, we want to Map Simplify or Full Simplify onto the parts in some fashion rather than apply it to the full expression.

>From the Help page for Map:

Map[f, expr]  or  f /@ expr
applies f to each element on the first level of expr

The following Maps the compound operation of ComplexExpand followed by FullSimplify onto the Re and Im components

FullSimplify[ComplexExpand[#]] & /@ (Re[g] + I*Im[g])

((a*x + b)*(c*x + d) + a*c*y^2)/
(c^2*y^2 + (c*x + d)^2) +
(I*(a*d*y - b*c*y))/(c^2*y^2 +
(c*x + d)^2)

Bob Hanlon

---- "Rommel.ua" <rommel.ua at gmail.com> wrote:

=============
On 28 =C9=C0=CE, 13:10, Alexander Erlich <alexander.erl... at gmail.com> wrote=
:
> Hi,
>
> thanks for the replies, ComplexExpand did the job! I don't know why I
> hadn't been familiar with it - I am reading Kofler's book (he's a very
> well known computer books author in Germany) which introduced
> Simplify, FullSimplify, Together, Apart, Expand, etc., but I didn't
> stumble over ComplexExpand yet.
>
> Question: What exactly does the line
>
> FullSimplify[ComplexExpand[#]] & /@ (Re[g] + I*Im[g])
>
> do? I guess it uses ComplexExpand to bring the expression to the form
> Re[g] + I*Im[g] and then fully simplifies (keeping this form), but
> it's only a guess. What does it really do?
>
> Thanks a lot to you!
>
> Alexander

FullSimplify simplifies expression obtained from ComplexExpand. The
tags  "& /@ (Re[g] + I*Im[g])" inform the mathematica kernel that
result must be in form a+i*b.

```

• Prev by Date: Re: stirring chocolate pudding backwards: identifying coordinates
• Next by Date: Re: LogLinearPlot strange "features"
• Previous by thread: Re: Separating real part and imaginary part from each
• Next by thread: Is it possible with Mathematica?