1 /***************************************
3 * This file contains some examples for simplify_sum function
6 * load("simplify_sum");
7 * load("simplify_sum_test");
9 ***************************************/
11 test_sum(sm, ass, use_gamma, smp, [comment]) := block(
12 [product_use_gamma : use_gamma, cs, f],
13 if length(ass)>0 then apply(assume, ass),
14 cs : simplify_sum(sm),
15 for f in smp do cs : apply(f, [cs]),
16 print("|----------------------------------------------------------|"),
17 if length(comment)>0 then apply(print, comment),
18 if length(ass)>0 then print("Assuming:", ass),
20 print("|----------------------------------------------------------|"),
21 if length(ass)>0 then apply(forget, ass)
25 sum(r/k*binomial(n,r)*binomial(m,k-r)/binomial(n+m,k),r,0,k),
28 [makefact, minfactorial]
32 sum(binomial(n,k)/(k+1), k, 0, n),
39 sum((-1)^k * binomial(a+b, a+k) * binomial(b+c, b+k) * binomial(c+a, c+k), k, -a, a),
46 sum((-1)^k * binomial(n,k)*x/(x+k), k, 0, n),
53 sum((-1)^k * binomial(2*n, k)^2, k, 0, 2*n),
60 sum((binomial(3*k+1,k)*binomial(3*(n-k),n-k))/(3*k+1), k, 0, n),
67 sum(binomial(n, k) * binomial(m, r - k), k, 0, r),
74 sum(binomial(2*n,2*k), k, 0, n),
81 sum((-1)^k*binomial(x-2*k,n-k)*binomial(x-k+1,k),k,0,n),
82 [x>2*n, x>2*n-1, x>n-1],
88 sum((-1)^s*binomial(2*m, s)^3, s, 0, 2*m),
95 sum((-1)^k*binomial(k,n-k), k, 0, n),
98 [rectform, trigreduce]
102 sum(binomial(n,k)^2*binomial(3*n+k,2*n), k, -inf, inf),
109 sum((-1)^k*binomial(n-k,k)*2^(n-2*k), k, 0, n),
116 sum(binomial(x,k)*binomial(y,k), k, 0, y),
123 sum((-1)^(n-k)*binomial(n,k)*binomial(k+b,k), k, 0, n),
130 sum(binomial(n+k,k)/2^k,k,0,n),
137 sum((2^(4*k)*binomial(2*n-2*k,n-k))/(2*k*(2*k+1)*binomial(2*k,k)), k, 1, n),
144 sum(k^2 * binomial(n, k), k, 1, n),
151 sum(2^(n-k)*binomial(n+k,2*k),k,-inf,inf),
158 sum(((-1)^k*binomial(2*k,k)*binomial(n,k))/4^k,k,0,n),
165 sum((-1)^k*binomial(2*k,k)*binomial(2*n,k)*binomial(4*n-2*k,2*n-k),k,0,2*n),
172 sum(binomial(l+j,j)*(-1)^(n-l-j)*binomial(n+1,l+j+1),l,0,n-j),
179 sum(binomial(n,4*k),k,0,inf),
185 (assume(n>0), declare(n, integer), 0);
189 sum(binomial(n, k)/binomial(2*n, k)/k!*(2*x)^k, k, 0, inf),
200 sum((n^2+n+1)/(n^4-2*n^2+1),n,2,inf),
207 sum(1/n/(2*n+1),n,1,inf),
214 sum(1/(5*n^2-1),n,1,inf),
221 sum(1/(5*n^2-3),n,1,inf),
229 sum(1/(n^2+1),n,1,inf),
236 sum(1/n/(n+a), n, 1, inf),
243 sum((-1)^(n+1)/n, n, 1, inf),
250 sum((-1)^k*(k+5)/(2*k+1)/(2*k+3), k, 1, inf),
257 sum((-1)^(k+1)/(2*k-1)^3, k, 1, inf),
264 sum(x^n/n!, n, 0, inf),
271 -sum(((-1)^i*x^(2*i))/i,i,1,inf),
278 sum(n/((n+1)*2^n),n,1,inf),
285 sum(n/((2*n+1)*2^n),n,0,inf),
292 sum((4^(-i-1)*(-1)^i*x^(i+1))/(i+1),i,0,inf),
300 'sum('sum(n!/(k!^2*(n - 2*k)!)*(x/y)^k*(x*y)^(n - k), n, 2*k, inf), k, 0, inf),
303 [lambda([u], scanmap(factor, u, 'bottomup))]
304 ), use_zeilberger=false$
314 sum(k*harmonic_number(k),k,1,n),
321 sum(k^2*harmonic_number(k),k,1,n),
328 sum(k^2*harmonic_number(n+k),k,1,n),
331 [lambda([u], u:ev(u, harmonic_number_expand=true), ratsimp(u))]
335 sum(((-4)^k*binomial(k,m)*binomial(n+k,2*k))*n/(n+k),k,m,n),
344 sum(harmonic_number(n)/2^n, n, 1, inf),
351 sum(harmonic_number(n)/n/(n+1), n, 1, inf),
358 sum(n*harmonic_number(n)/2^n, n, 1, inf),
365 sum(harmonic_number(n)/n/2^n, n, 1, inf),
369 "With sum_by_integral_transforms=[logcontract]"
370 ), sum_by_integral_transforms=[logcontract];
373 sum(n^2*harmonic_number(2*n)/2^n, n, 1, inf),
381 sum(((x-1)^(2*n+1)*(x+1)^(-2*n-1))/(2*n+1),n,0,inf),
384 [rootscontract, lambda([u], scanmap(factor, u)), ratsimp]
388 sum(-1/(2*k)+1/(2*2*k+1)+1/(2*2*k+3), k, 1, inf),
402 sum(i*fib(i-1)/2^i,i,1,inf),
409 sum(1/sqrt(k)/sqrt(k+1)/(sqrt(k)+sqrt(k+1)),k,1,inf),