Ask Your Question

F_Ranek's profile - activity

2022-04-30 07:58:36 +0200 received badge  Famous Question (source)
2016-11-04 05:01:10 +0200 received badge  Notable Question (source)
2016-10-02 23:30:57 +0200 received badge  Popular Question (source)
2013-11-06 13:49:05 +0200 marked best answer how to turn off symbolic sum evaluation

The problem is that, unlike some other symbolic operators, the symbolic sum does not accept the hold parameter:

sage: var('k n')
(k, n)
sage: sum(binomial(n,k),k,1,n, hold=True)
TypeError: symbolic_sum() got an unexpected keyword argument 'hold'

So, we have to look at the source code and figure out how to simulate one. It is not straightforward, but here is a possible solution:

sage: from sage.interfaces.maxima_lib import max_to_sr, sr_to_max, maxima_eval, max_ratsimp, max_sum, max_simplify_sum
unsimplified_sum = lambda args : max_to_sr(maxima_eval([[max_ratsimp],([max_sum],[sr_to_max(SR(a)) for a in args])]))
sage: further_simplify = lambda f : max_to_sr(maxima_eval([[max_ratsimp],[[max_simplify_sum],sr_to_max(f)]]))

Then, you can do:

sage: var('k n')
(k, n)
sage: s = unsimplified_sum((binomial(n, k), k, 1, n)) ; s
sum(binomial(n, k), k, 1, n)
sage: further_simplify(s)
2^n - 1


sage: s = unsimplified_sum((k^2,k,1,n)) ; s
sum(k^2, k, 1, n)
sage: further_simplify(s)
1/3*n^3 + 1/2*n^2 + 1/6*n


This issue might be fixed by trac ticket 21645.

2013-11-06 13:49:05 +0200 received badge  Scholar (source)
2013-11-06 13:49:03 +0200 received badge  Supporter (source)
2013-11-04 17:32:07 +0200 received badge  Student (source)
2013-11-04 10:15:35 +0200 asked a question how to turn off symbolic sum evaluation

I made some symbolic manipulation and finally... I want to save a 'sum()' in a input form (a evaluated version is horrible big). It is possible to turn off the sum evaluation in SAGE?