Skip to content

Commit 950cbb7

Browse files
committed
More L7 notes.
1 parent d0baa2a commit 950cbb7

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

L/07/W7.org

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,18 @@
160160
| 0 | 0 | 0 | 3 |
161161
+ Composing homomorphisms (here LinTran)
162162
+ Typing: let A, B, C be vector spaces and hᵢ linear transformations
163+
#+BEGIN_SRC text
163164
h₂ h₁
164165
C <———— B <———— A
165166
h₂∘h₁
166167
C <———————————— A
167-
168+
#+END_SRC
168169
+ Property: "homomorphisms compose"
170+
#+BEGIN_SRC text
169171
LinTran(h₁, A,B) ∧
170172
LinTran(h₂, B,C) ⇒
171173
LinTran(h₂∘h₁,A, C)
174+
#+END_SRC
172175
+ Composing LinTran (towards matrix multiplication)
173176
+ Typing + specification: let hᵢ = evalMV Mᵢ
174177
#+BEGIN_SRC text
@@ -181,9 +184,9 @@
181184
mulM M₂ M₁
182185
#+END_SRC
183186
+ Property? (three variants)
184-
∃ mulM . evalMV (mulM M₂ M₁) = evalMV M₂ ∘ evalMV M₁
185-
"can we compute a matrix for the composition h₂ ∘ h₁ from just M₂ and M₁?"
186-
∃ mulM . H2(evalMV, mulM, (∘))
187+
+ ∃ mulM . evalMV (mulM M₂ M₁) = evalMV M₂ ∘ evalMV M₁
188+
+ "can we compute a matrix for the composition h₂ ∘ h₁ from just M₂ and M₁?"
189+
+ ∃ mulM . H2(evalMV, mulM, (∘))
187190
+ Example:
188191
#+BEGIN_SRC text
189192
A = a->REAL; B=b->REAL; C=c->REAL
@@ -263,10 +266,13 @@
263266
mulM m₂ m₁
264267
#+END_SRC
265268
where we know
269+
#+BEGIN_SRC haskell
266270
h₁ = evalMV m₁;
267271
h₂ = evalMV m₂;
272+
#+END_SRC
268273

269274
Start computing (towards a definition of mulM):
275+
#+BEGIN_SRC haskell
270276
getCol (mulM m₂ m₁) i
271277
= -- Specification of (mulM m₂ m₁)
272278
(h₂ ∘ h₁) eᵢ
@@ -276,15 +282,23 @@
276282
evalMV m₂ (getCol m₁ i)
277283
= -- Def. of (∘)
278284
(evalMV m₂ ∘ getCol m₁) i
285+
#+END_SRC
279286
Thus we have
287+
#+BEGIN_SRC haskell
280288
getCol (mulM m₂ m₁) == evalMV m₂ ∘ getCol m₁
289+
#+END_SRC
281290
and we can apply flip to both sides (as before)
291+
#+BEGIN_SRC haskell
282292
flip (getCol (mulM m₂ m₁)) == flip (evalMV m₂ ∘ getCol m₁)
293+
#+END_SRC
283294
we notice getCol = flip and flip ∘ flip = id
295+
#+BEGIN_SRC haskell
284296
mulM m₂ m₁ == flip (evalMV m₂ ∘ getCol m₁)
297+
#+END_SRC
285298
This is now a definition of mulM which satisfies its specification.
286299
(Reminder: evalMV m v = linComb v m = Σᵢ scale vᵢ mᵢ)
287300
+ Summing up:
301+
#+BEGIN_SRC haskell
288302
type A = Vec s a
289303
type B = Vec s b
290304
type C = Vec s c
@@ -293,6 +307,7 @@
293307
mulM m₂ m₁ == flip (evalMV m₂ ∘ getCol m₁)
294308

295309
evalMV = mulMV : Mat s a b -> Vec s a -> Vec s b
310+
#+END_SRC
296311
+ Perhaps some live-coding [[Live_7_1_2023.hs]]
297312

298313
** Lecture 7.2 / 8.1: Laplace Transforms

0 commit comments

Comments
 (0)