Ask Your Question
3

Cast to Expression

asked 14 years ago

Ben Reynwar gravatar image

How do I cast a number to an Expression?

I would have assumed:

> Expression(0)
Traceback (click to the left of this block for traceback)
...
TypeError: Cannot convert sage.rings.integer.Integer to
sage.structure.parent.Parent
Preview: (hide)

1 Answer

Sort by » oldest newest most voted
4

answered 14 years ago

DSM gravatar image

Yeah, that tripped me up too!

You can do it by calling the parent ring, which in this case is the Symbolic Ring, abbreviated SR:

sage: a = 3
sage: type(a)
<type 'sage.rings.integer.Integer'>
sage: parent(a)
Integer Ring
sage: b = SR(a)
sage: type(b)
<type 'sage.symbolic.expression.Expression'>
sage: parent(b)
Symbolic Ring
Preview: (hide)
link

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: 14 years ago

Seen: 697 times

Last updated: Apr 08 '11