大家好,小编来为大家解答以下问题,python数学建模基础教程,如何用python数学建模,现在让我们一起来看看吧!
3.6求解下列线性方程组
import sympy as sp
A = sp.Matrix([[1,2,1,-1], [3,6,-1,-3], [5,10,1,-5]])
result = A.nullspace()
print("A的通解为: ", result)
import sympy as sp
A = sp.Matrix([[2,1,-1,1],[4,2,-2,1],[2,1,-1,-1]])
b = sp.Matrix([1,2,1])
b.transpose() #转置矩阵
C = A.row_join(b) #构造增广矩阵
print("增广矩阵的行最简形为:\n", C.rref())