CodingTheMatrix

学習目標と内容

線形代数をじっくりやってきたんですが, これがどのような問題に, どのように利用されているかは ぴんと来なかったと思います. そこで,Coding the Matrixという英語のテキストを読み込みながら, 線形代数がどのように使われているかに馴染んでいただきます.

日本語の翻訳をつけていますが,だいぶ問題の多い翻訳です. ですので,英語の意味が全くわからない時にチラ見するためと 思ってください.

また,テキスト中の課題には,Pythonによるcodeが含まれています. これをそのまま提出課題とするかは,演習を進めながら 検討していきます.ご容赦ください.

成績評価

  • 毎回出す課題,メモで評価
  • 前半部分と同じで,やることに意義があります.
  • メモを作る手順,覚えるコツ

教科書とリンク

出版物

  • 行列プログラマー ―Pythonプログラムで学ぶ線形代数 単行本(ソフトカバー) –オライリージャパン (2016/10/5) , Philip N. Klein (著), 松田 晃一 (翻訳), 弓林 司 (翻訳), 脇本 佑紀 (翻訳), 中田 洋 (翻訳), 5,940円
  • Coding the Matrix: Linear Algebra through Computer Science Applications (English Edition) 1st 版, Newtonian Press; 第1版 (2015/4/7) 7,704円, Kindle版,英語版 Philip Klein (著), 1,189円

テキストコピー

板書下書きメモ

url for coding the matrix

授業計画

day1 (11/10) cc0.1 - 0.3 : set, function

リンク

講義内容

  • (1) set terminology and notation
  • (2) Cartesian product
  • (3) The function

課題

  1. $f:A \rightarrow B$ の意味は何か?
  2. Example 0.3.5を訳せ.
  3. 「この定義域の要素が素数に写像されることがない」理由を具体的な例をあげて説明せよ.

day2 (11/17) c0.3.1 : invertible

リンク

講義内容

  • (3) The function
    • (3.1) functions vs procedures, vs computational problems
    • (3.2) forward and backward problems
    • (3.5) compositions of functions
    • (3.6) associativity of function composition
    • (3.7) functional inverse
      • one to one, onto
    • (3.8) invertibility
  • (4) probability
    • Scrabble

課題

  1. What are the criteria for $f$ to be an invertible function?
  2. What is associativity of functional composition?
  3. Lemma 0.3.16-18を(できるだけ英語の語順を残したまま)和訳せよ.
  4. p.8のProblem 0.3.22を描け.
  5. p.38のProblem 0.8.6, 0.8.7を解け.

day3 (11/24) c0.4 : probability and python

webの更新が遅れました.申し訳ない. 課題とかが違っています.注意してください.<2022-11-26 Sat>

リンク

講義内容

  • (4) probability
    • Scrabble
    • Events, and adding
    • perfect secrecy
    • Kerckhoffs Doctorine
  • (5) Lab: Python(sets, lists, dictionaries, and comprehensions)
    • Simple expression
    • Assignment statements
    • Sets
    • Lists
    • Tuples
   nonmutable : 変更不可能

課題

  1. Task0.5.1から0.5.17までをipythonで実行して,出力をtextなどに保存して提出しなさい.
  2. Task 0.5.8は私解けていません.時間かかるようなら跳ばしてください.解けた人は来週の授業で教えてください.

day4 (12/1) c0.5 : Python, c1 : The Field

リンク

講義内容

  • (5) Lab: Python(sets, lists, dictionaries, and comprehensions)
    • Other things to iterate over
    • Dictionaries
    • Defining one-line procedures

p.32からの0.6 Labはやらない.

  • 1. The Field
  • 1.1 Introduction to complex numbers
  • 1.2 Complex numbers in Python
    • a.k.a. /ˌeɪ.keɪˈeɪ/ also known as
  • 1.3 Abstracting over fields
  • 1.4 Playing with $\mathbb C$

関連コード

課題

  1. Tasks 0.5.18 -- 31
    1. ただし,0.5.22, 25, 26は難しいのでパスしてもいいよ.

day5 (12/8) c1 : The Field

リンク

前回のレポートコメント

よくできてます. レポート作成のコツとして書いていた通り,あとで見返した時に何をしているのか,何をどう解いたのかをメモしておくことが必要です.途中経過は他の人が読む時には,邪魔ですが,自分が見返す時にはどういう思考で試行錯誤のしたかを残しておくと,見返した時に便利です.

私のメモは,

Task 0.5.18: middle

Task 0.5.18: Write a comprehension over a range of the form range (n) such that the value of the comprehension is the set of odd numbers from 1 to 99.

