Ask Your Question

# how can i define a matrix product like a summation

asked 2017-08-03 06:43:33 +0200 This post is a wiki. Anyone with karma >750 is welcome to improve it.

first, my mother tongue is not English but I try it, my problem is that if I define a symbolic matrix V such that,

var('V_11,V_12,V_13,V_21,V_22,V_23,V_31,V_32,V_33')

V = matrix(SR,3,3,[V_11,V_12,V_13,V_21,V_22,V_23,V_31,V_32,V_33])


and then I define

P = [V[a,k]*V[b,k]*V[a,j]*V[b,j] for k in [0,1,2] for j in  [0,1,2]]


But if I evaluate, for example

P(a=0,b=1)


but the code is not work can someone help me?

edit retag close merge delete

## 1 Answer

Sort by » oldest newest most voted

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]

more

## Your Answer

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

Add Answer

## Stats

Asked: 2017-08-03 06:43:33 +0200

Seen: 82 times

Last updated: Aug 03 '17