线性方程组 python
Prerequisites:
先决条件:
Defining a Vectors
定义向量
Defining a Matrix
定义矩阵
In this article, we are going to learn how to represent a linear equation in Python using Linear Algebra. For example we are considering an equation with 3 variables (x,y,z and t).
在本文中,我们将学习如何使用线性代数在Python中表示线性方程。 例如,我们正在考虑具有3个变量( x,y,z 和t )的方程。
3x + 4y - 7z + 12t = 46
2x + 7y - 13z + 3t = 65
34x + 4y - 4z + 34t = 78
The above equation has a form as below in linear Algebra:
上式的线性代数形式如下:
Ax = b, x = (x y z t)
Application:
应用:
Machine Learning
机器学习
Calculus
结石
Linear Programming
线性规划
Physics and Kinetic Studies
物理与动力学研究
用于表示线性方程组的Python代码 (Python code for Representation of a system of linear equation)
# Linear Algebra Learning Sequence
# Representation of a System of Linear Equation
import numpy as np
# Use of np.array() to define an Vector
A = np.array([[3, 4, -7, 12], [2, 7, -13, 3], [34, 4, -4, 34]])
b = np.array([46, 65, 78])
print("The Matrix A : \n",A)
x = np.array(['x', 'y', 'z', 't'])
print("\nThe Vector x : ",x)
print("\nThe Vector b : ",b)
print("\n---Now the equations is represented in form of vector: Ax = b---")
print("This is just a python intrepetation of understanding a linear equation")
Output:
输出:
The Matrix A :
[[ 3 4 -7 12]
[ 2 7 -13 3]
[ 34 4 -4 34]]
The Vector x : ['x' 'y' 'z' 't']
The Vector b : [46 65 78]
---Now the equations is represented in form of vector: Ax = b---
This is just a python intrepetation of understanding a linear equation
翻译自: https://www.includehelp.com/python/representation-of-a-system-of-linear-equation.aspx
线性方程组 python