Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Thanks for your help niles. Here is the function I came up with to do this automatically from now on.

 def symbolic_matrix(root,m,n):
     mlist=[];
     for i in range(m):
         for j in range(n):
             mlist.append(root+'_'+str(i)+'_'+str(j));
             var(root+'_'+str(i)+'_'+str(j));
     return matrix(SR,m,n,mlist);

Note that root must be a string.

sage: pmat=symbolic_matrix('p',5,4)
sage: pmat
[p_0_0 p_0_1 p_0_2 p_0_3]
[p_1_0 p_1_1 p_1_2 p_1_3]
[p_2_0 p_2_1 p_2_2 p_2_3]
[p_3_0 p_3_1 p_3_2 p_3_3]
[p_4_0 p_4_1 p_4_2 p_4_3]