Ask Your Question
0

how can i define a matrix product like a summation

asked 2017-08-03 06:43:33 +0100

this post is marked as community wiki

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 flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2017-08-03 10:14:24 +0100

mforets gravatar image

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]
edit flag offensive delete link more

Comments

Thank you so much this is exactly i want

moiseszeleny gravatar imagemoiseszeleny ( 2017-08-03 19:21:25 +0100 )edit

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

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

Seen: 505 times

Last updated: Aug 03 '17