-
Notifications
You must be signed in to change notification settings - Fork 0
/
slides5.html
1392 lines (1082 loc) · 51.4 KB
/
slides5.html
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
<!doctype html>
<html>
<head>
<title>Math for ML</title>
<script src="lib/loader.js"></script>
</head>
<body onload="init()">
<div id="bgpage" class="background">
<canvas id="canvas"></canvas>
</div>
<div class="header">
<div id="follow" style="display:none">follow</div>
</div>
<div id="footer" class="footer">
<div id="navigator" class="large"></div>
</div>
<div id="slides" class="slides">
<div class="slide title"
style="background-color:black; padding:5vw"
onshow="d0('navigator','footer');v0('bgpage')"
onhide="d1('navigator','footer');v1('bgpage')">
<div style="height: 15%"></div>
<h1 style="color:#ffa540">Welcome to Math for Machine Learning!</h1>
<h1 style="color:#ffffff">Linear Algebra, Session
5 — Tensors</h1>
<h1 style="color:#808080">Mesch</h1>
<h2 style="position:absolute; bottom:5%; padding-left:0.1vw; color:red">X/Google, 2021</h2>
</div>
<div class="slide build-focus-visible" group="intro" name="intro">
<h1>Intro: Tensors!</h1>
<div>The ML library we all use is called
Tensorflow, after those things from Linear Algebra. But
what <em>are</em> Tensors really?</div>
<div>Important, is what they are!</div>
<ul>
<li step="1">In <b>General Relativity</b>, tensors describe
Gravitation.
<li step="2">In <b>Quantum Mechanics</b>, multi-particle states are
the tensor products of single particle states.
<li step="3">In <b>Quantum Computing</b>, each qubit is one factor of
a tensor product.
<li step="4">In <b>Machine Learning</b> ... well, the "tensors" in
Tensorflow are only superficially connected with what they are in
Mathematics — we'll explain how exactly! But tensor products
appear in interesting places when optimizing weight matrices in
large models.
</ul>
<div class="notes">Remember to look at the notes.</div>
</div>
<div class="slide build-focus-visible" group="intro" name="plan">
<h1>Game Plan</h1>
<div>Throughout the next 3 sessions:</div>
<ul>
<li step="1">We explain what tensors are, and why the name became
associated with multidimensional array data structures in software
engineering, especially in machine learning.
<li step="2" link="theme2">We illustrate how tensor products of vector spaces have a
peculiar scaling behavior in their dimension: Unlike the Cartesian
product, which adds the dimensions of its factors, the tensor
product multiplies. We also contemplate how confusing the fact
$$ 2 + 2 = 2 \times 2 = 2^2 $$
is for understanding what happens when we scale beyond 2.
<li step="3" link="theme3">We finally look again how tensors and their
products appear in machine learning models.
</ul>
</div>
<div class="slide build-focus-visible" group="intro">
<h1>Meta</h1>
<div>Besides the improved understanding of ML and QC, there are a few
tangential motivations that are inspiring in their own right, or for
building software:</div>
<ul>
<li step="1">Axiomatic construction.
<li step="2">Introduce more notation.
<li step="3">Revisit previous lessons from new viewpoints. (Remember
the Tensorflow code retreat.)
<li step="4">Encounter important mathematical concepts, such as
Isomorphism.
</ul>
</div>
<div class="slide noprint banner" group="theme1" name="theme1">
<h1>Vectors and Tensors</h1>
<div>
<em>Why, in software, arrays with multiple integer indices are called
tensors.</em>
</div>
</div>
<div class="slide build-visible" group="theme1">
<h1>Vectors and Tensors - Overview</h1>
<div>Plan for today.</div>
<ol>
<li step="0">Recap the Axioms of Vector Space
<li step="1">Einstein Notation
<li step="2">Linear Independence <em>gives rise to Bases and Coordinates</em>
<li step="3">Basis and Coordinate Transformations
<li step="4">The Scalar Product <span step="5">$\leftarrow$ This is
the first Tensor!</span>
<li step="6">Tensor Coordinates and Basis Transformations —
Definition of Tensors
<li step="7">Wrap up
</ol>
</div>
<div class="slide build-focus-visible" group="theme1-vs">
<h1>Axioms of Vector Space</h1>
<div>Recap what Vectors are, and Vector Spaces.</div>
<ul>
<li step="1"><b>Vectors</b> can be <b>added</b> to each other and
<b>multiplied with scalar</b> numbers.
<li step="2,3,4,5,6"><em>Scalar numbers</em> are elements of a <b>Field</b>,
often
<ul>
<li step="3"><b>Rational Numbers</b> $Q$,
<li step="4"><b>Real Numbers</b> $R$,
<li step="5">or <b>Complex Numbers</b> $C$,
<li step="6">but also <em>finite fields</em>,
notably the <b>Galois Field</b> $GF(2)$.
</ul>
</ul>
</div>
<div class="slide build-focus-visible continued" group="theme1-vs">
<h1>Axioms of Vector Space</h1>
<div>Every set $V$ whose elements can be <b>added</b> to each other, and
<b>multiplied</b> with elements from a field $F$, with the following
properties, is a vector space.</div>
<div step="1,2,3,4,5,6,7">Vector Addition:</div>
<ol>
<li step="2,7">is an operation from $V \times V$ on $V$:
$\xvec{a} + \xvec{b} \in V$
<li step="3,7">is associative:
$(\xvec{a} + \xvec{b}) + \xvec{c} = \xvec{a} + (\xvec{b} +
\xvec{c})$
<li step="4,7">is commutative:
$\xvec{a} + \xvec{b} = \xvec{b} + \xvec{a}$</li>
<li step="5,7">has a neutral element:
$\exists \xvec{0} \; \forall \xvec{a} \,:\, \xvec{a} + \xvec{0} =
\xvec{a}$
<li step="6,7">has an inverse:
$\forall \xvec{a} \; \exists -\!\xvec{a} \,:\, \xvec{a} +
(-\xvec{a}) = \xvec{0}$
</ol>
<div class="notes">
<ul>
<li>$\forall$ is implied where absent in the axioms.
</ul>
</div>
</div>
<div class="slide build-focus-visible continued" group="theme1-vs">
<h1>Axioms of Vector Space</h1>
<div>Every set $V$ whose elements can be <b>added</b> to each other, and
<b>multiplied</b> with elements from a field $F$, with the following
properties, is a vector space.</div>
<div step="1,2,3,4,5,6,7">Scalar Multiplication:</div>
<ol>
<li step="2,7">is an operation from $F \times V$ on $V$:
$a\xvec{a} \in V$
<li step="3,7">is compatible with Field multiplication: $a (b \xvec{a}) = (a b) \xvec{a}$
<li step="4,7">has a neutral element: $1 \xvec{a} = \xvec{a}$
<li step="5,7">is distributive over vector addition: $a \xvec{a} + a \xvec{b} = a (\xvec{a} + \xvec{b})$
<li step="6,7">is distributive over field addition: $a \xvec{a} + b \xvec{a} = (a + b) \xvec{a}$
</ol>
<div class="notes">
<ul>
<li>$\forall$ is implied where absent in the axioms.
<li>technically in some terminolgy systems, scalar multiplication is
not an operation but a function
</ul>
</div>
</div>
<div class="slide build-focus-visible" group="theme1-vs">
<h1>Axioms of Vector Space - Examples</h1>
<div>Two examples of what vector spaces are.</div>
<ul>
<li step="1">Example 1: Arrows over Rational Numbers.
<li step="2">Example 2: Tuples of Real Numbers over Real Numbers.
</ul>
</div>
<div class="slide build-focus" group="theme1-vs">
<h1>Axioms of Vector Space - Example: Arrows</h1>
<div>Arrows in the 2D plane are vectors, with their operations defined
by Euclidean Geometry.</div>
<div style="float:right">
<ul>
<li step="1,2,9">Vector Addition
<li step="3,4,9">Scalar Multiplication - negation
<li step="5,6,9">Scalar Multiplication - integers
<li step="7,8,9">Scalar Multiplication - integer fractions
<li step="9">Together: Vector operations over $Q$
</ul>
</div>
<div class="img">
<img class="img" src="img/vectors/vector-plus.png" step="1">
<img class="img" src="img/vectors/vector-plus-result.png" step="2">
<img class="img" src="img/vectors/vector-neg.png" step="3">
<img class="img" src="img/vectors/vector-neg-result.png" step="4">
<img class="img" src="img/vectors/vector-mult.png" step="5">
<img class="img" src="img/vectors/vector-mult-result.png" step="6">
<img class="img" src="img/vectors/vector-frac.png" step="7">
<img class="img" src="img/vectors/vector-frac-result.png" step="8">
</div>
<div class="notes">
<ul>
<li>All the operations are defined directly by operations in
Euclidean geometry, not by the corresponding operations on
coordinates.
</ul>
</div>
</div>
<div class="slide build-focus-visible" group="theme1-vs">
<h1>Axioms of Vector Space — Example: Tuples</h1>
<div>Tuples of rational or real numbers are vectors.</div>
<ul>
<li step="1,3">$(1, 2) + (1, 2) = (1 + 1, 2 + 2) = (2, 4)$</li>
<li step="2,3">$3 \times (1, 2) = (3 \times 3, 3 \times 2) = (3,
6)$</li>
<li step="3">Vector operations for tuples from $R^2$ over $R$.
</ul>
</div>
<div class="slide build-focus-visible banner" group="exercise" name="exercise1">
<h1>Axioms of Vector Space — Exercise</h1>
<div>Are these two examples vector spaces?
<div step="1">(a) Tuples of Rational Numbers over Real Numbers?</div>
<div step="2">(b) Tuples of Real Numbers over Rational Numbers?</div>
<div class="colab">(<a href="https://colab.research.google.com/drive/1_3JOAKP09ExBtJGEItyI-WV2JKuqI5yy#scrollTo=bbOvmXSUHBoB&line=3&uniqifier=1">colab</a>)</div>
</div>
</div>
<div class="slide build-focus" group="exercise">
<h1>Axioms of Vector Space — Solution</h1>
<div>Are these two examples vector spaces?</div>
<ul>
<li step="1,3">(a) Tuples of Rational Numbers over Real Numbers?
<ul>
<li>No,
violates first axiom of scalar multiplication.
</ul>
<li step="2,3">(b) Tuples of Real Numbers over Rational Numbers?
<ul>
<li>Tricky! Yes, but it's infinite-dimensional. We'll see how once we
understand linear independence ...
</ul>
</ul>
</div>
<div class="slide build-focus-visible" group="theme1-li">
<h1>Linear Independence</h1>
<div step="0">The existence of <b>coordinates</b> follows from the
axioms.</div>
<ul>
<li step="1">Vectors can be <b>linearly combined</b>, i.e. added
up with weights $w_i$:
$$\sum_{i} w_i \xvec{v}_i$$
<li step="2">Can such combinations yield $\xvec{0}$ with coefficients
that are not all $0$? (It's always possible with all coefficients 0,
of course.)
<li step="3">Vectors in the combination are then said to
be <b>linearly dependent</b>.
<li step="4">Otherwise they are <b>linearly indedendent</b>.
</ul>
<div class="notes">
<ul>
<li>This derivation leads to the introduction of coordinates.
<li>It follows directly form the algebraic structure introduced by
the axioms.
<li>The vectors $\xvec{v}_i$ in the sum are really <b>multiple
vectors</b> (one for each index), <b>not</b> the <b>coordinates of
one vector</b> — we get to coordinates later!
</ul>
</div>
</div>
<div class="slide build-focus-visible banner" group="exercise" name="exercise2">
<h1>Linear Independence — Exercise</h1>
<div>Imagine sets of arrows that are
<div step="1">(a) linearly independent,</div>
<div step="2">(b) linearly dependent.</div>
<div class="colab">(<a href="https://colab.research.google.com/drive/1_3JOAKP09ExBtJGEItyI-WV2JKuqI5yy#scrollTo=xuiUv3HRIcLu&line=5&uniqifier=1">colab</a>)</div>
</div>
</div>
<div class="slide build-focus" group="exercise">
<h1>Linear Independence — Solution</h1>
<div>Imagine sets of arrows that are</div>
<ul style="float:right">
<li step="1">(a) linearly independent,
<li step="2">(b) linearly dependent.
</ul>
<div class="img">
<img class="img" src="img/vectors/vector-independent.png" step="1">
<img class="img" src="img/vectors/vector-dependent.png" step="2">
</div>
</div>
<div class="slide build-focus-visible" group="theme1-li">
<h1>Einstein Notation</h1>
<div>We introduce a notation for vector algebra that's very neat.</div>
<ul>
<li step="1">Convention:
$$w^i \xvec{v}_i := \sum_{i} w_i \xvec{v}_i$$
<li step="2">If an index $i$ appears in a multiplication expression both as
upper index $w^i$ and as lower index $\xvec{v}_i$, then the sum over
the range of the index is implied.
<li step="3">Matrix multiplication can be written with it too:
$$\xvec{a}^T \xvec{M} \xvec{b} = a^i b^j M_{ij}$$
<li step="4">but it works with more than two indices as well:
$$a^i b^j c^k M_{ijk}$$
<li step="5">The latter is why it's the preferred notation for writing
tensors, as we will see.
</ul>
</div>
<div class="slide build-focus-visible continued" group="theme1-li">
<h1>Einstein Notation</h1>
<ul>
<li step="0">No sum for an index on its own:
$$\xvec{v}_i$$
is simply a tuple of vectors.
<li step="1">And:
$$w^i$$
is simply a tuple of weights, i.e. numbers.
<li step="2">No sum for a repeated index on top or bottom:
$$M_{ii}$$
is the tuple of the diagonal elements of the matrix $M_{ij}$.
</ul>
</div>
<div class="slide build-focus-visible continued" group="theme1-li">
<h1>Einstein Notation</h1>
<div step="0,4">One more bit of terminology:</div>
<ul>
<li step="1,4">Lower indices
$$\xvec{v}_i$$
are called <b>covariant</b> indices.
<li step="2,4">Upper indices
$$w^i$$
are called <b>contravariant</b> indices.
<li step="3,4">We will see why when we introduce basis and coordinate
transformations.
</ul>
</div>
<div class="slide build-focus-visible" group="theme1-li">
<h1>Linear Independence</h1>
<div class="notes">
More analysis yields interesting properties of linear independence.
</div>
<ul>
<li step="0">In each vector space, the maximum number of elements $\xvec{e}_i$
in a set of linearly independent vectors is <b>fixed</b>.
<li step="1,3">For every other vector $\xvec{v}$ added to such a set, there is a
linear combination that yields $\xvec{0}$:
$$v^{i}\xvec{e}_{i} + v^{0}\xvec{v} = \xvec{0}$$</li>
<li step="2,3">Another way of saying this is that $\xvec{v}$ can be combined from
$\xvec{e}_{i}$. With the same coefficients as above, and noticing that
$v^{0}$ cannot be $0$:
$$\xvec{v} = - \frac{v^{i}}{v^0} \xvec{e}_{i}$$
(Einstein notation applies.)
<li step="3"><b>Exercise:</b>
<ul>
<li>(a) why must be $v^{0} \neq 0$?
<li>(b) Why would it be a problem otherwise?
</ul>
</ul>
</div>
<div class="slide build-visible continued" group="theme1-li">
<h1>Linear Independence</h1>
<div class="notes">
One more property, and it all yields 3 important concepts.
</div>
<ul>
<li step="0">Write more simply;
$$\xvec{v} = v^{i} \xvec{e}_{i}$$
<li step="1">Are these coefficients unique?
<li step="2">It turns out yes they are!
<li step="3">Proof follows, to show how such things work ...
</ul>
</div>
<div class="slide build-focus-visible continued" group="theme1-li">
<h1>Linear Independence</h1>
<div step="0"><b>Proof</b> that the coefficients of any vector are unambiguous.</div>
<ul>
<li step="1">Assume there are two such sets of coefficients:
$$\xvec{v} = v^{i} \xvec{e}_{i} = u^{i} \xvec{e}_{i}$$
<li step="2">subtract one from the other:
$$\xvec{v} - \xvec{v} = v^{i} \xvec{e}_{i} - u^{i} \xvec{e}_{i}$$
$$\xvec{0} = (v^{i} - u^{i}) \xvec{e}_{i}$$
<li step="3">Now remember that $\xvec{e}_i$ are linearly independent and that
means $\xvec{0}$ can be combined <em>only</em> with <b>all</b>
coefficients $0$.
</ul>
</div>
<div class="slide build-focus-visible continued" group="theme1-li">
<h1>Linear Independence</h1>
<ul>
<li step="0">Thus for all $i$:
$$v^{i} - u^{i} = 0$$
(No Einstein sum here.)
<li step="1">Or:
$$v^{i} = u^{i}$$
QED.
<li step="2">Thus, every vector in the vector space can be represented
as a combination with unambiguous coefficients from any maximal set
of lineary independent vectors.</li>
</ul>
</div>
<div class="slide build-focus-visible" group="theme1-bt">
<h1>Dimension, Basis, and Coordinates</h1>
<div step="0">From the concept of Linear Indepdendece, we arrive
at <b>3 Definitions</b>:</div>
<ul>
<li step="1">The maximum number of elements in a set of linearly
independent vectors of a vector space is the <b>Dimension</b> of
that vector space.
<li step="2">Any such set itself is a <b>Basis</b> of that vector
space.
<li step="3">The coefficients in the linear combination of the basis
vectors that yields a vector are the <b>Coordinates</b> of the
vector in that basis.
</ul>
</div>
<div class="slide build-focus-visible" group="theme1-bt">
<h1>Isomorphism — Coordinate Tuples vs $F^n$ Vectors</h1>
<div step="0">We clear up the "confusion" of coordinate tuples and vectors from
$F^n$ over $F$.</div>
<ul>
<li step="1">Once a basis is picked, every vector is represented by
a tuple of coordinates.
<li step="2">The tuples are elements of $F^n$, the cartesian product space of
the scalar field.
<li step="3">The field $F$ by its own axioms has addition and multiplication
defined. The cartesian product naturally has addition and scalar
multiplication — $F^n$ is a vector space too!
<li step="4">This vector space is <b>isomorphic</b> to the original
vector space, which often misleads us to think that
vectors just <em>are</em> tuples of numbers.
<li step="5">The mapping of the vectors to its coordinate tuples is called
an <b>Isomorphism</b>. There are many such mappings, one for each
basis of the vector space.
<li step="6">Isomorphism is pervasive in Mathematics, and it's the
reason we can often afford to be "sloppy" when we speak.
</ul>
</div>
<div class="slide build-focus-visible banner" group="exercise" name="exercise3">
<h1>Coordinate Tuples vs $F^n$ Vectors — Exercise</h1>
<div>
<div step="1">Define two different bases in $R^2$, and compute the
coordinates of one vector $\xvec{v}$ in both bases.</div>
<div class="colab"><a href="https://colab.research.google.com/drive/1_3JOAKP09ExBtJGEItyI-WV2JKuqI5yy#scrollTo=VZ-yOI8ENddV&line=1&uniqifeier=1">colab</a></div>
</div>
</div>
<div class="slide build-focus-visible" group="exercise">
<h1>Coordinate Tuples vs $F^n$ Vectors — Solution</h1>
<div step="0,7">Define two different bases in $R^2$, and compute the
coordinates of one vector $\xvec{v} = \left[ \begin{array}{c} 1 \\ 1
\end{array} \right]$ in both bases.</div>
<table class="eqn">
<tr>
<td step="1,3,7">Basis 1:
<td step="4,6,7">Vector in Basis 1:
</tr>
<tr>
<td step="1,3,7">
$\{ \left[ \begin{array}{c} 1 \\ 3 \end{array} \right],
\left[ \begin{array}{c} 3 \\ 1 \end{array} \right]
\}$
<td step="4,6,7">
$\left[ \begin{array}{c} 1 \\ 1 \end{array} \right] =
\frac{1}{4} \left[ \begin{array}{c} 1 \\ 3 \end{array} \right] +
\frac{1}{4} \left[ \begin{array}{c} 3 \\ 1 \end{array} \right]$
</tr>
<tr>
<td step="2,3,7">Basis 2:
<td step="5,6,7">Vector in Basis 2:
</tr>
<tr>
<td step="2,3,7">
$\{ \left[ \begin{array}{c} 1 \\ 0 \end{array} \right],
\left[ \begin{array}{c} 0 \\ 1 \end{array} \right]
\}$
<td step="5,6,7">
$\left[ \begin{array}{c} 1 \\ 1 \end{array} \right] =
1 \left[ \begin{array}{c} 1 \\ 0 \end{array} \right] +
1 \left[ \begin{array}{c} 0 \\ 1 \end{array} \right]$
</tr>
</table>
</div>
<div class="slide build-focus-visible" group="theme1-bt">
<h1>Basis Transformation</h1>
<div step="0">Let's consider <b>two</b> different bases
$\{\xvec{a}_{i}\}$ and $\{\xvec{b}_{i^\prime}\}$ in the same vector
space.</div>
<ul>
<li step="1"><b>Notation:</b> Symbols with differently primed indices
refer to different objects. Thus $\xvec{a}_{i}$ is a different
vector from $\xvec{a}_{i^\prime}$ even for equal values of $i$ and
$i^\prime$.
<li step="2">Every vector $\xvec{v}$ of the vector space has
coordinates in the first base $\{\xvec{a}_{i}\}$ as well as in the
second base $\{\xvec{b}_{i^\prime}\}$ :
$$\xvec{v} = v^{i} \xvec{a}_{i} = v^{i^\prime} \xvec{b}_{i^\prime}$$
<li step="3,4">The vectors ${\xvec{b}_{i^\prime}}$ of the second basis
too have coordinates in the first base ${\xvec{a}_{i}}$. Let's call
$T_{i^\prime}^{i}$ the coordinates of $\xvec{b}_{i^\prime}$ in the
basis ${\xvec{a}_{i}}$:
$$\xvec{b}_{i^\prime} = T_{i^\prime}^{i} \xvec{a}_{i}$$
<li step="4"><b>Notation:</b> We could write $T$ as a matrix. But we
don't, and stick to Einstein notation instead. We'll see later why
— with tensors, will multiply such objects on "more than two
sides".
</ul>
</div>
<div class="slide build-focus-visible continued" group="theme1-bt">
<h1>Basis Transformation</h1>
<ul>
<li step="0,1">Conversely, the vectors of the first basis
$\{\xvec{a}_{i}\}$ also have coordinates in the second basis
$\{\xvec{b}_{i^\prime}\}$ just like every vector too:
$$\xvec{a}_{i} = T_{i}^{i^\prime} \xvec{b}_{i^\prime}$$
<li step="1"><b>Notation:</b> the indices on $T_{i}^{i^\prime}$ and
$T_{i^\prime}^{i}$ are different, so the note from the previous
slide applies, and these are different objects.
</ul>
</div>
<div class="slide build-focus-visible continued" group="theme1-bt">
<h1>Basis Transformation</h1>
<ul>
<li step="0">So the two sets of coordinates $T_{i}^{i^\prime}$ and
$T_{i^\prime}^{i}$ are different, but they are related, as we see
from inserting one equation into the other:
$$\xvec{a}_{i} = T_{i}^{i^\prime} \xvec{b}_{i^\prime}$$
$$\xvec{a}_{i} = T_{i}^{i^\prime} T_{i^\prime}^{j} \xvec{a}_{j}$$
<li step="1,2,3">thus:
$$T_{i}^{i^\prime} T_{i^\prime}^{j} = \delta_{i}^{j}
\;\;\mathrm{where}\;\;
\delta_{i}^{j} = 1 \; (i=j), \; 0 \; (i \neq j)$$
<li step="2">The two matrices $T_{i}^{i^\prime}$ and
$T_{i^\prime}^{j}$ are each other's inverse.
<li step="3"><b>Notation:</b> we don't have to care about transpose or
ordering of factors.
</ul>
</div>
<div class="slide build-focus-visible continued" group="theme1-bt">
<h1>Basis Transformation</h1>
<ul>
<li step="0">We can ask about the relationship of the coordinates of a
vector too:
$$\xvec{v} = v^{i} \xvec{a}_{i} = v^{i^\prime} \xvec{b}_{i^\prime}$$
$$\xvec{v} = v^{i} \xvec{a}_{i} = v^{i^\prime} T_{i^\prime}^{i} \xvec{a}_{i}$$
<li step="1,2">thus:
$$v^{i} = T_{i^\prime}^{i} v^{i^\prime}
\;\; \mathrm{and\;remember} \;\;\ \xvec{a}_{i} = T_{i}^{i^\prime} \xvec{b}_{i^\prime}$$
<li step="2">Basis vectors and coordinates transform inversely to each other.
<li step="3">Hence the <b>terminology</b>:
<ul>
<li>Coordinates
have <em>upper</em> indices, and they transform <b>contravriant</b>
to the basis vectors.
<li>Basis vectors have <em>lower</em> indices, and are
called <b>covariant</b>.
</ul>
<li step="4"><b>Notation:</b> again ordering of factors is not
important for meaning, unlike in matrix notation.
</ul>
</div>
<div class="slide build-focus-visible continued" group="theme1-bt">
<h1>Basis Transformation</h1>
<div>We now can <b>define</b>:</div>
<ul>
<li step="0">$T$ is called a <b>basis transformation</b>,
<li step="1">and correspondingly a <b>coordinate transformation</b>.
</ul>
</div>
<div class="slide build-focus-visible banner" group="exercise" name="exercise4">
<h1>Basis Transformation — Exercise</h1>
<div>
<div step="1">Write down the basis transformation and the coordinate
transformation for the transition from <em>Basis 1</em> to <em>Basis
2</em> in the previous exercise.</div>
<div class="colab">(<a href="https://colab.research.google.com/drive/1_3JOAKP09ExBtJGEItyI-WV2JKuqI5yy#scrollTo=3kk30hC3Wfok&line=2&uniqifier=1">colab</a>)</div>
</div>
</div>
<div class="slide build-focus-visible" group="exercise">
<h1>Basis Transformation — Solution</h1>
<div>Write down the basis transformation and the coordinate
transformation for the transition between <em>Basis 1</em>
and <em>Basis 2</em> in the previous exercise.</div>
<table class="eqn">
<tr>
<td step="1,4">Vector:
<td step="2,4">Basis 1:
<td step="3,4">Basis 2:
</tr>
<tr>
<td step="1,4">
$\xvec{v} = \left[ \begin{array}{c} 1 \\ 1 \end{array} \right]$
<td step="2,4">
$\begin{array}{c}
\xvec{e}_1 = \left[ \begin{array}{c} 1 \\ 3 \end{array} \right] &&
\xvec{e}_2 = \left[ \begin{array}{c} 3 \\ 1 \end{array} \right]
\end{array}$
<td step="3,4">
$\begin{array}{c}
\xvec{e}_{1^\prime} = \left[ \begin{array}{c} 1 \\ 0 \end{array}
\right] &&
\xvec{e}_{2^\prime} = \left[ \begin{array}{c} 0 \\ 1 \end{array}
\right]
\end{array}$
</tr>
</table>
</div>
<div class="slide build-focus-visible continued" group="exercise">
<h1>Basis Transformation — Solution</h1>
<div>Vector expressed in both bases:</div>
<table class="eqn">
<tr>
<td step="0,2">Vector in Basis 1:
<td step="1,2">Vector in Basis 2:
</tr>
<tr>
<td step="0,2">
$\xvec{v} = v^i\xvec{e}_i =
\frac{1}{4} \left[ \begin{array}{c} 1 \\ 3 \end{array} \right] +
\frac{1}{4} \left[ \begin{array}{c} 3 \\ 1 \end{array} \right]$
<td step="1,2">
$\xvec{v} = v^{i^\prime}\xvec{e}_{i^\prime} =
1 \left[ \begin{array}{c} 1 \\ 0 \end{array} \right] +
1 \left[ \begin{array}{c} 0 \\ 1 \end{array} \right]$
</tr>
<tr>
<td step="0,2">
$v^1 = \frac{1}{4}, \; v^2 = \frac{1}{4}$
<td step="1,2">
$v^1 = 1, \; v^2 = 1$
</tr>
</table>
</div>
<div class="slide build-focus-visible continued" group="exercise">
<h1>Basis Transformation — Solution</h1>
<div step="0,6">Basis transformation written down:</div>
<table class="eqn">
<tr>
<td step="1,6">
$\xvec{e}_{i^\prime} = T_{i^\prime}^{i} \xvec{e}_{i}$
</tr>
<tr>
<td step="2,6">
$\xvec{e}_{1^\prime} = \left[ \begin{array}{c} 1 \\ 0 \end{array}
\right] =
-\frac{1}{8} \left[ \begin{array}{c} 1 \\ 3 \end{array} \right] +
\frac{3}{8} \left[ \begin{array}{c} 3 \\ 1 \end{array} \right] =
-\frac{1}{8} \xvec{e}_{1} +
\frac{3}{8} \xvec{e}_{2}$
<td step="3,6">
$
\begin{array}{c}
T_{1^\prime}^{1} =-\frac{1}{8} &&
T_{1^\prime}^{2} = \frac{3}{8} \\
\end{array}$
</tr>
<tr>
<td step="4,6">
$\xvec{e}_{2^\prime} = \left[ \begin{array}{c} 0 \\ 1 \end{array}
\right] =
\frac{3}{8} \left[ \begin{array}{c} 1 \\ 3 \end{array} \right] -
\frac{1}{8} \left[ \begin{array}{c} 3 \\ 1 \end{array} \right] =
\frac{3}{8} \xvec{e}_{1} -
\frac{1}{8} \xvec{e}_{2}$
<td step="5,6">
$\begin{array}{c}
T_{2^\prime}^{1} = \frac{3}{8} &&
T_{2^\prime}^{2} = -1\frac{1}{8}
\end{array}$
</tr>
</table>
</div>
<div class="slide build-focus-visible continued" group="exercise">
<h1>Basis Transformation — Solution</h1>
<div step="0,9">Coordinate transformation written down:</div>
<table class="eqn">
<tr>
<td step="1,9">
$v^{i^\prime} = T_{i}^{i^\prime} v^{i}$
<td step="2,5,8,9">
$T_{i}^{i^\prime} T_{i^\prime}^{j} = \delta_i^j$
</tr>
<tr>
<td step="3,9">
$v^{1^\prime} = T_{1}^{1^\prime} v^{1} + T_{2}^{1^\prime} v^{2}$
<td step="4,9">
$1 = T_{1}^{1^\prime} \frac{1}{4} + T_{2}^{1^\prime} \frac{1}{4}$
<td step="5,9">
$\begin{array}{c}
T_{1}^{1^\prime} = 1 &&
T_{2}^{1^\prime} = 3
\end{array}$
</tr>
<tr>
<td step="6,9">
$v^{2^\prime} = T_{1}^{2^\prime} v^{1} + T_{2}^{2^\prime} v^{2}$
<td step="7,9">
$1 = T_{1}^{2^\prime} \frac{1}{4} + T_{2}^{2^\prime} \frac{1}{4}$
<td step="8,9">
$\begin{array}{c}
T_{1}^{2^\prime} = 3 &&
T_{2}^{2^\prime} = 1
\end{array}$
</tr>
</table>
</div>
<div class="slide build-focus-visible" group="theme1-sp">
<h1>Scalar Product and Metric Tensor</h1>
<div>Let's look at the scalar product in Vector Spaces.</div>
<ul>
<li step="0">The scalar product is a map from the vector space to its
scalar field:
$$\xvec{v} \cdot \xvec{w} = a \in F$$
<li step="1">linear:
$$(a \xvec{v}) \cdot \xvec{w} = a (\xvec{v} \cdot \xvec{w})$$
$$(\xvec{v} + \xvec{u}) \cdot \xvec{w} = \xvec{v} \cdot \xvec{w} + \xvec{u} \cdot \xvec{w}$$
<li step="2">commutative:
$\xvec{v} \cdot \xvec{w} = \xvec{w} \cdot \xvec{v}$
<li step="3">regular:
$\forall \xvec{v} \neq \xvec{0} \; \exists \xvec{w}: \xvec{v} \cdot
\xvec{w} \neq 0$
</ul>
<div class="notes">
<ul>
<li>For vector spaces over <b>Complex Numbers</b>, the scalar
product is hermitean instead of commutative.
<li>For "normal" vector spaces, the scalar product is also required
to be positive definite.
</ul>
</div>
</div>
<div class="slide build-focus-visible continued" group="theme1-sp">
<h1>Scalar Product and Metric Tensor</h1>
<div step="0">We are on the way to define the first tensor.</div>
<ul>
<li step="1">The vectors can be written with coordinates in a basis $\{\xvec{e}_{i}\}$:
$$\xvec{v} \cdot \xvec{w} = (v^{i}\xvec{e}_{i}) \cdot (w^{j} \xvec{e}_{j})$$
<li step="2">... using the linearity of the scalar product yields:
$$\xvec{v} \cdot \xvec{w} = v^{i} w^{j} (\xvec{e}_{i} \cdot \xvec{e}_{j})$$
<li step="3">The scalar products of the basis vectors are just
numbers. We call them $g$:
$$g_{ij} := \xvec{e}_{i} \cdot \xvec{e}_{j}$$
<li step="4">... then:
$$\xvec{v} \cdot \xvec{w} = v^{i} w^{j} g_{ij}$$
</ul>
</div>
<div class="slide build-focus-visible continued" group="theme1-sp">
<h1>Scalar Product and Metric Tensor</h1>
<div>
$$\xvec{v} \cdot \xvec{w} = v^{i} w^{j} g_{ij}$$
</div>
<ul>
<li step="0">For a given basis, these numbers $g_{ij}$ fully define the scalar
product in the vector space; they are the <em>coordinates</em> of
the bilinear map that is the scalar product.
<li step="1">We call them coordinates because they work like coordinates of
vectors.
<li step="2">The object they describe <em>is not</em> those numbers,
it's a map of vectors to scalar numbers, just like the vectors are
not their coordinates.
<li step="3">But once vectors are described by coordinates relative to
a basis, the map is described by coordinates too.
<li step="4">The coordinates of a bilinear map have <em>lower</em>
indices. What does this mean for their coordinate transformations?
</ul>
</div>
<div class="slide build-focus-visible banner" group="exercise" name="exercise5">
<h1>Scalar Product and Metric Tensor — Exercise</h1>
<div>
<div step="1">Write down the coordinates of the scalar product for
tuples from $R^2$ in the two bases from the previous
exercise.</div>
<div class="colab">(<a href="https://colab.research.google.com/drive/1_3JOAKP09ExBtJGEItyI-WV2JKuqI5yy#scrollTo=JTywKOH-P6ey&line=4&uniqifier=1">colab</a>)</div>
</div>
</div>
<div class="slide build-focus-visible" group="exercise">
<h1>Scalar Product and Metric Tensor — Solution</h1>
<div step="0,10">Write down the coordinates of the scalar product for
tuples from $R^2$ in the two bases from the previous exercise.</div>
<table class="eqn">
<tr>
<td step="1,2,7,10">Vectors:
<td step="3,4,8,10">Basis 1:
<td step="5,6,9,10">Basis 2:
</tr>
<tr>
<td step="2,10">
$\begin{array}{c}
\xvec{v} = \left[ \begin{array}{c} 1 \\ 1 \end{array} \right] &&
\xvec{w} = \left[ \begin{array}{c} 1 \\ 0 \end{array} \right]