A system of linear equations can be solved with the help of NumPy and arrays.
NumPy is a python package used for scientific computations in python. NumPy's core datatype is an array. NumPy functions operate on arrays.
### How to create an array in python
NumPy array is created with `np.array()` function. The arguments provided for `np.array()` must be list.
For example [10,20,30]
[In]
```
import numpy as np
np.array([10,20,30])
```
[out]
```
array([10,20.30])
```
### Solving linear equations in python
Linear equations can be solved by NumPy and array.
Consider the following equation
```
3x + 2y - z = 18
5x + 4y + z = 36
6x + y - 2z = 21
```
NumPy's `np.linalg.solve()` function can be applied to solve these linear equations.
Below are the steps for solving linear equations in python.
* Create NumPy array A as a 3X3 array of the coefficients on the left-hand side of equation
* Create a NumPy array B on the right-hand side of the equation
* Solve for the values of x, y and z using `np.linalg.solve(A, B)`.
Now the array has three entries, one entry for each variable.
In [1]
```
import numpy as np
A = np.array([[3, 2, -1], [5, 4, 1], [6, 1, -2]])
B = np.array([18, 36, 21])
x = np.linalg.solve(A, B)
x
```
Out [1]
`array([3,5,1])`
References
[1] https://www.statology.org/solve-system-of-equations-in-python/
[2] https://www.geeksforgeeks.org/python-solve-the-linear-equation-of-multiple-variable/
[3] https://dwightreid.com/site/how-to-solve-simultaneous-equations-with-python/