Restrict domain of nonlinsolve

118 views
Skip to first unread message

Simone Perriello

unread,
May 27, 2019, 6:14:02 AM5/27/19
to sympy
Well, the title says pretty much everything. Is it possible to restrict the domain of nonlinsolve to solve, say, only for real numbers? Restrictions on the domain of symbols doesn't seem to work for nonlinsolve, while works well with the simple solve.

Chris Smith

unread,
May 30, 2019, 3:39:36 AM5/30/19
to sympy
You could wrap your solution in a FiniteSet and attempt an Intersection:

>>> nonlinsolve([x**2 - 2*y**2 -2, x*y - 2], [x, y])
{(-2, -1), (2, 1), (-sqrt(2)*I, sqrt(2)*I), (sqrt(2)*I, -sqrt(2)*I)}
>>> _.intersect(S.Naturals**2)
{(2, 1)}
Reply all
Reply to author
Forward
0 new messages