Sage tutorial: solving equations numerically

816 views
Skip to first unread message

Minh Nguyen

unread,
Jul 20, 2009, 2:18:44 PM7/20/09
to sage-...@googlegroups.com
Hi folks,

I'm getting the following error when working through this part of the
Sage tutorial

http://www.sagemath.org/doc/tutorial/tour_algebra.html#solving-equations-numerically

<begin-transcript>
[mvngu@sage ~]$ sage
----------------------------------------------------------------------
| Sage Version 4.1, Release Date: 2009-07-09 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: theta = var('theta')
sage: solve(cos(theta)==sin(theta))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)

/home/mvngu/.sage/temp/sage.math.washington.edu/20214/_home_mvngu__sage_init_sage_0.py
in <module>()

/usr/local/sage/local/lib/python2.6/site-packages/sage/symbolic/relation.pyc
in solve(f, *args, **kwds)
478 """
479 try:
--> 480 return f.solve(*args,**kwds)
481 except AttributeError:
482 from sage.symbolic.ring import is_SymbolicVariable

/usr/local/sage/local/lib/python2.6/site-packages/sage/symbolic/expression.so
in sage.symbolic.expression.Expression.solve
(sage/symbolic/expression.cpp:21623)()

TypeError: solve() takes at least 1 positional argument (0 given)
sage: solve(cos(theta)==sin(theta), theta)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)

/home/mvngu/.sage/temp/sage.math.washington.edu/20214/_home_mvngu__sage_init_sage_0.py
in <module>()

/usr/local/sage/local/lib/python2.6/site-packages/sage/symbolic/relation.pyc
in solve(f, *args, **kwds)
478 """
479 try:
--> 480 return f.solve(*args,**kwds)
481 except AttributeError:
482 from sage.symbolic.ring import is_SymbolicVariable

/usr/local/sage/local/lib/python2.6/site-packages/sage/symbolic/expression.so
in sage.symbolic.expression.Expression.solve
(sage/symbolic/expression.cpp:22150)()

/usr/local/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc
in __call__(self, *args, **kwds)
1380
1381 def __call__(self, *args, **kwds):
-> 1382 return self._obj.parent().function_call(self._name,
[self._obj] + list(args), kwds)
1383
1384 def help(self):

/usr/local/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc
in function_call(self, function, args, kwds)
1288 [s.name() for s in args],
1289
['%s=%s'%(key,value.name()) for key, value in kwds.items()])
-> 1290 return self.new(s)
1291
1292 def _function_call_string(self, function, args, kwds):

/usr/local/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc
in new(self, code)
1084
1085 def new(self, code):
-> 1086 return self(code)
1087
1088 ###################################################################


/usr/local/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc
in __call__(self, x, name)
1019
1020 if isinstance(x, basestring):
-> 1021 return cls(self, x, name=name)
1022 try:
1023 return self._coerce_from_special_method(x)

/usr/local/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.pyc
in __init__(self, parent, value, is_name, name)
1423 except (TypeError, KeyboardInterrupt,
RuntimeError, ValueError), x:
1424 self._session_number = -1
-> 1425 raise TypeError, x
1426 self._session_number = parent._session_number
1427

TypeError: Error executing code in Maxima
CODE:
sage4 : to_poly_solve(sage0,sage3)$
Maxima ERROR:

Nonalgebraic argument given to 'topoly'
#0: to_poly_solve(e=cos(theta) =
sin(theta),vars=theta)(topoly_solver.mac line 10)
<end-transcript>

--
Regards
Minh Van Nguyen

Minh Nguyen

unread,
Jul 20, 2009, 3:34:03 PM7/20/09
to sage-...@googlegroups.com
On Tue, Jul 21, 2009 at 4:18 AM, Minh Nguyen<nguye...@gmail.com> wrote:
> Hi folks,
>
> I'm getting the following error when working through this part of the
> Sage tutorial
>
> http://www.sagemath.org/doc/tutorial/tour_algebra.html#solving-equations-numerically

<SNIP>

Here's a weird thing: The example concerned is in the file

