Ask Your Question
1

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

asked 2010-12-01 07:47:42 +0100

Taylor Series gravatar image

updated 2011-04-28 17:02:45 +0100

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
4

answered 2010-12-01 08:06:54 +0100

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
sage: f.degree
<built-in method degree of sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular object at 0x10cb0b8c0>
sage: f.degree()
2

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

Comments

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 08:11:15 +0100 )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 09:01:09 +0100 )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 11:03:54 +0100 )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

Stats

Asked: 2010-12-01 07:47:42 +0100

Seen: 780 times

Last updated: Dec 01 '10