Ah, that *might* be considered a bug. Our assumptions system(s) don't really have a clear distinction between real numbers and extended real numbers, unfortunately.
Aaron Meurer On Wed, Jul 24, 2013 at 9:27 PM, Ben Lucato <[email protected]> wrote: > Yeah I initially thought of doing this - but say I want to do: > > y = Symbol('y') > domain = And(-oo < y, y < oo) > print domain >>>> True > > Which is unfortunate! Since having a domain over all real numbers is not > uncommon > > > On 25 July 2013 02:17, Aaron Meurer <[email protected]> wrote: >> >> You can already write inequalities, and combine them using And and Or: >> >> In [25]: x > 0 >> Out[25]: x > 0 >> >> In [26]: Or(x > 0, x < 1) >> Out[26]: x > 0 ∨ x < 1 >> >> In [27]: Or(x > 0, x < 1).subs(x, 2) >> Out[27]: True >> >> If all you care about is getting it to work mathematically (i.e., with >> subs), then you can get pretty far with this. It won't work with the >> assumptions system, though, and it can get messy fast, especially if >> you do care about printing. >> >> I think what we need is just a Contains object, subclassing from >> Boolean, which would work like Contains(x, Set), where Set is any set >> from the sets module. It shouldn't be too hard to write something like >> this. Basic functionality just needs to check set.contains for >> evaluation, and implement basic pretty printing with ∈. >> >> One issue is that there still isn't a very clear separation between >> boolean and symbolic objects >> (https://code.google.com/p/sympy/issues/detail?id=1887). And there are >> of course issues with the assumptions system in general. >> >> Aaron Meurer >> >> >> On Wed, Jul 24, 2013 at 6:34 AM, Stefan Krastanov >> <[email protected]> wrote: >> > It depends what exactly you want to do. >> > >> > If you need it just for typography purposes (e.g. writing something in >> > IPython notebook and wanting to print the expression) you are using >> > sympy >> > incorrectly. SymPy is not a typography library. (if you insists there >> > are >> > hacks to do it) >> > >> > On the other hand quite frequently you need this for meaningful >> > mathematics. >> > >> > - if you want to work on polynomials and do certain operations (finding >> > roots, etc) over a given field, you do this by specifying the field >> > during >> > the creation of the polynomial. >> > >> > - there is some work in progress to be able to do the same for matrices, >> > but >> > it is not ready. >> > >> > - in general, there is the assumption module. It is a bit of a mess, >> > because >> > we have an old and a new assumption module and we try to move to the new >> > one. If all that you want is for abs(x) to automatically return x (or >> > something similar) it suffices to define x as `x=Symbol('x', >> > positive=True)`. There are a few other handles like `real` and >> > `integer`. >> > >> > - if you need something more general or more fancy, we may have it in >> > some >> > (possibly unfinished, mostly unused) form, but it goes deeper in SymPy >> > so a >> > more precise question will help us give you a more precise answer. >> > >> > >> > On 24 July 2013 13:10, Ben Lucato <[email protected]> wrote: >> >> >> >> We can represent domains on paper quite easily - for instance we can >> >> write >> >> x < 0, or alternatively x (epsilon symbol) R-, or even x (epsilon >> >> symbol) >> >> (-infinity, 0) >> >> >> >> I looked around but couldn't really find that - is there a canonical >> >> way >> >> to be writing domains in SymPy? >> >> >> >> -- >> >> You received this message because you are subscribed to the Google >> >> Groups >> >> "sympy" group. >> >> To unsubscribe from this group and stop receiving emails from it, send >> >> an >> >> email to [email protected]. >> >> To post to this group, send email to [email protected]. >> >> Visit this group at http://groups.google.com/group/sympy. >> >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> >> >> > >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups >> > "sympy" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> > an >> > email to [email protected]. >> > To post to this group, send email to [email protected]. >> > Visit this group at http://groups.google.com/group/sympy. >> > For more options, visit https://groups.google.com/groups/opt_out. >> > >> > >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "sympy" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/sympy/vMa2TEbdb-k/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> [email protected]. >> >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/sympy. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> > > > > -- > > > Ben Lucato > ---------------------------------------------------------------------------------- > Phone: +61 400 159 632 | Email: [email protected] > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sympy. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.
