Assumptions on symbols

14 views
Skip to first unread message

G B

unread,
Sep 19, 2012, 7:34:35 PM9/19/12
to sy...@googlegroups.com
I'm trying to figure out how assumptions work and how they might be used to reject complex solutions.

The first problem I'm having is how to test assumptions manually.  I'm finding that:
ask(Q.positive(1))  --> True
ask(Q.positive(-1)) --> False

but:
d=symbols('d',positive=True)
ask(Q.positive(d))  --> None

d.is_positive does True (though I could swear it returned None before I started this email...).

What is the right interface for testing assumptions?  

Thanks!

Aaron Meurer

unread,
Sep 19, 2012, 7:45:39 PM9/19/12
to sy...@googlegroups.com
Unfortunately, we have two assumptions systems, the old one, and the
new one (which will someday completely replace the old one), and they
aren't fully integrated. Symbol('p', positive=True) and p.is_positive
is the old system. This is the system that most parts of SymPy use,
so it should work the best. In particular, for your use case, you can
do something like

In [1]: x = Symbol('x', real=True)

In [2]: solve(x**3 + x, x)
Out[2]: [0]

(with generic x, you would get [0, I, -I])

The ask() and Q are the new assumptions. These are still a work in
progress, but will ultimately provide a much more expressive system,
since you can assume things on arbitrary expressions instead of just
symbols, and combine them into arbitrary logical expressions.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/sympy/-/1Ws-C-kKRoIJ.
> To post to this group, send email to sy...@googlegroups.com.
> To unsubscribe from this group, send email to
> sympy+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sympy?hl=en.
Reply all
Reply to author
Forward
0 new messages