how does solveset handle the assumption system

88 views
Skip to first unread message

chaowen guo

unread,
May 24, 2016, 5:05:28 PM5/24/16
to sympy
Hi:

the example

import sympy
energy=sympy.symbols('E',positive=True)
from sympy.assumptions.assume import global_assumptions
global_assumptions.add(sympy.Q.positive(energy-1))
position=sympy.symbols('r',real=True)
momentum=energy-1-sympy.exp(position)
interval=sympy.solveset(momentum,position,sympy.S.Reals)   
print(interval)

the output is:Intersection((-oo, oo), {log(E - 1)})

And then I ask:
sympy.ask(sympy.Q.positive(energy-1))
the output is true

So it seems that solveset totally ignores the global_assumptions. How to tell solveset the global_assumptions, so it can use them to do more simplification?

I also try sympy.refine and sympy.simplify to simplify the final interval, but none of them can simplify interval to just {log(E-1)};

By the way, I want to ask how does the assumption system interact with other part of sympy. I know I can give assumption when I define variables, like real=True,
positive=True. But I can not give relative assumption, like E+1 is positive or A-B is greater than C. I figure out global_assumptions may consider relative
assumption. But how about the other parts of sympy, like solveset, integrate, integrate.transform, simplify? Do they take global_assumptions into consideration?
I know mathematica, maple and maxima all support relative assumption. And they can use the assumptions to do more simplification. Does the assumption system in
sympy act like the same way?

Aaron Meurer

unread,
May 24, 2016, 6:55:43 PM5/24/16
to sy...@googlegroups.com
solveset ignores assumptions. Instead, you should pass the domain that
you wish to solve over as the domain parameter, like solveset(eq, x,
domain=S.Reals).

Relational assumptions like E+1 require the new assumptions (ask(), Q,
refine()). This is still a work in progress and may not work very well
in every case. Most functions in SymPy only consider the old
assumptions (positive=True, is_positive).

Aaron Meurer
> --
> 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 sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/8ca64f15-1a83-4a66-87db-fa0f9ebea279%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

chaowen guo

unread,
May 25, 2016, 3:44:12 PM5/25/16
to sympy
Well, I want to make sure, does solveset just ignore the assumptions about unknown, or ignore everything?

For example:

solveset(a+x**2,x);

Of course, assumption about x is ignored. How about assumption about a?

Shekhar Prasad Rajak

unread,
Jun 5, 2016, 2:09:54 PM6/5/16
to sympy
Solveset ignores assumptions for all the symbols. Actually it doesn't check assumptions.
Reply all
Reply to author
Forward
0 new messages