# Strategies for simplifying complicated expressions

I have a very complicated expression involving trigonometric functions, complex numbers etc. You may find it here as it is too long to be pasted here. You may also find a screenshot of it here.

Assumptions: All variables are real and strictly positive. This expression should be real!

I'm dealing with this expression for days. Could someone tell me a strategy for simplifying it within Mathematica 8 ?

More generaly, are there good tutorials or textbooks or lessons on strategies for simplifications? Perhaps is simplification a subjective concept? In my case it means more readable, and why not something that could fit in a research paper.

-
On a quite pessimistic note, I’d say that when you arrive to such an overlong expression, you’ve lost the battle. Even with all parameters having a simple value (1), the expression you get is epic! See how even Factor@FullSimplify[finalnew /. {d -> 1, kd -> 1, ka -> 1, L -> 1, \[Omega] -> 1, u -> 1}] does not simplify a lot. I’d advise to go back and try separating that expression into individual parts that make sense (mathematically or physically), and then try to simplify each part… – F'x Mar 28 '12 at 9:33

I don't know why you would expect Mathematica to understand that this is a real expression when you have I, (-1)^(1/4) and (-1)^(3/4) at various places in the expression.

(-1)^(1/4) // N
(* Out[1]= 0.707107 + 0.707107 I *)

(-1)^(3/4) // N
(* Out[2]= -0.707107 + 0.707107 I *)


In this particular instance, the denominator is pretty obviously real.

Simplify[Sign@Denominator[finalnew],
Assumptions -> {ka > 0, kd > 0, L > 0, ω > 0, d > 0}]

(*
Out[3]= Sign[(ka^4 ω^2 + d^2 (kd^2 + ω^2)^2 - 4 d ka^2 ω (kd^2 - kd ω + ω^2))
Cos[ Sqrt[2] L Sqrt[ω/d]] - (ka^4 ω^2 + d^2 (kd^2 + ω^2)^2 + 4 d ka^2 ω (kd^2 + kd ω + ω^2))
Cosh[Sqrt[2] L Sqrt[ω/d]] - 2 Sqrt[2] ka ((d^(3/2) (kd - ω) ω^(5/2) -
kd^2 (d ω)^(3/2) + kd^3 Sqrt[d^3 ω] - ka^2 kd Sqrt[d ω^3] + ka^2 Sqrt[d ω^5])
Sin[Sqrt[2] L Sqrt[ω/d]] + (kd^2 (d ω)^(3/2) + kd^3 Sqrt[d^3 ω] + ka^2 kd Sqrt[d ω^3] +
ka^2 Sqrt[d ω^5] + d^(3/2) ω^(5/2) (kd + ω))
Sinh[ Sqrt[2] L Sqrt[ω/d]])
]
*)

Simplify[Im@Denominator[finalnew], Assumptions -> {ka > 0, kd > 0, L > 0, ω > 0, d > 0, u > 0}]
(* Out[4]= 0 *)


So concentrate on refining the numerator. The equivalent

Simplify[Im@Numerator[finalnew],
Assumptions -> {ka > 0, kd > 0, L > 0, ω > 0, d > 0, u > 0}]


does not simplify to zero. For example:

Expand@Im@Numerator[finalnew] /. {ka -> 1, kd -> 1, L -> 1, ω -> 1, d -> 1, u -> 1}

(*
Out[5]= 6 Im[(-24 - 168 I) Cos[(-1)^(1/4)] - (24 - 168 I) Cosh[(-1)^(1/4)] -
(78 - 102 I) (-1)^(1/4) Sin[(-1)^(1/4)] + (42 + 24 I) (-1)^(3/4) Sin[(-1)^(1/4)] +
(108 + 144 I) (-1)^(1/4) Sinh[(-1)^(1/4)] + 6 (-1)^(3/4) Sinh[(-1)^(3/4)]]
*)


You can confirm the numerator is also real for specific values of the parameters:

FullSimplify@ Im[Numerator[finalnew] /. {ka -> 1, kd -> 1, L -> 1, ω -> 1,  d -> 1, u -> 1}]
(* result is zero *)


But this takes an inordinate amount of time and the result is a long complex expression.

FullSimplify[Im[Numerator[finalnew]], Assumptions -> {ka > 0, kd > 0, L > 0, ω > 0, d > 0, u > 0}]


As for general strategies, FullSimplify with as many variables in the Assumptions option is a good bet in most cases, as is separately simplifying numerators and denominators. I don't know if there are best-practice strategies, though. I would expect it would depend on the kind of expression, for example, whether it is a polynomial or contains trigonometric expressions.

-
The expression might indeed be real, even though it is not clearly apparent. The fact that Mathematica can’t simplify it to a real expression, or can’t provable determine that its imaginary part is zero doesn’t mean it isn’t so. – F'x Mar 28 '12 at 10:12
First of all thank you for your answer. I'd add to @F'x remark that the fact that Mathematica does not see a real expression is a consequence to the FullSimplify_cation_ not as effective as I would expect. – max Mar 28 '12 at 10:44
I think it probably is real, but that relies on the various imaginary terms cancelling in the numerator and that's just not obvious to Mathematica. See my edit. I'm still waiting for the last FullSimplify to finish calculating. – Verbeia Mar 28 '12 at 10:52

To show that your expression is real you could use ComplexExpand. By default, ComplexExpand will expand a complex expression into its real and imaginary part under the assumption that all undefined symbols occurring in the expression are real. The only problem here is that as far as I know there is no way to provide extra assumptions to ComplexExpand, especially that ω and d are positive which means that Sqrt[ω] and Sqrt[d] are real as well. The easiest way around this is to replace these symbols with the square of another symbol, e.g.

Simplify[ComplexExpand[Im[finalnew /. {ω -> om^2, d -> dd^2}]], dd > 0]


which returns 0.

-

Building on @Verbeia's observation that the denominator is real:

almostThere = ComplexExpand[1/2 (Numerator[finalnew] - Conjugate[Numerator[finalnew]]),
TargetFunctions -> {Re, Im}];


Then if you can make the assumptions ArcTan[x_, 0] == 0, ω > 0, d > 0 :

Simplify[almostThere /. (ArcTan[x_, 0] -> 0), Assumptions -> {ω > 0, d > 0}]
(* Out[1]= 0 *)

-