Is there a python module to solve linear equations?

后端 未结 6 914
生来不讨喜
生来不讨喜 2020-11-27 16:32

I want to solve a linear equation with three or more variables. Is there a good library in python to do it?

6条回答
  •  难免孤独
    2020-11-27 17:10

    You can use least square method in python to solve system of equations for example for solving equations 3x+4y=7 and 5x+6y=8

    >>> import numpy
    >>> a=[[3,4],[5,6]]
    >>> b=[7,8]
    >>> numpy.linalg.lstsq(a,b)
    (array([-5. ,  5.5]), array([], dtype=float64), 2, array([ 9.27110906,  0.21572392]))
    

提交回复
热议问题