Ask Your Question
3

Cast to Expression

asked 2011-04-08 12:02:33 +0100

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
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2011-04-08 12:07:14 +0100

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
edit flag offensive delete link more

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: 2011-04-08 12:02:33 +0100

Seen: 653 times

Last updated: Apr 08 '11