Ask Your Question

Sage cell server isn't giving me the output I expect

asked 2023-06-17 02:41:35 +0200

lane gravatar image

This code runs fine on CoCalc:

def D(n):
    if n <= 1:
        return matrix([1])
    l = [1,-1] + [0]*(n-2)
    M = matrix(l)
    i = 1
    for _ in range(n - 1):
        l = [i] + l[:-1]
        M = M.stack(matrix(l))
        i = 0
    return M

for i in range(6):
    A = D(i)

But when I put it in the box at there's no output. Why could this be?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2023-06-18 16:26:47 +0200

Emmanuel Charpentier gravatar image

Your code computes A and A.det(), but nowhere you ask for their output. Try, e. g. :

for i in range(6):
    A = D(i)
    show(A, A.det())

Demonstration here.


edit flag offensive delete link more


Thank you very much!

lane gravatar imagelane ( 2023-06-26 02:50:10 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2023-06-17 02:41:35 +0200

Seen: 197 times

Last updated: Jun 18 '23