Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

One alternative: instead of having a loop and a 'print', you build the list of your expressions. On this list, you can call "view":

view([sum(factorial(j)*stirling_number1(n,j)*(x-1)^(-j-1) for j in (0,n)) for n in range(4)])

The problem that you meed in your second code is that 'stirling1' does not understand symbolic variables

sage: stirling_number1(4,3)
6
sage: stirling_number1(4,x)
TypeError: unable to convert x to an integer
sage: stirling_number1(x,4)
TypeError: unable to convert x to an integer

One alternative: instead of having a loop and a 'print', you build the list of your expressions. On this list, you can call "view":

view([sum(factorial(j)*stirling_number1(n,j)*(x-1)^(-j-1) for j in (0,n)) for n in range(4)])

The problem that you meed in your second code is that 'stirling1' does not understand symbolic variables

sage: stirling_number1(4,3)
6
sage: stirling_number1(4,x)
TypeError: unable to convert x to an integer
sage: stirling_number1(x,4)
TypeError: unable to convert x to an integer

EDIT: If you want this loop to work, you cannot use 'symbolic_sum', as it feeds stirling_number1 wich a symbolic variable. You must build a list and use 'sum'

for n in range(5):
    S = sum(factorial(j)*stirling_number1(n,j)*(x-1)^(-j-1) for j in range(n))   
    print S

One alternative: instead of having a loop and a 'print', you build the list of your expressions. On this list, you can call "view":

view([sum(factorial(j)*stirling_number1(n,j)*(x-1)^(-j-1) for j in (0,n)) for n in range(4)])

The problem that you meed in your second code is that 'stirling1' does not understand symbolic variables

sage: stirling_number1(4,3)
6
sage: stirling_number1(4,x)
TypeError: unable to convert x to an integer
sage: stirling_number1(x,4)
TypeError: unable to convert x to an integer

EDIT: If you want this loop to work, you cannot use 'symbolic_sum', as it feeds stirling_number1 wich with a symbolic variable. You must build a list and use 'sum'

for n in range(5):
    S = sum(factorial(j)*stirling_number1(n,j)*(x-1)^(-j-1) for j in range(n))   
    print S

One alternative: instead of having a loop and a 'print', you build the list of your expressions. On this list, you can call "view":

view([sum(factorial(j)*stirling_number1(n,j)*(x-1)^(-j-1) for j in (0,n)) for n in range(4)])

The problem that you meed in your second code is that 'stirling1' does not understand symbolic variables

sage: stirling_number1(4,3)
6
sage: stirling_number1(4,x)
TypeError: unable to convert x to an integer
sage: stirling_number1(x,4)
TypeError: unable to convert x to an integer

EDIT: If you want this loop to work, you cannot use 'symbolic_sum', as it feeds stirling_number1 with a symbolic variable. You must build a list and use 'sum'

for n in range(5):
    S = sum(factorial(j)*stirling_number1(n,j)*(x-1)^(-j-1) for j in range(n))   
    print S

EDIT2: I just understood that your problem was not the hard-to-read output but the results themselves. Instead of (0,n) (which is the PAIR (0,n)) you probably want to use range(n) or [0..n])

One alternative: instead of having a loop and a 'print', you build the list of your expressions. On this list, you can call "view":

view([sum(factorial(j)*stirling_number1(n,j)*(x-1)^(-j-1) for j in (0,n)) for n in range(4)])

The problem that you meed in your second code is that 'stirling1' does not understand symbolic variables

sage: stirling_number1(4,3)
6
sage: stirling_number1(4,x)
TypeError: unable to convert x to an integer
sage: stirling_number1(x,4)
TypeError: unable to convert x to an integer

EDIT: If you want this loop to work, you cannot use 'symbolic_sum', as it feeds stirling_number1 with a symbolic variable. You must build a list and use 'sum'

for n in range(5):
    S = sum(factorial(j)*stirling_number1(n,j)*(x-1)^(-j-1) for j in range(n))   
    print S

EDIT2: I just understood that your problem was not the hard-to-read output but the results themselves. Instead of (0,n) (which is the PAIR (0,n)) you probably want to use range(n) range(n+1) or [0..n])