代码之家  ›  专栏  ›  技术社区  ›  Tim unnamed eng

同伦中矩阵的逆?

  •  9
  • Tim unnamed eng  · 技术社区  · 14 年前

    我想知道如何在Python中使用SymPy创建一个矩阵并计算它的逆矩阵?

    例如,对于这个符号矩阵:

    2 回复  |  直到 7 年前
        1
  •  14
  •   vlsd    12 年前

    如果你的问题是:如何计算矩阵M的逆矩阵,那么:

    M_inverse = M.inv()
    

    关于如何创建矩阵:

    M = Matrix(2,3, [1,2,3,4,5,6])
    

    将为您提供以下2X3矩阵:

    1 2 3个

    四五六

    见: http://docs.sympy.org/0.7.2/modules/matrices/matrices.html

        2
  •  3
  •   Georgy rassa45    7 年前

    下面是我们如何计算 象征的 矩阵(取问题中的一个):

    import sympy as sym
    
    
    # Not necessary but gives nice-looking latex output
    # More info at: http://docs.sympy.org/latest/tutorial/printing.html
    sym.init_printing()
    
    sx, sy, rho = sym.symbols('sigma_x sigma_y rho')
    matrix = sym.Matrix([[sx ** 2, rho * sx * sy], 
                         [rho * sx * sy, sy ** 2]])
    

    现在打印相反的 matrix.inv() 将给予:
    enter image description here

    可以进一步简化为 sym.simplify(matrix.inv()) :
    enter image description here