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
```

2 | No.2 Revision |

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
```

3 | No.3 Revision |

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
```

4 | No.4 Revision |

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

```
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])

5 | No.5 Revision |

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

```
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])

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.