Processing math: 100%
Ask Your Question
1

Compute power series

asked 1 year ago

Thrash gravatar image

I would like to compute k=0(1+(1)k)xk. In Mathematica, one can do

In[1]:= Sum[(1+(-1)^k)*x^k,{k,0,Infinity}]                                     

          -2
Out[1]= -------
              2
        -1 + x

How does it work in Sage? I tried

sage: var('k')
k
sage: sum((1+(-1)^k)*x^k, k, 0, oo)
sum(((-1)^k + 1)*x^k, k, 0, +Infinity)

which doesn't give me any new information.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
2

answered 1 year ago

achrzesz gravatar image

updated 1 year ago

For example

giac('normal(sum((1+(-1)^k)*x^k,k,0,inf))').sage()

-2/(x^2 - 1)
Preview: (hide)
link

Comments

1

Nice ! I didn't know this one.

Alternate way to express, possibly more "natural"' to Python/Sage :

sage: sum((1+(-1)^k)*x^k, k, 0, oo)._giac_().normal()._sage_()
-2/(x^2 - 1)

Note a convergence condition given by Sympy's solution (currently not directly translatable in Sage) :

sage: sum((1+(-1)^k)*x^k, k, 0, oo)._sympy_().doit()
Piecewise((1/(1 - x), Abs(x) < 1), (Sum(x**k, (k, 0, oo)), True)) + Piecewise((1/(x + 1), Abs(x) < 1), (Sum((-1)**k*x**k, (k, 0, oo)), True))

This convergence radius is important.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 1 year ago )

Thank you both!

Thrash gravatar imageThrash ( 1 year ago )

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: 1 year ago

Seen: 194 times

Last updated: Jul 09 '23