同形中的不相容矩阵

2024-09-28 05:19:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我在计算SymPy中的简化梯队形式。我正在尝试获取以下矩阵的轴列:

exercise4 = Matrix([[1,3,5,7],[3,5,7,9],[5,7,9,1]])

我用以下内容检查矩阵:

exercise4.rref()[0]

Matrix([
[1, 0, -1, 0],
[0, 1,  2, 0],
[0, 0,  0, 1]])

…作为旁白,这和我的简化矩阵是不同的

exercise4 = np.array([[1,3,5,7],[3,5,7,9],[5,7,9,1]])
exercise4[1] = exercise4[1] + -3*exercise4[0]
exercise4[2] = exercise4[2] + -5*exercise4[0]
exercise4[1] = -1/4*exercise4[1]
exercise4[0] = exercise4[0] + -3*exercise4[1]
exercise4[2] = exercise4[2] + 8*exercise4[1]
exercise4

array([[  1,   0,  -1,  -2],
       [  0,   1,   2,   3],
       [  0,   0,   0, -10]])

rref()[1]这里返回(0, 1, 3),第三个元素显然不正确,因为它是增广矩阵的最后一个元素。第三行不一致,不应该有第三个透视列。你知道吗

sympy.Matrix().rref()的固有缺陷是它会错误地解释不一致的数据透视列吗?这是我需要注意的,还是有办法解决的?你知道吗


Tags: 数据元素错误np矩阵arraymatrix形式
1条回答
网友
1楼 · 发布于 2024-09-28 05:19:59

以[2,3]为轴心点生成rref矩阵:

In [269]: M                                                                     
Out[269]: 
array([[  1.,   0.,  -1.,  -2.],
       [ -0.,   1.,   2.,   3.],
       [  0.,   0.,   0., -10.]])
In [271]: M[0]-=M[2]*(-2/-10)                                                                                                             
In [276]: M[1]-=M[2]*(3/-10)                                                    
In [278]: M[2]/= -10                                                                                                                    
In [281]: M                                                                     
Out[281]: 
array([[ 1.,  0., -1.,  0.],
       [ 0.,  1.,  2.,  0.],
       [-0., -0., -0.,  1.]])

当我把你的矩阵插入一个交互式表单时,我得到了sympy结果

http://www.math.odu.edu/~bogacki/cgi-bin/lat.cgi?c=rref

这里也是:https://www.emathhelp.net/calculators/linear-algebra/reduced-row-echelon-form-rref-caclulator/

此版本减少了最后一行,因此所有前导项都是1。但有一个来源允许:

https://stattrek.com/statistics/dictionary.aspx?definition=reduced_row_echelon_form

Note: Some references present a slightly different description of the row echelon form. They do not require that the first non-zero entry in each row is equal to 1.

相关问题 更多 >

    热门问题