-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpdf_input2.txt
executable file
·737 lines (737 loc) · 13.3 KB
/
pdf_input2.txt
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
EECS 16A Designing Information Devices and Systems I
Fall 2018 Lecture Notes Note 10
10.1 Change of Basis for Vectors
Previously, we have seen that matrices can be interpreted as linear transformations between vector spaces.
In particular, an m×n matrix A can be viewed as a function A :U →V mapping a vector~u from vector space
U ∈ R
n
to a vector A~u in vector space V ∈ R
m. In this note, we explore a different interpretation of square,
invertible matrices: as a change of basis.
Let’s first start with an example. Consider the vector ~u =
"
u1
u2
#
=
"
4
3
#
. When we write a vector in this
form, implicitly we are representing it in the standard basis for R
2
, ~e1 =
"
1
0
#
and ~e2 =
"
0
1
#
. This means
that we can write ~u = 4~e1 +3~e2. Geometrically, ~e1 and ~e2 defines a grid in R
2
, and ~u is represented by the
coordinates in the grid, as shown in the figure below:
What if we want to represent ~u as a linear combination of another set of basis vectors, say ~a1 =
"
1
1
#
and
~a2 =
"
0
−1
#
? This means that we need to find scalars ua1
and ua2
such that ~u = ua1
~a1 +ua2
~a2. We can write
EECS 16A, Fall 2018, Note 10 1this equation in matrix form:
| |
~a1 ~a2
| |
"
ua1
ua2
#
=
"
u1
u2
#
"
1 0
1 −1
#"ua1
ua2
#
=
"
4
3
#
Thus we can find ua1
and ua2
by solving a system of linear equations. Since the inverse of "
1 0
1 −1
#
is
"
1 0
1 −1
#
, we get ua1 = 4 and ua2 = 1. Then we can write ~u as 4~a1 +~a2. Geometrically, ~a1 and ~a2 defines a
skewed grid from which the new coordinates are computed.
From this example, we can see that the same vector ~u can be represented in multiple ways! In the standard
basis ~e1,~e2, the coordinates for ~u are 4,3. In the skewed basis ~a1,~a2, the coordinates for ~u are 4,1. It’s the
same vector geometrically, but with different coordinates.
In general, suppose we are given a vector~u ∈ R
n
in the standard basis and want to change to a different basis
with linearly independent basis vectors ~a1,··· ,~an. If we denote the vector in the new basis as ~ua =
ua1
.
.
.
uan
,
we solve the following equation A~ua = ~u, where A is the matrix h
~a1 ··· ~an
i
. Therefore the change of
basis is given by:
~ua = A
−1
~u
EECS 16A, Fall 2018, Note 10 2I f we already have a vector ~ua in the basis ~a1,··· ,~an, how do we change it back to a vector ~u in the standard
basis? We can reverse the change of basis transformation, thus ~u = A~ua.
Pictorially, the relationship between any two bases and the standard basis is given by:
Basis ~a1,··· ,~an
A
✛✲
A
−1
Standard Basis
B
−1
✛✲
B
Basis~b1,··· ,~bn
For example, consider a vector in the basis of ~a1,··· ,~an:
~u = ua1
~a1 +···+uan
~an = A~ua
Suppose we would like to represent it as a linear combination of different basis vectors~b1,··· ,~bn. In other
words, we’d like to write it as:
~u = ub1
~b1 +···+ubn
~bn = B~ub
Setting these equal gives the following relationship:
B~ub = ub1
~b1 +···+ubn
~bn =~u = ua1
~a1 +···+uan
~an = A~ua
B~ub = A~ua
~ub = B
−1A~ua
Thus the change of basis transformation from basis ~a1,··· ,~an to basis~b1,··· ,~bn is given by B
−1A.
10.2 Change of Basis for Linear Transformations
Now that we know how to change the basis of vectors, let’s shift our attention to linear transformations.
We will answer these questions in this section: how do we change the basis of linear transformations and
what does this mean? First let’s review linear transformations. Suppose we have a linear transformation T
represented by a n×n matrix that transforms ~u ∈ R
n
to v ∈ R
n
:
~v = T~u
Although T is represented by a matrix, we can think of it as a geometric transformation on vectors. Implicit
in this representation is the choice of a coordinate system. Unless stated otherwise, we always assume that
vectors lie in the coordinate system defined by the standard basis vectors~e1,~e2,...,~en.
But what if our vectors represented in a different basis? Suppose we have basis vectors ~a1,··· ,~an ∈ R
n
, and
the vectors ~u,~v above are represented in this basis:
~u =ua1
~a1 +···+uan
~an
~v =va1
~a1 +···+van
~an
Can we also represent the transformation T above, such that~va = Ta~ua? Let’s start by defining the matrix A:
A =
| |
~a1 ··· ~an
| |
EECS 16A, Fall 2018, Note 10 3Since our vectors ~u and ~v are linear combinations of the basis vectors we can write them as ~u = A~ua and
~v = A~va. This is exactly the formula defined in the previous section to change a vector back to the standard
basis! Now, starting with our transformation T in the standard basis, we can plug in these relationships:
T~u =~v
TA~ua = A~va
A
−1TA~ua =~va
By pattern matching, we see that if we set Ta = A
−1TA, we get our desired relationship, Ta~ua =~va.
The correspondences stated above are all represented in the following diagram:
~u
T ✲ ~v
~ua
A
−1
❄
A
✻
Ta
✲ ~va
A
✻
A
−1
❄
For example, there are two ways to get from ~ua to ~va. First is the transformation Ta. Second, we can trace
out the longer path, applying transformations A, T and A
−1
in order. This is represented in matrix form as
Ta = A
−1TA (Recall that matrices act from right to left: the closest matrix to the vector will be applied first.)
By the same logic, we can go in the reverse direction: T = ATaA
−1
. Let’s look at whats happing at each
step. First, A
−1
transforms a vector in the standard basis into the A basis. Then, Ta then acts on it, returning
a new vector which also in the A basis. Finally, multiplying by A returns a weighted sum of the columns of
A, in other words, transforming the vector back into the original standard basis.
10.3 A Diagonalizing Basis
We just saw that transformations are different in different bases. Is there a special basis under which a
transformation attains a particularly nice form? Making our transformation into a diagonal matrix is very
useful since diagonal matrices are easily invertible, they can be raised to high powers without a lot of
computation, and multiplication between diagonal matrices is commutative.
Suppose that we choose our basis vectors ~a1,··· ,~an to be the eigenvectors of the transformation matrix T,
which have associated eigenvalues λ1,··· ,λn. What does T~u look like now? Recall that ~u can be written in
the new basis: ua1
~a1 +···+uan
~an.
T~u = T(ua1
~a1 +···+uan
~an)
= ua1T~a1 +···+uanT~an
EECS 16A, Fall 2018, Note 10 4By the definition of eigenvectors and eigenvalues:
= ua1λ1~a1 +···+uanλn~an
=
| ··· |
~a1 ··· ~an
| ··· |
λ1
.
.
.
λn
ua1
.
.
.
uan
= AD~ua
= ADA−1
~u,
where D is the diagonal matrix of eigenvalues and A is a matrix with the corresponding eigenvectors as its
columns. Thus we have proved that in an eigenvector basis, T = ADA−1
. In particular, Ta, the counterpart
of T in the eigenvector basis, is a diagonal matrix.
How is transforming T into a diagonal matrix useful? Say we want apply our transformation T many
times. We might be interested in calculating T
k where k could be quite large. Although you could do this
calculation with repeated matrix multiplication, it would quite tedious and even with a computer is slow for
large matrices.
However, we just showed that we can write T = ADA−1 where D is diagonal. Consider raising this to the
power of k:
T
k =(ADA−1
)
k
We can expand this out k times and then regroup the terms:
T
k =(ADA−1
)(ADA−1
)...(ADA−1
)(ADA−1
)
=AD(A
−1A)D(A
−1
...A)D(A
−1A)DA−1
=AD(I)D(I...)D(I)DA−1
=ADD...DDA−1
)
=ADkA
−1
To raise a diagonal matrix to a power, one can raise each element to that power (try proving this to yourself by
writing out the multiplication element by element). This is a much simpler calculation that repeatedly doing
the full matrix multiplication! In addition, this formulation better allows us to write equations describing
how the transformation changes with k – having equations will help us better understand and design systems.
10.4 Diagonalization
Under what circumstances is a matrix diagonalizable? We’ve seen that our change of basis matrix A must
be invertible, so its columns must be linearly independent. Therefore, a n×n matrix T is diagonalizable
if it has n linearly independent eigenvectors. If it has n linearly independent eigenvectors ~a1,··· ,~an with
eigenvalues λ1,···λn, then we can write:
T = ADA−1
EECS 16A, Fall 2018, Note 10 5Where A =
h
~a1 ··· ~an
i
and D is a diagonal matrix of eigenvalues. Note that the eigenvalues must be
arranged to match the arrangement of eignevectors in A. For example, the eigenvalue associated with ~a1
should be in the first column on D, the eigenvalue associated with ~a2 should be in the second column on D,
and so on.
Example 10.1 (A matrix that is not diagonalizable): Let T =
"
1 0
−1 1#
. To find the eigenvalues, we
solve the equation:
det(T −λI) = 0
(1−λ)
2 = 0
λ = 1
The eigenvector corresponding to λ = 1 is ~a =
"
0
1
#
. Since this matrix only has 1 eigenvector but exists in
R
2×2
, it is not diagonalizable.
Example 10.2 (Diagonalization of a 3×3 matrix):
T =
3 2 4
2 0 2
4 2 3
To find the eigenvalues, we solve the equation:
det(T −λI) = 0
λ
3 −6λ
2 −15λ −8 = 0
(λ −8)(λ +1)
2 = 0
λ = −1,8
If λ = −1, we need to find ~a such that:
4 2 4
2 1 2
4 2 4
~a = 0 =⇒
2 1 2
0 0 0
0 0 0
~a = 0
Thus the dimension of the nullspace of T −(−1)I is 2, and we can find two linearly independent vectors in
this basis:
~a1 =
1
0
−1
~a2 =
1
−2
0
If λ = 8, we need to find ~a such that:
−5 2 4
2 −8 2
4 2 −5
~a = 0 =⇒
1 0 −1
0 2 −1
0 0 0
~a = 0
EECS 16A, Fall 2018, Note 10 6Thus the dimension of the nullspace of T −(8)I is 1, and we find the vector in the nullspace:
~a3 =
2
1
2
Now we define:
A =
1 1 2
0 −2 1
−1 0 2
D =
−1 0 0
0 −1 0
0 0 8
A
−1 =
1
9
4 2 −5
1 −4 1
2 1 2
Then T can be diagonalized as T = ADA−1
.
Additional Resources For more on diagonalization, read Strang pages 304 - 309. In Schuam’s,
read pages 299 - 301 and try Problems 9.9 to 9.21, and 9.45 to 9.51.
10.5 A Proof with Diagonalization
Not only can diagonalization help us raise matrices to powers, it can also help us understand some underlying properties of matrices. In this example, we use diagonalization to understand when matrices are
commutative.
Show that if two n×n diagonalizable matrices A and B have the same eigenvectors, then their matrix
multiplication is commutative (i.e. AB = BA)
Let~v1,...,~vn be the eigenvectors of A and B, and P = [~v1,...,~vn] be a matrix constructed from the
eigenvectors of A and B. Also let λa1,...,λan be the eigenvalues of A, and λb1,...,λbn be the eigenvalues of
B.
Using diagonalization, we can decompose A and B such that A = PDAP
−1
and B = PDBP
−1
, where DA is
the diagonal matrix of A, and DB is the diagonal matrix of B:
DA =
λa1
.
.
.
λan
DB =
λb1
.
.
.
λbn
Now we can write
AB = (PDAP
−1
)(PDBP
−1
)
= PDA(P
−1P)DBP
−1
= PDA(I)DBP
−1
= PDADBP
−1
Because DA and DB are both diagonal matrices, DADB = DBDA. To see why this is the case, let’s look at it
element by element:
EECS 16A, Fall 2018, Note 10 7DADB =
λa1
.
.
.
λan
λb1
.
.
.
λbn
(1)
=
λa1λb1
.
.
.
λanλbn
(2)
=
λb1λa1
.
.
.
λbnλan
(3)
=
λb1
.
.
.
λbn
λa1
.
.
.
λan
= DBDA (4)
Thus:
PDADBP
−1 = PDBDAP
−1
= PDBIDAP
−1
= (PDBP
−1
)(PDAP
−1
)
= BA
We’ve now shown that A and B are commutative if they have the same eigenvectors. We can use this to
design matrices that commute!
10.6 Practice Problems
These practice problems are also available in an interactive form on the course website.
1. If~v =
1
2
3
is in the standard basis, what is~v in the basis of ~a1 =
1
0
1
,~a2 =
0
1
0
,~a3 =
1
1
0
?
2. True or False: A 3×3 matrix with the following eigenvectors is diagonalizable:
1
1
2
,
0
2
4
,
0
1
0
.
3. Which of the following matrices is equivalent to "
1 0
0.5 0.5
#k
?
(a) "
1 0
0 0.5
k
#
EECS 16A, Fall 2018, Note 10 8(b) "
1 0
1−0.5
k 0.5
k
#
(c) "
0.5
k 0
0.5
k −1 1#
(d) "
1 0
1+0.5
k 0.5
k
#
EECS 16A, Fall 2018, Note 10 9