-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path7.html
More file actions
2098 lines (1932 loc) · 71 KB
/
7.html
File metadata and controls
2098 lines (1932 loc) · 71 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
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>プログラマの為の数学勉強会</title>
<!-- For reveal.js -->
<link rel="stylesheet" href="lib/reveal/css/reveal.css">
<link rel="stylesheet" href="lib/reveal/css/theme/night.css">
<link rel="stylesheet" href="lib/reveal/lib/css/ir_black.css">
<!-- For Graphics -->
<link rel="stylesheet" href="css/graphics.css">
<style>
.reveal .chapter-title {
margin-top: 3em;
}
.reveal {
font-size: 32px;
line-height: 1.4em;
}
.reveal .slides {
text-align: left;
}
.reveal section img {
border: none;
background: 0;
margin-left: 1em;
margin-right: 1em;
box-shadow: none;
}
.reveal strong {
color: yellow;
}
.reveal sup {
font-size: 40%;
}
.reveal table {
margin-top: 0.5em;
margin-bottom: 0.5em;
border: 2px solid lightblue;
}
.reveal pre {
font-size: 0.7em;
}
.reveal pre code {
max-height: 600px;
}
.reveal .note {
font-size: 50%;
}
.reveal .controls div.navigate-up,
.reveal .controls div.navigate-down {
display: none;
}
.reveal .block {
border: solid 2px;
position: relative;
border-radius: 8px;
margin-top: 0.8em;
margin-bottom: 0.8em;
padding: 1em 0.8em 1em 0.8em;
}
.reveal .block:after {
content: "";
display: block;
clear: both;
height: 1px;
overflow: hidden;
}
.reveal .answer {
color: #111111;
}
.reveal .block h4 {
position: absolute;
top: -0.5em;
margin: 0 auto;
background: #111111;
font-weight: bold;
}
</style>
<!-- Setup libraries for RequireJS-->
<script src="lib/require.js"></script>
<script>
requirejs.config({
baseUrl: "js",
paths: {
d3: "../lib/d3/d3.v3.min",
numeric: "../lib/numeric-1.2.6",
MathJax: "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS_HTML"
},
shim: {
d3: { exports: "d3" },
numeric: { exports: "numeric" },
MathJax: { exports: "MathJax" }
}
});
</script>
<!-- Initialize MathJax -->
<script type="text/x-mathjax-config">
require(["MathJax"], function (MathJax){
MathJax.Hub.Register.StartupHook("AsciiMath Jax Config", function () {
var AM = MathJax.InputJax.AsciiMath.AM;
AM.symbols.push(
{input:"mathbi",tag:"mstyle",atname:"mathvariant",atval:"bold-italic",
output:"mathbi",tex:null,ttype:AM.TOKEN.UNARY}
);
});
MathJax.Hub.Config({
showProcessingMessages: false,
skipStartupTypeset: true,
tex2jax: {
inlineMath: [ ["\\(","\\)"] ],
displayMath: [ ["\\[","\\]"] ]
}
});
});
</script>
<script>
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section style="text-align: center">
<h1> プログラマの為の<br>数学勉強会<br>第7回</h1>
<span>
(於)ワークスアプリケーションズ<br>
中村晃一<br>
2013年10月24日
</span>
</section>
<section>
<h2>謝辞</h2>
<p>
この会の企画・会場設備の提供をして頂きました<br>
㈱ ワークスアプリケーションズ様<br>
にこの場をお借りして御礼申し上げます。
</p>
</section>
<section>
<h2> この資料について </h2>
<p>
<ul>
<li> <a href="http://nineties.github.com/math-seminar">
http://nineties.github.com/math-seminar
</a>に置いてあります。 </li>
<li> SVGに対応したブラウザで見て下さい。主要なブラウザで古いバージョンでなければ大丈夫だと思います。</li>
<li> 内容の誤り、プログラムのバグは<a href="http://twitter.com/9_ties">@9_ties</a>かkoichi.nakamur AT gmail.comまでご連絡下さい。</li>
<li> サンプルプログラムはPythonで記述しています。 </li>
</ul>
</p>
</section>
<section>
<h2 class="chapter-title"> 線型代数 </h2>
</section>
<section>
<p>
本日から<strong>線型代数学</strong>を学んでいきます。微積分学と同様に,理工学の様々な問題に取り組む上で必須の学問です。
</p>
<p>
線型代数は大きく分けて
</p>
<ul>
<li> 行列・行列式と連立一次方程式の理論 </li>
<li> 線型空間・線型写像の理論 </li>
</ul>
<p>
からなりますが,まず前者から解説を始めます。
</p>
</section>
<section>
<h2 class="chapter-title"> 行列とベクトル </h2>
</section>
<section>
<h2> 行列とベクトル </h2>
<p>
まず,<strong>行列</strong>と<strong>ベクトル</strong>についての基本的な知識をざっと確認します。
</p>
</section>
<section>
<h2> 行列 </h2>
<p>
以下のように\(m\times n\)個の数・式を縦横に並べたものを<strong>\((m,n)\)型行列</strong>と言い,アルファベットの大文字を用いて
\[ A = \begin{pmatrix}
a_{11} & a_{12} & \cdots & a_{1n} \\
a_{21} & a_{22} & \cdots & a_{2n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{m1} & a_{m2} & \cdots & a_{mn} \\
\end{pmatrix}
\]
と表します。
</p>
<p>
\(a_{ij}\)を\((i,j)\)成分と呼び,
\( a_{i1}, a_{i2}, \cdots, a_{in} \)を第\(i\)行,
\( a_{1j}, a_{2j}, \cdots, a_{mj} \)を第\(j\)列と呼びます。
</p>
<p>
また\((n,n)\)型行列を<strong>\(n\)次正方行列</strong>と呼び,\((i,i)\)成分を対角成分と呼びます。
</p>
</section>
<section>
<p>
また,\((i,j)\)成分が\(a_{ij}\)である\((m,n)\)型行列を
\[ (a_{ij})_{m,n} \]
や,添字の範囲を明示して
\[ (a_{ij})_{1\leq i\leq m, 1\leq i\leq n} \]
と書きます。前者の場合,添字は1から始める事にします。
</p>
<p>
例えば
\[ \begin{aligned}
(i+2j)_{2,3}
&=
\begin{pmatrix}
1+2\cdot 1 & 1+2\cdot 2 & 1+2\cdot 3 \\
2+2\cdot 1 & 2+2\cdot 2 & 2+2\cdot 3 \\
\end{pmatrix}\\
&=
\begin{pmatrix}
3 & 5 & 7 \\
4 & 6 & 8
\end{pmatrix}
\end{aligned}
\]
という感じです。
</p>
<p>
</p>
</section>
<section>
<p>
成分が全て\(0\)の行列
\[ O = (0)_{m,n} =
\begin{pmatrix}
0 & 0 & \cdots & 0 \\
0 & 0 & \cdots & 0 \\
\vdots & \vdots & \ddots & \vdots \\
0 & 0 & \cdots & 0 \\
\end{pmatrix}
\]
を<strong>零行列</strong>と言います。型を明示して\(O_{m,n}\)と書く場合もあります。
</p>
</section>
<section>
<p>
対角成分が全て\(1\),それ以外が\(0\)である\(n\)次正方行列を<strong>単位行列</strong>と呼び\(E\)や\(E_n\)と表します。
\[ E_n = (\delta_{ij})_{n,n} =
\begin{pmatrix}
1 & 0 & \cdots & 0 \\
0 & 1 & \cdots & 0 \\
\vdots & \vdots & \ddots & \vdots \\
0 & 0 & \cdots & 1 \\
\end{pmatrix} \]
但し,\(\delta_{ij}\)は<strong>クロネッカーのデルタ</strong>
\[\delta_{ij} = \left\{
\begin{array}{ll}
1 & (i = j) \\
0 & (i \neq j)
\end{array}
\right.\]
です。
</p>
</section>
<section>
<h2> 行列の演算 </h2>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> 和・差・定数倍 </h4>
<p>
型が等しい行列の和・差,行列の定数倍を
\[ \begin{aligned}
&(a_{ij})_{m,n} \pm (b_{ij})_{m,n} = (a_{ij} \pm b_{ij})_{m,n} \\
&k(a_{ij})_{m,n} = (ka_{ij})_{m,n}
\end{aligned} \]
によって定義する。型が異なる行列の和・差は定義されない。
</p>
<p style="font-size:70%">
\[ \begin{aligned}
&\begin{pmatrix}
a_{11} & \cdots & a_{1n} \\
\vdots & \ddots & \vdots \\
a_{m1} & \cdots & a_{mn} \\
\end{pmatrix}
\pm
\begin{pmatrix}
b_{11} & \cdots & b_{1n} \\
\vdots & \ddots & \vdots \\
b_{m1} & \cdots & b_{mn} \\
\end{pmatrix}
=
\begin{pmatrix}
a_{11} \pm b_{11} & \cdots & a_{1n} \pm b_{1n} \\
\vdots & \ddots & \vdots \\
a_{m1} \pm b_{m1} & \cdots & a_{mn} \pm b_{mn} \\
\end{pmatrix} \\
&k\begin{pmatrix}
a_{11} & \cdots & a_{1n} \\
\vdots & \ddots & \vdots \\
a_{m1} & \cdots & a_{mn} \\
\end{pmatrix}
=
\begin{pmatrix}
ka_{11} & \cdots & ka_{1n} \\
\vdots & \ddots & \vdots \\
ka_{m1} & \cdots & ka_{mn} \\
\end{pmatrix}
\end{aligned} \]
</p>
</div>
</section>
<section>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> 和・差・定数倍の性質 </h4>
以下の各演算が定義される場合には
\[ \begin{aligned}
A + B &= B + A \\
(A + B) + C &= A + (B + C) \\
k(A + B) &= kA + kB \\
(k + l)A &= kA + lA \\
(kl)A &= k(lA) \\
A + O &= O + A = A \\
A - A &= O
\end{aligned} \]
が成立する。
</div>
<p>
これらの成立は明らかなので証明は省略します。
</p>
</section>
<section>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> 行列の積 </h4>
<p>
\((l,m)\)型行列と\((m,n)\)型行列の積を
\[ (a_{ij})_{l,m}(b_{ij})_{m,n} = \left( \sum_{k=1}^m a_{ik}b_{kj} \right)_{l,n} \]
によって定義する。これ以外の型の行列の積は定義されない。
</p>
</div>
<div align="center"> <img width="700px" src="fig/matrix-multiplication.png"> </div>
</section>
<section>
<p style="font-size:80%">
具体的な行列では,以下のようになります。
\[ \begin{aligned}
&\begin{pmatrix}
a & b \\
c & d
\end{pmatrix}
\begin{pmatrix}
e & f \\
g & h
\end{pmatrix}
=
\begin{pmatrix}
ae+bg & af+bh \\
ce+dg & cf+dh
\end{pmatrix}
\\
&\begin{pmatrix}
a & b & c\\
d & e & f
\end{pmatrix}
\begin{pmatrix}
g \\ h \\ i
\end{pmatrix}
=
\begin{pmatrix}
ag+bh+ci \\
dg+eh+fi
\end{pmatrix}
\\
&\begin{pmatrix}
a & b & c\\
\end{pmatrix}
\begin{pmatrix}
d \\ e \\ f\\
\end{pmatrix}
=
ad+be+cf
\end{aligned} \]
</p>
<p>
最後の例のように\((1,1)\)型行列は一つの数と同一視出来るので,括弧を外して書くこともあります。
</p>
</section>
<section style="font-size:80%">
<div class="block" style="border-color:lightgreen">
<h4 style="color:lightgreen"> 練習 </h4>
<p>
好きな言語で行列の和・差・定数倍・積を計算するプログラムを書いて下さい。もしくは,既存ライブラリの使い方を調べて下さい。
</p>
</div>
<p>
例えばPythonだとNumPyというライブラリを利用できます。練習として自前で実装すると以下のようなコードとなります。
</p>
<pre><code class="python" style="max-height:400px"># -*- coding: utf-8 -*-
import numpy as np
def mat_add(a, b): # 行列の和
if a.shape != b.shape:
raise ArithmeticError, u"行列の型の不一致"
(m,n) = a.shape # 行列の型
r = np.zeros( (m,n) )
for i in xrange(m):
for j in xrange(n):
r[i,j] = a[i,j] + b[i,j]
return r
def mat_scale(k, a): # 行列の定数倍
(m,n) = a.shape
r = np.zeros( (m,n) )
for i in xrange(m):
for j in xrange(n):
r[i,j] = k * a[i,j]
return r
def mat_mul(a, b): # 行列の積
(l, m) = a.shape
(m2, n) = b.shape
if m != m2:
raise ArithmeticError, u"行列の型の不整合"
c = np.zeros( (l,n) )
for i in xrange(l):
for j in xrange(n):
v = 0
for k in xrange(m):
v += a[i,k] * b[k,j]
c[i,j] = v
return c
a = np.array([[1,2,3],[4,5,6]])
b = np.array([[2,1,4],[5,2,1]])
print mat_add(a, b)
print mat_scale(2, a)
a = np.array([[1,2,3],[4,5,6]])
b = np.array([[2,1,4],[5,2,1],[0,1,3]])
print mat_mul(a, b)
</code></pre>
</section>
<section>
<h2> 行列演算の計算量 </h2>
<p>
少し話題を変えて,行列演算の計算量について考えて見ましょう。
</p>
<p>
\((m,n)\)型行列の和・差・定数倍はもちろん\(\color{yellow}{\mathcal{O}(mn)}\)です。
</p>
<p>
\((l,m)\)型行列と\((m,n)\)型行列の積
\[ (a_{ij})_{l,m}(b_{ij})_{m,n} = \left( \sum_{k=1}^m a_{ik}b_{kj} \right)_{l,n} \]
の計算では,\( \sum_{k=1}^m a_{ik}b_{kj} \)の計算に\(m\)回の加算と乗算が必要で,これが\(ln\)要素あるので\(\color{yellow}{\mathcal{O}(lmn)}\)の計算量となります。
</p>
</section>
<section>
<p>
現実の問題では,数万とか数億といった次元の行列を扱わなければならなくなりますが,
例えば倍精度浮動小数点数の百万次正方行列を使う場合
</p>
<ul>
<li> 行列一つあたり,
\[ \text{8バイト}\times(\text{百万}\times \text{百万})\text{要素} \approx \text{7.3テラバイト} \]
のメモリが必要で </li>
<li>
行列を二つ掛ける為に
\( \text{百万}^3 = \text{百京}\)回の加算・乗算が必要
</li>
</ul>
<p>
という事になります。
</p>
<p>
こんな計算を力技で行う事は困難ですので,問題を数学的に良く考察し適切にデータ構造・アルゴリズムを選択する事が重要となります。
</p>
</section>
<section>
<p>
話題を戻して,行列積の性質を確認していきます。
</p>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> 行列積の性質 </h4>
以下の等式が各演算が定義される場合において成立する。
\[ \begin{aligned}
A(BC) &= (AB)C \qquad\text{(結合則)}\\
A(B+C) &= AB+AC \qquad\text{(右分配則)}\\
(A+B)C &= AC+BC \qquad\text{(左分配則)}\\
\end{aligned} \]
</div>
</section>
<section style="font-size:80%">
<p>
\( A = (a_{ij})_{m,n}\)という表記を利用して記述する証明に慣れておきましょう。
</p>
<p>
【\(A(BC)=(AB)C\)の証明】<br>
\[ \begin{aligned}
A(BC) &= (a_{ij})_{s,t}((b_{ij})_{t,u}(c_{ij})_{u,v})= (a_{ij})_{s,t}\left(\sum_{l=1}^ub_{il}c_{lj}\right)_{t,v} \\
&= \left(\sum_{k=1}^ta_{ik}\sum_{l=1}^ub_{kl}c_{lj}\right)_{s,v} = \left(\sum_{l=1}^u(\sum_{k=1}^ta_{ik}b_{kl})c_{lj}\right)_{s,v} \\
&= \left(\sum_{k=1}^ta_{ik}b_{kj}\right)_{s,u}(c_{ij})_{u,v} = ((a_{ij})_{s,t}(b_{ij})_{t,u})(c_{ij})_{u,v} \\
&= (AB)C
\end{aligned} \]
<span style="float:right">□</span> </p>
</p>
</section>
<section style="font-size:80%">
<p>
【\(A(B+C)=AB+AC\)の証明】<br>
\[ \begin{aligned}
A(B+C) &= (a_{ij})_{l,m}(b_{ij}+c_{ij})_{m,n} \\
&= \left(\sum_{k=1}^ma_{ik}(b_{kj}+c_{kj})\right)_{m,n}\\
&= \left(\sum_{k=1}^ma_{ik}b_{kj}+\sum_{k=1}^ma_{ik}c_{kj}\right)_{m,n}\\
&= \left(\sum_{k=1}^ma_{ik}b_{kj}\right)_{m,n}+\left(\sum_{k=1}^ma_{ik}c_{kj}\right)_{m,n}\\
&= AB+AC
\end{aligned} \]
<span style="float:right">□</span> </p>
</p>
<p>
\((A+B)C=AC+BC\)の証明も同様です。
</p>
</section>
<section>
<p>
正方行列\(A\)を\(n\)個掛ける場合,結合則より掛ける順番は任意なので単純に\(A^n\)と書くことが出来ます。
</p>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> 正方行列の累乗 </h4>
<p> \(A\)を正方行列,\(n\)を自然数とする。<br>
\(A\)を\(n\)個掛けたものを
\[ A^n = A\cdot A\cdots A \]
と書く。また
\[ A^0 = E \]
と定める。
</p>
</div>
</section>
<section>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> 単位行列・ゼロ行列との積 </h4>
<p>
\(A\)を\((m,n)\)型行列とすると
\[ \begin{aligned}
&O_{l,m}A = O_{l,n},\ AO_{n,l} = O_{m,l} \\
&E_m A = A E_n = A
\end{aligned} \]
が成り立つ。
</p>
</div>
<p style="font-size:80%">
【証明】<br>
零行列の方は明らかに成立します。単位行列の方は
\[ E_m A = \left(\sum_{k=1}^m\delta_{ik}a_{kj}\right)_{m,n} = (a_{ij})_{m,n} = A \quad\text{($\because \delta_{ii}$のみ1,他は0)} \]
となります。\(AE_n = A\)も同様です。
<span style="float:right">□</span> </p>
</p>
</section>
<section>
<p>
以上の性質から解る様に,行列の計算規則は通常の文字式の計算規則と殆ど同じです。但し,以下の二点に関しては注意が必要です。
</p>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> 積の非可換性 </h4>
一般に
\[ AB \neq BA \]
</div>
<p style="font-size:70%">
例えば
\[
\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}
\begin{pmatrix} 0 & 1 \\ 2 & 1 \end{pmatrix}
=
\begin{pmatrix} 4 & 3 \\ 8 & 7 \end{pmatrix}
,\qquad
\begin{pmatrix} 0 & 1 \\ 2 & 1 \end{pmatrix}
\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}
=
\begin{pmatrix} 3 & 4 \\ 5 & 8 \end{pmatrix}
\]
</p>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> 零因子の存在 </h4>
\[ AB = O \ \not\Rightarrow\ A = O\text{または} B = O \]
</div>
<p style="font-size:70%">
例えば
\[
\begin{pmatrix} -2 & 1 \\ 4 & -2 \end{pmatrix}
\begin{pmatrix} 1 & 2 \\ 2 & 4 \end{pmatrix}
=
\begin{pmatrix} 0 & 0 \\ 0 & 0 \end{pmatrix}
\]
</p>
</section>
<section>
<p>
非可換性によって,数式の展開公式は使えなくなります。
\[ \begin{aligned}
(A+B)^2 &= (A+B)(A+B) \\
&= A^2+AB+BA+B^2 \\
&\neq A^2+2AB+B^2
\end{aligned} \]
また,方程式を因数分解によって解くことも出来ません。
\[ \begin{aligned}
X^2-3X+2E = O\ &\Leftrightarrow\ (X-E)(X-2E) = O\\
&\not\Rightarrow\ X = E, 2E
\end{aligned} \]
</p>
</section>
<section>
<h2> 行列の転置 </h2>
<div class="block" style="border-color:pink;font-size:90%">
<p>
行列\(A = (a_{ij})_{m,n}\)に対して,その<strong>転置行列</strong>を
\[ A^T = (a_{ji})_{n,m} \]
と定義する。
</p>
<p style="font-size:70%">
\[ A = \begin{pmatrix}
a_{11} & a_{12} & \cdots & a_{1n} \\
a_{21} & a_{22} & \cdots & a_{2n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{m1} & a_{m2} & \cdots & a_{mn} \\
\end{pmatrix}
\Rightarrow
A^T = \begin{pmatrix}
a_{11} & a_{21} & \cdots & a_{n1} \\
a_{12} & a_{22} & \cdots & a_{n2} \\
\vdots & \vdots & \ddots & \vdots \\
a_{1m} & a_{2m} & \cdots & a_{nm} \\
\end{pmatrix}
\]
</p>
<p>
また,正方行列\(A\)が\(A^T = A\)を満たすとき,これを<strong>対称行列</strong>,\(A^T=-A\)を満たすとき<strong>交代行列</strong>という。
</p>
</div>
</section>
<section>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> 転置行列の性質 </h4>
<p>
以下の等式が各演算が定義される場合において成立する。
\[ \begin{aligned}
(A^T)^T &= A \\
(A+B)^T &= A^T + B^T \\
(kA)^T &= kA^T \\
(AB)^T &= B^TA^T \\
\end{aligned} \]
</p>
</div>
<p style="font-size:70%">
最初の3つは自明だと思います。最後の一つだけ証明しましょう。<br>
【\((AB)^T=B^TA^T\)の証明】<br>
\(A\)が\((l,m)\)型,\(B\)が\((m,n)\)型のとき
\[
(AB)^T = \left(\sum_{k=1}^m a_{ik}b_{kj}\right)^T_{l,n} =
\left(\sum_{k=1}^m a_{jk}b_{ki}\right)_{n,l} = (b_{ji})_{n,m}(a_{ji})_{m,l} = B^TA^T
\]
<span style="float:right">□</span> </p>
</p>
</section>
<section style="font-size:80%">
<div class="block" style="border-color:lightgreen">
<h4 style="color:lightgreen">練習問題</h4>
<p>
任意の正方行列\(A\)に対して
\[ S = \frac{A+A^T}{2},\ T=\frac{A-A^T}{2} \]
とおくと,\(S\)は対称行列,\(T\)は交代行列となる事を証明して下さい。
</p>
<p>
すると\(A = S + T\)が成立するので,任意の正方行列は対称行列と交代行列の和で表せる事が判ります。
</p>
<p>
以下の行列を対称行列と交代行列に分解して下さい。
\[
\begin{pmatrix}
1 & 5 & 2 \\
2 & 1 & 3 \\
4 & 2 & 1
\end{pmatrix}
\]
</p>
</div>
<p class="fragment" style="font-size:70%">
【答え】<br>
\[
\begin{pmatrix} 1 & 5 & 2 \\ 2 & 1 & 3 \\ 4 & 2 & 1 \end{pmatrix}
=
\begin{pmatrix} 1 & \frac72 & 3 \\ \frac72 & 1 & \frac52 \\ 3 & \frac52 & 1 \end{pmatrix}
+
\begin{pmatrix} 0 & \frac32 & -1 \\ -\frac32 & 0 & \frac12 \\ 1 & -\frac12 & 0 \end{pmatrix}
\]
</p>
</section>
<section>
<h2> ベクトル </h2>
<p>
数や式を\(n\)個を縦に並べたものを<strong>\(n\)次元列ベクトル</strong>と言い,ボールド体を用いて
\[ \mathbf{x} = \begin{pmatrix} x_1 \\ \vdots \\ x_n \end{pmatrix} \]
と表します。また全ての成分が\(0\)の列ベクトルを<strong>零ベクトル</strong>と言い0と表します。
</p>
<p>
同様に\(n\)個を横に並べたものを<strong>\(n\)次元行ベクトル</strong>と言い,
\[ \mathbf{x}^T = \begin{pmatrix} x_1 & \cdots & x_n \end{pmatrix} \]
などと表します。
</p>
<p>\(x_i\)をこれらベクトルの第\(i\)成分と呼びます。
</p>
</section>
<section>
<p>
\(n\)次元列ベクトルは\((n,1)\)型行列,行ベクトルは\((1,n)\)型行列でもあります。行列と全く同じ演算規則が適用されます。
</p>
<p style="margin-top:1em">
この勉強会では主に実数成分のベクトル(実ベクトル)を考えます。実数成分の\(n\)次元列ベクトルの集合を<strong> \(\mathbb{R}^n\) </strong>と表します。
</p>
<p style="margin-top:1em">
列ベクトルと行ベクトルは常に区別されますので注意して下さい。
今後,単に「ベクトル」と言った場合,それは列ベクトルの事であるとします。
</p>
</section>
<section>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> ベクトルの内積・ノルム </h4>
<p>
\(n\)次元実ベクトル\(\mathbf{x}, \mathbf{y}\)に対して
\[ (\mathbf{x}, \mathbf{y}) = x_1y_1 + x_2y_2 + \cdots + x_ny_n \]
を<strong>内積</strong>と言う。
</p>
<p>
また,実ベクトル\( \mathbf{x} = (x_1,\cdots,x_n)^T \)に対して
\[ ||\mathbf{x}||=\sqrt{x_1^2 + \cdots + x_n^2} \]
をベクトルの<strong>ノルム</strong>(ユークリドッドノルム)と言う。
</p>
</div>
<p style="font-size:80%">
【注】 ベクトルの内積・ノルムという概念は実際にはその性質によって抽象的に定義され,上の定義以外にも様々な内積・ノルムが存在します。しかし,よく使われる上の定義だけをここでは考える事にします。
</p>
</section>
<section>
<p>
ベクトルの内積・ノルムは,行列の記法を利用すれば
\[ \begin{aligned}
(\mathbf{x}, \mathbf{y}) &=
\begin{pmatrix}x_1&\cdots&x_n\end{pmatrix}
\begin{pmatrix}y_1\\ \vdots \\ y_n\end{pmatrix}
=
\color{yellow}{\mathbf{x}^T\mathbf{y}} \\
||\mathbf{x}||^2 &= (\mathbf{x},\mathbf{x}) = \color{yellow}{\mathbf{x}^T\mathbf{x}}
\end{aligned} \]
と記述する事が出来ます。
</p>
</section>
<section>
<div class="block" style="border-color:lightgreen">
<h4 style="color:lightgreen">練習問題</h4>
\(n\)次元ベクトル\(\mathbf{x}, \mathbf{y}\)と,\(n\)次正方行列\(A\)について
\[ (A\mathbf{x}, \mathbf{y}) = (\mathbf{x}, A^T\mathbf{y}) \]
である事を示して下さい。
</div>
<p class="fragment" style="font-size:70%">
【証明】
\[ (A\mathbf{x}, \mathbf{y}) = (A\mathbf{x})^T\mathbf{y} = \mathbf{x}^TA^T\mathbf{y}=(\mathbf{x}, A^T\mathbf{y}) \]
<span style="float:right">□</span> </p>
</p>
</section>
<section>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> コーシー・シュワルツの不等式 </h4>
<p>
\(n\)次元実ベクトル\(\mathbf{x},\mathbf{y}\)に対して
\[ ||\mathbf{x}||^2||\mathbf{y}||^2 \geq (\mathbf{x},\mathbf{y})^2 \]
が成立する。等号はある実数\(t\)が存在して\(\mathbf{y}=t\mathbf{x}\)となる時に成立する。
</p>
<p>
</p>
</div>
<p style="font-size:70%">
【証明】<br>
\[ (tx_i-y_i)^2 = x_i^2t^2-2x_iy_it+y_i^2\geq 0 \]
を\(i = 1,\cdots,n\)について加えて
\[ (x_1^2+\cdots+x_n^2)t^2-2(x_1y_1+\cdots+x_ny_n)t+(y_1^2+\cdots+y_n^2)\geq 0 \]
が任意の実数\(t\)について成立する。従って左辺の判別式を考えて
\[ D\leq 0\ \Leftrightarrow\ (x_1y_1+\cdots+x_ny_n)^2-(x_1^2+\cdots+x_n^2)(y_1^2+\cdots+y_n^2)\leq 0 \]
である。
<span style="float:right">□</span> </p>
</p>
</section>
<section>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> 内積・ノルムの性質 </h4>
<p>
内積に関して
\[ \begin{aligned}
(\mathbf{x}, \mathbf{y}) &= (\mathbf{y}, \mathbf{x}) \\
(k\mathbf{x}, \mathbf{y}) &= k(\mathbf{x}, \mathbf{y})\\
(\mathbf{x}+\mathbf{y}, \mathbf{z}) &= (\mathbf{x},\mathbf{z}) + (\mathbf{y},\mathbf{z})
\end{aligned} \]
が成立する。
</p>
<p>
また,ノルムに関して
\[ \begin{aligned}
&||k\mathbf{x}|| = |k|\,||\mathbf{x}|| \\
&||\mathbf{x}+\mathbf{y}||\leq ||\mathbf{x}||+||\mathbf{y}|| \quad\text{(三角不等式)}
\end{aligned} \]
が成立する。
</p>
</div>
</section>
<section>
<p style="font-size:80%">
【三角不等式の証明】<br>
\[ \begin{aligned}
||\mathbf{x}+\mathbf{y}||^2 &= (x_1+y_1)^2 + \cdots + (x_n+y_n)^2 \\
&= x_1^2+\cdots+x_n^2 + y_1^2 + \cdots + y_n^2 + 2(x_1y_1 + \cdots + x_ny_n) \\
&= ||\mathbf{x}||^2 + ||\mathbf{y}||^2 + 2(\mathbf{x},\mathbf{y}) \\
&\leq ||\mathbf{x}||^2+||\mathbf{y}||^2 + 2||\mathbf{x}|| ||\mathbf{y}|| \qquad\text{(コーシー・シュワルツの不等式)}\\
&= (||\mathbf{x}|| + ||\mathbf{y}||)^2
\end{aligned}
\]
<span style="float:right">□</span>
</p>
<p>
その他の性質の証明は省略します。
</p>
</section>
<section>
<h2> 小行列への分解 </h2>
<p>
\[
\begin{pmatrix} a & b & c \\ d & e & f \\ g & h & i \end{pmatrix}
=
\begin{pmatrix}
A & B \\ C & D
\end{pmatrix}
\]
\[
A = \begin{pmatrix} a & b \\ d & e \end{pmatrix},
B = \begin{pmatrix} c \\ f \end{pmatrix},
C = \begin{pmatrix} g & h \end{pmatrix},
D = (i)
\]
の様に行列を<strong>小行列</strong>へ分解する操作もよく行われます。
</p>
</section>
<section>
<p>
行列\(X,Y\)を小行列\(A,B,C,D,E,F,G,H\)へ分解したとき,以下の各演算が定義されるならば
\[ \begin{aligned}
XY &= \begin{pmatrix} A & B \\ C & D \end{pmatrix}
\begin{pmatrix} E & F \\ G & H \end{pmatrix} \\
&= \begin{pmatrix}
AE+BG & AF+BH \\ CE+DG & CF+DH
\end{pmatrix}
\end{aligned} \]
が成立します。これの成立も明らかでしょう。
</p>
<p>
例えば,行列\(A\)を各列ベクトルに分解して
\[ BA = B(\mathbf{a_1}, \cdots, \mathbf{a_n}) = (B\mathbf{a_1},\cdots,B\mathbf{a_n}) \]
と書くといった事が良く行われます。
</p>
</section>
<section>
<h2> 行列・ベクトルで何を表すのか? </h2>
<p>
さて,行列・ベクトルの定義と演算を確認しましたが,これらを一体どのように利用するのかイメージが湧かない方もいるでしょう。
</p>
<p>
そこで,行列・ベクトルで表すことの出来る様々な問題を紹介します。様々な読者を想定していろんな話をしますが、個別の話は解らない事があっても良いです。線型代数はほぼありとあらゆる場面で必要となるのだということが解ってもらえれば結構です。
</p>
</section>
<section style="font-size:80%">
<h2> 連立一次方程式 </h2>
<p>
連立一次方程式
\[ \left\{\begin{array}{c}
a_{11}x_1+a_{12}x_2+\cdots+a_{1n}x_n = b_1 \\
a_{21}x_1+a_{22}x_2+\cdots+a_{2n}x_n = b_2 \\
\vdots \\
a_{m1}x_1+a_{m2}x_2+\cdots+a_{mn}x_n = b_m
\end{array}\right.
\]
は
\[
\begin{pmatrix}
a_{11} & a_{12} & \cdots & a_{1n} \\
a_{21} & a_{22} & \cdots & a_{2n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{m1} & a_{m2} & \cdots & a_{mn} \\
\end{pmatrix}
\begin{pmatrix} x_1 \\ x_2 \\ \vdots \\ x_n \end{pmatrix}
=
\begin{pmatrix} b_1 \\ b_2 \\ \vdots \\ b_m \end{pmatrix}
\]
と表す事が出来ます。多くの問題が連立一次方程式を解く事に帰着します。
</p>
</section>
<section style="font-size:80%">
<h2> 連立一次漸化式 </h2>
<p>
全く同じ事ですが,連立漸化式
\[ \left\{\begin{array}{c}
x_1(i+1) = a_{11}x_1(i)+a_{12}x_2(i)+\cdots+a_{1n}x_n(i) \\
x_2(i+1) = a_{21}x_1(i)+a_{22}x_2(i)+\cdots+a_{2n}x_n(i) \\
\vdots \\
x_n(i+1) = a_{n1}x_1(i)+a_{m2}x_2(i)+\cdots+a_{nn}x_n(i)
\end{array}\right.
\]
も
\[
\begin{pmatrix} x_1(i+1) \\ x_2(i+1) \\ \vdots \\ x_n(i+1) \end{pmatrix}
=
\begin{pmatrix}
a_{11} & a_{12} & \cdots & a_{1n} \\
a_{21} & a_{22} & \cdots & a_{2n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{n1} & a_{n2} & \cdots & a_{nn} \\
\end{pmatrix}
\begin{pmatrix} x_1(i) \\ x_2(i) \\ \vdots \\ x_n(i) \end{pmatrix}
\]
と表されます。
</p>
</section>
<section>
<p>
漸化式が
\[ \mathbf{x}_{i+1} = A\mathbf{x}_i \]
と表される場合,
\[ \mathbf{x}_i = A\mathbf{x}_{i-1} = AA\mathbf{x}_{i-2} = \cdots = A^i\mathbf{x}_0 \]