# Typing in a command of an adding-to-infinity sum

1/1-x = x^0+x^1+x^2+...

How can I type in such a command of an adding-to-infinity sum?

Urgent! If anyone have any answer or suggestion, please type in here! Thanks!

edit retag close merge delete

Note that the question is about 1/(1 - x), not (1/1) - x.

( 2018-09-04 11:49:43 +0200 )edit

Sort by » oldest newest most voted

Depends if you want to input the series and get the sum of the series (in that case follow Eric's answer), or the converse, in which case you can ask for the series expansion.

sage: f = 1/(1-x)
sage: f.series(x)
1 + 1*x + 1*x^2 + 1*x^3 + 1*x^4 + 1*x^5 + 1*x^6 + 1*x^7 + 1*x^8
+ 1*x^9 + 1*x^10 + 1*x^11 + 1*x^12 + 1*x^13 + 1*x^14 + 1*x^15
+ 1*x^16 + 1*x^17 + 1*x^18 + 1*x^19 + Order(x^20)

more

Like this:

sage: assume(abs(x)<1)
sage: n = var('n')
sage: sum(x^n, n, 0, oo)
-1/(x - 1)

more

slelièvre's answer gives a finite series, completed byy an O(n) term.. If you want the (supposedly exact) infinite series, you have (at least) two possibilities :

• Maxima's powerseries does the job :

sage: (1/(1-x)).maxima_methods().powerseries(x,0)

sum(x^i1, i1, 0, +Infinity)

• Sympy''s summation does it also :

sage: sympy.summation(x^j,(j,0,oo))

Piecewise((1/(-x + 1), Abs(x) < 1), (Sum(x**j, (j, 0, oo)), True))

Sympy's solution is better (it gives the conditions of validity of the result), but currently can't be automatically transtaled to Sage, because Sympy's Sum method does not (yet) have a _sage_() method.

more