Does the Im
function work with symbolic arguments?
Clear[ y, t, k, ω ]
A ( Cos[ k y ] + I Sin[ k y ] ) 2I Sin[ ω t ] //ComplexExpand
(* Output: 2 I A Cos[ k y] Sin[ t ω ] - 2 A Sin[ k y ] Sin[ t ω ] *)
Im[ % ]
(* Output: -2 Im[ A Sin[ k y ] Sin[ t ω ] ] + 2 Re[ A Cos[ k y ] Sin[ t ω ] ] *)
Expected output: -2 A Sin[ k y ] Sin[ t ω ]
Answer
You should assume that your variables are real, (if you want M to proceed further) because Mathematica treats variables in general as complex. One of many ways to do it :
expr = A ((Cos[k y] + I Sin[k y]) 2 I Sin[t ω]);
Refine[ Im[ expr], (A | k y | t ω) ∈ Reals]
2 A Cos[k y] Sin[t ω]
We needn't use ComplexExpand
defining expr
, but in this case it is the simplest approach (pointed out by Heike) :
ComplexExpand @ Im @ expr
Some other ways of imposing assumptions :
Assuming[(A | k y | t ω) ∈ Reals, Refine[ Im[ expr] ] ]
another way yielding the same result :
Block[{$Assumptions = A ∈ Reals && k y ∈ Reals && t ω ∈ Reals},
Refine @ Im[ expr] ]
2 A Cos[k y] Sin[t ω]
Comments
Post a Comment