Hi Jeremy,
thanks for sharing your link and thanks for compiling the documentation. And
indeed it helped, with the information I could easily fix it:
rd@h370:~/tmp.nobackup$ cat test-sympy.py
import sympy
x, y, z = sympy.symbols('x y z')
sympy.init_printing(use_unicode=True)
print(sympy.solvers.inequalities.reduce_rational_inequalities([[x + 2 > 0]],
x))
print(sympy.solvers.inequalities.reduce_rational_inequalities([[x + 2 > 0,x <
5]], x))
rd@h370:~/tmp.nobackup$ python3 test-sympy.py
(-2 < x) & (x < oo)
(-2 < x) & (x < 5)
rd@h370:~/tmp.nobackup$
I read through your page and posted some feedback at
https://github.com/sympy/sympy/pull/23768
My real problem is somewhat more complex though:
I want to find out if
f_vec+a*x_vec+b*y_vec+n*s_vec=sh_vec+c*xsh_vec+d*ysh_vec
has a solution with
0<=a,b,c,d<=1
All quantities with _vec are 3 dimensional vectors. I want to to find out if
for a given set of vectors a solution exists or not.
Extending my testcase in this direction does not work though:
rd@h370:~/tmp.nobackup$ cat test-sympy.py
import sympy
x, y, z = sympy.symbols('x y z')
sympy.init_printing(use_unicode=True)
print(sympy.solvers.inequalities.reduce_rational_inequalities([[x + 2 > 0]],
x))
print(sympy.solvers.inequalities.reduce_rational_inequalities([[x*5 + y*2 =
10,x <= 1, x >= 0, y <= 1, y >= 0]], x))
rd@h370:~/tmp.nobackup$ python3 test-sympy.py
File "/home/rd/tmp.nobackup/test-sympy.py", line 9
print(sympy.solvers.inequalities.reduce_rational_inequalities([[x*5 + y*2
= 10,x <= 1, x >= 0, y <= 1, y >= 0]], x))
^
SyntaxError: invalid syntax
rd@h370:~/tmp.nobackup$
I suspect that reduce_rational_inequalities is the wrong approach here, but
what would the the right functions to use?
Any hint is welcome :-)
Many thanks
Rainer
PS: Also thanks for hint towards less-verbose function calls. I typically
write it verbose, since I am not writing Python code too frequently, and for
me the verbose version is something like a documentation, since I see where
the functions come from.
Am Samstag, 6. August 2022, 17:19:45 CEST schrieb Jeremy Monat:
> Hi Ranier,
>
> Here's a way to do it:
> >>> import sympy
> >>> x, y, z = sympy.symbols('x y z')
> >>> sympy.solvers.inequalities.reduce_inequalities([x + 2 > 0, x < 5], x)
>
> (-2 < x) & (x < 5)
>
> reduce_inequalities is the top-level inequality reducer, which will call
> other lower-level functions (such as reduce_rational_inequalities) as
> needed. reduce_inequalities takes a simple list, rather than a nested list,
> of inequalities.
>
> I'm actually drafting a guide page on this topic now; glad to know it's of
> interest! You can access the draft
> <
https://output.circle-artifacts.com/output/job/a1f8297d-6be8-4627-9f47-a969
> 709f9293/artifacts/0/doc/_build/html/guides/solving/solve-system-of-inequali
> ties-algebraically.html>, and I'd appreciate any feedback (either here or on
> the pull request <
https://github.com/sympy/sympy/pull/23768> on GitHub).