Vectors and matrices: what Ax ≤ b means
Write a plan as a vector and the rules as a matrix, then check every rule at once
- Math toolbox
- 25 min guided · about 30 min practice
- After K4
- Completed
Lesson 10's hour, 19:00, as arrays, in seven moves
- A plan is a vector, an ordered list: x = (x₁, x₂) = (100, 45) is 100 MW from the combined-cycle plant and 45 MW from the peaker; (45, 100) is a different plan.
- Each output lasts one hour (100 MW × 1 h = 100 MWh), so the cost is a dot product: c · x = 40 × 100 + 100 × 45 = 8,500 dollars.
- The four rules stack into a matrix A, one row per rule and one column per decision.
- A x is every row's dot product with x: (145, 100, 45, 61.75), one number per rule.
- Multiplying the cover row by −1 turns x₁ + x₂ ≥ 145 into −x₁ − x₂ ≤ −145, so every row reads ≤.
- A x ≤ b checks all four rules at once: (130, 100) supplies at least the 145 MW and fits both plants, but emits 103.1 t, so only the CO₂ row fails.
- A is 4 × 2 here. Lesson 11's day, as its solver stores it, is 72 rows × 96 columns, 24 of the rows equalities; only 190 of its 6,912 entries are not zero.
| Row (rule) | Column 1: x₁ | Column 2: x₂ | A x at (100, 45) | Limit b | Check |
|---|---|---|---|---|---|
| Cover | 1 | 1 | 145 | ≥ 145 | passes |
| Combined-cycle size | 1 | 0 | 100 | ≤ 150 | passes |
| Peaker size | 0 | 1 | 45 | ≤ 100 | passes |
| CO₂ cap | 0.37 | 0.55 | 61.75 | ≤ 100 | passes |
With JavaScript on, you set the plan, read each row as a rule and watch every rule checked at once.
- The hour is lesson 10's: 19:00 on lesson 0's day, 3 September 2025, when gas must supply 145 MW (Southwest Power Pool shapes, EIA-930, scaled to Prairie Town).
- Prairie Town is fictional: its plants' sizes, running costs ($40 and $100 per MWh, 2025 dollars), CO₂ rates (0.37 and 0.55 t per MWh, t = metric tonnes) and the 100 t cap are illustrative.
- A toy model, as lesson 10's chart: the cover rule asks for at least 145 MW. Extra gas would be spilled as wind and sun, at most 86 MW at 19:00, a limit left out here.
- Outputs cannot be negative, x₁ ≥ 0 and x₂ ≥ 0: the sliders stop at 0, so the four rows are the rules left to check.
- Lessons 10 and B1 call the two outputs x and y; here they are x₁ and x₂, the entries of the plan vector x.
Need a refresher first? Toolbox K4 (one inequality as a half-plane).
What you just did, as diagrams
- Vector
- An ordered list of numbers; the order is the meaning: x = (x₁, x₂) = (100, 45).
- Dot product
- Multiply two vectors in pairs and add: c · x = 8,500 dollars.
- Matrix
- A table of numbers with m rows and n columns: here one row per rule, one column per decision.
- A x
- Every row's dot product with x, one number per rule.
- A x ≤ b
- Every rule at once: each entry of A x at most its limit in b.
Go deeper · ModelerThe form solvers read, and sparse matrices
- Rows and bounds. Solvers such as HiGHS (its form) give each row a lower and an upper limit, and keep a limit on one decision, like a plant’s size, as a bound, not a row.
- Counting rows. The count depends on the form. Lesson 11’s day, as stored, has 72 rows, 24 of them equalities; strictly as A x ≤ b, each becomes two rows: 96 rows, 286 non-zero entries.
- The transpose. \(c^\mathsf{T} x\) (B1’s notation) is the dot product written as a row times a column; \(\mathsf{T}\) turns a column into a row.
- Sparse. Large models are mostly zeros: each rule touches a few decisions. Lesson 11’s stored matrix has 190 non-zero entries out of 6,912, about 2.7%, so solvers keep only those.
- Where next. Building these arrays in code comes in B2 and M1; Gaussian processes (M9) work with matrices of similarities between data points.
Check yourself
Myth or fact? “(100, 45) and (45, 100) are the same plan: the same two numbers.”
- Myth
- Fact
Answer
Myth. The order is the meaning: the first costs 8,500 dollars, the second 11,800, because the peaker's MWh cost more.
Myth or fact? “Multiplying a rule by −1 keeps the same plans if the sign flips too.”
- Myth
- Fact
Answer
Fact. x + y ≥ 145 and −x − y ≤ −145 pass exactly the same plans.
With A's rows (1, 1) and (0.37, 0.55), what is A x for x = (145, 0)?
- (145, 145)
- (145, 53.65)
- (145, 79.75)
- (0, 53.65)
Answer
(145, 53.65): 1 × 145 + 1 × 0 = 145 and 0.37 × 145 + 0.55 × 0 = 53.65. (145, 79.75) uses the peaker's rate on the combined-cycle MW.
A model has 3 decisions and 2 rules in each of 24 hours. What size is A?
- 2 rows × 3 columns
- 72 rows × 48 columns
- 48 rows × 72 columns
- 24 rows × 24 columns
Answer
48 rows × 72 columns: one row per rule (2 × 24 = 48) and one column per decision (3 × 24 = 72).
Numbers, sources and what’s next
Numbers to remember
| Number | What it means | Source |
|---|---|---|
| m × n | The size of A: one row per rule, one column per decision. | Convention |
| 4 × 2 | Lesson 10's hour: four rules, two decisions. | Lesson 10's model |
| 72 × 96 | Lesson 11's day as its solver stores it, 24 of the rows equalities; 190 entries are not zero. | Lesson 11's model |
Next
Sources and further reading
- Boyd, S. and Vandenberghe, L. (2018). Introduction to Applied Linear Algebra: Vectors, Matrices, and Least Squares. Cambridge University Press.
- HiGHS documentation: the form of the linear programs it solves.
- Where this is used: lesson 10 (the hour as a linear program), lesson 11 (a day solved by HiGHS) and B1 (the same model as A x ≤ b, then a solver).
Spotted an error, or stuck? Write to hlli@ksu.edu. Corrections are made in place and dated here.
Text licensed CC BY 4.0, code MIT: teachers and students may reuse and adapt it, with credit to Honglin Li.