-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02-LinearAlgebra.Rmd
More file actions
4234 lines (2951 loc) · 99.5 KB
/
02-LinearAlgebra.Rmd
File metadata and controls
4234 lines (2951 loc) · 99.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Linear Algebra
When formalizing intuitive mathematical ideas, we define a set of *objects* and *rules* for manipulating them—this structure is called an *algebra*. In particular, **linear algebra** focuses on **vectors** and the rules that govern how they can be **added** and **scaled**.
<p align="center">
<img src="Figure2.1MML.png" alt="A mind map of the concepts introduced in this chapter, along with where they are used in other parts of the book." width="400">
</p>
---
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
## **2.0** Vectors {-}
<div class="definition">
A **vector** is a mathematical object that can be **added** to other vectors and **multiplied by scalars**, resulting in another vector of the same kind. A vector $\mathbf{v} \in \mathbb{R}^n$ has the form \[
\mathbf{v} =
\begin{bmatrix}
v_1 \\ v_2 \\ \vdots \\ v_n
\end{bmatrix},
\]
where each $v_i \in \mathbb{R}$.
</div>
### Vector Spaces
While most people are familiar with *geometric vectors* (arrows with direction and magnitude), vectors can also take more abstract forms—as long as they obey the two key operations:
1. **Addition:** \( \mathbf{a} + \mathbf{b} = \mathbf{c} \)
2. **Scalar multiplication:** \( \lambda \mathbf{a} = \mathbf{b} \)
<div class="definition">
A set \( V \) is a **vector space** over \( \mathbb{R} \) if for any \( \mathbf{u}, \mathbf{v} \in V \) and any scalar \( \lambda \in \mathbb{R} \):
\[
\mathbf{u} + \mathbf{v} \in V \quad \text{and} \quad \lambda \mathbf{u} \in V
\]
</div>
<div class="definition">
Let \( \mathbf{u}, \mathbf{v} \in \mathbb{R}^n \) be two vectors. The *sum* of two vectors is obtained by adding their corresponding components:
\[
\mathbf{u} + \mathbf{v} =
\begin{bmatrix}
u_1 \\ u_2 \\ \vdots \\ u_n
\end{bmatrix}
+
\begin{bmatrix}
v_1 \\ v_2 \\ \vdots \\ v_n
\end{bmatrix}
=
\begin{bmatrix}
u_1 + v_1 \\ u_2 + v_2 \\ \vdots \\ u_n + v_n
\end{bmatrix}
\]
</div>
<div class="example">
We can add two vectors componentwise:
\[
\begin{bmatrix} 1 \\ 4 \\ 10\\ 20 \end{bmatrix} + \begin{bmatrix} 2 \\ 6 \\ 15\\ 30 \end{bmatrix} = \begin{bmatrix} 1+2 \\ 4+6 \\ 10+15\\ 20+30 \end{bmatrix} = \begin{bmatrix} 2 \\ 10 \\ 25\\ 50 \end{bmatrix}.
\]
</div>
<div class="definition">
Let \( \mathbf{u} \in \mathbb{R}^n \) be a vector, and let \( \lambda \in \mathbb{R} \) be a scalar. The *product* of a scalar \( \lambda \) and a vector \( \mathbf{u} \) is obtained by multiplying each component of the vector by the scalar:
\[
\lambda \mathbf{u} =
\lambda
\begin{bmatrix}
u_1 \\ u_2 \\ \vdots \\ u_n
\end{bmatrix}
=
\begin{bmatrix}
\lambda u_1 \\ \lambda u_2 \\ \vdots \\ \lambda u_n
\end{bmatrix}
\]
</div>
<div class="example">
Scalar multiplication is applied to each term:
\[
5\begin{bmatrix} 1 \\ 4 \\ 10\\ 20 \end{bmatrix} = \begin{bmatrix} 5 \times 1 \\ 5 \times 4 \\ 5 \times 10\\ 5 \times 20 \end{bmatrix} = \begin{bmatrix} 5 \\ 20 \\ 50\\ 100 \end{bmatrix}.
\]
</div>
<div class="example">
The set of complex numbers $\mathbb{C}$ is a vector space. To prove this, we need to show that it satisfies the two properties:
1. For $u, v \in \mathbb{C}$, we have $u+v \in \mathbb{C}$.
2. For $u \in \mathbb{C}$ and $\lambda \in \mathbb{R}$, we have $\lambda u \in \mathbb{C}$.
Let $u,v \in \mathbb{C}$. Then $u = a+bi$ and $v = c + di$.
1. **Vector addition:** The usual complex addition is defined as:
$$
u + v = (a + bi) + (c + di) = (a + c) + (b + d)i \in \mathbb{C}
$$
2. **Scalar multiplication:** For real scalars \( r \in \mathbb{R} \), scalar multiplication is defined as:
$$
r \cdot (a + bi) = (ra) + (rb)i \in \mathbb{C}.
$$
</div>
Other examples of Vector spaces include:
- **Geometric vectors:** Can be drawn in space and manipulated visually.
- **Polynomials:** Can be added and scaled to form new polynomials.
- **Audio signals:** Represented as sequences of numbers that can be combined or scaled.
- **Tuples of real numbers** in \( \mathbb{R}^n \)
Treating vectors as elements of \( \mathbb{R}^n \) aligns with how data is represented in computer programs—arrays of real numbers. This makes linear algebra essential for computational work and for algorithms in machine learning and data science.
---
### Closure
A central idea in mathematics, known as **closure**, asks what new elements can be formed by combining existing ones through defined operations. In linear algebra, the set of all possible linear combinations of vectors forms a **vector space**, a foundational concept throughout machine learning.
<div class="definition">
The **closure property** (or simply *closure*) describes whether a set is **closed under an operation** — meaning that when the operation is applied to elements of the set, the result is also an element of the same set.
Formally, a set \( S \) is **closed** under an operation \( \circ \) if for all \( a, b \in S \):
\[
a \circ b \in S
\]
</div>
<div class="example">
The set of real numbers \( \mathbb{R} \) is **closed under addition** because for any \( a, b \in \mathbb{R} \), the sum \( a + b \in \mathbb{R} \).
</div>
<div class="example">
The set of integers \( \mathbb{Z} \) is **not closed under division**, since \( 1 \div 2 = 0.5 \notin \mathbb{Z} \).
</div>
<div class="example">
The set of vectors of a set length, $n$, is closed since $\mathbf{a}, \mathbf{b} \in \mathbb{R}^n$ implies that \[\mathbf{a} + \mathbf{b} = \begin{bmatrix} a_1 \\ a_2 \\ \vdots \\ a_n \end{bmatrix} + \begin{bmatrix} b_1 \\ b_2 \\ \vdots \\ b_n \end{bmatrix} = \begin{bmatrix} a_1+b_1 \\ a_2+b_2 \\ \vdots \\ a_n+b_n \end{bmatrix}.
\]
However, the set of all vectors is not closed since $\begin{bmatrix} 1 \\ 2 \end{bmatrix} + \begin{bmatrix} 1 \\ 2 \\3 \end{bmatrix}$ is undefined.
</div>
---
### Other Properties of Vectors
Vectors obey a set of algebraic rules that make them fundamental in both geometry and linear algebra.
<div class="lemma">
Let \( \mathbf{u}, \mathbf{v}, \mathbf{w} \) be vectors, and let \( c, d \) be scalars.
1. **Commutativity of Addition**
\[
\mathbf{u} + \mathbf{v} = \mathbf{v} + \mathbf{u}
\]
2. **Associativity of Addition**
\[
(\mathbf{u} + \mathbf{v}) + \mathbf{w} = \mathbf{u} + (\mathbf{v} + \mathbf{w})
\]
3. **Additive Identity**
There exists a **zero vector** \( \mathbf{0} \) such that
\[
\mathbf{v} + \mathbf{0} = \mathbf{v}
\]
4. **Additive Inverse**
For every vector \( \mathbf{v} \), there exists a vector \( -\mathbf{v} \) such that
\[
\mathbf{v} + (-\mathbf{v}) = \mathbf{0}
\]
5. **Distributive Properties**
\[
c(\mathbf{u} + \mathbf{v}) = c\mathbf{u} + c\mathbf{v}
\]
\[
(c + d)\mathbf{v} = c\mathbf{v} + d\mathbf{v}
\]
6. **Associativity of Scalar Multiplication**
\[
c(d\mathbf{v}) = (cd)\mathbf{v}
\]
7. **Multiplicative Identity**
\[
1 \mathbf{v} = \mathbf{v}
\]
</div>
Sometimes, we use row vectors rather than column vectors simply to save space or for aesthetic reasons.
<div class="example">
To prove the commutative rule for vector addition, write \(\mathbf{u}=[u_1,\dots,u_n]\), \(\mathbf{v}=[v_1,\dots,v_n]\). Addition is componentwise:
\[
u + v = [u_1+v_1,\dots,u_n+v_n].
\]
By commutativity in \(\mathbb{R}\),
\[
u_i + v_i = v_i + u_i \quad \forall i,
\]
so
\[
\mathbf{u} + \mathbf{v} = [v_1+u_1, \dots, v_n+u_n] = \mathbf{v} + \mathbf{u}.
\]
</div>
The **dot product** (also called the **inner product**) is an operation that takes two vectors and returns a single number. It measures how similar or aligned the two vectors are.
<div class="definition">
For vectors \( \mathbf{a}, \mathbf{b} \in \mathbb{R}^n \), the dot product is defined as:
\[
\mathbf{a} \cdot \mathbf{b} = \sum_{i=1}^{n} a_i b_i
\]
</div>
<div class="example">
Compute the dot product of $\begin{bmatrix} 2 \\ 5 \\ 4 \end{bmatrix}$ and $\begin{bmatrix} -3\\ 0 \\ -2 \end{bmatrix}$.
\begin{align*}
\begin{bmatrix} 2 \\ 5 \\ 4 \end{bmatrix} \cdot \begin{bmatrix} -3\\ 0 \\ -2 \end{bmatrix} &= \sum_{i=1}^{3} a_i b_i\\
&= a_1b_1 + a_2 b_2 + a_3 b_3\\
&= 2(-3) + 5(0) + 4(-2)\\
&= -14
\end{align*}
</div>
---
### Geometric Interpretation of a Vector
Geometrically, vectors can be thought of as **arrows** that have both **magnitude** (length) and **direction**. They are often used to represent quantities such as displacement, velocity, or force.
Vector addition corresponds to placing one arrow’s tail at the head (the *triangle rule*), resulting in a new vector that represents the combined effect of both.
<p align="center">
<img src="TipToTail2.png" alt="https://courses.lumenlearning.com/ccbcmd-math/chapter/performing-vector-addition-and-scalar-multiplication/" width="400">
</p>
Scalar multiplication stretches or shrinks a vector and can reverse its direction if the scalar is negative.
<p align="center">
<img src="ScalarMultiplication2.png" alt="https://courses.lumenlearning.com/ccbcmd-math/chapter/performing-vector-addition-and-scalar-multiplication/" width="400">
</p>
These geometric operations follow the same algebraic properties found in vector spaces—such as commutativity, associativity, and distributivity — allowing us to interpret abstract vector operations visually as movements and scalings in space.
<div class="example">
Let $\mathbf{u} = [3,-2]$ and $\mathbf{v} = [-1,4]$. Then $\mathbf{u} + \mathbf{v}$ and $\mathbf{u} - \mathbf{v}$ can be computed using vectors:
\[\mathbf{u} + \mathbf{v}= [2,2] \;\;\; \text{ and } \;\;\; \mathbf{u} - \mathbf{v} = [4,-6].\]
<p align="center">
<img src="VectorAdditionExample.png" alt="https://courses.lumenlearning.com/ccbcmd-math/chapter/performing-vector-addition-and-scalar-multiplication/" width="400">
</p>
</div>
---
### Exercises {.unnumbered .unlisted}
<div class="exercise">
Vector addition
<div style="text-align: right;">
[Solution]( )
</div>
</div><div class="exercise">
Scalar Multiplication
<div style="text-align: right;">
[Solution]( )
</div>
</div>
</div><div class="exercise">
Both
<div style="text-align: right;">
[Solution]( )
</div>
</div>
<div class="exercise">
Show that each of the following are vector spaces:
- $\mathbb{R}^n$
- Polynomials
- Continuous functions
- Sequences
<div style="text-align: right;">
[Solution]( )
</div>
</div>
<div class="exercise">
Let \( \mathbf{u}, \mathbf{v}, \mathbf{w} \) be vectors, and let \( c, d \) be scalars. Prove each of the following properties:
1. **Commutativity of Addition**
\[
\mathbf{u} + \mathbf{v} = \mathbf{v} + \mathbf{u}
\]
2. **Associativity of Addition**
\[
(\mathbf{u} + \mathbf{v}) + \mathbf{w} = \mathbf{u} + (\mathbf{v} + \mathbf{w})
\]
3. **Additive Identity**
There exists a **zero vector** \( \mathbf{0} \) such that
\[
\mathbf{v} + \mathbf{0} = \mathbf{v}
\]
4. **Additive Inverse**
For every vector \( \mathbf{v} \), there exists a vector \( -\mathbf{v} \) such that
\[
\mathbf{v} + (-\mathbf{v}) = \mathbf{0}
\]
5. **Distributive Properties**
\[
c(\mathbf{u} + \mathbf{v}) = c\mathbf{u} + c\mathbf{v}
\]
\[
(c + d)\mathbf{v} = c\mathbf{v} + d\mathbf{v}
\]
6. **Associativity of Scalar Multiplication**
\[
c(d\mathbf{v}) = (cd)\mathbf{v}
\]
7. **Multiplicative Identity**
\[
1 \mathbf{v} = \mathbf{v}
\]
<div style="text-align: right;">
[Solution]( )
</div>
</div>
<div class="exercise">
Dot product example
<div style="text-align: right;">
[Solution]( )
</div>
</div>
<div class="exercise">
<div style="text-align: right;">
[Solution]( )
</div>
</div>
---
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
## Systems of Linear Equations
Systems of linear equations are fundamental in linear algebra, as many problems can be formulated in this way. Linear algebra provides the tools to solve these systems efficiently.
<div class="example">
A company produces products \( N_1, \ldots, N_n \) using resources \( R_1, \ldots, R_m \). Each product \( N_j \) requires \( a_{ij} \) units of resource \( R_i \). If \( b_i \) units of each resource \( R_i \) are available, then the total resources used must satisfy
\[
a_{i1}x_1 + a_{i2}x_2 + \cdots + a_{in}x_n = b_i, \quad i = 1, \ldots, m
\]
or, in general matrix form,
\[
A\mathbf{x} = \mathbf{b},
\]
where \( A = [a_{ij}] \in \mathbb{R}^{m \times n} \), \( \mathbf{x} \in \mathbb{R}^n \), and \( \mathbf{b} \in \mathbb{R}^m \).
</div>
<div class="example">
Suppose a factory produces two products: **P1** and **P2**.
Let:
- \(x_1\) = units of P1 produced
- \(x_2\) = units of P2 produced
**Constraints:**
1. Labor: Each unit of P1 requires 2 hours, P2 requires 3 hours, and total available labor is 120 hours:
\[
2x_1 + 3x_2 \leq 120
\]
2. Material: Each unit of P1 uses 1 kg of material, P2 uses 2 kg, and total available material is 100 kg:
\[
1x_1 + 2x_2 \leq 100
\]
3. Non-negativity:
\[
x_1 \geq 0, \quad x_2 \geq 0
\]
We can rewrite the inequalities as a matrix inequality:
\[
\underbrace{
\begin{pmatrix}
2 & 3 \\
1 & 2
\end{pmatrix}}_{A}
\begin{pmatrix}
x_1 \\ x_2
\end{pmatrix}
\leq
\underbrace{
\begin{pmatrix}
120 \\ 100
\end{pmatrix}}_{b}
\]
Here:
- \(\mathbf{A}\) is the **constraint matrix**.
- \(x = \begin{pmatrix}x_1 \\ x_2\end{pmatrix}\) is the **decision variable vector**.
- \(b\) is the **resource vector**.
</div>
---
### Solutions to Systems of Linear Equations
In general, a system of linear equations can have:
- no solution,
- exactly one solution, or
- infinitely many solutions.
<div class="example">
The system
\[
\begin{aligned}
x_1 + x_2 + x_3 &= 3 \\
x_1 - x_2 + 2x_3 &= 2 \\
2x_1 + 3x_3 &= 1
\end{aligned}
\]
has **no solution**, since combining the first two equations gives \( 2x_1 + 3x_3 = 5 \), which contradicts the third equation.
</div>
Systems of equations with no solutions are called *inconsistent*.
<div class="definition">
A system of linear equations is said to be **inconsistent** if no set of values for the unknown variables satisfies all equations simultaneously.
</div>
In other words, the equations contradict each other, and there is no common solution.
<div class="example">
The system
\[
\begin{aligned}
x_1 + x_2 + x_3 &= 3 \\
x_1 - x_2 + 2x_3 &= 2 \\
x_2 + x_3 &= 2
\end{aligned}
\]
has **a unique solution** \( (x_1, x_2, x_3) = (1, 1, 1) \).
</div>
<div class="example">
The system
\[
\begin{aligned}
x_1 + x_2 + x_3 &= 3 \\
x_1 - x_2 + 2x_3 &= 2 \\
2x_1 + 3x_3 &= 5
\end{aligned}
\]
has **infinitely many solutions**, since the third equation is a linear combination of the first two.
If we set \( x_3 = a \in \mathbb{R} \), then
\[
(x_1, x_2, x_3) =
\left( \tfrac{5}{2} - \tfrac{3}{2}a,\,
\tfrac{1}{2} + \tfrac{1}{2}a,\,
a \right),
\quad a \in \mathbb{R}.
\]
Hence, the solution set forms a line in \(\mathbb{R}^3\).
</div>
<div class="definition">
A system of linear equations is called **consistent** if there exists at least one set of values for the unknown variables that satisfies all equations simultaneously.
- If there is exactly one solution, the system is **uniquely consistent**.
- If there are infinitely many solutions, the system is **dependent** (still consistent).
</div>
<div class="example">
The system of equations\[
\begin{cases}
x + y = 5 \\
2x - y = 1
\end{cases}
\]
is a consistent system with a unique solution: \(x = 2\), \(y = 3\).
</div>
<div class="example">
The system of equations
\[
\begin{cases}
x + y = 4 \\
2x + 2y = 10
\end{cases}
\]
is inconsistent since the second equation is equivalent to \(x + y = 5\), which contradicts the first equation (\(x + y = 4\)). Thus, the system has no solution.
</div>
---
### Geometric Interpretation
In two dimensions, each linear equation represents a **line** on the \( x_1x_2 \)-plane. The **solution set** is the intersection of these lines, which can be:
- a **point** (unique solution),
- a **line** (infinitely many solutions), or
- **empty** (no solution).
For three variables, each equation defines a **plane** in \( \mathbb{R}^3 \). Their intersection can be a plane, line, point, or empty set.
<div class="example">
\[
\begin{aligned}
4x_1 + 4x_2 &= 5 \\
2x_1 - 4x_2 &= 1
\end{aligned}
\]
has the unique solution \( (x_1, x_2) = (1, \tfrac{1}{4}) \).
</div>
<div class="example">
Consider the system:
\[
\begin{cases}
x + y + z = 3 \\
2x + 2y + 2z = 6 \\
x - y + z = 1
\end{cases}
\]
The second equation is just \(2 \times\) the first equation, so it doesn't add a new constraint. The first and third equations define a plane intersection. This leaves one free variable, so there are infinitely many solutions.
Let \(z = t\) (free parameter), then:
\[
\begin{aligned}
x + y + t &= 3 \implies x = 3 - y - t \\
x - y + t &= 1 \implies (3 - y - t) - y + t = 1 \implies 2y = 2 \implies y = 1 \\
x &= 3 - 1 - t = 2 - t
\end{aligned}
\]
Thus, the general solution is:
\[
(x, y, z) = (2 - t, 1, t), \quad t \in \mathbb{R}.
\]
</div>
---
### Matrix Formulation
A system of linear equations can be written compactly as:
\[
\begin{bmatrix}
a_{11} & a_{12} & \cdots & a_{1n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{m1} & a_{m2} & \cdots & a_{mn}
\end{bmatrix}
\begin{bmatrix}
x_1 \\ \vdots \\ x_n
\end{bmatrix}
=
\begin{bmatrix}
b_1 \\ \vdots \\ b_m
\end{bmatrix}
\]
This matrix representation \( \mathbf{A}\mathbf{x} = \mathbf{b} \) provides a compact and powerful way to describe and solve systems of linear equations.
<div class="example">
Write the system of equations as a matrix: \[
\begin{cases}
x + y = 5 \\
2x - y = 1
\end{cases}
\]
The matrix version of this system is:
\[
\begin{bmatrix}
1 & 1 \\
2 & -1
\end{bmatrix}
\begin{bmatrix}
x \\ y
\end{bmatrix}
=
\begin{bmatrix}
5 \\ 1
\end{bmatrix}
\]
</div>
<div class="example">
Write the system of equations as a matrix: \[\begin{cases}
x + y = 4 \\
2x + 2y = 10
\end{cases}
\]
The matrix version of this system is:
\[
\begin{bmatrix}
1 & 1 \\
2 & 2
\end{bmatrix}
\begin{bmatrix}
x \\ y
\end{bmatrix}
=
\begin{bmatrix}
4 \\ 10
\end{bmatrix}
\]
</div>
---
### Exercises {.unnumbered .unlisted}
<div class="exercise">
Write a system of equations with a unique solution.
</div>
<div class="exercise">
Write a system of equations with infinitely many solutions.
</div>
<div class="exercise">
Write a system of equations with no solutions.
</div>
<div class="exercise">
Solve example 2.11
<div style="text-align: right;">
[Solution]( )
</div>
</div>
<div class="exercise">
Write 2.15 and 2.16 as a matrix equations
<div style="text-align: right;">
[Solution]( )
</div>
</div>
<div class="exercise">
Solve a system of equations
<div style="text-align: right;">
[Solution]( )
</div>
</div>
<div class="exercise">
Solve a system of equations
<div style="text-align: right;">
[Solution]( )
</div>
</div>
<div class="exercise">
Turn into a matrix form
<div style="text-align: right;">
[Solution]( )
</div>
</div>
<div class="exercise">
Change from matrix to equations
<div style="text-align: right;">
[Solution]( )
</div>
</div>
---
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
<!-- NEW SECTION --><!-- NEW SECTION --><!-- NEW SECTION -->
## Matrices
Matrices play a central role in linear algebra. They provide a compact way to represent *systems of linear equations* and also serve as representations of linear functions (or mappings).
<div class="definition">
A **matrix** is a rectangular array of numbers arranged in $m$ rows and $n$ columns.
Formally, a real-valued matrix \( \mathbf{A} \in \mathbb{R}^{m \times n} \) is:
\[
\mathbf{A} =
\begin{bmatrix}
a_{11} & a_{12} & \dots & a_{1n} \\
a_{21} & a_{22} & \dots & a_{2n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{m1} & a_{m2} & \dots & a_{mn}
\end{bmatrix}
\]
</div>
The notation $(\mathbf{A})_{ij}$ refers to the $ij^{th}$ element of $\mathbf{A}$. So, $(\mathbf{A})_{ij} = a_{ij}$. For example, if \[
\mathbf{A} =
\begin{bmatrix}
2 & 4 \\
1 & 3
\end{bmatrix},
\]
Then $\mathbf{A}_{11} = 2, \mathbf{A}_{12} = 4, \mathbf{A}_{21} = 1$ and $\mathbf{A}_{22} = 3$.
Matrices with one row are called **row vectors**, and those with one column are **column vectors**.
---
### Matrix Addition
<div class="definition">
For two matrices \( \mathbf{A}, \mathbf{B} \in \mathbb{R}^{m \times n} \), their sum and difference are defined element-wise:
\[
(\mathbf{A} + \mathbf{B})_{ij} = a_{ij} + b_{ij} \;\;\;\;\;\;\;\;\; (\mathbf{A} - \mathbf{B})_{ij} = a_{ij} - b_{ij}
\]
</div>
The result of matrix addition is another \( m \times n \) matrix.
<div class="example">
Let:
\[
\mathbf{A} =
\begin{bmatrix}
2 & 4 \\
1 & 3
\end{bmatrix},
\quad
\mathbf{B} =
\begin{bmatrix}
5 & 0 \\
-2 & 1
\end{bmatrix}.
\]
Then \[
\mathbf{A} + \mathbf{B} =
\begin{bmatrix}
2 + 5 & 4 + 0 \\
1 + (-2) & 3 + 1
\end{bmatrix}
=
\begin{bmatrix}
7 & 4 \\
-1 & 4
\end{bmatrix}
\]
\[
\mathbf{A} - \mathbf{B} =
\begin{bmatrix}
2 - 5 & 4 - 0 \\
1 - (-2) & 3 - 1
\end{bmatrix}
=
\begin{bmatrix}
-3 & 4 \\
3 & 2
\end{bmatrix}.
\]
</div>
<div class="example">
In the previous example, we can see that \[(\mathbf{A}+\mathbf{B})_{21} = -1 \quad \text{and} \quad (\mathbf{A}-\mathbf{B})_{22} = 2.\]
</div>
---
### Matrix Multiplication
<div class="definition">
For matrices \( \mathbf{A} \in \mathbb{R}^{m \times n} \) and \( \mathbf{B} \in \mathbb{R}^{n \times k} \), their product \( \mathbf{C} = \mathbf{A}\mathbf{B} \in \mathbb{R}^{m \times k} \) is defined as:
\[
c_{ij} = \sum_{l=1}^{n} a_{il} b_{lj}
\]
</div>
That is, each element of \( \mathbf{C} \) is obtained by taking the dot product of the corresponding row of \( \mathbf{A} \) and column of \( \mathbf{B} \).
<div class="note">
Matrix multiplication is only defined when the inner dimensions match (the number of columns of \( \mathbf{A} \) equals the number of rows of \( \mathbf{B} \)).
</div>
<div class="note">
Matrix multiplication is **not commutative**, meaning \( \mathbf{A}\mathbf{B} \neq \mathbf{B}\mathbf{A} \) in general.
</div>
<div class="example">
Let
\[
\mathbf{A} =
\begin{bmatrix}
1 & 2 \\
3 & 4
\end{bmatrix},
\quad
\mathbf{B} =
\begin{bmatrix}
2 & 0 \\
1 & 2
\end{bmatrix}.
\]
Then
\[
\mathbf{A} \mathbf{B} =
\begin{bmatrix}