Try running this code in either the cell server or the cloud:
f = lambda p,q: matrix(p-1, p-1, lambda i,j: q*(p-1)/p if i==j else -q/p)
for p in range(3,4):
for q in range(2,3):
print f(p,q)
print f(3,2)
This produces the following output:
[4/3 -1]
[ -1 4/3]
[ 4/3 -2/3]
[-2/3 4/3]
What is going on here? Those -1's are just incorrect. I think the problem
must be in the inner lambda, since if I instead do
def e(i,j):
if i==j:
return q*(p-1)/p
else:
return -q/p
f = lambda p,q: matrix(p-1, p-1,e)
then everything works OK. But shouldn't these two pieces of code produce
the same output? Sorry if I am missing something obvious.
-Jeremy
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.