Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to extract the integer part from a symbolic expressions?

Suppose I solve the following quadratic equation using SAGE and store the solution in two variables, a and b :

sage: x = var('x')
sage: qe = (x^2 - 618*x + 90581 == 0)
sage: a, b = solve(qe, x)

Which gives me the following output:

sage: a
sage: x == 379
sage: b  
sage: x == 239
sage: type(a), type(b)
sage: (sage.symbolic.expression.Expression, sage.symbolic.expression.Expression)

I wish to get the output in this form:

sage: a
sage: 379
sage: b  
sage: 239
sage: type(a), type(b)
sage: (sage.rings.integer.Integer, sage.rings.integer.Integer)

How can I do this easily?

How to extract the integer part from a symbolic expressions?

Suppose I solve the following quadratic equation using SAGE and store the solution in two variables, a and b :

sage: x = var('x')
sage: qe = (x^2 - 618*x + 90581 == 0)
sage: a, b = solve(qe, x)

Which gives me the following output:

sage: a
sage: x == 379
sage: b  
sage: x == 239
sage: type(a), type(b)
sage: (sage.symbolic.expression.Expression, sage.symbolic.expression.Expression)

I wish to get the output in this form:

sage: a
sage: 379
sage: b  
sage: 239
sage: type(a), type(b)
sage: (sage.rings.integer.Integer, sage.rings.integer.Integer)

How can I do this easily?