The Origin#

Understanding Systems of Linear Equations with Real-World Analogies#

Introduction#

Linear equations form the backbone of many mathematical and practical applications. However, their abstract representation often creates a barrier to understanding. In this guide, we use a relatable analogy of apples, bananas, and their pricing to intuitively understand systems of linear equations, using proper vector and matrix notations.

Vector Representation of Quantities#

A 2D coordinate system helps track two distinct quantities simultaneously:

  • \(x\): Number of apples

  • \(y\): Number of bananas

Using vector notation, we represent these quantities as:

\(\mathbf{v}_\text{apple} = \begin{bmatrix} 1 \\ 0 \end{bmatrix}\), \(\mathbf{v}_\text{banana} = \begin{bmatrix} 0 \\ 1 \end{bmatrix}\), \(\mathbf{v}_\text{combo} = \begin{bmatrix} 1 \\ 1 \end{bmatrix}\)

Here:

  • \(\mathbf{v}_\text{apple}\) represents one unit of apple

  • \(\mathbf{v}_\text{banana}\) represents one unit of banana

  • \(\mathbf{v}_\text{combo}\) represents one unit of apple and one unit of banana

This vector representation allows us to track quantities both visually and mathematically. Each vector can be plotted on a coordinate plane, where the x-axis represents apples and the y-axis represents bananas.

The Vendorā€™s Combo#

Imagine a fruit vendor selling a combo where the number of apples is twice the number of bananas. Mathematically, this relationship can be represented as:

\(y = \frac{1}{2}x\)

In vector form, each combo lies on the line defined by:

\(\mathbf{v}_\text{combo} = \alpha \begin{bmatrix} 2 \\ 1 \end{bmatrix}\), where \(\alpha \in \mathbb{R}\)

Here, the line passes through \(\begin{bmatrix} 0 \\ 0 \end{bmatrix}\) and \(\begin{bmatrix} 2 \\ 1 \end{bmatrix}\), indicating all valid combinations of apples and bananas offered by the vendor.

Geometric Interpretation#

This line has a geometric meaning: any point \((x,y)\) on this line represents a valid combo. For example:

  • When \(\alpha = 1\): \(\begin{bmatrix} 2 \\ 1 \end{bmatrix}\) (2 apples, 1 banana)

  • When \(\alpha = 2\): \(\begin{bmatrix} 4 \\ 2 \end{bmatrix}\) (4 apples, 2 bananas)

  • When \(\alpha = 0.5\): \(\begin{bmatrix} 1 \\ 0.5 \end{bmatrix}\) (1 apple, 0.5 bananas)

Moving from Single Equations to Systems#

While a single equation describes one relationship (like our vendorā€™s combo), real-world scenarios often involve multiple relationships simultaneously. For instance, we might want to:

  1. Know the individual prices of apples and bananas

  2. Calculate total costs for different combinations

  3. Compare prices across different vendors

This is where systems of linear equations become necessary, and we need a new notation to handle multiple variables and equations efficiently.

Introducing Prices and Variable Notation#

We now transition from using \((x,y)\) for quantities to using price variables \((x_1,x_2)\) where:

  • \(x_1\): Price per apple

  • \(x_2\): Price per banana

This change in notation helps distinguish between quantities and prices. For any combination of apples (\(a_1\)) and bananas (\(b_1\)), the total price is:

\(c_1 = a_1x_1 + b_1x_2\)

For example, if you buy 3 apples and 2 bananas, your total cost would be: \(c_1 = 3x_1 + 2x_2\)

Matrix Representation of Total Cost#

Consider two scenarios at different stores:

  1. Store A: \(a_1\) apples and \(b_1\) bananas sold at total price \(c_1\)

  2. Store B: \(a_2\) apples and \(b_2\) bananas sold at total price \(c_2\)

In matrix form, these scenarios can be expressed as:

\(\begin{bmatrix} x_1 & x_2 \end{bmatrix} \begin{bmatrix} a_1 & a_2 \\ b_1 & b_2 \end{bmatrix} = \begin{bmatrix} c_1 & c_2 \end{bmatrix}\)

To understand how this multiplication works:

  1. First row-column multiplication: \(x_1a_1 + x_2b_1 = c_1\)

  2. Second row-column multiplication: \(x_1a_2 + x_2b_2 = c_2\)

Practical Example#

Letā€™s say:

  • Store A sells 2 apples and 1 banana for $5

  • Store B sells 3 apples and 2 bananas for $8

This gives us: \(\begin{bmatrix} x_1 & x_2 \end{bmatrix} \begin{bmatrix} 2 & 3 \\ 1 & 2 \end{bmatrix} = \begin{bmatrix} 5 & 8 \end{bmatrix}\)

Row-Vector Equation Format#

For clarity, we define:

\(\mathbf{x}_\text{row} = \begin{bmatrix} x_1 & x_2 \end{bmatrix}\) \(\mathbf{A} = \begin{bmatrix} a_1 & a_2 \\ b_1 & b_2 \end{bmatrix}\) \(\mathbf{c}_\text{row} = \begin{bmatrix} c_1 & c_2 \end{bmatrix}\)

The relationship is then compactly written as:

\(\mathbf{x}_\text{row} \cdot \mathbf{A} = \mathbf{c}_\text{row}\)

Solving the System#

This system can be solved using various methods:

  1. Substitution

  2. Elimination

  3. Matrix inverse (when A is invertible)

  4. Numerical methods for larger systems

The solution will give us the individual prices \(x_1\) and \(x_2\) that satisfy all equations simultaneously.

Conclusion#

This analogy simplifies linear equations by linking them to tangible scenarios. By moving from vector representations of quantities to scalar representations of price, we gain an intuitive understanding of how matrices capture relationships between variables. The row-vector equation format provides a concise expression of these relationships, making it easier to extend to more complex systems in practical applications.

Understanding these concepts allows us to:

  1. Model real-world relationships mathematically

  2. Solve for unknown variables systematically

  3. Apply these techniques to more complex problems in fields like economics, engineering, and data science

import numpy as np

# Coefficient matrix A (row-based)
A = np.array([[40, 20], [6, 8]])

# Constant vector c (row-vector)
c = np.array([100, 80])

# Ensure A is invertible by checking its determinant
if np.linalg.det(A) == 0:
    raise ValueError("Matrix A is singular and cannot be inverted")

# Solve the system of linear equations (Ax = c)
x = c @ np.linalg.inv(A)

# Output the solution vector
print(f"Solution vector x: {x}")
Solution vector x: [1.6 6. ]