Loading [MathJax]/jax/output/HTML-CSS/jax.js
Ask Your Question
1

Expanding summation with factorial

asked 7 years ago

tomcho gravatar image

If I do this in sage

F=sum(k^2*factorial(n), v=k, a=1, b=n+1); F

it correctly expands to what I want:

   3      2              
2n  + 9n  + 13n + 6⎠⋅n!
───────────────────────────
             6

However, if the factorial is a function of the summed variable, it doesn't work anymore:

sage: F=sum(k^2*factorial(k), v=k, a=1, b=n+1); F
sum(k^2*factorial(k), k, 1, n + 1)
sage: F.expand_sum()
sum(k^2*factorial(k), k, 1, n + 1)

Is this the expected behavior? How can I get it to expand no matter what's inside the summation?

I'm using Sagemath 7.5, by the way.

Thank you.

Preview: (hide)

Comments

Note that the following works:

sage: var( 'k,n' );
sage: sum( k*factorial(k), k, 1, n )
factorial(n + 1) - 1
sage: sum( (k^2+3*k+1)*factorial(k), k, 1, n )
(n + 3)*factorial(n + 1) - 3
sage: sum( (k^3+6*k^2+11*k+5)*factorial(k), k, 1, n )
(n^2 + 6*n + 9)*factorial(n + 1) - 9

Now somebody has to implement the trick also for all sums of the shape 1knP(k)k! with an arbitrary polynomial P. (Well, simplify_factorial did not help...)

dan_fulea gravatar imagedan_fulea ( 7 years ago )

1 Answer

Sort by » oldest newest most voted
2

answered 7 years ago

dan_fulea gravatar image

There is no closed formula for the given sum 1knk2k! . (At least i cannot see any at the first glance.) As in the comment i committed some seconds in advance, the implemented algorithm works for 1knP(k)k! . iff the polynomial P that appears is in the linear span of the polynomials:

  • P1=(k+1)1 ,
  • P2=(k+2)(k+1)1 ,
  • P3=(k+3)(k+2)(k+1)1 ,
  • P4=(k+4)(k+3)(k+2)(k+1)1 and so on.

(They all satisfy the necessary condition P(1)=1.)

But P(k)=k2 is not in this span. Instead, k2+1=P23P1 is.

So the following works for some simple polynomials in the span:

sage: for P in ( k, k^2+1, k^3-1 ):
....:     print ( "P = %-7s and sum( P(k).k! for k=1..n ) is %s" 
....:             % ( P, sum( P*factorial(k), k, 1, n ) ) )
....:             
P = k       and sum( P(k).k! for k=1..n ) is factorial(n + 1) - 1
P = k^2 + 1 and sum( P(k).k! for k=1..n ) is n*factorial(n + 1)
P = k^3 - 1 and sum( P(k).k! for k=1..n ) is (n^2 - 2)*factorial(n + 1) + 2

Bonus: (Out of scope. Please ignore if annoying.)

Let us do the job completely in LATEX for polynomials of the shape kpower+constant:

Code:

D = 9    # stop at this dimension of vector space to be used

R.<x> = QQ[]

L = [ R(1), ] + [ prod( x+j for j in [1..k] ) - 1 for k in [1..D-1] ]
L = [ p.coefficients( sparse=0 ) for p in L ]
L = [ p+[ QQ(0) for _ in range(D-len(p)) ] for p in L ]

V = (QQ^D) . span_of_basis( L )

for kk in [1..D-1]:
    v = vector( QQ, [ j==kk for j in [0..D-1] ] )
    print "%s -> %s" % ( v, V.coordinate_vector(v) )

# and now for the problem
import re
var( 'k,n' );
for kk in [1..D-1]:
    v = vector( QQ, [ j==kk for j in [0..D-1] ] )
    c = V.coordinate_vector(v)[0]
    P = k^kk - c
    print ( r" - $ P = %s$ and $\sum_1^n P\cdot k! = %s$"
            % ( P, re.sub( r'\\,', '', latex( sum( P*factorial(k), k, 1, n ) ) ) ) )

Relevant results are now copy+pasted here:

  • P=k and n1Pk!=(n+1)!1
  • P=k2+1 and n1Pk!=n(n+1)!
  • P=k31 and n1Pk!=(n22)(n+1)!+2
  • P=k42 and n1Pk!=(n33n+3)(n+1)!3
  • P=k5+9 and n1Pk!=(n44n2+6n+4)(n+1)!4
  • P=k69 and n1Pk!=(n55n3+10n2+5n30)(n+1)!+30
  • P=k750 and n1Pk!=(n66n4+15n3+4n266n+55)(n+1)!55
  • P=k8+267 and n1Pk!=(n77n5+21n4119n2+175n+126)(n+1)!126

All above results are computed and displayed via sage.

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 7 years ago

Seen: 635 times

Last updated: Sep 12 '17