Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

プログラマのための線形代数再入門2 〜 要件定義から学ぶ行列式と逆行列

55.216 Aufrufe

Veröffentlicht am

2015/03/27 「第2回プログラマのための数学勉強会」にて発表。
http://maths4pg.connpass.com/event/11781/

Veröffentlicht in: Bildung
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • DOWNLOAD FULL BOOKS, INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • DOWNLOAD FULL BOOKS, INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • DOWNLOAD FULL BOOKS, INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/yxufevpm } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier

プログラマのための線形代数再入門2 〜 要件定義から学ぶ行列式と逆行列

  1. 1. プログラマのための線形代数 再 入門 2 ∼要件定義から学ぶ行列式と逆行列∼ @taketo1024 2015/03/27 第2回プログラマのための数学勉強会
  2. 2. 今回の目標 ただの計算地獄だった行列式と逆行列を システム開発の文脈で説明し直し、 プログラマが納得して使えるようになること。
  3. 3. 行列式 (determinant)
  4. 4. 行列式 (determinant) A = ✓ 1 2 3 4 ◆
  5. 5. 行列式 (determinant) A = ✓ 1 2 3 4 ◆ detA = 1 2 3 4 = 1 · 4 2 · 3
  6. 6. 行列式 (determinant) A = ✓ 1 2 3 4 ◆ detA = 1 2 3 4 = 1 · 4 2 · 3 +
  7. 7. 行列式 (determinant) A = ✓ 1 2 3 4 ◆ detA = 1 2 3 4 = 1 · 4 2 · 3 -
  8. 8. 行列式 (determinant) A = ✓ 1 2 3 4 ◆ detA = 1 2 3 4 = 1 · 4 2 · 3 = 2
  9. 9. 行列式 (determinant) A = 0 @ 1 2 3 4 5 6 7 8 9 1 A
  10. 10. 行列式 (determinant) A = 0 @ 1 2 3 4 5 6 7 8 9 1 A detA = 1 2 3 4 5 6 7 8 9 = 1 · 5 · 9 + 2 · 6 · 7 + 3 · 4 · 8 3 · 5 · 7 2 · 4 · 9 1 · 6 · 8
  11. 11. 行列式 (determinant) A = 0 @ 1 2 3 4 5 6 7 8 9 1 A detA = 1 2 3 4 5 6 7 8 9 = 1 · 5 · 9 + 2 · 6 · 7 + 3 · 4 · 8 3 · 5 · 7 2 · 4 · 9 1 · 6 · 8
  12. 12. 行列式 (determinant) A = 0 @ 1 2 3 4 5 6 7 8 9 1 A detA = 1 2 3 4 5 6 7 8 9 = 1 · 5 · 9 + 2 · 6 · 7 + 3 · 4 · 8 3 · 5 · 7 2 · 4 · 9 1 · 6 · 8
  13. 13. 行列式 (determinant) A = 0 @ 1 2 3 4 5 6 7 8 9 1 A detA = 1 2 3 4 5 6 7 8 9 = 1 · 5 · 9 + 2 · 6 · 7 + 3 · 4 · 8 3 · 5 · 7 2 · 4 · 9 1 · 6 · 8
  14. 14. 行列式 (determinant) A = 0 @ 1 2 3 4 5 6 7 8 9 1 A detA = 1 2 3 4 5 6 7 8 9 = 1 · 5 · 9 + 2 · 6 · 7 + 3 · 4 · 8 3 · 5 · 7 2 · 4 · 9 1 · 6 · 8
  15. 15. 行列式 (determinant) A = 0 @ 1 2 3 4 5 6 7 8 9 1 A detA = 1 2 3 4 5 6 7 8 9 = 1 · 5 · 9 + 2 · 6 · 7 + 3 · 4 · 8 3 · 5 · 7 2 · 4 · 9 1 · 6 · 8
  16. 16. 行列式 (determinant) A = 0 @ 1 2 3 4 5 6 7 8 9 1 A detA = 1 2 3 4 5 6 7 8 9 = 1 · 5 · 9 + 2 · 6 · 7 + 3 · 4 · 8 3 · 5 · 7 2 · 4 · 9 1 · 6 · 8
  17. 17. 行列式 (determinant) A = 0 @ 1 2 3 4 5 6 7 8 9 1 A detA = 1 2 3 4 5 6 7 8 9 = 1 · 5 · 9 + 2 · 6 · 7 + 3 · 4 · 8 3 · 5 · 7 2 · 4 · 9 1 · 6 · 8 = 0
  18. 18. 行列式 (determinant) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
  19. 19. 行列式 (determinant) = 1 · 6 · 11 · 16 1 · 6 · 12 · 15 + 1 · 7 · 12 · 14 1 · 7 · 10 · 16 + 1 · 8 · 11 · 14 1 · 8 · 10 · 15 +2 · 5 · 12 · 15 2 · 5 · 11 · 16 + 2 · 7 · 9 · 16 2 · 7 · 12 · 13 + 2 · 8 · 11 · 13 2 · 8 · 9 · 15 +3 · 5 · 10 · 16 3 · 5 · 12 · 14 + 3 · 6 · 12 · 13 3 · 6 · 9 · 16 + 3 · 8 · 9 · 14 3 · 8 · 10 · 13 +4 · 5 · 10 · 15 4 · 5 · 11 · 14 + 4 · 6 · 9 · 15 4 · 6 · 11 · 13 + 4 · 7 · 10 · 13 4 · 7 · 9 · 13 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 !?
  20. 20. 人間がやるべき計算じゃない
 (コンピュータのある時代でよかった)
  21. 21. 計算は機械がやればいいが、 これが何なのかは分かっておきたい。
  22. 22. プログラマの「理解」の3層構造 • 要件が分かる:何のためのものなのか • 仕様が分かる:何を与えると何が返ってくるのか • 実装が分かる:どのように動いているのか プログラマはこの3つが ってはじめて「分かった」と言える。
  23. 23. 1. 行列式の「要件」
  24. 24. (復習) 行列は線形変換の定量表現 ✓ x y ◆ x ✓ 1 0 ◆ y ✓ 0 1 ◆ f y ✓ bx by ◆ x ✓ ax ay ◆ f ✓ x y ◆ = ✓ ax bx ay by ◆ ✓ x y ◆
  25. 25. (復習) 等倍・偏倍変換 A = ✓ a 0 0 b ◆ ✓ 1 0 ◆ ✓ 0 1 ◆ f ✓ a 0 ◆ ✓ 0 b ◆
  26. 26. (復習) 回転 A = ✓ cos✓ sin✓ sin✓ cos✓ ◆ ✓ 1 0 ◆ ✓ 0 1 ◆ f ✓ cos ✓ sin ✓ ◆ ✓ sin ✓ cos ✓ ◆
  27. 27. (復習) 反転 A = ✓ 1 0 0 1 ◆ ✓ 1 0 ◆ ✓ 0 1 ◆ f ✓ 0 1 ◆ ✓ 1 0 ◆
  28. 28. (復習) 正射影 A = ✓ 1 0 0 0 ◆ ✓ 1 0 ◆ ✓ 0 1 ◆ f ✓ 1 0 ◆
  29. 29. ✓ 1 0 ◆ ✓ 0 1 ◆ ✓ a 0 ◆ ✓ 0 b ◆ ✓ cos ✓ sin ✓ ◆ ✓ sin ✓ cos ✓ ◆ ✓ 0 1 ◆ ✓ 1 0 ◆ ✓ 1 0 ◆ f 変換の特徴を表す 1次元の量 を考えたい 特に潰れるかどうかを 判別したい
  30. 30. 潰れると元に戻せない! ✓ 1 0 ◆ ✓ 0 1 ◆ ✓ 1 0 ◆ f ✓ 1 0 ◆ ✓ 0 1 ◆ f f 1 ? 同じように潰れてしまう 復元できない!
  31. 31. 行列式の「要件」 • n次元の線形変換は n次正方行列 (n2 個の数) で表される。 • 線形変換の特徴を 1次元の量 によって表したい。 • 特に「潰れてしまう」かどうかを判別したい。 n次正方行列 A detAの行列式A (1次元の量)
  32. 32. 2. 行列式の「仕様」
  33. 33. 変換後の面積と向きに注目!
  34. 34. ✓ 1 0 ◆ ✓ 0 1 ◆ ✓ a 0 ◆ ✓ 0 b ◆ ✓ cos ✓ sin ✓ ◆ ✓ sin ✓ cos ✓ ◆ ✓ 0 1 ◆ ✓ 1 0 ◆ ✓ 1 0 ◆ f 面積 ab 倍 面積同じ 面積同じ 面積 0
  35. 35. ✓ 1 0 ◆ ✓ 0 1 ◆ ✓ a 0 ◆ ✓ 0 b ◆ ✓ cos ✓ sin ✓ ◆ ✓ sin ✓ cos ✓ ◆ ✓ 0 1 ◆ ✓ 1 0 ◆ ✓ 1 0 ◆ f 表向き 表向き 裏向き 向きなし
  36. 36. ✓ 1 0 ◆ ✓ 0 1 ◆ ✓ a 0 ◆ ✓ 0 b ◆ ✓ cos ✓ sin ✓ ◆ ✓ sin ✓ cos ✓ ◆ ✓ 0 1 ◆ ✓ 1 0 ◆ ✓ 1 0 ◆ f detA = ab detA = 1 detA = -1 detA = 0
  37. 37. detA = 「面積の倍率 向き」 ✓ x y ◆ x ✓ 1 0 ◆ y ✓ 0 1 ◆ f y ✓ bx by ◆ x ✓ ax ay ◆ f ✓ x y ◆ = ✓ ax bx ay by ◆ ✓ x y ◆
  38. 38. 3次元(さらに高次元)の場合、 det A = 体積の倍率 向き f 0 @ ax ay az 1 A 0 @ bx by bz 1 A 0 @ cx cy cz 1 A 右手系 → 左手系 の場合 detA < 0
  39. 39. 行列式の「仕様」 detA > 0 = 0 < 0 … 向きを保ち、体積 detA 倍 … 潰れる … 向きを変えて、体積 -detA 倍
  40. 40. 3. 行列式の「実装」
  41. 41. 「n2 次元 → 1次元」の関数を 一発で出すのは難しい
  42. 42. 複雑なものは簡単なものの組み合わせに (設計の基本!)
  43. 43. 1) det E = 1 ✓ 1 0 ◆ ✓ 0 1 ◆ ✓ 1 0 ◆ ✓ 0 1 ◆ E = ✓ 1 0 0 1 ◆ id detE = 1 1 0 0 1 = 1
  44. 44. 2) det(b, a) = -det(a, b) ✓ 1 0 ◆ ✓ 0 1 ◆ ✓ 1 0 ◆ ✓ 0 1 ◆ A = ✓ 0 1 1 0 ◆ 裏向き f det(b, a) = det(a, b) 0 1 1 0 = 1 0 0 1 = 1
  45. 45. det(a1 + a2, b) = det(a1, b) + det(a2, b), det(k・a, b) = k・det(a, b) ✓ 1 0 ◆ ✓ 0 1 ◆ f 3) det(ka, b) = k · det(a, b) A = ✓ 2 0 0 1 ◆ ✓ 0 1 ◆ ✓ 2 0 ◆ 2 0 0 1 = 2 · 1 0 0 1 = 2 det(a1 + a2, b) = det(a1, b) + det(a2, b)
  46. 46. 実はこれが行列式の全て! detE = 1 det(b, a) = det(a, b) det(ka, b) = k · det(a, b) 1) 2) 3) (交代性) (多重線形性) det(a1 + a2, b) = det(a1, b) + det(a2, b)
  47. 47. 1) ∼ 3) から導かれる便利な性質 4) 5) det(a, a) = 0 det(a kb, b) = det(a, b)
  48. 48. 計算してみよう!
  49. 49. 1 2 3 4
  50. 50. 1 2 3 4
  51. 51. 1 2 3 4 = 1 2 0 4 +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 1 0 1 0 +2 · 4 · 9 0 1 0 1 0 0 0 0 1 + 2 · 6 · 7 0 1 0 0 0 1 1 0 0 +3 · 4 · 8 0 0 1 1 0 0 0 1 0 + 3 · 5 · 7 0 0 1 0 1 0 1 0 0 = 1 = 1 = 1 = 1 = 1 = 1
  62. 62. 1 2 3 4 5 6 7 8 9 = 1 · 5 · 9 1 0 0 0 1 0 0 0 1 + 1 · 6 · 8 1 0 0 0 0 1 0 1 0 +2 · 4 · 9 0 1 0 1 0 0 0 0 1 + 2 · 6 · 7 0 1 0 0 0 1 1 0 0 +3 · 4 · 8 0 0 1 1 0 0 0 1 0 + 3 · 5 · 7 0 0 1 0 1 0 1 0 0 = 1 · 5 · 9 1 · 6 · 8 +2 · 6 · 7 2 · 4 · 9 +3 · 4 · 8 3 · 5 · 7 = 0
  63. 63. 行列式計算のアルゴリズム 1. 各行から列が重複しないように成分を取り出して掛ける 2. 残った 0, 1 だけの行列式を計算する(偶数回の交代で単 位行列になる場合 1、奇数回の場合 -1) 3. これらの取り出し方の全パターンを足し合わせる
  64. 64. アルゴリズムを数式にすると… detA = X 2Sn Y i ai, (i) . . . . . . . . .
  65. 65. detA = X 2Sn Y i ai, (i) . . . . . . . . . アルゴリズムを数式にすると… A の i 行から取り出した成分
  66. 66. detA = X 2Sn Y i ai, (i) . . . . . . . . . 各行に渡る成分の積 アルゴリズムを数式にすると…
  67. 67. detA = X 2Sn Y i ai, (i) . . . . . . . . . 残った 0, 1 だけの行列式 アルゴリズムを数式にすると…
  68. 68. detA = X 2Sn Y i ai, (i) . . . . . . . . . 並べ替えの全パターンの総和 アルゴリズムを数式にすると…
  69. 69. アルゴリズムを数式にすると… detA = X 2Sn Y i ai, (i) . . . . . . . . .
  70. 70. detA = X 2Sn Y i ai, (i) . . . . . . . . . = X 2Sn Y i ai, (i)sgn( ) アルゴリズムを数式にすると… 並べ替えの「符号」 (偶数回: 1, 奇数回: -1)
  71. 71. 1 2 3 4 5 6 7 8 9 = 1 · 5 · 9 1 0 0 0 1 0 0 0 1 + 1 · 6 · 8 1 0 0 0 0 1 0 1 0 +2 · 4 · 9 0 1 0 1 0 0 0 0 1 + 2 · 6 · 7 0 1 0 0 0 1 1 0 0 +3 · 4 · 8 0 0 1 1 0 0 0 1 0 + 3 · 5 · 7 0 0 1 0 1 0 1 0 0 detA = X 2Sn Y i ai, (i)sgn( ) 同じ式に見えるかな?
  72. 72. これが行列式の「定義」として 数学の本に出てくる
  73. 73. 理解すべき原理はこっち: detE = 1 det(b, a) = det(a, b) det(ka, b) = k · det(a, b) 1) 2) 3) (交代性) (多重線形性) det(a1 + a2, b) = det(a1, b) + det(a2, b)
  74. 74. 出発点はシンプルな方が良い
  75. 75. 宿題: 行列と行列式を好きな言語で 実装してみましょう
  76. 76. 行列式の展開
  77. 77. 1 2 3 4 5 6 7 8 9 = 1 · 5 · 9 1 0 0 0 1 0 0 0 1 + 1 · 6 · 8 1 0 0 0 0 1 0 1 0 +2 · 4 · 9 0 1 0 1 0 0 0 0 1 + 2 · 6 · 7 0 1 0 0 0 1 1 0 0 +3 · 4 · 8 0 0 1 1 0 0 0 1 0 + 3 · 5 · 7 0 0 1 0 1 0 1 0 0
  78. 78. 1 2 3 4 5 6 7 8 9 = 1 · 5 · 9 1 0 0 0 1 0 0 0 1 + 1 · 6 · 8 1 0 0 0 0 1 0 1 0 +2 · 4 · 9 0 1 0 1 0 0 0 0 1 + 2 · 6 · 7 0 1 0 0 0 1 1 0 0 +3 · 4 · 8 0 0 1 1 0 0 0 1 0 + 3 · 5 · 7 0 0 1 0 1 0 1 0 0
  79. 79. 1 2 3 4 5 6 7 8 9 = 1 0 @5 · 9 1 0 0 0 1 0 0 0 1 + 6 · 8 1 0 0 0 0 1 0 1 0 1 A +2 0 @4 · 9 0 1 0 1 0 0 0 0 1 + 6 · 7 0 1 0 0 0 1 1 0 0 1 A +3 0 @4 · 8 0 0 1 1 0 0 0 1 0 + 5 · 7 0 0 1 0 1 0 1 0 0 1 A
  80. 80. 1 2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3 · 4 · 8 0 0 1 1 0 0 0 1 0 + 3 · 5 · 7 0 0 1 0 1 0 1 0 0 くくり出し方を変えれば、任意の行・列で展開できる = 2 4 6 7 9 + 5 1 3 7 9 8 1 3 4 6
  86. 86. n次行列式は (n-1) 次行列式の和に展開できる → 再帰呼び出しでも実装できる(宿題)
  87. 87. そして逆行列
  88. 88. ✓ 1 0 ◆ ✓ 0 1 ◆ ✓ a 0 ◆ ✓ 0 b ◆ ✓ cos ✓ sin ✓ ◆ ✓ sin ✓ cos ✓ ◆ ✓ 0 1 ◆ ✓ 1 0 ◆ ✓ 1 0 ◆ f 逆行列:逆変換に対応する行列 f 1 A 1 = ✓ cos( ✓) sin( ✓) sin( ✓) cos( ✓) ◆ A 1 = ✓ 1/a 0 0 1/b ◆ A 1 = ✓ 1 0 0 1 ◆ 逆変換なし!
  89. 89. A = 0 @ 1 2 3 1 0 1 2 1 2 1 A
  90. 90. A = 0 @ 1 2 3 1 0 1 2 1 2 1 A 0 @ x y z 1 A 0 @ x + 2y + z x z 2x + y 2z 1 A A 1 det A 0 であれば、逆行列 A-1 は取れるはず。 A 1 A = E AA 1 = E
  91. 91. やってみましょう。 (トリッキーなことをします)
  92. 92. 1 2 3 1 0 1 2 1 2 = 1 0 1 1 2 2 1 1 2 2 + 3 1 0 2 1 = 4 第1行で展開
  93. 93. 1 2 3 1 0 1 2 1 2 = 1 0 1 1 2 2 1 1 2 2 + 3 1 0 2 1 = 4 1 0 1 1 0 1 2 1 2 = 1 0 1 1 2 0 1 1 2 2 1 1 0 2 1 2行目を1行目にコピペ
  94. 94. 1 2 3 1 0 1 2 1 2 = 1 0 1 1 2 2 1 1 2 2 + 3 1 0 2 1 = 4 1 0 1 1 0 1 2 1 2 = 1 0 1 1 2 0 1 1 2 2 1 1 0 2 1 = 0
  95. 95. 1 2 3 1 0 1 2 1 2 = 1 0 1 1 2 2 1 1 2 2 + 3 1 0 2 1 = 4 1 0 1 1 0 1 2 1 2 = 1 0 1 1 2 0 1 1 2 2 1 1 0 2 1 = 0 同じ行が並んでいるので 計算するまでもなく 0
  96. 96. 1 2 3 1 0 1 2 1 2 = 1 0 1 1 2 2 1 1 2 2 + 3 1 0 2 1 = 4 1 0 1 1 0 1 2 1 2 = 1 0 1 1 2 0 1 1 2 2 1 1 0 2 1 2 1 2 1 0 1 2 1 2 = 2 0 1 1 2 1 1 1 2 2 2 1 0 2 1 = 0 = 03行目を1行目にコピペ
  97. 97. 1 2 3 1 0 1 2 1 2 = 1 0 1 1 2 2 1 1 2 2 + 3 1 0 2 1 = 4 1 0 1 1 0 1 2 1 2 = 1 0 1 1 2 0 1 1 2 2 1 1 0 2 1 2 1 2 1 0 1 2 1 2 = 2 0 1 1 2 1 1 1 2 2 2 1 0 2 1 = 0 = 0
  98. 98. 1 2 3 1 0 1 2 1 2 = 1 0 1 1 2 2 1 1 2 2 + 3 1 0 2 1 = 4 1 0 1 1 0 1 2 1 2 = 1 0 1 1 2 0 1 1 2 2 1 1 0 2 1 2 1 2 1 0 1 2 1 2 = 2 0 1 1 2 1 1 1 2 2 2 1 0 2 1 = 0 = 0 Aの要素が並んでいる…
  99. 99. 1 2 3 1 0 1 2 1 2 = 1 0 1 1 2 2 1 1 2 2 + 3 1 0 2 1 = 4 1 0 1 1 0 1 2 1 2 = 1 0 1 1 2 0 1 1 2 2 1 1 0 2 1 2 1 2 1 0 1 2 1 2 = 2 0 1 1 2 1 1 1 2 2 2 1 0 2 1 = 0 = 0 縦には同じ行列式…これは…!
  100. 100. ドーン! 0 @ 1 2 3 1 0 1 2 1 2 1 A 0 B B B B B B B B B B @ 0 1 1 2 1 1 2 2 1 0 2 1 1 C C C C C C C C C C A = 0 @ 4 0 0 1 A
  101. 101. 同じことを 第2行、第3行 でもやる。
  102. 102. ドドーン! 0 @ 1 2 3 1 0 1 2 1 2 1 A 0 B B B B B B B B B B @ 2 3 1 2 1 3 2 2 1 2 2 1 1 C C C C C C C C C C A = 0 @ 0 4 0 1 A 0 @ 1 2 3 1 0 1 2 1 2 1 A 0 B B B B B B B B B B @ 2 3 0 1 1 3 1 1 1 2 1 0 1 C C C C C C C C C C A = 0 @ 0 0 4 1 A
  103. 103. 全部合わせて… 0 @ 1 2 3 1 0 1 2 1 2 1 A 0 B B B B B B B B B B @ 0 1 1 2 1 1 2 2 1 0 2 1 1 C C C C C C C C C C A = 0 @ 4 0 0 1 A 0 @ 1 2 3 1 0 1 2 1 2 1 A 0 B B B B B B B B B B @ 2 3 1 2 1 3 2 2 1 2 2 1 1 C C C C C C C C C C A = 0 @ 0 4 0 1 A 0 @ 1 2 3 1 0 1 2 1 2 1 A 0 B B B B B B B B B B @ 2 3 0 1 1 3 1 1 1 2 1 0 1 C C C C C C C C C C A = 0 @ 0 0 4 1 A
  104. 104. Enter the Matrix… 0 @ 1 2 3 1 0 1 2 1 2 1 A 0 B B B B B B B B B B @ 0 1 1 2 2 3 0 1 2 3 0 1 1 1 2 2 1 3 2 2 1 3 1 1 1 0 2 1 1 2 2 1 1 2 1 0 1 C C C C C C C C C C A = 0 @ 4 0 0 0 4 0 0 0 4 1 A
  105. 105. 両辺 detA = 4 で割れば… 0 @ 1 2 3 1 0 1 2 1 2 1 A 0 B B B B B B B B B B @ 0 1 1 2 2 3 0 1 2 3 0 1 1 1 2 2 1 3 2 2 1 3 1 1 1 0 2 1 1 2 2 1 1 2 1 0 1 C C C C C C C C C C A = 0 @ 4 0 0 0 4 0 0 0 4 1 A detA = 4
  106. 106. できあがり! 0 @ 1 2 3 1 0 1 2 1 2 1 A · 1 detA 0 B B B B B B B B B B @ 0 1 1 2 2 3 0 1 2 3 0 1 1 1 2 2 1 3 2 2 1 3 1 1 1 0 2 1 1 2 2 1 1 2 1 0 1 C C C C C C C C C C A = 0 @ 1 0 0 0 1 0 0 0 1 1 A = A 1 = 1 4 0 @ 1 7 1 0 8 4 1 3 2 1 A
  107. 107. n次行列の場合も全く同じ (宿題ってことで)
  108. 108. 高次元の計算にはもっと効率的な方法がある • 余因子行列による方法 … O(n3) • 掃き出し法 … O(n2) • LU分解 … O(n2) • …
  109. 109. まとめ • 行列式は線形変換の特徴を表す1次元の量 • detA 0 のとき、逆変換が作れる • 計算は機械に任せよう(仕組みが分かってれば良い)
  110. 110. 行列式の原理: detE = 1 det(b, a) = det(a, b) det(ka, b) = k · det(a, b) 1) 2) 3) (交代性) (多重線形性) det(a1 + a2, b) = det(a1, b) + det(a2, b)
  111. 111. 線形変換は多変数の変換のうち最も単純なもの。 ホントは逆変換が一発で求められること自体ありがたい。
  112. 112. プログラマのための線形代数 再 入門 3 ∼基底変換、固有値、そしてその先∼ 次回予告:
  113. 113. Thanks! Twitter: @taketo1024
 Blog: http://taketo1024.hateblo.jp 0 @ 1 2 3 1 0 1 2 1 2 1 A · 1 detA 0 B B B B B B B B B B @ 0 1 1 2 2 3 0 1 2 3 0 1 1 1 2 2 1 3 2 2 1 3 1 1 1 0 2 1 1 2 2 1 1 2 1 0 1 C C C C C C C C C C A = 0 @ 1 0 0 0 1 0 0 0 1 1 A

×