SAGE_ROOT/devel/sage-main/doc/en/tutorial/tour_algebra.rst

Doctesting it shows that all tests passed:

[mvngu@sage sage-4.1-sage.math.washington.edu-x86_64-Linux]$ ./sage -t
-long devel/sage-main/doc/en/tutorial/tour_algebra.rst
sage -t -long "devel/sage-main/doc/en/tutorial/tour_algebra.rst"
[5.7 s]

----------------------------------------------------------------------
All tests passed!
Total time for all tests: 5.7 seconds


But manually evaluating the commands on the command line results in errors:

[mvngu@sage sage-4.1-sage.math.washington.edu-x86_64-Linux]$ ./sage


----------------------------------------------------------------------
| Sage Version 4.1, Release Date: 2009-07-09 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: theta = var('theta')
sage: solve(cos(theta)==sin(theta))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)

/home/mvngu/.sage/temp/sage.math.washington.edu/17516/_home_mvngu__sage_init_sage_0.py
in <module>()

/scratch/mvngu/sage-4.1-sage.math.washington.edu-x86_64-Linux/local/lib/python2.6/site-packages/sage/symbolic/relation.pyc


in solve(f, *args, **kwds)
478 """
479 try:
--> 480 return f.solve(*args,**kwds)
481 except AttributeError:
482 from sage.symbolic.ring import is_SymbolicVariable

/scratch/mvngu/sage-4.1-sage.math.washington.edu-x86_64-Linux/local/lib/python2.6/site-packages/sage/symbolic/expression.so
in sage.symbolic.expression.Expression.solve
(sage/symbolic/expression.cpp:21623)()

TypeError: solve() takes at least 1 positional argument (0 given)

But the tutorial has the output as:

sage: theta = var('theta')
sage: solve(cos(theta)==sin(theta))

[sin(theta) == cos(theta)]

John H Palmieri

unread,
Jul 20, 2009, 3:50:13 PM7/20/09
to sage-devel


On Jul 20, 12:34 pm, Minh Nguyen <nguyenmi...@gmail.com> wrote:
> On Tue, Jul 21, 2009 at 4:18 AM, Minh Nguyen<nguyenmi...@gmail.com> wrote:
> > Hi folks,
>
> > I'm getting the following error when working through this part of the
> > Sage tutorial
>
> >http://www.sagemath.org/doc/tutorial/tour_algebra.html#solving-equati...
>
> <SNIP>
>
> Here's a weird thing: The example concerned is in the file
>
> SAGE_ROOT/devel/sage-main/doc/en/tutorial/tour_algebra.rst
>
> Doctesting it shows that all tests passed:

This much I think I understand: if you change the end of the line
before the doctest from

"the following equation::"

to

"the following equation:

::"

Then doctests fail, as you report that they should. So the doctesting
process only detects doctests when they are preceded by a double colon
on its own line? Looks like we need to go through the documentation
(or the doctesting process) to fix this. Care to open a ticket? I'll
try to help.

John

Minh Nguyen

unread,
Jul 20, 2009, 4:13:11 PM7/20/09
to sage-...@googlegroups.com
Hi John,

On Tue, Jul 21, 2009 at 5:50 AM, John H Palmieri<jhpalm...@gmail.com> wrote:

<SNIP>

> This much I think I understand: if you change the end of the line
> before the doctest from
>
> "the following equation::"
>
> to
>
> "the following equation:
>
> ::"
>
> Then doctests fail, as you report that they should. So the doctesting
> process only detects doctests when they are preceded by a double colon
> on its own line? Looks like we need to go through the documentation
> (or the doctesting process) to fix this. Care to open a ticket? I'll
> try to help.

So this is only for documents in the standard documentation, minus the
reference manual? The reference manual doesn't suffer from the problem
above, so I think we can leave it out. OK, let's start with fixing the
tutorial first. This is now ticket #6572

http://trac.sagemath.org/sage_trac/ticket/6572

Thank you for your offer to help out.

Reply all
Reply to author
Forward
0 new messages