Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Recursive computation oa a symbolic sum

Hello,

I would like to program the computation of the following symbolic sum, defined recursively, where n and k are positive integers : $$M_1(n)=n+1,\quad M_k(n)=\sum_{u=0}^nM_{k-1}(n-u) \quad (k>1).$$

I tried the following

def M(kk,nn) :
if kk==1:
    nn+1
else :
    SS=0
    for uz in [0..nn]:
        SS+=M(kk-1,nn-uz)
    SS

but in return of

n = var('n')
assume(n,'integer')
M(3,n)

I receive a long error message the more interesting par of which seems to be "TypeError: cannot evaluate symbolic expression to a numeric value".

Is there a way to deal with this issue?

Recursive computation oa a symbolic sum

Hello,

I would like to program the computation of the following symbolic sum, defined recursively, where n and k are positive integers : $$M_1(n)=n+1,\quad M_k(n)=\sum_{u=0}^nM_{k-1}(n-u) \quad (k>1).$$

I tried the following

def M(kk,nn) :
if kk==1:
    nn+1
else :
    SS=0
    for uz in [0..nn]:
        SS+=M(kk-1,nn-uz)
    SS

but in return of

n = var('n')
assume(n,'integer')
M(3,n)

I receive a long error message the more interesting par of which seems to be "TypeError: cannot evaluate symbolic expression to a numeric value".

Is there a way to deal with this issue?

Recursive computation oa a symbolic sum

Hello,

I would like to program the computation of the following symbolic sum, defined recursively, where n and k are positive integers : $$M_1(n)=n+1,\quad M_k(n)=\sum_{u=0}^nM_{k-1}(n-u) \quad (k>1).$$

I tried the following

def M(kk,nn) :
if kk==1:
    nn+1
else :
    SS=0
    for uz in [0..nn]:
        SS+=M(kk-1,nn-uz)
    SS

but in return of

n = var('n')
assume(n,'integer')
M(3,n)

I receive a long error message the more interesting par of which seems to be "TypeError: cannot evaluate symbolic expression to a numeric value".

Is there a way to deal with this issue?

Recursive computation oa a symbolic sum

Hello,

I would like to program the computation of the following symbolic sum, defined recursively, where n and k are positive integers : $$M_1(n)=n+1,\quad M_k(n)=\sum_{u=0}^nM_{k-1}(n-u) \quad (k>1).$$

I tried the following

def M(kk,nn) :
if kk==1:
    nn+1
else :
    SS=0
    for uz in [0..nn]:
        SS+=M(kk-1,nn-uz)
    SS

but in return of

n = var('n')
assume(n,'integer')
M(3,n)

I receive a long error message the more interesting par of which seems to be "TypeError: cannot evaluate symbolic expression to a numeric value".

Is there a way to deal with this issue?

click to hide/show revision 5
None

Recursive computation oa of a symbolic sum

Hello,

I would like to program the computation of the following symbolic sum, defined recursively, where n and k are positive integers : $$M_1(n)=n+1,\quad M_k(n)=\sum_{u=0}^nM_{k-1}(n-u) \quad (k>1).$$

I tried the following

def M(kk,nn) :
 if kk==1:
     nn+1
 else :
     SS=0
     for uz in [0..nn]:
         SS+=M(kk-1,nn-uz)
     SS

but in return of

n = var('n')
assume(n,'integer')
M(3,n)

I receive a long error message the more interesting par of which seems to be "TypeError: cannot evaluate symbolic expression to a numeric value".

Is there a way to deal with this issue?

Recursive computation of a symbolic sum

Hello,

I would like to program the computation of the following symbolic sum, defined recursively, where n and k are positive integers : $$M_1(n)=n+1,\quad M_k(n)=\sum_{u=0}^nM_{k-1}(n-u) \quad (k>1).$$

I tried the following

def M(kk,nn) :
    if kk==1:
        nn+1
    else :
        SS=0
        for uz in [0..nn]:
            SS+=M(kk-1,nn-uz)
        SS

but in return of

n = var('n')
assume(n,'integer')
M(3,n)

I receive a long error message the more interesting par of which seems to be "TypeError: cannot evaluate symbolic expression to a numeric value".

Is there a way to deal with this issue?

NB. This is quite a theoretical general question with a specific example since, with this specific example, the sum can indeed be computed through a closed formula involving Stirling numbers.

Recursive computation of a symbolic sum

Hello,

I would like to program the computation of the following symbolic sum, defined recursively, where n and k are positive integers : $$M_1(n)=n+1,\quad M_k(n)=\sum_{u=0}^nM_{k-1}(n-u) \quad (k>1).$$

I tried the following

 def M(kk,nn) :
    if kk==1:
        nn+1
SS=nn+1
    else :
        SS=0
        for uz in [0..nn]:
            SS+=M(kk-1,nn-uz)
     return SS

but in return of

n = var('n')
assume(n,'integer')
M(3,n)

I receive a long error message the more interesting par of which seems to be "TypeError: cannot evaluate symbolic expression to a numeric value".

Is there a way to deal with this issue?

NB. This is quite a theoretical general question with a specific example since, with this specific example, the sum can indeed be computed through a closed formula involving Stirling numbers.