2014-10-20 13:56:36 +0200 answered a question Construct a matrix row by row with some rules on elements It seems to work, thanks. Code like m=matrix.identity(nn+1) nn1_half=(nn+1)/2 for j in range(nn1_half) : m=m*elementary_matrix(nn+1,row1=j,row2=nn-j) vecordinv_matrix=m # a (nn+1)-sized matrix with 1 on the anti-diagonal and 0 as other entries # A=matrix(CC,nn+1) A[0,0:4]=vector((N(m11_tot(aa,nn)),N(m12_tot(aa,nn)),N(m13_tot(aa,nn)),N(m14_tot(aa,nn)))) A[1,0:5]=vector((N(m12_tot(aa,nn)),N(m22_tot(aa,nn)),N(m23_tot(aa,nn)),N(m24_tot(aa,nn)), \ N(m25_tot(aa,nn)))) A[2,0:6]=vector((N(m13_tot(aa,nn)),N(m23_tot(aa,nn)),N(m33_tot(aa,nn)),N(m34_tot(aa,nn)), \ N(m35_tot(aa,nn)),N(m36_tot(aa,nn)))) A[3,0:7]=vector((N(m14_tot(aa,nn)),N(m24_tot(aa,nn)),N(m34_tot(aa,nn)),N(m33_tot(aa,nn)), \ N(m34_tot(aa,nn)),N(m35_tot(aa,nn)),N(m36_tot(aa,nn)))) A[4,1:8]=vector((N(m25_tot(aa,nn)),N(m35_tot(aa,nn)),N(m34_tot(aa,nn)),N(m33_tot(aa,nn)), \ N(m34_tot(aa,nn)),N(m35_tot(aa,nn)),N(m36_tot(aa,nn)))) for j in [5..nn-5] : A[j,j-3:j+4]=vector((N(m36_tot(aa,nn)),N(m35_tot(aa,nn)),N(m34_tot(aa,nn)),N(m33_tot(aa,nn)), \ N(m34_tot(aa,nn)),N(m35_tot(aa,nn)),N(m36_tot(aa,nn)))) A_aux=matrix(CC,nn+1,5) for j in range(5) : A_aux[:,j]=vecordinv_matrix*A[j,:].transpose() A[nn-j,:]=A_aux[:,j].transpose() M=nn*A  correctly outputs the desired results. Differently from Matlab/Octave, a:b means from a to b-1 and not from a to b (the right extremum is excluded). Also, matrix has to be declared with the right type of entries (complex, CC, in this case), otherwise they are assumed to be integers, and in the case they are not, an error message is displayed (something that has the meaning of attempted coercition of non integral number in an integer). 2014-10-18 20:14:37 +0200 asked a question Construct a matrix row by row with some rules on elements I want to construct a matrix in which the first rows, along with the last ones, are peculiar, being the last ones the inverted forms of the first ones, while the central rows have the same form, just with the nonzero part shifted right by proceeding from one row to the next one. In Matlab or Octave I would have written something like: # begin Matlab equivalent code for matrix # A=zeros(nn+1) # A(1,1:4)=[m11 m12 m13 m14] # A(2,1:5)=[m12 m22 m23 m24 m25] # A(3,1:6)=[m13 m23 m33 m34 m35 m36] # A(4,1:7)=[m14 m24 m34 m33 m34 m35 m36] # A(5,2:8)=[m25 m35 m34 m33 m34 m35 m36] # for i=6:nn-4 # A(i,i-3:i+3)=[m36 m35 m34 m33 m34 m35 m36] # end # A(nn-3,nn-6:nn)=A(5,8:-1:2) # A(nn-2,nn-5:nn+1)=A(4,7:-1:1) # A(nn-1,nn-4:nn+1)=A(3,6:-1:1) # A(nn,nn-3:nn+1)=A(2,5:-1:1) # A(nn+1,nn-2:nn+1)=A(1,4:-1:1) # end Matlab equivalent code for matrix  Although I was able to construct it also in Sage with a fixed nn=10: aa=10 nn=10 vecordinv_matrix=matrix([[0,0,0,0,0,0,0,0,0,0,1],[0,0,0,0,0,0,0,0,0,1,0],[0,0,0,0,0,0,0,0,1,0,0], \ [0,0,0,0,0,0,0,1,0,0,0],[0,0,0,0,0,0,1,0,0,0,0],[0,0,0,0,0,1,0,0,0,0,0], \ [0,0,0,0,1,0,0,0,0,0,0],[0,0,0,1,0,0,0,0,0,0,0],[0,0,1,0,0,0,0,0,0,0,0], \ [0,1,0,0,0,0,0,0,0,0,0],[1,0,0,0,0,0,0,0,0,0,0]]) mv1=vector((N(m11_tot(aa,nn)),N(m12_tot(aa,nn)),N(m13_tot(aa,nn)),N(m14_tot(aa,nn)), \ 0,0,0,0,0,0,0)) mv2=vector((N(m12_tot(aa,nn)),N(m22_tot(aa,nn)),N(m23_tot(aa,nn)),N(m24_tot(aa,nn)), \ N(m25_tot(aa,nn)),0,0,0,0,0,0)) mv3=vector((N(m13_tot(aa,nn)),N(m23_tot(aa,nn)),N(m33_tot(aa,nn)),N(m34_tot(aa,nn)), \ N(m35_tot(aa,nn)),N(m36_tot(aa,nn)),0,0,0,0,0)) mv4=vector((N(m14_tot(aa,nn)),N(m24_tot(aa,nn)),N(m34_tot(aa,nn)),N(m33_tot(aa,nn)), \ N(m34_tot(aa,nn)),N(m35_tot(aa,nn)),N(m36_tot(aa,nn)),0,0,0,0)) mv5=vector((0,N(m25_tot(aa,nn)),N(m35_tot(aa,nn)),N(m34_tot(aa,nn)),N(m33_tot(aa,nn)), \ N(m34_tot(aa,nn)),N(m35_tot(aa,nn)),N(m36_tot(aa,nn)),0,0,0)) mv6=vector((0,0,N(m36_tot(aa,nn)),N(m35_tot(aa ... 2014-10-18 13:19:34 +0200 received badge ● Scholar (source) 2014-10-17 17:35:46 +0200 commented answer N(): is it possible to display less digits than those use to compute? It works, manies of thanks. :) By the way, is there a similar command in order to display only the real part of the matrix elements? I have some computations in the complex field where imaginary parts should have cancellation, but due to roundoff they remain with a decimal magnitude of -13 or -14. Usual commands real and imag, along with their synonyms real_part and imag_part, both by writing real(x) and x.real(), seem not to work for matrices. Thanks again... EDIT: a workaround like (1/2)*A+(1/2)*A.conjugate() seems to work... 2014-10-17 00:42:39 +0200 asked a question N(): is it possible to display less digits than those use to compute? Is there a way to do numerical computations in a certain precision, while displaying a lower number of digits, for example if I want to output a matrix of a certain dimension, and I would prefer a consistent layout? An example with another CAS is format short in Matlab and Octave, which allows to compute in double precision (15 or 16 digits) by displaying only 5 digits. Thanks in advance.