Is this a bug?

54 views
Skip to first unread message

Trevor Karn

unread,
Feb 23, 2026, 7:43:59 PM (21 hours ago) Feb 23
to sage-devel
Hi all,

I attempted to solve a system of equations today. I am wondering if this is a bug. When I run the following code from SageCell, I get complex solutions despite explicitly assuming x,y,k are real and specifying the domain to be 'real':

x,y,k=var('x,y,k')
assume(x,'real')
assume(y,'real')
assume(k,'real')
print(assumptions())

eqns = [4*x == k*4*x^3,
        12*y == k*12*y^3,
        x^4 + 3*y^4 == 1]

print(solve(eqns, [x,y,k],algorithm='sympy',domain='real'))
print(solve(eqns, [x,y,k],domain='real'))

Michael Orlitzky

unread,
Feb 23, 2026, 8:44:42 PM (20 hours ago) Feb 23
to 'Trevor Karn' via sage-devel
On 2026-02-23 16:43:58, 'Trevor Karn' via sage-devel wrote:
> Hi all,
>
> I attempted to solve a system of equations today. I am wondering if
> this is a bug. When I run the following code from SageCell I get
> complex solutions despite explicitly assuming x,y,k are real and
> specifying the domain to be 'real':

Sadly, "assumptions don't work" is a long-standing meta bug. The
assume() function makes assumptions primarily through maxima, but not
even maxima uses them consistently. Sympy has its own assumptions,
but sage's assume() does not use them.

The solve() function is not doing anything special to handle them...

if algorithm == 'sympy':
from sympy import solve as ssolve
sympy_f = [s._sympy_() for s in f]
sympy_vars = tuple([v._sympy_() for v in x])
ret = ssolve(sympy_f, sympy_vars, dict=True)

so they are not taken into consideration. The "domain" parameter to
solve is also ignored because you have more than one equation. (That
much is vaguely documented, but sucks as a UI.)

Trevor Karn

unread,
Feb 23, 2026, 8:47:39 PM (20 hours ago) Feb 23
to sage-...@googlegroups.com
Hm. Well, thanks for the information!

On Mon, Feb 23, 2026 at 7:44 PM Michael Orlitzky <mic...@orlitzky.com> wrote:
On 2026-02-23 16: 43: 58, 'Trevor Karn' via sage-devel wrote: > Hi all, > > I attempted to solve a system of equations today. I am wondering if > this is a bug. When I run the following code from SageCell I get > complex solutions
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
 
ZjQcmQRYFpfptBannerEnd
On 2026-02-23 16:43:58, 'Trevor Karn' via sage-devel wrote:
> Hi all,
> 
> I attempted to solve a system of equations today. I am wondering if
> this is a bug. When I run the following code from SageCell I get
> complex solutions despite explicitly assuming x,y,k are real and
> specifying the domain to be 'real':

Sadly, "assumptions don't work" is a long-standing meta bug. The
assume() function makes assumptions primarily through maxima, but not
even maxima uses them consistently. Sympy has its own assumptions,
but sage's assume() does not use them.

The solve() function is not doing anything special to handle them...

  if algorithm == 'sympy':
      from sympy import solve as ssolve
      sympy_f = [s._sympy_() for s in f]
      sympy_vars = tuple([v._sympy_() for v in x])
      ret = ssolve(sympy_f, sympy_vars, dict=True)

so they are not taken into consideration. The "domain" parameter to
solve is also ignored because you have more than one equation. (That
much is vaguely documented, but sucks as a UI.)

-- 
You received this message because you are subscribed to a topic in the Google Groups "sage-devel" group.
To unsubscribe from this topic, visit https://urldefense.com/v3/__https://groups.google.com/d/topic/sage-devel/AeQ3qE75QaY/unsubscribe__;!!KwNVnqRv!GyP6gME9swpw3AXr-yaHS5333Ff5gO-nd3BRv-zINKTbwcgm-nl784EjmclQw-2_FrbgLhueUM6HlRhJdg$.
To unsubscribe from this group and all its topics, send an email to sage-devel+...@googlegroups.com.
To view this discussion visit https://urldefense.com/v3/__https://groups.google.com/d/msgid/sage-devel/aZ0ChPN55KfceMC_*40mertle__;JQ!!KwNVnqRv!GyP6gME9swpw3AXr-yaHS5333Ff5gO-nd3BRv-zINKTbwcgm-nl784EjmclQw-2_FrbgLhueUM5bZ0aQIg$.

