9
$\begingroup$

I am trying to isolate out the real and complex terms in a fairly large expression. During the process, I have made several assumptions that last throughout the entire process.

$Assumptions = Element[{x,y},Reals] && {x,y}>0 

When I try separating the real and complex parts, the Re and Im functions have trouble with terms where variables appear in the denominator. For example

Im[1/(x^2 + 4 y^2)^(9/2)] //Simplify = Im[1/(x^2 + 4 y^2)^(9/2)]

Even though all the terms are real and positive, meaning there should be no complex component, and the expression should be zero

I have checked, and if the denominator does not involve two or more terms, Im does work successfully. For example

Im[1/(x^2)^(9/2) ] //Simplify = 0
Im[1/(4 y^2)^(9/2)] //Simplify = 0

Can someone please comment on if this is a bug in the version I have, or am I doing something incorrect here? A mwe is provided below. For reference, I am using version 10.0.0.0

-Thanks

In[421]:=
$Assumptions = Element[{x, y}, Reals] && {x, y} > 0 ;
Simplify[Im[1/(x^2 + 4*y^2)^(9/2)]]
Simplify[Im[1/(x^2)^(9/2)]]
Simplify[Im[1/(y^2)^(9/2)]]

Out[424]= Im[1/(x^2+4 y^2)^(9/2)]
Out[425]= 0
Out[426]= 0

Edit

If I modify the assumptions to define each one separately, the code runs fine. e.g

$Assumptions = Element[x, Reals] && Element[y, Reals] && x > 0 && y > 0 ;

In my main program, I have a large number of variables that are both real and positive, is there a way to assign these all at once, or do I need to do each one separately?

$\endgroup$
2
  • 2
    $\begingroup$ To the edit: If you have those variables in a list varlist then $Assumptions = And @@ (Element[#, Reals] && # > 0 & /@ varlist) will do the trick. $\endgroup$ Nov 10, 2015 at 7:07
  • 2
    $\begingroup$ Try ComplexExpand[Im[...]]. That should work. Same for the real part $\endgroup$
    – Lukas
    Nov 10, 2015 at 7:08

2 Answers 2

7
$\begingroup$

{x,y} > 0 is not doing what you think it does. In contrast to Element which, as its documentation states, accepts arbitrary patterns and in which first argument, being a List of more than one elements, evaluates to Alternatives:

$Assumptions = {x, y} ∈ Reals
(* (x | y) ∈ Reals *)
x ∈ Reals // Refine
(* True *)
y ∈ Reals // Refine
(* True *)

{x,y} > 0 in assumptions is just stating that literal list expression {x, y} is greater than zero and not that individual elements of list are greater than zero:

$Assumptions = {x, y} > 0
(* {x, y} > 0 *)
{x, y} > 0 // Refine
(* True *)
x > 0 // Refine
(* x > 0 *)
y > 0 // Refine
(* y > 0 *)

Using expression in inequality in assumptions implies that this expression is real:

$Assumptions = x > 0;
x ∈ Reals // Refine
(* True *)

For some reason, although {x, y} > 0 assumption, assumes that only literal list is greater than zero, it also results in individual elements being assumed real:

$Assumptions = {x, y} > 0;
{x, y} ∈ Reals // Refine
(* True *)
x ∈ Reals // Refine
(* True *)
y ∈ Reals // Refine
(* True *)

Going back to expression from question it's enough to assume that individual symbols are greater than zero, this will automatically imply that they are real.

$Assumptions = And @@ Thread[{x, y} > 0]
(* x > 0 && y > 0 *)
Im[1/(x^2 + 4*y^2)^(9/2)] // Refine
(* 0 *)
Im[1/(x^2)^(9/2)] // Refine
(* 0 *)
Im[1/(y^2)^(9/2)] // Refine
(* 0 *)
$\endgroup$
1
  • $\begingroup$ That works exactly like what I was looking for. Thanks for the clear answer $\endgroup$
    – jpdomann
    Nov 10, 2015 at 15:03
3
$\begingroup$
$Assumptions = And @@ Thread[Greater[{x, y, d, e}, 0]] && Element[{x, y, d, e}, Reals]
x > 0 && y > 0 && d > 0 && e > 0 && (x | y | d | e) ∈ Reals
ComplexExpand[Im[1/(y^2)^(9/2)]]
0 
$\endgroup$
3
  • $\begingroup$ By the way, Greater[{x, y, d, e}, 0] is just {x, y, d, e} > 0 even inside Thread $\endgroup$
    – ybeltukov
    Nov 10, 2015 at 12:25
  • $\begingroup$ @ybeltukov, I don't think so. Greater[{x, y, d, e}, 0] === Thread[Greater[{x, y, d, e}, 0]] evaluates to flase False $\endgroup$
    – rhermans
    Nov 11, 2015 at 14:06
  • $\begingroup$ I mean a more obvious thing: Thread[{x, y, d, e} > 0] === Thread[Greater[{x, y, d, e}, 0]] $\endgroup$
    – ybeltukov
    Nov 11, 2015 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.