Ask Your Question
1

Coefficients of inversed polynomial

asked 2019-04-10 15:28:16 -0600

PaulRa gravatar image

I want to lazily compute coefficients of inversed integer based polynomial.

For example, I have: $$ P = 1 - x $$ and I want to get formal power series of it's inverse: $$ \frac{1}{P} = \frac{1}{1-x} = 1 + x + x^2 + \dots $$

But actually, I would like to get the n-th coefficient of it.

How can I do it?

P.S: I tried the following code, but it computes only 20 coefficients:

sage:> F.<x> = PowerSeriesRing(ZZ); F
sage:> F([1])/(1-x)
1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^10 + x^11 + x^12 + x^13 + x^14 + x^15 + x^16 + x^17 + x^18 + x^19 + O(x^20)

I think I can change precision every time I want to get a coefficient bigger than default 20, but it requires recomputing of that power series, so I want to know is there another way.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-04-10 19:51:27 -0600

slelievre gravatar image

updated 2019-04-17 12:19:32 -0600

The appropriate object would be a "lazy power series".

One can define a LazyPowerSeriesRing in Sage, but it does not seem very capable so far, and in particular cannot compute $1 / (1 - x)$.

From the list of tickets whose summary contains "lazy", the most relevant are:

Many seem stalled but #27347 seems promising.

Edit: With #27347 (now closed and hopefully making it into Sage 8.8.beta3), one can now do:

sage: from sage.rings.lazy_laurent_series_ring import LazyLaurentSeriesRing
sage: L = LazyLaurentSeriesRing(ZZ, 'x')
sage: x = L.gen()
sage: f = ~(1 - x)
sage: f
1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + ...
sage: f[800]
1

A related interesting package is ore_algebra, see

edit flag offensive delete link more

Comments

Thanks.

Maybe I can at least divide 1 by polynomial and get quotient and remainder? I can compute these coefficients by myself this way, but quo_rem method returns the trivial answer (0, 1).

PaulRa gravatar imagePaulRa ( 2019-04-11 03:03:27 -0600 )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

1 follower

Stats

Asked: 2019-04-10 15:28:16 -0600

Seen: 54 times

Last updated: Apr 17