# Factoring for exponents

How can I factorise into powers of integer exponents?

An expression such as,

factored =
2^(-j - k) E^(-y/t)
(I (E^(-I y w) - E^(I y w)))^k (E^(-I y w) + E^(I y w))^j


can be expressed as,

unfactored =
I^k 2^(-j - k) E^(-y/t - I j y w - I k y w)
(1 - E^(2 I y w))^k (1 + E^(2 I y w))^j


My aim is to reduce unfactored to $e^{-y/t}\cos^j (y\,w)\sin^k (y\,w)$, but Mathematica doesn't seem to be able to do this unless the expression is factorised in terms of j, k as in factored

### Attempts

• Collect[unfactored, {E^(y w), E^(- y w)}] and variants
• ExpToTrig[unfactored] // FullSimplify and variants

### Working Example and a sanity check!

ExpToTrig[
(I/2 E^(-I y w) (1 - E^(2 I y w)))^k
(1/2 E^(-I y w) (1 + E^(2 I y w)))^j] // FullSimplify


gives, $\cos^j(y\,w) \sin ^k(y\,w)$

• Have you looked into ComplexExpand[], by any chance? – J. M. is away Jul 31 '16 at 21:08
• Thanks, just tried that and it didn't really help. Should I explicitly specify somehow that $j,k \in \mathbb{N}$ – Alexander McFarlane Jul 31 '16 at 21:10
• Did you try adjusting TargetFunctions? – J. M. is away Jul 31 '16 at 21:17
• Do factored and unfactored really represent the same quantity? – m_goldberg Jul 31 '16 at 23:36
• Yeah I actually brute forced the comparison by changing it one tiny bit at a time. I will post the forced method later today – Alexander McFarlane Aug 1 '16 at 2:16

## 2 Answers

I have encountered problems of this sort when deriving plasma dispersion relations with Mathematica. The essence of the problem appears to be that FullSimplify does not have

tf[e_] := e //.
{Exp[z1_ - I z2_ z3_] (1 + Exp[2 I z3_])^z2_ -> Exp[z1] (Exp[-I z3] + Exp[I z3])^z2,
Exp[z1_ - I z2_ z3_] (1 - Exp[2 I z3_])^z2_ -> Exp[z1] (Exp[-I z3] - Exp[I z3])^z2}


among its TransformationFunctions. Adding it solves the problem.

FullSimplify[unfactored, (j | k) ∈ Integers, TransformationFunctions -> {Automatic, tf}]

(* E^(-(y/t)) Cos[w y]^j Sin[w y]^k *)


Note that, if j and k were specific integers, FullSimplify together with Expand would be sufficient. For instance,

FullSimplify[Expand[unfactored /. {j -> 3, k -> 4}]]

(*( E^(-(y/t)) Cos[w y]^3 Sin[w y]^4 *)

• strange... If you use exactly the same expression but remove -y/t from the exponential then it fails. Is this because the rule explicitly references Exp[z1]? Just tested and confirmed that is the reason. Very informative answer. – Alexander McFarlane Aug 1 '16 at 16:49
• @AlexanderMcFarlane That right. If z1 is zero, a different rule is needed, tf[e_] := e //. {Exp[z1_ - I z2_ z3_] (1 + Exp[2 I z3_])^z2_ -> Exp[z1] (Exp[-I z3] + Exp[I z3])^z2, Exp[-I z2_ z3_] (1 - Exp[2 I z3_])^z2_ -> (Exp[-I z3] - Exp[I z3])^ z2}. – bbgodfrey Aug 1 '16 at 17:12

Try this:

unfactored /.
E^(a_ - I *p_* w y)*(1 + E^(2*I * w y))^p_ :> E^a*2*Cos[p w y]^p /.
E^(a_ - I *p_* w y)*(1 - E^(2*I * w y))^p_ :> -E^a*2*I*Sin[p w y]^p

(*  -I I^k 2^(2 - j - k) E^(-(y/t)) Cos[j w y]^j Sin[k w y]^k  *)


Have fun!

• can you briefly explain what the two pieces of notation: /. and :> are doing? Is this an in-line version of @bbgodfrey 's answer? – Alexander McFarlane Aug 1 '16 at 16:51
• @Alexander McFarlane Just type ?/.+Enter and ?:>+Enter and you will have an explanation, and then click on the >> sign in its end to have details. It is more or less the same as in bbgodfrey answer, differing in fine details. – Alexei Boulbitch Aug 2 '16 at 8:47