>> I wonder in Sympy, is it possible to isolate the complex numbers for
>> the solution set produced for my problem and only show real numbers
>> which are greater than 0? I actually need the real number part of the
>> solution.
>
> Since your solution only contains numbers, this is going to work for
> you:

im and re would work not only on numbers but also on symbols with
correctly set assumptions.

>
> In [19]: sols = [-1, 2, 3 + 4*I, 5 + 6*I]
>
> In [23]: filter(lambda x: (im(x) == 0) and (x > 0), sols)
> Out[23]: [2]
>

A more pythonic and more readable way to do this is with a list
comprehension. (and it does not need a lambda)

filtered_sols = [s for s in sols if im(x)==0 and re(x)>0]

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to