Ask Your Question

Revision history [back]

maybe this is what you want to do?

sage: var('V_11,V_12,V_13,V_21,V_22,V_23,V_31,V_32,V_33');
sage: V = matrix(SR,3,3,[V_11,V_12,V_13,V_21,V_22,V_23,V_31,V_32,V_33])
sage: P = lambda a, b : [V[a,k]*V[b,k]*V[a,j]*V[b,j] for k in [0,1,2] for j in  [0,1,2]]
sage: P(a=0, b=1)

[V_11^2*V_21^2,
 V_11*V_12*V_21*V_22,
 V_11*V_13*V_21*V_23,
 V_11*V_12*V_21*V_22,
 V_12^2*V_22^2,
 V_12*V_13*V_22*V_23,
 V_11*V_13*V_21*V_23,
 V_12*V_13*V_22*V_23,
 V_13^2*V_23^2]