您的位置:首页 > 编程语言 > Python开发

numpy解方程

2015-06-15 22:04 645 查看
Examples

Solve the system of equations 3 * x0 + x1 = 9 and x0 + 2 * x1 = 8:

>>>
>>> a = np.array([[3,1], [1,2]])
>>> b = np.array([9,8])
>>> x = np.linalg.solve(a, b)
>>> x
array([ 2.,  3.])


Check that the solution is correct:

>>>
>>> np.allclose(np.dot(a, x), b)
True
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: