Error in solving system of non-linear equations

8 views
Skip to first unread message

R (Chandra) Chandrasekhar

unread,
Mar 13, 2009, 2:44:29 AM3/13/09
to debia...@googlegroups.com, sage-s...@googlegroups.com
Dear Folks,

Pardon for the double-posting since I am unsure which list is more
appropriate.

In section 2.4.1 of the Sage Tutorial, there is a non-linear equation
example from Jason Grout that I tried out, but it failed. Details follow.

My version is built from the Ubuntu jaunty package source and runs on a
Kubuntu Intrepid AMD 64 PC. The startup banner is

----------------------------------------------------------------------

| SAGE Version 3.0.5, Release Date: 2008-07-11 |

| Type notebook() for the GUI, and license() for information. |

----------------------------------------------------------------------

When I load the file with these contents for the example:
===
var('x y p q')
(x, y, p, q)
eq1 = p+q==9
eq2 = q*y+p*x==-6
eq3 = q*y^2+p*x^2==24
solve([eq1,eq2,eq3,p==1],p,q,x,y)
===

I get this error (with directory paths anonymized):
---------------------------------------------------------------------------

ValueError Traceback (most recent call
last)

/Path-To-File_non_linear_eq_sage_0.py in <module>()

8 eq2 = q*y+p*x==-Integer(6)

9 eq3 = q*y**Integer(2)+p*x**Integer(2)==Integer(24)

---> 10 solve([eq1,eq2,eq3,p==Integer(1)],p,q,x,y) 11
12

/usr/lib/python2.5/site-packages/sage/calculus/equations.pyc in solve(f,
*args, **kwds)
1386 s = m.solve(args)
1387 except:
-> 1388 raise ValueError, "Unable to solve %s for %s"%(f, args)
1389 a = repr(s)
1390 sol_list = string_to_list_of_solutions(a)

ValueError: Unable to solve [q + p == 9, q*y + p*x == -6, q*y^2 + p*x^2
== 24, p == 1] for (p, q, x, y)
WARNING: Failure executing file: <Path-To-File_non_linear_eq_sage_0.py>
---------------------------------------------------------------------------

The version of the tutorial that I am using came with the version of
Sage installed. So, I do not think it is a version incmpatibility problem.

Can someone tell me what the workaround is, or whether I need to file a
bug report.

Thank you.

Chandra

R (Chandra) Chandrasekhar

unread,
Mar 13, 2009, 3:23:29 AM3/13/09
to sage-s...@googlegroups.com, debia...@googlegroups.com
Jason Grout wrote:

> I'm not sure what is going on here. Version 3.0.5 is from quite a while
> ago, at least in Sage terms. The calculation works great in the current
> version of Sage (version 3.4, just released yesterday, as tested on
> http://www.sagenb.org.) Did you say that this was from the jaunty
> source, as in the debian packaging of Sage?

Yes. It is from the prospective Ubuntu 9.04 (April 2009) Jaunty release
built from Debian packages that might be customized for Ubuntu.

Would you recommend that I compile from the source tarball instead?

> Does running "sage -maxima"
> run maxima? Can you solve simpler equations?

I am unfamiliar with maxima and its syntax, but typing

sage -maxima

gives
---
Maxima 5.13.0 http://maxima.sourceforge.net
Using Lisp GNU Common Lisp (GCL) GCL 2.6.8 (aka GCL)
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
This is a development version of Maxima. The function bug_report()
provides bug reporting information.
(%i1)
---

I was able to solve the preceding equations on that tutorial page
without error. I think I saw a maxima crash and then a message saying
"automatically restarted" but have not been able to replicate it. In any
case I remember I got the correct answer without any manual intervention.

I am copying this reply to the debian-sage mailing list as well if it
might help in the solution.

Thank you.

Chandra

R (Chandra) Chandrasekhar

unread,
Mar 14, 2009, 5:02:49 AM3/14/09
to sage-s...@googlegroups.com, debia...@googlegroups.com
Jason Grout wrote:

> R (Chandra) Chandrasekhar wrote:
>> Would you recommend that I compile from the source tarball instead?
>
>
> Personally, that's what I recommend. Sage development moves at a nice
> pace, and you're already missing out on a lot of very nice features and
> a lot of bugfixes because the debian package hasn't kept up. The Sage
> that you download is self-contained in one directory, which you can
> delete or move around, so it is trivial to have multiple versions of
> Sage installed in parallel in your home directory, for example.

Thank you. I have downloaded, compiled and installed sage-3.4 from the
source tarball on my Kubuntu Intrepid PC. It has been packaged really
well because there were no hiccups. I only did two things after that.

1. On the first invocation of sage after installation, with

sudo sage

I ran

install_scripts('/usr/local/bin')

at the sage: prompt.

2. I also symlinked the sage script so:

sudo ln -sf /path-to-untarred-sage/sage-3.4/sage /usr/local/bin/sage

After that, things have been running smoothly and the problem with
solving non-linear equations that originally prompted this thread has gone.

>>> Does running "sage -maxima"
>>> run maxima? Can you solve simpler equations?

This time, on running sage -maxima I get:

---
Maxima 5.16.3 http://maxima.sourceforge.net
Using Lisp CLISP 2.46 (2008-07-02)


Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.

The function bug_report() provides bug reporting information.

---

For the benefit of the debian-sage team, the result for the Debian
package was

---
> Maxima 5.13.0 http://maxima.sourceforge.net
> Using Lisp GNU Common Lisp (GCL) GCL 2.6.8 (aka GCL)
> Distributed under the GNU Public License. See the file COPYING.
> Dedicated to the memory of William Schelter.
> This is a development version of Maxima. The function bug_report()
> provides bug reporting information.

---

Perhaps the differences between these two versions, including the type
of Lisp, (plus other possible differences) contributed to the error I
originally saw with the Debian package.

Cheers!

Chandra

Tim Abbott

unread,
Mar 14, 2009, 6:48:23 PM3/14/09
to debia...@googlegroups.com, sage-s...@googlegroups.com
On Sat, 14 Mar 2009, R (Chandra) Chandrasekhar wrote:

> For the benefit of the debian-sage team, the result for the Debian
> package was
>
> ---
> > Maxima 5.13.0 http://maxima.sourceforge.net
> > Using Lisp GNU Common Lisp (GCL) GCL 2.6.8 (aka GCL)
> > Distributed under the GNU Public License. See the file COPYING.
> > Dedicated to the memory of William Schelter.
> > This is a development version of Maxima. The function bug_report()
> > provides bug reporting information.
> ---
>
> Perhaps the differences between these two versions, including the type
> of Lisp, (plus other possible differences) contributed to the error I
> originally saw with the Debian package.

It appears that this is because while Maxima 5.13.0 works fine in Debian
lenny, it crashes frequently in Intrepid and Jaunty because of some
Ubuntu-specific changes. See
<https://bugs.launchpad.net/ubuntu/+source/maxima/+bug/261056>

-Tim Abbott

Reply all
Reply to author
Forward
0 new messages