# Distribute conjugate and simplify to absolute values

I have a cubic like

-w^3 + w^2 x Conjugate[x] + w^2 y Conjugate[y] -
w x y Conjugate[x] Conjugate[y] - a w^2 x Conjugate[-a x + a y] +
a w^2 y Conjugate[-a x + a y]


where a, x, y are complex constants. When I use Solve for w, I get very long expressions like (in part)

w -> 1/2 (x Conjugate[x] + y Conjugate[y] - a x Conjugate[-a x + a y] + ...


What I'm looking for is how to distribute the Conjugates across +s, factor out scalars (like -1), and then simplify expressions of the form z Conjugate[z] to Abs[z]^2, where z may be a product of terms (like a x as above).

I have tried to use Distribute but it does nothing to the output, and commands like /.{x Conjugate[x] -> Abs[x]^2} work when x is specified but doesn't handle, say, x^2 Conjugate[x]^2. My actual use case seems like it will be far too long for Simplify or FullSimplify to reasonably handle.

Thanks in advance for any thoughts.

• if you know that a,x,y are complex, will writing these as a=a0+I*a1 where a0 is the real part and a1 is the imaginary part help? The same for x,y. Like this a=a0+I*a1; x=x0+I*x1; y=y0+I*y1; expr=-w^3+w^2 x Conjugate[x]+w^2 y Conjugate[y]-w x y Conjugate[x] Conjugate[y]-a w^2 x Conjugate[-a x+a y]+a w^2 y Conjugate[-a x+a y]; Solve[Simplify@ComplexExpand[expr]==0,w] which gives simpler output !Mathematica graphics Just have to remember that a0 is the real part of a and so on... Aug 4 at 20:21

Not to make things too complicated, I only use the first part of w for an example:

w = 1/2 (x Conjugate[x] + y Conjugate[y] - a x Conjugate[-a x + a y])


Then distribute over Plus and factor out minus signs and simplify

w= w /.
Conjugate[x1_ + x2__] -> Conjugate[x1] + Conjugate[x2] /.
Conjugate[-x_] -> -Conjugate[x] //Simplify

(* 1/2 (x Conjugate[x] + a x Conjugate[a x] + y Conjugate[y] -
a x Conjugate[a y]) *)


Finally introduce Abs:

w= w /. x_ Conjugate[x_] -> Abs[x]^2

(* 1/2 (Abs[x]^2 + Abs[a x]^2 + Abs[y]^2 - a x Conjugate[a y]) *)

• Conjugate[-a x + a y + u] does not seem to work with that code but //.Conjugate[x1_ + x2_] -> Conjugate[x1] + Conjugate[x2] or /. Conjugate -> (Thread[Conjugate[#], Plus] &) does Aug 4 at 20:49

You could define your own "fake" symbolic conjugate that has the properties you want and then use the real Conjugate only when you need it.

Clear[conjugate]; conjugate /: r_*conjugate[r_] := Abs[r]^2;
conjugate[a_ + r_] := conjugate[a] + conjugate[r];
conjugate[a_*r_] := conjugate[a]*conjugate[r];
conjugate[a_?NumericQ*r_] := Conjugate[a]*conjugate[r];
conjugate[a_?NumericQ + r_] := Conjugate[a] + conjugate[r]


I added multiplication among the properties of conjugate in case you wanted it but you can remove it. In essence, the definition of conjugate above is no different than using replacement rules but it has the advantage that you do not need to specify the rules for every input. Moreover, that definition works as expected when adding three or more numbers like Conjugate[a+b+c].

example:

complicated=1/2 (x Conjugate[x] + y Conjugate[y] -
a x Conjugate[-a x + a y + n*Exp[I*4]]) + Conjugate[1 + b] /.
Conjugate -> conjugate // Expand


evaluates to:

1 + Abs[x]^2/2 + 1/2 Abs[a]^2 Abs[x]^2 + Abs[y]^2/2 + conjugate[b] -
1/2 a E^(-4 I) x conjugate[n] - 1/2 x Abs[a]^2 conjugate[y]


you can define a rule:

realconjugate= conjugate->Conjugate


so that you can use the real Conjugate when you need:

complicated /. realconjugate


Remember that if you want to apply a function f before then you can use the operator form of ReplaceAll:

complicated //f // ReplaceAll[realconjugate]