Ask Your Question
1

Coercion from symbolic ring to Laurent series ring?

asked 2016-06-15 23:12:44 +0100

jaicouru gravatar image

Is there a good way to convert from a symbolic expression to a Laurent series ring? For example, if x is a symbolic variable and LSR is a laurent series ring, then sage produces an error for

LSR(1/x)

saying that the element is not integral.

edit retag flag offensive close merge delete

Comments

You should rather avoid using the symbolic ring at all if possible.

FrédéricC gravatar imageFrédéricC ( 2016-06-17 14:02:25 +0100 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2016-06-20 12:14:23 +0100

slelievre gravatar image

This is a known bug in Sage, developers are working on it.

In the meanwhile, a workaround is to use the numerator and denominator.

Suppose you have defined the Laurent series ring

sage: L.<x> = LaurentSeriesRing(QQ)

and the symbolic variable

sage: xx = SR.var('x')

and you want to convert this symbolic expression

sage: f = 1/xx + xx
sage: f
x + 1/x

into an element of L, the direct approach fails as you noted

sage L(f)
Traceback (most recent call last)
...
TypeError: denominator must be a unit

but this will work:

sage: a, b = f.numerator(), f.denominator()
sage: L(a) / L(b)
x^-1 + x

You can now write a small function laurent that will take f and L as arguments, and return L(f.numerator())/L(f.denominator()).

def laurent(f, L):
    """
    Return the Laurent series for this symbolic expression
    """
    return L(f.numerator()) / L(f.denominator())

Test it using the above examples

sage: laurent(f, L)
x^-1 + x
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: 2016-06-15 23:12:44 +0100

Seen: 325 times

Last updated: Jun 20 '16