Dima Pasechnik

unread,
Feb 23, 2026, 11:38:38 PM (17 hours ago) Feb 23
to sage-...@googlegroups.com
One should do this sort of solving via polynomial functionality - setting up a lex order Groebner basis, etc

Trevor Karn

unread,
7:44 AM (9 hours ago) 7:44 AM
to sage-...@googlegroups.com
I agree in principle, but this is an example I am trying to use for my multi variable calculus class and I was trying to avoid using Groebner bases. 

On Mon, Feb 23, 2026 at 10:38 PM Dima Pasechnik <dim...@gmail.com> wrote:
One should do this sort of solving via polynomial functionality - setting up a lex order Groebner basis, etc On February 23, 2026 6: 43: 58 PM CST, 'Trevor Karn' via sage-devel <sage-devel@ googlegroups. com> wrote: Hi all, I attempted to
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
 
ZjQcmQRYFpfptBannerEnd
--
You received this message because you are subscribed to a topic in the Google Groups "sage-devel" group.

To unsubscribe from this group and all its topics, send an email to sage-devel+...@googlegroups.com.

Michael Orlitzky

unread,
8:27 AM (8 hours ago) 8:27 AM
to 'Trevor Karn' via sage-devel
On 2026-02-24 06:44:07, 'Trevor Karn' via sage-devel wrote:
> I agree in principle, but this is an example I am trying to use for my
> multi variable calculus class and I was trying to avoid using Groebner
> bases.

If it's just for an example, you can do it in sympy directly:

>>> from sympy import Symbol, solve
>>> x = Symbol('x', real=True)
>>> y = Symbol('y', real=True)
>>> k = Symbol('k', real=True)
>>> eqns = [4*x - k*4*x**3,
... 12*y - k*12*y**3,
... x**4 + 3*y**4 - 1]
>>> solve(eqns, (x,y,k))
[(-1, 0, 1),
(1, 0, 1),
(-sqrt(2)/2, -sqrt(2)/2, 2),
(-sqrt(2)/2, sqrt(2)/2, 2),
(sqrt(2)/2, -sqrt(2)/2, 2),
(sqrt(2)/2, sqrt(2)/2, 2),
(0, -3**(3/4)/3, sqrt(3)),
(0, 3**(3/4)/3, sqrt(3))]

A faithful mapping between the various assumption frameworks is a huge
task, but it might be comparatively easy to fix this in sage for a few
easy assumptions like "integer" and "real". Calling x.assume() for
example could check for a sympy of the same name and then replace it
with a new one having real=True or integer=True.

Trevor Karn

unread,
10:08 AM (6 hours ago) 10:08 AM
to sage-...@googlegroups.com
This is helpful, thanks!

On Tue, Feb 24, 2026 at 7:27 AM Michael Orlitzky <mic...@orlitzky.com> wrote:
On 2026-02-24 06: 44: 07, 'Trevor Karn' via sage-devel wrote: > I agree in principle, but this is an example I am trying to use for my > multi variable calculus class and I was trying to avoid using Groebner > bases. If it's just for
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
 
ZjQcmQRYFpfptBannerEnd
On 2026-02-24 06:44:07, 'Trevor Karn' via sage-devel wrote:
> I agree in principle, but this is an example I am trying to use for my
> multi variable calculus class and I was trying to avoid using Groebner
> bases.

