Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Recurrence, for-loop and zero.

Hello guys! Hope you guys are having a nice day.

I have some problem as follows: I setup some recurrence as follows

def f(j,k):
if k==0:
elif j==0:
return m

And if we calculate

f(1,1), f(2,1), f(1,2), f(2,2)

in sage, then what we get are

4, 35/2, 35/2, 105/2.

However, if we do the for loop as in the below, I found the above results to be zero!!:

for k in range(3):
    for j in range(3):
        (j,k), expVal(j,k)

And the calculation result from the sage is:

((0, 0), 0)

((1, 0), 1)

((2, 0), 2)

((0, 1), 1)

((1, 1), 0)

((2, 1), 0)

((0, 2), 2)

((1, 2), 0)

((2, 2), 0)

And observe the bolded result above... it is weird that the result is zero... Can anyone help me fix this please...

Thank you for any help! Hope you have a nice rest of the day!