Question: Error, out of bound assignment to a list

Hello,

I need to construct a sequence of matrices of different sizes, but with similar structure, and to study their determinants etc.

I wrote the following code:

restart: with(LinearAlgebra):
for n from 5 to 8 do:
for i from 1 to n do for j from 1 to n do A[i,j]:=0 od: od:
for i from 1 to n-1 do A[i,i+1]:=3 od:
for i from 1 to n do A[i,i]:=4 od:
for i from 2 to n do A[i,i-1]:=5 od:
A:=([seq([seq(A[i,j],j=1..n)],i=1..n)]);
Determinant(evalm(1-t*A));
od:

 

However, I get the following error message: "Error, out of bound assignment to a list".

If I add evalm to A:=..., it changes to "Error, 2nd index, 6, larger than upper array bound 5".

I don't see why. I think that by the moment that i and/or j can assume 6, n is already 6.

So what is wrong, and how can this be fixed? Thanks in advance.

Please Wait...