1
我寫了, 給定的矩陣3的a
矢量a1
,a2
,a3
python程序進行操作,它計算一個矩陣3個矢量b1
,b2
,b3
在的b
下列方式:Python程序與矩陣和矢量叉積
三重產品(分母)就是決定因素。
爲了檢查程序工作,這種關係必須滿足:
換句話說:
det(b) = 1/det(a)
在節目我都小心使用cross
和np array
。然而,它並沒有滿足上述關係:
import numpy as np
from numpy import pi as pi
# 'a' matrix:
a = np.array([[ 0.291761097764E+01 , 0.000000000000E+00 , 0.574463427333E+01 ],
[ -0.145880548882E+01 , 0.252672522500E+01 , 0.574463427333E+01 ],
[ -0.145880548882E+01 ,-0.252672522500E+01 , 0.574463427333E+01 ]])
# 'a' vectors:
a_1 = [ 0.291761097764E+01 , 0.000000000000E+00 , 0.574463427333E+01 ]
a_2 = [ -0.145880548882E+01 , 0.252672522500E+01 , 0.574463427333E+01 ]
a_3 = [ -0.145880548882E+01 ,-0.252672522500E+01 , 0.574463427333E+01 ]
# volume of 'a' matrix:
V_a = np.linalg.det(a)
print 'V_a = ', V_a
cte = (2*pi)/V_a
VEC_1 = np.cross(a_2, a_3)
VEC_2 = np.cross(a_3, a_1)
VEC_3 = np.cross(a_1, a_2)
# calculation of 'b' vectors:
b_1 = cte * VEC_1
b_2 = cte * VEC_2
b_3 = cte * VEC_3
print 'b_1 = ', b_1
print 'b_2 = ', b_2
print 'b_3 = ', b_3
# building 'b' matrix:
b = np.vstack ([ b_1 , b_2, b_3 ])
print 'b = ', b
# volume of 'b' matrix:
V_b = np.linalg.det(b)
print 'V_b = ', V_b
print "1/V_a = ", 1/V_a
print "1/V_a should be equal to V_b; however, we do not get this equality"
EDIT:顯示的最後一個方程是不正確的。以下應更確切:
你是完全正確的....看到編輯,我已經推導出適當的方程,以便(8 * pi ** 3)自然產生。讓我知道,如果您對派生有一些擔憂,我認爲必須應用向量四重產品規則。 –