Ask Your Question

Why does almost everything return "<built-in method METHOD of sage.symbolic.expression.Expression object at SOME_ADDRESS>"?

asked 2010-12-01 00:47:42 -0500

Taylor Series gravatar image

updated 2011-04-28 10:02:45 -0500

Kelvin Li gravatar image

Maybe the answer is obvious, but I couldn't find anything. Let's say I have a variable that contains a symbolic expression. I can type a "." (dot) at the end and press TAB and I get a huge list of methods I can choose from. So I choose simplify_full or trig_reduce or something similar (I tried about 8 different methods). Now comes the thing I don't understand: Almost anything returns:

built-in method METHODNAME of sage.symbolic.expression.Expression object at SOME_ADDRESS

For example:

built-in method reduce_trig of sage.symbolic.expression.Expression object at 0x73b5ab8

Is there something wrong with my sage configuration? I'm running Ubuntu 10.10 64-bit.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2010-12-01 01:06:54 -0500

niles gravatar image

Ah, the trick is that you have to type parentheses after the method name to evaluate the method:

sage: R.<s,t> = PolynomialRing(QQ,2)
sage: f = 1 + s + t + t*s
<built-in method degree of sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular object at 0x10cb0b8c0>

Note that if the method requires arguments, you put those in the parentheses:

sage: f.change_ring()
Traceback (most recent call last):
TypeError: change_ring() takes exactly one argument (0 given)

sage: f.change_ring(ZZ)
s*t + s + t + 1
edit flag offensive delete link more


thanks a lot :-) I don't know why I haven't thought of this. Maybe I spent too many years using Mathematica.

Taylor Series gravatar imageTaylor Series ( 2010-12-01 01:11:15 -0500 )edit

Yes, and this is pretty clear in the documentation. Don't forget that you can do `f.change_ring?` and similar to get lots of cool info!

kcrisman gravatar imagekcrisman ( 2010-12-01 02:01:09 -0500 )edit

seems like I'm spoiled by Netbeans which always writes all parentheses and arguments like needed.

Taylor Series gravatar imageTaylor Series ( 2010-12-01 04:03:54 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2010-12-01 00:47:42 -0500

Seen: 280 times

Last updated: Dec 01 '10