Ask Your Question
1

working with coefficients of formal series

asked 2017-12-20 08:44:55 -0500

charleslebarron gravatar image

I want to define a truncated series or polynomial of arbitrary degree and then work algebraically with the polynomial to solve for various quantities in terms of the coefficients. When I write something like

i,n,z=var('i,n,z')
c=function('c')
p=z^(-4)+sum(c(i)/z^i,i,0,2)
p

this returns

(z^2*c(0) + z*c(1) + c(2))/z^2 + 1/z^4

But if I try to define an arbitrary polynomial of this type

p(n)=z^(-2n) + sum(c(i)/z^i,i,0,2n-2)
p(2)

returns

z^4 + sum(z^(-i)*c(i), i, 0, 2)

What is the crucial difference here?

I had a similar problem when working with truncated power series over the ring PowerSeriesRing(SR). I want to manipulate these expressions algebraically as elements of a ring then ask for info about certain coefficients. But working with formal sums and substituting values of n returns power series coefficients, e.g. the following expression as the coefficient of z^-4 (after some computations...f and g are symbolic functions)

1/4*(sum(z^i*f(i), i, 1, 3)*sum(z^i*g(i), i, 1, 3) + 2)^2 + sum(z^i*f(i), i, 1, 3)*sum(z^i*g(i), i, 1, 3)

How do I get sage to work with the series and also give info about the coefficients, i.e. multiply series expressions but then expand them out in z? I've tried expand() in this setting with mixed success.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-12-20 08:56:06 -0500

B r u n o gravatar image

Is the following what you need?

sage: f = function('f')
sage: g = function('g')
sage: R.<z> = PowerSeriesRing(SR)
sage: F = sum(f(i)*z^i for i in range(3)) + O(z^3)
sage: G = sum(g(i)*z^i for i in range(3)) + O(z^3)
sage: F*G
f(0)*g(0) + (f(0)*g(1) + f(1)*g(0))*z + (f(0)*g(2) + f(1)*g(1) + f(2)*g(0))*z^2 + O(z^3)
edit flag offensive delete link more

Comments

Ideally, we would leave n as a variable, only specifying n=3 when necessary to return meaningful results. Something more like:

F(n)=sum(f(i)*z^i,i,1,n)
G(n)=sum(g(i)*z^i,i,1,n)
F(3)*G(3)

...

charleslebarron gravatar imagecharleslebarron ( 2017-12-20 11:00:51 -0500 )edit

But also, what makes the difference in whether Sage returns the expanded expression or the just something like

sum(z^i*f(i), i, 1, 2)*sum(z^i*g(i), i, 1, 2)
charleslebarron gravatar imagecharleslebarron ( 2017-12-20 11:03:05 -0500 )edit
  1. I don't think you can leave n unspecified and in the same time get it in explicit form in z.
  2. There are (in some sense) two different functions called sum:
    • sum(ex, i, start, end) gives you the symbolic sum made of the expression ex where i goes from start to end. Sometimes, SageMath knows how to simplify it, as in sum(i, i, 0, n).
    • sum(it) where it is an iterator (ex for i in range(12) for instance) is the standard sum function from Python, that sums a definite number of terms. You cannot in this case have a number of terms that is a variable as in the first case. My example uses the second function, while you use the first one. That makes the difference in the results.
B r u n o gravatar imageB r u n o ( 2017-12-20 12:47:40 -0500 )edit

Now another approach, fully working with symbolics, is a follows:

sage: var('i,n,z')
(i, n, z)
sage: f = function('f')
sage: g = function('g')
sage: F = sum(f(i)*z^i, i, 0, n)
sage: G = sum(g(i)*z^i, i, 0, n)
sage: (F*G).subs(n=3).expand_sum().collect(z)
z^6*f(3)*g(3) + (f(2)*g(3) + f(3)*g(2))*z^5 + (f(1)*g(3) + f(2)*g(2) + f(3)*g(1))*z^4 + (f(0)*g(3) + f(1)*g(2) + f(2)*g(1) + f(3)*g(0))*z^3 + (f(0)*g(2) + f(1)*g(1) + f(2)*g(0))*z^2 + (f(0)*g(1) + f(1)*g(0))*z + f(0)*g(0)

Note though that you aren't working with power series, but with polynomials in z.

B r u n o gravatar imageB r u n o ( 2017-12-20 12:49:25 -0500 )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: 2017-12-20 08:44:55 -0500

Seen: 43 times

Last updated: Dec 20 '17