3
$\begingroup$

Given a list, I want to find all elements that have positive imaginary part.

For example, if $y,z\in\mathbb R$ and $a>0$ and the list is $\{ ia+y, -ia+z\}$, then the result should be $\{ia+y\}$.

However, my code using Assuming and Select does not work.

Assuming[{y \[Element] Reals, z \[Element] Reals, a > 0}, 
 Select[{I a + y, -I a + z2}, Im[#] > 0 &]]

Although the expected reslut is {I a + y}, Mathematica gives {}. I suspect that condition given by Assuming seems to be not effective. How can I fix this problem?

$\endgroup$
1
  • 2
    $\begingroup$ Assuming[{y \[Element] Reals, z2 \[Element] Reals, a > 0}, Select[{I a + y, -I a + z2}, Simplify[Im[#] > 0] &]] $\endgroup$
    – Bob Hanlon
    Commented May 6, 2022 at 2:44

1 Answer 1

5
$\begingroup$

Use Refine to evaluate a > 0

Assuming[{a > 0}, a > 0]
(*a>0*)

Assuming[{a > 0}, Refine[a > 0]]
(*True*)

So you can

Assuming[{y ∈ Reals, z ∈ Reals, a > 0}, Select[{I a + y, -I a + z2}, Refine[Im[#] > 0] &]]

(*{I a + y}*)
$\endgroup$

Your Answer

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

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