If it's just for an example, you can do it in sympy directly:

  >>> from sympy import Symbol, solve
  >>> x = Symbol('x', real=True)
  >>> y = Symbol('y', real=True)
  >>> k = Symbol('k', real=True)
  >>> eqns = [4*x - k*4*x**3,
  ...         12*y - k*12*y**3,
  ...         x**4 + 3*y**4 - 1]
  >>> solve(eqns, (x,y,k))
  [(-1, 0, 1),
   (1, 0, 1),
   (-sqrt(2)/2, -sqrt(2)/2, 2),
   (-sqrt(2)/2, sqrt(2)/2, 2),
   (sqrt(2)/2, -sqrt(2)/2, 2),
   (sqrt(2)/2, sqrt(2)/2, 2),
   (0, -3**(3/4)/3, sqrt(3)),
   (0, 3**(3/4)/3, sqrt(3))]

A faithful mapping between the various assumption frameworks is a huge
task, but it might be comparatively easy to fix this in sage for a few
easy assumptions like "integer" and "real". Calling x.assume() for
example could check for a sympy of the same name and then replace it
with a new one having real=True or integer=True.

-- 
You received this message because you are subscribed to a topic in the Google Groups "sage-devel" group.
To unsubscribe from this topic, visit https://urldefense.com/v3/__https://groups.google.com/d/topic/sage-devel/AeQ3qE75QaY/unsubscribe__;!!KwNVnqRv!EWjDGKhEuAni1zZKTZ2TuJeoPVcrTBQBxDQvV4dmqMsbT0W6b9gIOsshGgYcpduyyNGQUSyQhLiypRxWBg$.
To unsubscribe from this group and all its topics, send an email to sage-devel+...@googlegroups.com.
To view this discussion visit https://urldefense.com/v3/__https://groups.google.com/d/msgid/sage-devel/aZ2nPDDUaoCrNsDX*40mertle__;JQ!!KwNVnqRv!EWjDGKhEuAni1zZKTZ2TuJeoPVcrTBQBxDQvV4dmqMsbT0W6b9gIOsshGgYcpduyyNGQUSyQhLiusBykiA$.

Trevor Karn

unread,
10:22 AM (6 hours ago) 10:22 AM
to sage-...@googlegroups.com
Is implementing a faithful mapping between some of the assumption frameworks a good GSOC project?

Vincent Delecroix

unread,
10:37 AM (6 hours ago) 10:37 AM
to sage-...@googlegroups.com
I would say : yes and no. A GSOC student is not at best position for
repairing the sage symbolic code and designing a reasonable
substitute. One needs a good knowledge of Sage code, symbolic library
and CAS, and a lot of math. Though, many of the tasks in such a
project might be easy to implement by a student.
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/sage-devel/CAO5hkkSC6MPMhnoCYdnFM_63dXfyT7dLtYNWPYec2tdsZ3r4Fg%40mail.gmail.com.

Michael Orlitzky

unread,
11:45 AM (5 hours ago) 11:45 AM
to 'Trevor Karn' via sage-devel
On 2026-02-24 09:21:55, 'Trevor Karn' via sage-devel wrote:
> Is implementing a faithful mapping between some of the assumption
> frameworks a good GSOC project?

The SymPy documentation at

https://docs.sympy.org/latest/guides/assumptions.html

says,

The "new assumptions" system is not really used anywhere in SymPy yet
and the "old assumptions" system will not be removed. At the time of
writing (SymPy 1.7) it is still recommended for users to use the old
assumption system.

I'm not very familiar with either, but it sounds risky to invest a lot
of time in the old (i.e. current) assumptions system.

Dima Pasechnik

unread,
11:47 AM (5 hours ago) 11:47 AM
to sage-...@googlegroups.com


On February 24, 2026 7:27:24 AM CST, Michael Orlitzky <mic...@orlitzky.com> wrote:
>On 2026-02-24 06:44:07, 'Trevor Karn' via sage-devel wrote:
>> I agree in principle, but this is an example I am trying to use for my
>> multi variable calculus class and I was trying to avoid using Groebner
>> bases.

You can use resultants instead.
That's much less extra material...
Reply all
Reply to author
Forward
0 new messages