-
Notifications
You must be signed in to change notification settings - Fork 5
/
11.html
1175 lines (1083 loc) · 45.9 KB
/
11.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 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>第11回</h1>
<span>
(於)ワークスアプリケーションズ<br>
中村晃一<br>
2013年11月21日
</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及びMaximaで記述しています。 </li>
</ul>
</p>
</section>
<section>
<h2 class="chapter-title"> 連立一次方程式の反復解法 </h2>
</section>
<section>
<p>
連立一次方程式
\[ A\mathbf{x} = \mathbf{b} \]
の解法として,ガウス消去法やLU分解法などの直接解法は既に紹介しました。
直接解法はメモリの消費が大きいので,<strong>直接解法は比較的サイズが小さい連立方程式</strong>に向いています。
</p>
<p>
一方,<strong>反復解法はサイズが大きく・係数が疎な(係数に0が多い)連立方程式</strong>に向いています。
</p>
</section>
<section style="font-size:80%">
<h2> 疎行列 </h2>
<p>
成分がほとんど0の行列を<strong>疎行列</strong>と言います。現実の問題で現れる行列の多くが疎です。
疎行列は0でない成分の値と場所のみで表現できるので,記憶容量を抑えることができます。
</p>
<p class="fragment">
\[ \begin{pmatrix}
0 & 1 & 0 & 0 \\ 3 & 2 & 0 & 0 \\ 0 & 5 & 0 & 1 \\ 0 & 2 & 4 & 0
\end{pmatrix}\ \rightarrow\
\left\{\begin{array}{ll}
\text{値}: &[1, 3, 2, 5, 1, 2, 4] \\
\text{行番号}: &[1, 2, 2, 3, 3, 4, 4] \quad\text{(これを更に圧縮)}\\
\text{列番号}: &[2, 1, 2, 2, 4, 2, 3]
\end{array}\right.
\]
行優先の<strong>CSR(Compressed Sparse Row)方式</strong>,<strong>列優先のCSC(Compressed Sparse Column)方式</strong>などいくつかの表現方式があります。
</p>
<p class="fragment">
疎行列では,行列演算の計算量を比較的抑える事ができます。特に,
\[ A\mathbf{x}\ \text{や}\mathbf{x}^TA \]
という形の行列とベクトルの積を高速に計算する事ができます(\(\mathcal{O}(\text{非零要素数})\)のオーダー)。
</p>
</section>
<section>
<h2> 反復解法 </h2>
<p>
反復解法とは収束する数列
\[ x_0,\ x_1=f(x_0),\ x_2=f(x_1),\ x_3=f(x_2),\ \cdots \]
を途中で打ち切る事によって,方程式
\[ \color{yellow}{x = f(x)} \]
の近似解を求める手法です。第4回には線形反復法やニュートン法などの反復解法を紹介しました。
</p>
</section>
<section>
<p>
連立一次方程式
\[ A\mathbf{x}=\mathbf{b} \]
に対しては,適当な行列\(C\)によって
\[ \color{yellow}{\mathbf{x}_{i+1} = \mathbf{x}_i - C(A\mathbf{x}_{i}-\mathbf{b}) = (E-CA)\mathbf{x}+C\mathbf{b}} \]
という漸化式を作ります。
</p>
<p>
仮に\(C=A^{-1}\)であれば
\[ \mathbf{x}_{i+1} = \mathbf{x}_i - A^{-1}A\mathbf{x}_{i}+A^{-1}\mathbf{b} = A^{-1}\mathbf{b} \]
となるので,一回で真の解に収束します。そこで,\(C\)は\(A^{-1}\)に出来るだけ近いものを取れば良いだろうと考えられます。
</p>
</section>
<section>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> ヤコビ法 </h4>
<p>
行列\(A\)の対角成分が全て非零であるとする。\(A\)の対角だけ取り出した対角行列を\(D\)として
\[ \mathbf{x}_{i+1}=\mathbf{x}_i-D^{-1}(A\mathbf{x}_i-\mathbf{b})=(E-D^{-1}A)\mathbf{x}_i+D^{-1}\mathbf{b} \]
により反復する解法を<strong>ヤコビ法</strong>と言う。
初期値は\(\mathbf{x}_0 = \mathbf{0}\)とすれば良い。
</p>
</section>
<section style="font-size:70%">
<div class="block" style="border-color:lightgreen;font-size:90%">
<h4 style="color:lightgreen"> 例 </h4>
<p>
\[
\begin{pmatrix}
2 & -1 & 0 \\
-1 & 2 & -1 \\
0 & -1 & 2 \\
\end{pmatrix}
\begin{pmatrix}
x \\ y \\ z
\end{pmatrix}
=
\begin{pmatrix}
-1 \\ 0 \\ 3
\end{pmatrix}
\]
をヤコビ法で解いてみましょう。
</p>
</div>
<p>
\[
\begin{pmatrix}
2 & 0 & 0 \\
0 & 2 & 0 \\
0 & 0 & 2 \\
\end{pmatrix}^{-1} =
\frac{1}{2}\begin{pmatrix}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1 \\
\end{pmatrix}
\]
なので
\[
\begin{aligned}
\begin{pmatrix}
x_{i+1} \\ y_{i+1} \\ z_{i+1}
\end{pmatrix}
&=
\begin{pmatrix}
x_i \\ y_i \\ z_i
\end{pmatrix}
-
\frac{1}{2}
\begin{pmatrix}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1 \\
\end{pmatrix}^{-1}
\left\{
\begin{pmatrix}
2 & -1 & 0 \\
-1 & 2 & -1 \\
0 & -1 & 2 \\
\end{pmatrix}
\begin{pmatrix}
x_i \\ y_i \\ z_i
\end{pmatrix}
-
\begin{pmatrix}
-1 \\ 0 \\ 3
\end{pmatrix}
\right\} \\
&=
\begin{pmatrix}
0 & 1/2 & 0 \\
1/2 & 0 & 1/2 \\
0 & 1/2 & 0 \\
\end{pmatrix}
\begin{pmatrix}
x_i \\ y_i \\ z_i
\end{pmatrix}
+
\begin{pmatrix}
-1/2 \\ 0 \\ 3/2
\end{pmatrix}
\end{aligned}
\]
によって反復を行えば良いです。
</p>
</section>
<section style="font-size:80%">
<p>
計算してみると以下のようになります。厳密解は\((x,y,z)=(0,1,2)\)です。
</p>
<pre><code class="python" style="max-height:400px">>>> import numpy as np
>>> from numpy import linalg as LA
>>> A = np.array([[2,-1,0],[-1,2,-1],[0,-1,2]])
>>> b = np.array([-1,0,3])
>>>
>>> D = np.diag(np.diag(A)) # 対角だけ取り出す
>>> D
array([[2, 0, 0],
[0, 2, 0],
[0, 0, 2]])
>>> P = np.identity(3) - LA.inv(D).dot(A) # E-D^(-1)A を計算しておく
>>> q = LA.inv(D).dot(b) # D^(-1)b を計算しておく
>>> x = np.array([0,0,0])
>>> for i in range(100): # 反復回数には上限を定める事
... new_x = P.dot(x) + q
... if LA.norm(new_x-x) < LA.norm(new_x) * 1.0e-10: # 相対誤差で収束判定
... break
... x = new_x
...
>>> i
64 # 64回で収束した
>>> x
array([ -2.32830644e-10, 1.00000000e+00, 2.00000000e+00])
</code></pre>
<p style="font-size:90%">
上のコードでは簡単の為,終了条件を\( |\mathbf{x}_{i+1}-\mathbf{x}_i|/|\mathbf{x}_{i+1}| < \varepsilon \)としていますが,\(\mathbf{x}_i\)の第\(k\)成分を\(x_k^{(i)}\)として
\( \max_k\frac{|x_k^{(i+1)}-x_k^{(i)}|}{|x_k^{(i+1)}|} < \varepsilon \)
とする方が一般的だと思います(成分毎の誤差を抑えられる)。
</p>
</section>
<section style="font-size:90%">
<h2> 収束性 </h2>
<p>
反復解法はいつでも収束するわけではありません。その収束性は固有値と関係します。
</p>
<p>
\[ \mathbf{x}_{i+1}=A\mathbf{x}_i+\mathbf{b} \]
で反復を行うとします。求める真の解を\(\mathbf{x}\)とすれば
\[ \mathbf{x}=A\mathbf{x}+\mathbf{b} \]
が成り立つので差を取れば
\[ (\mathbf{x}-\mathbf{x}_{i+1})=A(\mathbf{x}-\mathbf{x}_i) \]
となります。従って真の解との誤差\(\mathbf{e}_i = \mathbf{x}-\mathbf{x}_i\)は
\[ \mathbf{e}_{i+1} = A(\mathbf{e}_i)\ \Rightarrow \color{yellow}{\mathbf{e}_i = A^i\mathbf{e}_0} \]
で得られますから
\[ \lim_{i\rightarrow\infty}A^i\mathbf{e}_0 = \mathbf{0} \]
であれば,収束するということになります。
</p>
</section>
<section style="font-size:90%">
<p>
ここで\(A\)が固有ベクトル\(\mathbf{v}_1,\cdots,\mathbf{v}_n\)からなる基底を持つ場合を考えます。対応する固有値を\(\lambda_1,\cdots,\lambda_n\)とします。
</p>
<p>
誤差\(\mathbf{e}_i\)の第\(k\)成分を\(e_k^{(i)}\)と表せば前回説明した通り
\[ \mathbf{e}_i = A^i\mathbf{e}_0\ \Leftrightarrow\ \color{yellow}{e_k^{(i)} = \lambda_k^i e_k^{(0)}} \]
となるので各固有値\(\lambda_k\)について
\[ (\lambda_k)^i\ \rightarrow\ 0 \]
である事が誤差が0に収束する十分条件となります。その為には\(|\lambda_k|\)の最大値が1未満であれば良いです。
</p>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> スペクトル半径 </h4>
<p>
行列\(A\)の固有値の絶対値の最大値を<strong>スペクトル半径</strong>という。スペクトル半径が1未満であれば,任意の\(\mathbf{b}\)に対して
\[ \mathbf{x}_{i+1}=A\mathbf{x}_i+\mathbf{b} \]
で定まる数列は収束する。
</p>
</div>
</section>
<section style="font-size:80%">
<p>
スペクトル半径の計算は面倒である事が多いのですが,ヤコビ法に関しては以下の事実が知られています。
</p>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> ヤコビ法の収束条件 </h4>
<p>
\(n\)次正方行列\(A\)が,各\(i = 1,\cdots,n\)について
\[ |a_{ii}| > \sum_{j\neq i} | a_{ij} | \]
を満たす時,\(A\)は<strong>優対角</strong>であるという。
</p>
<p>
\(A\)が優対角であれば,方程式
\[ A\mathbf{x} = \mathbf{b} \]
に対するヤコビ法は必ず収束する。
</p>
</div>
</section>
<section style="font-size:80%">
<p>
ヤコビ法を改良した<strong>ガウス・ザイデル法</strong>では
\[ A=L+D+U\qquad\text{($D$は$A$の対角,$L$は対角より下の部分,$U$は上)} \]
と分解して\(C = (L+D)^{-1}\)と置きます。すると
\[ \begin{aligned}
&\mathbf{x}_{i+1}=\mathbf{x}_i - (L+D)^{-1}(A\mathbf{x}_i-\mathbf{b}) \\
\Leftrightarrow & \color{yellow}{\mathbf{x}_{i+1}=D^{-1}(-L\mathbf{x}_{i+1}-U\mathbf{x}_i+\mathbf{b})} \\
\end{aligned} \]
という陰的な方程式が得られますが,\(L\)が下三角なので第1行目から順番に解くことができます。
</p>
<p>
更にガウス・ザイデル法を改良して,
\[C = (L+ D/\omega)^{-1}\qquad (0 < \omega < 2) \]
とする<strong>逐次過大緩和法(SOR)法</strong>など様々な手法が存在します。
</p>
<p>
詳しくは専門書を参照してください。
</p>
</section>
<section>
<h2 class="chapter-title"> 二次形式 </h2>
</section>
<section>
<h2> 二次形式 </h2>
<p>
変数の2次の項のみで表される多項式
\[ \begin{aligned}
f(x_1) &= ax_1^2 \\
f(x_1,x_2) &= ax_1^2 + bx_2^2 + cx_1x_2 \\
f(x_1,x_2,x_3) &= ax_1^2 + bx_2^2 + cx_3^2 + dx_1x_2 + ex_2x_3 + fx_3x_1\\
\vdots
\end{aligned} \]
を<strong>二次形式</strong>と呼びます。後の話に必要となる話題だけ説明をします。
また,全ての変数・係数は実数であるとします。
</p>
</section>
<section>
<p>
まず,全ての二次形式は
\[ \begin{aligned}
f(x_1) &= ax_1^2 \\
f(x_1,x_2) &= ax_1^2 + bx_2^2 + \frac{c}{2}x_1x_2 + \frac{c}{2}x_2x_1\\
f(x_1,x_2,x_3) &= ax_1^2 + bx_2^2 + cx_3^2 + \frac{d}{2}x_1x_2 +\frac{d}{2}x_2x_1\\
& + \frac{e}{2}x_2x_3 + \frac{e}{2}x_3x_2 + \frac{f}{2}x_3x_1 + \frac{f}{2}x_1x_3\\
\end{aligned} \]
のように,\(x_ix_j\)と\(x_jx_i\)の係数が等しい多項式として書き直す事ができます。よって2次形式は
\[ \color{yellow}{ f(\mathbf{x}) = \sum_{i,j} a_{ij}x_ix_j\qquad (a_{ij} = a_{ji})} \]
と書くことができます。
</p>
</section>
<section>
<p>
さらに,二次形式
\[ f(\mathbf{x}) = \sum_{i,j} a_{ij}x_ix_j\qquad (a_{ij} = a_{ji}) \]
に対して
\[ A=(a_{ij})\]
と置けば
\[ \color{yellow}{f(\mathbf{x}) = \mathbf{x}^TA\mathbf{x}} \]
と書き表される事がわかります。更に\(a_{ij}=a_{ji}\)より<strong>\(A\)は対称行列</strong>です。
</p>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> 二次形式 </h4>
<p>
任意の二次形式は,実対称行列(実数成分の対称行列)\(A\)を用いて
\[ f(\mathbf{x})= \mathbf{x}^TA\mathbf{x} \]
と表す事ができる。
</p>
</div>
</section>
<section>
<div class="block" style="border-color:lightgreen;font-size:90%">
<h4 style="color:lightgreen"> 例 </h4>
\[ f(x,y) = x^2 + 3xy + 2y^2 \]
を行列で表してみましょう。
</div>
<p>
\[ f(x,y) = x^2 + \frac{3}{2}xy + \frac{3}{2}yx + 2y^2 \]
なので
\[ f(x,y) =
\begin{pmatrix} x & y \end{pmatrix}
\begin{pmatrix} 1 & \frac{3}{2} \\ \frac{3}{2} & 2 \end{pmatrix}
\begin{pmatrix} x \\ y \end{pmatrix}
\]
と表す事ができます。
</p>
</section>
<section>
<p>
ここで,実対称行列の性質をいくつか確認しておきましょう。
</p>
<div class="block" style="border-color:pink;font-size:90%">
<p> 実対称行列の固有値は全て実数である </p>
</div>
<p style="font-size:70%">
【証明】<br>
行列・ベクトルの成分を全て複素数範囲で考える。また複素共役を\(\overline{(\ -\ )}\)で表す。
\[ A\mathbf{v} = \lambda\mathbf{v} \]
ならば
\[ \lambda\mathbf{\overline{v}}^T\mathbf{v} = \mathbf{\overline{v}}^T\lambda\mathbf{v} = \mathbf{\overline{v}}^TA\mathbf{v} = (A\mathbf{\overline{v}})^T\mathbf{v}
= (\overline{A\mathbf{v}})^T\mathbf{v} = (\overline{\lambda\mathbf{v}})^T\mathbf{v} = \overline{\lambda}\mathbf{\overline{v}}^T\mathbf{v} \]
となるので,\(\mathbf{\overline{v}}^T\mathbf{v} = ||\mathbf{v}||^2\neq 0\)であることより
\[ \lambda = \overline{\lambda} \]
である。すなわち\(\lambda\)は実数。
<span style="float:right">□</span>
</p>
</section>
<section>
<div class="block" style="border-color:pink;font-size:90%">
<p> 実対称行列は直交行列により対角化可能である。<br>
すなわち,\(A\)が実対称行列ならばある直交行列\(P\)が存在して
\[ P^TAP \]
が固有値を対角成分に持つ対角行列となる。
</p>
</div>
</section>
<section>
<p style="font-size:70%">
【証明】<br>
\(n\)次実対称行列\(A\)について,数学的帰納法で証明する。<br>
\(n=1\)の時の成立は明らかなので,\(n \geq 2\)の場合を考える。
前頁の定理より,\(A\)の固有値\(\lambda \in\mathbb{R}\)を1つとれる。
\(\lambda\)の固有ベクトルの1つを\(\mathbf{v}_1\)とし,\(\mathbf{v}_1\)を含む正規直交基底
\[ \{\mathbf{v}_1,\cdots,\mathbf{v}_n\} \]
をとる。ここで
\[ Q = (\mathbf{v}_1,\cdots,\mathbf{v}_n) \]
とおけば,これは直交行列であり\(\mathbf{v}_1\)が\(A\)の固有値であることから
\[ Q^TAQ \]
の一列目は\((\lambda,0,\cdots,0)^T\)となる。更に
\[ (Q^TAQ)^T = Q^TA^T(Q^T)^T = Q^TAQ \]
であるから,
\[ Q^TAQ = \begin{pmatrix}
\lambda & \\
& A'
\end{pmatrix} \]
という形である。ここで帰納法の仮定から直交行列\(R\)が存在して
\[ R^TA'R = \Lambda \]
という対角化が可能であるから
\[ P = Q\begin{pmatrix}
1 & \\
& R
\end{pmatrix} \]
とおけば良い。対角化が可能である時,対角成分が固有値である事は前回説明した通り。
<span style="float:right">□</span>
</p>
</section>
<section>
<p>
では、二次形式の話に戻ります。実対称行列\(A\)を
\[ A=P^T\Lambda P \]
と直交行列で対角化したならば
\[ f(\mathbf{x})=\mathbf{x}^TA\mathbf{x} = \mathbf{x}^TP^T\Lambda P\mathbf{x} = (P\mathbf{x})^T\Lambda(P\mathbf{x}) \]
となりますから,\(\mathbf{y}=P\mathbf{x}\)と置けば
\[ \color{yellow}{ f(\mathbf{x})=\mathbf{y}^T\Lambda\mathbf{y}
= \lambda_1y_1^2 + \lambda_2y_2^2 + \cdots + \lambda_ny_n^2} \]
と単純化できます。これを二次形式の<strong>標準形</strong>と言います。
</p>
</section>
<section style="font-size:80%">
<div class="block" style="border-color:lightgreen;font-size:90%">
<h4 style="color:lightgreen"> 例 </h4>
\[ f(x,y) = x^2 + y^2 - xy \]
を標準形に変換しましょう。
</div>
<p>
対応する行列は
\[ \begin{pmatrix}
1 & -1/2 \\
-1/2 & 1
\end{pmatrix}
=
\begin{pmatrix}
1/\sqrt{2} & -1/\sqrt{2} \\
1/\sqrt{2} & 1/\sqrt{2}
\end{pmatrix}^T
\begin{pmatrix}
3/2 & 0 \\
0 & 1/2
\end{pmatrix}
\begin{pmatrix}
1/\sqrt{2} & -1/\sqrt{2} \\
1/\sqrt{2} & 1/\sqrt{2}
\end{pmatrix}
\]
と直交行列で対角化する事ができるので
\[ \color{yellow}{ f(x,y) = \frac{3}{2}s^2 + \frac{1}{2}t^2\quad\left( s = \frac{x-y}{\sqrt{2}},\ t = \frac{x+y}{\sqrt{2}}\right)} \]
となります。
</p>
</section>
<section style="font-size:80%">
<p>
今の例題の応用ですが,曲線
\[ x^2+y^2-xy=1\cdots (1)\]
を作図したい場合には,\((x,y)\longmapsto(s,t)\)の座標変換を行って
\[ \frac{3}{2}s^2+\frac{1}{2}t^2 = 1 \]
とします。これは\(st\)平面における長半径\(\sqrt{2}\),短半径\(\sqrt{2/3}\)の楕円です。
</p>
<p>
ところで,<strong>直交変換は図形の形状を保つ</strong>(基底の直交性と長さを保つから)事がわかるので\(xy\)平面においても(1)の表す曲線は同じ楕円であるということになります。
</p>
<div align="center"> <img width="400" src="fig/paraboloid3.png"> </div>
</section>
<section>
<h2 class="chapter-title"> 多変数関数の極値 </h2>
</section>
<section>
<p>
各種最適化問題は,関数の最大値・最小値を求める事に帰着するので,極値の理解が重要となるというのはこれまで説明した通りです。
</p>
<p class="fragment">
復習すると,十分滑らかな一変数関数\(y=f(x)\)に関しては
\[ \begin{aligned}
f'(a)=0,\ f''(a) < 0\ &\Rightarrow\ f(a)\text{は極大値} \\
f'(a)=0,\ f''(a) > 0\ &\Rightarrow\ f(a)\text{は極小値} \\
\end{aligned} \]
が成り立つのでした(第3回資料)。
</p>
<p class="fragment">
多変数関数において同様の判定を行うことを考えます。二次形式の知識を利用します。
</p>
</section>
<section style="font-size:80%">
<p> 二変数関数で説明します。 </p>
<p>
十分滑らかな二変数関数\(y = f(x,y)\)について
\[ f(a,b)\text{が極値}\ \Rightarrow\ \mathrm{grad} f(a,b) = \left(\frac{\partial f}{\partial x}(a,b),\frac{\partial f}{\partial y}(a,b)\right) = \mathbf{0} \]
が成り立つのでした(第4回資料)。
</p>
<p class="fragment">
よって,テイラーの定理によって\(f(a,b)\)が極値ならば
\[ f(x,y) = f(a,b) + \frac{1}{2}\left((x-a)\frac{\partial}{\partial x} + (y-b)\frac{\partial}{\partial y}\right)^2f(a,b) + \text{(剰余)}
\]
という形になりますが,関数の連続性から\((x,y)\)と\((a,b)\)が十分近い時には
\[ f(x,y) > f(a,b)\ \Leftrightarrow\
\left((x-a)\frac{\partial}{\partial x} + \cdots + (y-b)\frac{\partial}{\partial y}\right)^2f(a,b) > 0 \]
という同値関係が成り立ちます。
</p>
</section>
<section style="font-size:80%">
<p>
展開してみれば
\[ \begin{aligned}
& \left((x-a)\frac{\partial}{\partial x} + (y-b)\frac{\partial}{\partial y}\right)^2f \\
=& \color{yellow}{\frac{\partial^2f}{\partial x^2} (x-a)^2 + \frac{\partial^2f}{\partial y^2}(y-b)^2 + \frac{\partial^2f}{\partial x\partial y}(x-a)(y-b) + \frac{\partial^2f}{\partial y\partial x}(y-b)(x-a) }
\end{aligned} \]
となります(\(f(a,b)\)の\((a,b)\)を省略)が,これは\(X=x-a,Y=y-b\)を変数とする二次形式になっています。ここで,\(f\)が十分滑らかならば
\[ \frac{\partial^2 f}{\partial x\partial y} = \frac{\partial^2 f}{\partial y\partial x} \]
であった事に注意すれば,行列
\[ H = \begin{pmatrix}
\frac{\partial^2 f}{\partial x^2} & \frac{\partial^2 f}{\partial x\partial y} \\
\frac{\partial^2 f}{\partial y\partial x} & \frac{\partial^2 f}{\partial y^2}
\end{pmatrix} \]
が対称行列となります。
</p>
</section>
<section style="font-size:80%">
<p>
よって,\(H\)の固有値を\(\lambda_1,\lambda_2\)とすれば,適当な変数変換\((x,y)\longmapsto (s,t)\)によって(\((x,y)\)が\((a,b)\)に十分近い範囲で)
\[ f(x,y) > f(a,b)\ \Leftrightarrow\ \lambda_1s^2+\lambda_2t^2 > 0 \]
と簡略化する事ができます。
</p>
<p>
(細かい議論がいろいろと必要ですが)右辺の条件は
\[ \lambda_1 > 0,\ \lambda_2 > 0 \]
ですので\(H\)の固有値によって極値の判定ができるという事になります。
</p>
<p>
以上は\(n\)変数の場合に一般化する事ができます。
</p>
</section>
<section style="font-size:80%">
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> 極値の判定 </h4>
<p>
\(f\)を十分滑らかな\(n\)変数関数とする。このとき
\[ H(f) = \begin{pmatrix}
\frac{\partial^2 f}{\partial x_1^2} & \frac{\partial^2 f}{\partial x_1\partial x_2} & \cdots & \frac{\partial^2 f}{\partial x_1\partial x_n} \\
\frac{\partial^2 f}{\partial x_2\partial x_1} & \frac{\partial^2 f}{\partial x_2^2} & \cdots & \frac{\partial^2 f}{\partial x_2\partial x_n} \\
\vdots & \vdots & \ddots & \vdots \\
\frac{\partial^2 f}{\partial x_n\partial x_1} & \frac{\partial^2 f}{\partial x_n\partial x_2} & \cdots & \frac{\partial^2 f}{\partial x_n^2} \\
\end{pmatrix} \]
を<strong>ヘッセ行列</strong>と言い,以下が成り立つ。
</p>
<p>
\(\mathrm{grad} f(\mathbf{a})=\mathbf{0}\)である点\(\mathbf{a}\)において,
\[ \begin{aligned}
H(f)\text{の固有値が全て正}\ &\Rightarrow\ \text{$f(\mathbf{a})$は極小値} \\
H(f)\text{の固有値が全て負}\ &\Rightarrow\ \text{$f(\mathbf{a})$は極大値} \\
H(f)\text{が正負の固有値を持つ}\ &\Rightarrow\ \text{$f(\mathbf{a})$は極大でも極小でもない(鞍点という)} \\
\end{aligned} \]
</p>
</div>
</section>
<section style="font-size:90%">
<div class="block" style="border-color:lightgreen;font-size:90%">
<h4 style="color:lightgreen"> 例 </h4>
\[ f(x,y) = \cos x\cos y \]
の値\(f(0,0)=1\)について調べてみましょう。
</div>
<p>
まず
\[ \mathrm{grad} f = (-\sin x\cos y, -\cos x\sin y) \]
より\(\mathrm{grad}f(0,0) = (0,0)\)です。また点\((0,0)\)でのヘッセ行列の値は
\[ H(f)(0,0) = \left.\begin{pmatrix}
-\cos x\cos y & \sin x\sin y \\
\sin x\sin y & -\cos x\cos y
\end{pmatrix}\right|_{(x,y)=(0,0)} =
\begin{pmatrix}
-1 & 0 \\ 0 & -1
\end{pmatrix} \]
なので,固有値はどちらも負です。従って\(f(0,0)=1\)は極大値である事がわかりました。
</p>
</section>
<section>
<div align="center"> <img width="600" src="fig/cosxcosy.png"> </div>
</section>
<section>
<h2 class="chapter-title"> 重積分 </h2>
</section>
<section>
<p>
確率・統計の計算では重積分が頻繁に登場します。しかも,他の分野ではあまり使われない様な非常に高次元の重積分も登場しますので,よく理解する事が必要です。
</p>
</section>
<section>
<p>
一変数関数の定積分は
\[ \color{yellow}{\int_a^bf(x)\mathrm{d} x = \lim_{n\rightarrow\infty}\sum_{i=1}^nf(t_i)(x_i-x_{i-1})} \]
というリーマン和の極限として定義されました(第5回)が,多変数関数においても同様に定積分を定義する事ができます。
</p>
</section>
<section style="font-size:80%">
<p>
二変数の場合を考えます。定積分を行う\(xy\)平面上の領域を\(D\)とします。更に\(x\)軸,\(y\)軸上に分点を
\[ x_0 < x_1 < \cdots, y_0 < y_1 < \cdots \]
というように取り,\(\Delta S_{ij}=(x_i-x_{i-1})(y_j-y_{j-1})\)とおきます。\(\Delta S_{ij}\)は図の長方形の面積となります。
ここで,図の\(xy\)平面上の長方形の中に点\(s_{ij},t_{ij}\)をとって
\[ \sum f(s_{ij},t_{ij})\Delta S_{ij} \]
という和を考えます。
</p>
<div align="center"> <img width="600" src="fig/multiple-integral.png"> </div>
</section>
<section style="font-size:80%">
<p>
\[ \sum f(s_{ij},t_{ij})\Delta S_{ij} \qquad \cdots(1)\]
の和の取り方は
</p>
<ul>
<li> \(D\)を覆う長方形達について取る </li>
<li> \(D\)に含まれる長方形達について取る </li>
</ul>
<p>
の2通りを考えます。ここで,\(x_i-x_{i-1},y_j-y_{j-1}\)がいずれも\(0\)に収束するような極限をとった時に,
(1)が和の取り方・\((s_{ij},t_{ij})\)の取り方に一切よらずに収束するならば,その値を<strong> \(f(x,y)\)の\(D\)上での重積分 </strong>と言い
\[ \color{yellow}{\int\int_D f(x,y)\mathrm{d}x\mathrm{d}y} \]
とか
\[ \color{yellow}{\int_D f(x,y)\mathrm{d}x\mathrm{d}y} \]
とか
\[ \color{yellow}{\int_D f(x,y)\mathrm{d}S} \]
などと書きます。
</p>
</section>
<section style="font-size:80%">
<p>
直感的に言えば,
\[ \int\int_D f(x,y)\mathrm{d}x\mathrm{d}y \]
は下図の様な立体の体積(符号付き体積)となります。 </p>
<div align="center"> <img width="600" src="fig/multiple-integral2.png"> </div>
</section>
<section>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> 重積分の性質 </h4>
<p> \(a,b\in \mathbb{R}\)の時
\[
\int_D(af+bg)\mathrm{d}x\mathrm{d}y =
a\int_Df\mathrm{d}x\mathrm{d}y +
b\int_Dg\mathrm{d}x\mathrm{d}y \]
</p>
<p>
領域\(D\)が\(D_1,D_2\)に分割できる時
\[\int_Df\mathrm{d}x\mathrm{d} y =
\int_{D_1}f\mathrm{d}x\mathrm{d} y +
\int_{D_2}f\mathrm{d}x\mathrm{d} y
\]
</p>
</div>
</section>
<section>
<h2> 累次積分への変換 </h2>
<p>
重積分を定義通りに計算するのは大変面倒ですので,実際に計算する際には<strong>累次積分</strong>に変換します。
</p>
<p class="fragment">
先ほどのリーマン和は\(\Delta x_i = (x_i-x_{i-1}),\ \Delta y_j = (y_j-y_{j-1})\)として
\[ \sum f(s_{ij},t_{ij})\Delta S_{ij} = \sum_i (\sum_j f(s_{ij}, t_{ij})\Delta y_j)\Delta x_i \]
と書き直す事ができますので,まず<strong>\(y\)に関して積分し,次に\(x\)に関して積分する</strong>という事ができると予想できます。
</p>
<p class="fragment">
この事の詳しい議論はむずかしいのですが,実用上登場するほとんどの関数では次頁の定理が成り立ちます。
</p>
</section>
<section>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> 重積分から累次積分への変換 </h4>
<p>
領域\(D\)を
\[ a \leq x \leq b,\ g(x)\leq y\leq h(x) \]
と表す事ができるならば
\[ \int_Df(x,y)\mathrm{d}x\mathrm{d}y
= \int_a^b\left\{ \int_{g(x)}^{h(x)}f(x,y)\mathrm{d} y\right\}\mathrm{d} x \]
である。
<div align="center"> <img width="350" src="fig/multiple-integral3.png"> </div>
</p>
</div>
</section>
<section>
<div class="block" style="border-color:lightgreen;font-size:90%">
<h4 style="color:lightgreen"> 例 </h4>
<p> \(D\)を以下の領域として
<div align="center"> <img width="300" src="fig/multiple-integral4.png"> </div>
以下の重積分を計算してみましょう。
\[ \int_D (x^2+y)\mathrm{d}x\mathrm{d}{y} \]
</p>
</div>
</section>
<section style="font-size:80%">
<p>
\(x\)を固定すれば図の領域は
\[ 0 \leq x \leq 1,\ 0 \leq y\leq 1-x \]
となりますので
\[ \begin{aligned}
\int_D (x^2+y)\mathrm{d}x\mathrm{d}{y} &= \int_0^1\left\{\int_0^{1-x}(x^2+y)\mathrm{d}y\right\}\mathrm{d} x \\
&= \int_0^1 \left[x^2y+\frac{y^2}{2}\right]_0^{1-x}\mathrm{d} x \\
&= \int_0^1 \left(x^2(1-x)+\frac{(1-x)^2}{2}\right)\mathrm{d} x \\
&= \frac{1}{4}
\end{aligned} \]
となります。
</p>
</section>
<section>
<h2> 変数の変換 </h2>
<p>
変数\(x,y\)を他の変数\(p,q\)に一対一に置換する事を考えます。この置換えを
\[ x = \phi(p,q),\ y = \psi(p, q) \]
としましょう。<br>
リーマン和は
\[ f(s_{ij},t_{ij})(x_i-x_{i-1})(y_j-y_{j-1}) \]
という形の積の和でしたが,変数を置き換えても\(f\)の値は変化しません。従って置換によって
\[ \color{yellow}{(x_i-x_{i-1})(y_j-y_{j-1})} \]
がどうなるかを考える事となります。
</p>
</section>
<section style="font-size:80%">
<p>
テイラー展開を行ってみると
\[ \begin{aligned}
\Delta x &= \phi(p+\Delta p, q+\Delta q)-\phi(p, q) \\
&= \phi(p,q)+\frac{\partial \phi}{\partial p}\Delta p + \frac{\partial \phi}{\partial q}\Delta q + \mathcal{O}(\Delta p^2+\Delta q^2) - \phi(p,q)\\
&= \frac{\partial \phi}{\partial p}\Delta p + \frac{\partial \phi}{\partial q}\Delta q + \mathcal{O}(\Delta p^2+\Delta q^2)\\
\end{aligned} \]
となります。\(\psi\)についても同様なので
\[
\color{yellow}{\begin{pmatrix} \Delta x \\ \Delta y \end{pmatrix} \approx
\begin{pmatrix}
\frac{\partial\phi}{\partial p} & \frac{\partial\phi}{\partial q} \\
\frac{\partial\psi}{\partial p} & \frac{\partial\psi}{\partial q} \\
\end{pmatrix}
\begin{pmatrix}
\Delta p \\ \Delta q
\end{pmatrix}}
\]
と書くことが出来て,誤差ベクトルは\(\Delta p^2,\Delta q^2\)で各成分を抑える事ができます。
</p>
</section>
<section>
<p>
ここで出てきた行列が表す線形写像は,面積1の正方形を下図の平行四辺形に移します。この平行四辺形の面積は
\[ \left| \frac{\partial\phi}{\partial p} \frac{\partial\psi}{\partial q} - \frac{\partial\phi}{\partial q} \frac{\partial\psi}{\partial p} \right| = \left|\det
\begin{pmatrix}
\frac{\partial\phi}{\partial p} & \frac{\partial\phi}{\partial q} \\
\frac{\partial\psi}{\partial p} & \frac{\partial\psi}{\partial q} \\
\end{pmatrix}
\right|
\]
です。
</p>
<div align="center"> <img width="700" src="fig/jacobian.png"> </div>
</section>
<section>
<p>
面積\(\Delta p\Delta q\)の長方形についても同様に考えると
\[ \Delta x\Delta y \approx \left|\det
\begin{pmatrix}
\frac{\partial\phi}{\partial p} & \frac{\partial\phi}{\partial q} \\
\frac{\partial\psi}{\partial p} & \frac{\partial\psi}{\partial q} \\
\end{pmatrix}
\right| \Delta p\Delta q \]
という関係があり,誤差はやはり\(\Delta p^2,\Delta q^2\)で抑える事ができます。
</p>
</section>
<section>
<div class="block" style="border-color:pink;font-size:90%">
<h4 style="color:pink"> 積分変数の変換 </h4>
<p>
変数の変換\( (x,y) \longmapsto (p,q) \)が一対一であり,
\[x = \phi(p,q),\ y = \psi(p,q)\]
と表されるとする。この時
\[ J = \det
\begin{pmatrix}
\frac{\partial\phi}{\partial p} & \frac{\partial\phi}{\partial q} \\
\frac{\partial\psi}{\partial p} & \frac{\partial\psi}{\partial q} \\
\end{pmatrix} \]
を<strong>ヤコビアン</strong>と言う。この時,変数変換によって領域\(D\)が\(D'\)に移るとすると
\[ \int_D f(x,y)\mathrm{d}x\mathrm{d}y = \int_{D'}f(\phi(p,q),\psi(p,q))|J|\mathrm{d}p\mathrm{d}q \]
が成立する。
</p>
</div>
</section>
<section>
<div class="block" style="border-color:lightgreen;font-size:90%">
<h4 style="color:lightgreen"> 例 </h4>
<p>
\(D\)を単位円の周および内部
\[ x^2 + y^2 \leq 1 \]
とした時に
\[ \int_D x^2\mathrm{d}x\mathrm{d} y\]
を求めてみましょう。
</p>
</div>
</section>