Ask Your Question

Glenn Tesler's profile - activity

2021-05-23 21:29:29 +0200 received badge  Supporter (source)
2021-05-22 18:17:21 +0200 marked best answer Incorrect symbolic sum w/binomial coefficients

This should give (t+1)^(n-1), but instead it gives 0:

sage: var('n k t');
sage: sum(binomial(n-1,k-1)*t^(k-1), k, 1, n)
0

A version w/o -1's works correctly:

sage: var('n k t');
sage: sum(binomial(n,k)*t^k, k, 0, n)
(t + 1)^n

With -2's, it's left unevaluated:

sage: var('n k t');
sage: sum(binomial(n-2,k-2)*t^(k-2), k, 2, n)
sum(t^(k - 2)*binomial(n - 2, k - 2), k, 2, n)

However, Mathematica and Maple can do problems like this. E.g., in Mathematica,

In[1]:= Sum[Binomial[n-2, k-2]*t^(k-2), {k, 2, n}]
Out[1]= (1 + t)^(-2 + n)

With positive offsets instead of negative offsets, it works correctly:

sage: var('n k t');
sage: sum(binomial(n+2,k+2)*t^(k+2), k, -2, n)
(t^2 + 2*t + 1)*(t + 1)^n

The result is correct, although it could be simplified better: (t + 1)^(n + 2)

Version: 'SageMath version 9.2, Release Date: 2020-10-24'

I also get the same results on http://sagecell.sagemath.org

2021-05-22 18:17:21 +0200 received badge  Scholar (source)
2021-05-22 00:28:31 +0200 received badge  Nice Answer (source)
2021-05-21 23:32:06 +0200 received badge  Teacher (source)
2021-05-21 23:20:59 +0200 answered a question How to make a hexadecimal number into a string

For a Sage integer (vs. python int), s.hex() gives just the hex digits, without the prefix '0x': sage: s=123456

2021-05-20 23:51:34 +0200 received badge  Student (source)
2021-05-20 23:41:32 +0200 asked a question Incorrect symbolic sum w/binomial coefficients

Incorrect symbolic sum w/binomial coefficients This should give (t+1)^(n-1), but instead it gives 0: sage: var('n k t')