why doesn`t solve() give a proper answer

109 views
Skip to first unread message

Slava

unread,
Jan 9, 2009, 8:51:48 AM1/9/09
to sage-support
Hello.
I`m trying to solve such simple system of equations: [sqrt(x) == 1, x
== y],
so I type:

x,y = var('x,y');
solve([sqrt(x) == 1, x == y], x, y);

the answer is: []
(just two brackets)

How to make it work?

Robert Dodier

unread,
Jan 9, 2009, 12:01:46 PM1/9/09
to sage-support
On Jan 9, 6:51 am, Slava <slava_se...@mail.ru> wrote:

> I`m trying to solve such simple system of equations: [sqrt(x) == 1, x
> == y],
> so I type:
>
> x,y = var('x,y');
> solve([sqrt(x) == 1, x == y], x, y);
>
> the answer is: []

If I understand correctly, Sage punts to Maxima to solve equations.
Maxima's built-in solver is not too strong. There is an add-on package
which can solve equations which contain radicals. Dunno how to call
it from Sage, but in Maxima itself it's like this:

load (topoly_solver);
to_poly_solve ([sqrt(x) = 1, x = y], [x, y]);
=> [[x = 1, y = 1]]

Maybe at some point in the not-too-distant future, the built-in
solver would call to_poly_solve automatically ....

HTH

Robert Dodier

William Stein

unread,
Jan 9, 2009, 12:05:06 PM1/9/09
to sage-s...@googlegroups.com

That would be nice. Here's doing the above in sage:

sage: x,y=var('x,y')
sage: v = [sqrt(x)==1, x==y]
sage: w = maxima(v)
sage: maxima.load('topoly_solver')
sage: w.to_poly_solve([x,y])
[[x=1,y=1]]

There's currently no simple code in sage to turn the output of
to_poly_solve into native sage objects.

William

William Stein

unread,
Jan 9, 2009, 12:07:32 PM1/9/09
to sage-s...@googlegroups.com

I should correct myself and say it doesn't have any "trivial to use"
function to do that. Of course we wrote code to do that when
implementing our solve command (which does work as you suggest above).

William

Slava

unread,
Jan 10, 2009, 4:27:41 AM1/10/09
to sage-support
Thank you!
to_poly_solve() is a strong function, and it works fast.

William Stein

unread,
Jan 10, 2009, 4:04:20 PM1/10/09
to sage-s...@googlegroups.com
On Fri, Jan 9, 2009 at 9:05 AM, William Stein <wst...@gmail.com> wrote:
> On Fri, Jan 9, 2009 at 9:01 AM, Robert Dodier <robert...@gmail.com> wrote:
>>
>> On Jan 9, 6:51 am, Slava <slava_se...@mail.ru> wrote:
>>
>>> I`m trying to solve such simple system of equations: [sqrt(x) == 1, x
>>> == y],
>>> so I type:
>>>
>>> x,y = var('x,y');
>>> solve([sqrt(x) == 1, x == y], x, y);
>>>
>>> the answer is: []
>>
>> If I understand correctly, Sage punts to Maxima to solve equations.
>> Maxima's built-in solver is not too strong. There is an add-on package
>> which can solve equations which contain radicals. Dunno how to call
>> it from Sage, but in Maxima itself it's like this:
>>
>> load (topoly_solver);
>> to_poly_solve ([sqrt(x) = 1, x = y], [x, y]);
>> => [[x = 1, y = 1]]
>>
>> Maybe at some point in the not-too-distant future, the built-in
>> solver would call to_poly_solve automatically ....

Robert,

Is there any reason not to just *always* use topoly_solver? I.e.,
maybe Sage's solve should
just 100% always only call topoly_solver. What do you think?

William

>
> That would be nice. Here's doing the above in sage:
>
> sage: x,y=var('x,y')
> sage: v = [sqrt(x)==1, x==y]
> sage: w = maxima(v)
> sage: maxima.load('topoly_solver')
> sage: w.to_poly_solve([x,y])
> [[x=1,y=1]]
>
> There's currently no simple code in sage to turn the output of
> to_poly_solve into native sage objects.
>
> William
>

--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

Robert Dodier

unread,
Jan 10, 2009, 6:29:57 PM1/10/09
to sage-support
William Stein wrote:

> Is there any reason not to just *always* use topoly_solver? I.e.,
> maybe Sage's solve should just 100% always only call topoly_solver.
> What do you think?

to_poly_solve can only handle equations in polynomials and radicals,
while solve can handle a somewhat wider range of equations.
I guess one could invent heuristics -- e.g. try to_poly_solve first
and if it can't find anything then try solve.

Of course such heuristics could be applied within solve itself (and
there are already some in place to handle different kinds of
equations).
If you 'd like to press for modify solve to call to_poly_solve, then
I'll
encourage you to take it up on the Maxima mailing list.

Robert Dodier
Reply all
Reply to author
Forward
0 new messages