On 07/24/2013 12:17 PM, Aaron Meurer 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.
Why not implement the following for domain definition. Let
f(x_1,...,x_n) be a real function of n real variables then if
f(x_1,...,x_n) > 0 the point [x_1,...,x_n] is outside the domain and if
f(x_1,...,x_n) <= 0 the point is inside the domain.
--
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.