![]() | 1 | initial version |
The problem is that, unlike some other symbolic operators, the symbolic sum
do 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. I 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(s)]]))
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
![]() | 2 | No.2 Revision |
The problem is that, unlike some other symbolic operators, the symbolic sum
do 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. I 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(s)]]))
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
![]() | 3 | No.3 Revision |
The problem is that, unlike some other symbolic operators, the symbolic sum
do 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(s)]]))
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
Or:
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
![]() | 4 | No.4 Revision |
The problem is that, unlike some other symbolic operators, the symbolic sum
do 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(s)]]))
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
Or:
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
![]() | 5 | No.5 Revision |
The problem is that, unlike some other symbolic operators, the symbolic sum
do 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
Or:
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
![]() | 6 | No.6 Revision |
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
Or:
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
EDIT
![]() | 7 | No.7 Revision |
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
Or:
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
EDIT
This issue might be fixed by trac ticket 21645.