"solve" doesn't return anything

663 views
Skip to first unread message

dennis

unread,
Feb 16, 2012, 7:39:41 PM2/16/12
to sy...@googlegroups.com
Hi,

when i run "solve(['x-1', 'x-2'])" there is nothing returned. Shouldn't it return an empty list [], as there are no solutions?

David Joyner

unread,
Feb 16, 2012, 8:03:22 PM2/16/12
to sy...@googlegroups.com

sage: x = var("x")
sage: solve([x-1, x-2],[x])
[]

>
> --
> 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/-/97WBZB6-hAsJ.
> 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.

David Joyner

unread,
Feb 16, 2012, 8:06:39 PM2/16/12
to sy...@googlegroups.com
On Thu, Feb 16, 2012 at 8:03 PM, David Joyner <wdjo...@gmail.com> wrote:
> On Thu, Feb 16, 2012 at 7:39 PM, dennis <dennis...@googlemail.com> wrote:
>> Hi,
>>
>> when i run "solve(['x-1', 'x-2'])" there is nothing returned. Shouldn't it
>> return an empty list [], as there are no solutions?
>
> sage: x = var("x")
> sage: solve([x-1, x-2],[x])
> []


Please, ignore that reply of mine. I thought you were asking about Sage!

Chris Smith

unread,
Feb 16, 2012, 9:47:40 PM2/16/12
to sy...@googlegroups.com
The docstring notes:

* when the system is linear

* with a solution

>>> solve([x - 3], x)
{x: 3}
>>> solve((x + 5*y - 2, -3*x + 6*y - 15), x, y)
{x: -3, y: 1}
>>> solve((x + 5*y - 2, -3*x + 6*y - 15), x, y, z)
{x: -3, y: 1}
>>> solve((x + 5*y - 2, -3*x + 6*y - z), z, x, y)
{x: -5*y + 2, z: 21*y - 6}

* without a solution

>>> solve([x + 3, x - 3])

So you are dealing with a linear system that has no solution. An empty
list might be returned if there were no solutions satisfying the
requirements (assumptions, etc...) but for this system there is no
solution so None is returned.

Aaron Meurer

unread,
Feb 18, 2012, 4:20:54 AM2/18/12
to sy...@googlegroups.com

So would it be accurate to say that None means that we know that there
are no solutions and [] means that we just didn't find any?

Aaron Meurer

Chris Smith

unread,
Feb 18, 2012, 6:39:29 AM2/18/12
to sy...@googlegroups.com
For a multi-equation system, yes.
Reply all
Reply to author
Forward
0 new messages