46. Linear Equations

46.1. Solving Systems of Linear Equations

Linear Equation

𝑦=𝑎1𝑥1+𝑎1𝑥2++𝑎𝑛𝑥𝑛
  1. Consistency

Whether a system of linear equations has at least one solution

Example

Consistent System

𝑥+𝑦=3𝑥𝑦=1

This system has a unique solution

(𝑥,𝑦)=(2,1)

Inconsistent System

𝑥+𝑦=3𝑥+𝑦=5

This system is inconsistent (equations contradict each other, no solution can satisfy both)

  1. Independence

Whether the equations in the system provide unique and non-redundant information about the variables

Example

Independent Equations

𝑥+𝑦=3𝑥𝑦=1

Neither equation can be derived from the other (they provide unique information and intersect at a single point)

Dependent Equations

𝑥+𝑦=32𝑥+2𝑦=6

Second equation is just a multiple of the first equation (they describe the same line)

  1. Recognizing Systems with No Solution or Infinite Solutions
Example
3𝑥+2𝑦=6(Equation1)6𝑥+4𝑦=12(Equation2)

Unique Solution (Consistent and Independent):

No Solution (Inconsistent):

Infinitely Many Solutions (Consistent and Dependent):

  1. Matrix Representation

System of Equations

𝑎11𝑥1+𝑎12𝑥2++𝑎1𝑛𝑥𝑛=𝑏1𝑎21𝑥1+𝑎22𝑥2++𝑎2𝑛𝑥𝑛=𝑏2𝑎𝑚1𝑥1+𝑎𝑚2𝑥2++𝑎𝑚𝑛𝑥𝑛=𝑏𝑚

Matrix Representation

Coefficient vector (Α)

𝐴=[𝑎11𝑎12𝑎1𝑛𝑎21𝑎22𝑎2𝑛𝑎2𝑚1𝑎𝑚2𝑎𝑚𝑛]

Variable vector (𝑥)

𝑥=[𝑥1𝑥2𝑥𝑛]

Constant vector (𝑏)

𝑏=[𝑏1𝑏2𝑏𝑚]

Matrix equation

𝐴𝑥=𝑏
linear_eq.py
from scipy.linalg import solve

X = np.array([
  [1, 1, 1],
  [2, -1, 3],
  [3, 4, -1]
])

Y = np.array([6, 14, 1])

intersection_point = solve(X, Y)