# How do I simplify an embedded sub-expression without affecting other sub-expressions?

I have an expression which is very large and which has several sub-expressions with head Conjugate. What I want to do is simplify the Conjugate[...] sub-expressions without affecting other sub-expressions.

The first method I considered is was the Transformationfunctions option of Simplify. I wrote:

Simplify[expr,Transformationfunctions->{Conjugate}]


Well, Conjugate does indeed disappear, but the result is wrong. For example (with \$Assumptions set so all variables are considered real)

FullSimplify[Conjugate[
t1 (2 Cos[(Sqrt kx)/2] Cos[ky/2] + Cos[ky]) +
I t1 (-2 Cos[(Sqrt kx)/2] Sin[ky/2] + Sin[ky])],
Transformationfunctions->{Conjugate}]


gives

t1 (2 Cos[(Sqrt kx)/2] Cos[ky/2] + Cos[ky]) +
I t1 (-2 Cos[(Sqrt kx)/2] Sin[ky/2] + Sin[ky])


The second method I considered is to use ComplexExpand //@ Conjugate. Since all the variables in my expression are declared real variables, Conjugate[expr] will become ComplexExpand //@ Conjugate[expr]. To make such this substitution, I could use search-and-replace and evaluate-in-place, but as I have said, the expression is large, so I don't want to do it that way. Instead I did the following:

largeexpr /. Conjugate -> ComplexExpand //@ Conjugate


But this did not work.

Here largeexpr is an expression containing sub-expressions with head Conjugate. For example,

Sqrt[t1^2]+Conjugate[
t1 (2 Cos[(Sqrt kx)/2] Cos[ky/2] + Cos[ky]) +
I t1 (-2 Cos[(Sqrt kx)/2] Sin[ky/2] + Sin[ky])]


So can anyone point out what I did wrong? Or suggest a better solution?

## 1 Answer

The TransformationFunctions used in Simplify should be functions that transform an expression without changing it. So things like Expand and Factor are fine, but Conjugate should not be used because Conjugate[z] is not the same as z.

I think what you are trying to do in your second method is to apply ComplexExpand on any subexpression with head Conjugate. Something like this:

expr = Sqrt[t1^2] +
Conjugate[
t1 (2 Cos[(Sqrt kx)/2] Cos[ky/2] + Cos[ky]) +
I t1 (-2 Cos[(Sqrt kx)/2] Sin[ky/2] + Sin[ky])];

expr /. c_Conjugate :> ComplexExpand[c]

(* Sqrt[t1^2] + t1 (2 Cos[(Sqrt kx)/2] Cos[ky/2] + Cos[ky]) -
I t1 (-2 Cos[(Sqrt kx)/2] Sin[ky/2] + Sin[ky]) *)

• Thank you very much !! Your solution to my second method is perfect !! But about TransformationFunctions, I still have doubt. For example I want to simplify an expression only use Expand and Together. How should I write? I've tried write like Simplify[(1 + x)^6, TransformationFunctions -> {Expand}] (use only expand), but it didn't work. – matheorem Dec 15 '12 at 1:21
• @user15964, it did work, but remember that Simplify aims to reduce the complexity of the expression. In this case, Expand increases the complexity, and the so lowest complexity expression Simplify can find is the one you started with. – Simon Woods Dec 15 '12 at 11:40