Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
sage: var("t, k, n")
(t, k, n)
sage: foo = sum(binomial(n - 1, k - 1)*t^(k - 1), k, 1, n, hold=True) ; foo
sum(t^(k - 1)*binomial(n - 1, k - 1), k, 1, n)
sage: foo.unhold()
0

Problematic, indeed. Workaround : try to replace "non-atomic" symbolic expressions by variables in binomial's arguments :

sage: var("k1, n1")
(k1, n1)

But this is not a simple substitution : k is a summation variable, so it must be treated as such :

sage: bar = foo.maxima_methods().changevar(k1-(k - 1), k1, k).subs(n - 1==n1) ; bar
sum(t^k1*binomial(n1, k1), k1, 0, n1)

(You'll note that this is different from your version w/o -1...)

Now we can compute the result and express it in terms of the original variables ; since there is no summation anymore, a simple substitution suffices :

sage: bar.unhold().subs({k1:k - 1, n1:n - 1})
(t + 1)^(n - 1)

This is the same answer as Mathematica's :

sage: %%mathematica
....: Sum[Binomial[n-1, k-1]*t^(k-1), {k, 1, n}]
....: 
....: 
               -1 + n
        (1 + t)

Giac agrees :

sage: sum(t^(k - 1)*binomial(n - 1, k - 1), k, 1, n, algorithm="giac")
(t + 1)^(n - 1)

Sympy concurs, but assorts its answer of a complicated condition, not yet backtranslatable in Sage. So we treat it manually :

sage: gee = foo._sympy_().doit().simplify()
sage: gee = foo._sympy_().doit().simplify() ; gee
Piecewise(((t + 1)**(n - 1), (Abs(t) <= 1) & ((Abs(t) < 1) | (re(n) - 1 > -1)) & (Ne(t, -1) | (Abs(t) < 1) | (re(n) - 1 > 0)) & (Ne(t, -1) | (re(n) - 1 <= -1) | (re(n) - 1 > 0))), (Sum(t**k*binomial(n - 1, k - 1), (k, 1, n))/t, True))
sage: gee.args[0][0]._sage_()
(t + 1)^(n - 1)

This now Trac#31844.

HTH,