Ask Your Question
1

Coefficients of series

asked 2016-11-29 11:10:51 +0200

Peter Luschny gravatar image

updated 2016-11-29 11:20:20 +0200

Consider the sequence of polynomials:

g = lambda x, n: ((1 + x^2)^n + n*x*(1 + x^2)^(n - 1))

for n in (0..4):
    print g(x,n).series(x,3*n)

1
1 + 1*x + 1*x^2
1 + 2*x + 2*x^2 + 2*x^3 + 1*x^4
1 + 3*x + 3*x^2 + 6*x^3 + 3*x^4 + 3*x^5 + 1*x^6
1 + 4*x + 4*x^2 + 12*x^3 + 6*x^4 + 12*x^5 + 4*x^6 + 4*x^7 + 1*x^8

for n in (0..4):
    print g(x,n).list()

[1]
[1, 1, 1]
[1, 2, 2, 2, 1]
[1, 3, 3, 6, 3, 3, 1]
[1, 4, 4, 12, 6, 12, 4, 4, 1]

These are obviously the coefficients of the polynomials.

So I expected that I could also write instead

for n in (0..4):
    print g(x,n).series(x,3*n).coefficients()

But this is not the case. What I get is:

[]
[[1, 0], [1, 1]]
[[1, 0], [2, 1], [2, 2], [2, 3]]
[[1, 0], [3, 1], [3, 2], [6, 3], [3, 4], [3, 5]]
[[1, 0], [4, 1], [4, 2], [12, 3], [6, 4], [12, 5], [4, 6], [4, 7]]

Here the term 1x^(2n) is missing. Is this a bug?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-11-29 12:18:52 +0200

slelievre gravatar image

I think it is a bug.

A workaround for now is to use coeffs instead of coefficients.

Here is what you get then.

sage: for n in (0..4):
....:     print g(x,n).series(x,3*n).coeffs()
....:     
/opt/s/sage-7.4/src/bin/sage-ipython:2: DeprecationWarning: coeffs is deprecated. Please use coefficients instead.
See http://trac.sagemath.org/17438 for details.
  # -*- coding: utf-8 -*-
[[1, 0]]
[[1, 0], [1, 1], [1, 2]]
[[1, 0], [2, 1], [2, 2], [2, 3], [1, 4]]
[[1, 0], [3, 1], [3, 2], [6, 3], [3, 4], [3, 5], [1, 6]]
[[1, 0], [4, 1], [4, 2], [12, 3], [6, 4], [12, 5], [4, 6], [4, 7], [1, 8]]

Note however that coeffs is deprecated, so it might disappear in a future version of Sage.

I'll edit later today with more on the bug.

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

1 follower

Stats

Asked: 2016-11-29 11:10:51 +0200

Seen: 625 times

Last updated: Nov 29 '16