range(n)という形式でrangeを使って comprehensionを書け: そのcomprehensionの値は1から99の奇数の集合となる.

In [3]: set(i for i in range(9))
Out[3]: {0, 1, 2, 3, 4, 5, 6, 7, 8}

In [4]: set(i+1 for i in range(9))
Out[4]: {1, 2, 3, 4, 5, 6, 7, 8, 9}

In [5]: set(i+1 for i in range(9))
Out[5]: {1, 2, 3, 4, 5, 6, 7, 8, 9}

In [6]: set(i+1 for i in range(9) if i%2==1)
Out[6]: {2, 4, 6, 8}

In [8]: set(i+1 for i in range(9) if (i+1)%2==1)
Out[8]: {1, 3, 5, 7, 9}

In [9]: set(i+1 for i in range(99) if (i+1)%2==1)
Out[9]: 
{1,
 3,
...
 97,
 99}

In [10]: range(1,99,2)
Out[10]: range(1, 99, 2)

In [11]: list(range(1,99,2))
Out[11]: 
[1,
...
 97]

In [12]: list(range(1,100,2))
Out[12]: 
[1,
...
 97,
 99]

なんかです.

講義内容

  • CUI vs GUI
  • 1.4 Playing with $\mathbb C$
    • 1.4.1 The absolute value of a complex number
    • 1.4.2 Adding complex numbers
    • 1.4.3 Multiplying complex numbers by a positive real number
    • 1.4.4 Multiplying complex numbers by a negative number: rotation by 180 degrees
    • 1.4.5 Multiplying by i: rotation by 90 degrees

関連コード

課題

イニシャル

p.44のTask 1.4.1: 図を描いてプリントアウトして提出せよ. 自分のイニシャルを書いて提出せよ.例えば,'S N'は

In [30]: S={1+1j, 1.5+1j, 2+1j, 2+1.5j, 2+2j, 1.5+2j, 1+
    ...: 2j, 1+2.5j, 1+3j, 1.5+3j, 2+3j}

In [31]: N={1+1j, 1+1.5j, 1+2j, 1+2.5j, 1+3j, 1.25+2.5j,
    ...:  1.5+2j, 1.75+1.5j, 2+1j, 2+1.5j, 2+2j, 2+2.5j,
    ...:  2+3j}

In [32]: plot(S | {x+2 for x in N}, 4)
複素数の変換

Task 1.4.2 - 1.4.9を実装して,提出せよ.

  • 画像はcaptureしてWordなどに貼り付けて提出せよ.
  • 集合データはイニシャルでも,テキストのインベーダでもどちらでも良い.
  • おすすめは,VSCode + Markdown形式だが,画像の貼り付けは少し難しいかも.
  • pdfにして提出.
  • 結果だけでなく,問題文とか途中経過も残しておくといいよ.

12/15 c1.4 : $\mathbb{C}$

リンク

講義内容

  • 1.4 Playing with $\mathbb{C}$
    • 1.4.6 The unit circle in the complex plane: argument and angle
    • 1.4.7 Euler's formula
    • 1.4.8 Polar representation for complex numbers
    • 1.4.9 The First Law of Exponentiation
    • 1.4.10 Rotation by $\tau$ radians
    • 1.4.11 Combining operations
    • 1.4.12 Beyond two dimensions
  • Euler's formula with introductory group theory (英語の字幕をつけられます)

Task1.4.10

解答例です.

In [1]: from image import file2image
In [2]: filename = 'img01.png'
In [3]: data=file2image("img01.png")
In [5]: len(data)
Out[5]: 189
In [6]: len(data[0])
Out[6]: 166
In [7]: len(data[0][0])
Out[7]: 3
In [8]: print(data[0][0])
(183, 183, 183)
In [5]: Y = list(range(0,189,1))
In [6]: X = list(range(0, 166,1))
In [7]: pts=[x+(189j+y*-1j) for x in X for y in Y if data[y][x][0]<120]
In [9]: from plotting import plot
In [10]: plot(pts, 200, 1)

課題

12/22 c1.5 : GF(2),ネットワークコーディング

リンク

講義内容

  • 1.5 Playing with GF(2)
    • 1.5.1 Perfect secrecy revisited
    • 1.5.2 Network coding

課題

  • Problem 1.7.10(easy), complex numbers
  • Problem 1.7.13(easy), GF(2)
    • GF(2) をDLしてimport,やり方はテキストのp.55あたり
  • Problem 1.5.1 (very tough), decrypt
  • Problem 1.7.14(so, so), Network coding
  • アンケート に答えてください

    
Last modified:2024/04/25 03:30:44
Keyword(s):
References:[LectureNotes]