Eata fo Edition of Coding the Matix, Januay 3, 07 You coy might not contain some of these eos. Most do not occu in the coies cuently being sold as Ail 05. Section 0.3:... the inut is a e-image of the inut... the inut is a e-image of the outut. Figue 4 in Section 0.3.8: The figue as follows: g f A A f g B B 3 C C 3 f - A g - A (f g) - =g - f - B B C C 3 3 Definition 0.3.4: thee exists x A such that f(x) = z thee exists x D such that f(x) = z. Section 4=0.4.4:...the cytogahe changes the scheme simly by emoving as a ossible value fo... as a ossible value fo k. Section 0.5.4: At the end of the section labeled Mutating a set, >>> U=S.coy() >>> U.add(5) >>> S {, 3} should end with >>> S {6} Poblem 0.8.5: ow() ow(, n). Section.4.: Using the fact that i = Using the fact that i = Section.4.5: The diagam illustating otation by 90 degees is incoect. The dots should fom vetical lines to the left of the y-axis. Task.4.8 and.4.9: The figues accomanying these tasks ae incoect; they involve otation by -90 degees (i.e. 90 degees clockwise) instead of 90 degees (i.e. 90 degees counteclockwise). Task.4.0: image.fileimage(filename) etuns a eesentation of a colo image, namely a list of lists of 3-tules. Fo the uose of this task, you must tansfom it to a eesentation of a gayscale image, using image.cologay( ). Also, the ixel intensities ae numbes between 0 and 55, not between 0 and. In this task, you should assign to ts the list of comlex numbes x + iy such that the image intensity of ixel (x, y) is less than 0. Task.4.: The task mentions ts but S is intended. Section.3: We ve seen two examles of what we can eesent with vectos: multisets and sets. Actually, we ve only seen multisets.
Section.4.: o fom [ 4, 4 to [ 3, o fom [ 4, 4 to [ 3,. Examle.6.8: Fo α =.75, β =.5, αu + βv [6.5, 0, not [6.5,. Section.8.3: Hee is an examle of solving an instance of the 3 3 uzzle Hee is an examle of one ste towads solving an instance of the 3 3 uzzle. Examle.9.: Conside the dot-oduct of [,,,, with [0, 0, 0, 40, 00 Conside the dot-oduct of [,,,, with [0, 0, 0, 40, 00. Section.9.:...in tems of five linea euations......in tems of thee linea euations.... Examle.9.5: cost = Vec(D, {hos : $.50/ounce, malt : $.50/ound, wate : $0.006}, yeast : $0.45/gam) cost = Vec(D, {hos : $.50/ounce, malt : $.50/ound, wate : $0.006, yeast : $0.45/gam}) Definition.9.6: A linea euation is an euation of the fom a = β, whee... is a vecto vaiable. A linea euation is an euation of the fom a x = β, whee... x is a vecto vaiable. Examle.9.7: The total enegy is not 65J but is 0.0845J, as the Python shows. Quiz.9.9: The total enegy consumed in the last ow of the table J, not W. Definition.9.0: In geneal, a system of linea euations (often abbeviated linea system) is a collection of euations: a = β a = β a m = β m whee is a vecto vaiable. A solution is a vecto ˆ that satisfies all the euations. In geneal, a system of linea euations (often abbeviated linea system) is a collection of euations: a x = β a x = β a m x = β m whee x is a vecto vaiable. A solution is a vecto ˆx that satisfies all the euations. Quiz.9.3: The solution The dot-oducts ae [,, 0, 0. Quiz.9.4: The solution [4, 0, 6, 3... Quiz.9.5: In the solution, the ange ange(len(haystack)-s+), not ange(len(haystack)-s). Examle.9.7: The asswod is ˆ = 0 The asswod is ˆx = 0,
Hay comutes the dot-oduct a ˆ Hay comutes the dot-oduct a ˆx Hay comutes the dot-oduct a ˆ Hay comutes the dot-oduct a ˆx Caole lets Hay log in if β = a ˆ, β = a ˆ,..., β k = a k ˆ. Caole lets Hay log in if β = a ˆx, β = a ˆx,..., β k = a k ˆx. Examle.9.8: Eve can use the distibutive oety to comute the dot-oduct of this sum with the asswod even though she does not know the asswod: (00 + 0) = 00 + 0 = 0 + = Eve can use the distibutive oety to comute the dot-oduct of this sum with the asswod x even though she does not know the asswod: (00 + 0) x = 00 x + 0 x = 0 + = Task..8: Did you get the same esult as in Task??? Did you get the same esult as in Task..7? Quiz 3..7: the solution def lin_comb(vlist,clist): etun sum([coeff*v fo (c,v) in zi(clist, vlist)) def lin_comb(vlist,clist): etun sum([coeff*v fo (coeff,v) in zi(clist, vlist)) Section 3..4: The eesentation of the old geneato [0, 0, in tems of the new geneatos [, 0, 0, [,, 0, and [,, [0, 0, = 0 [, 0, 0 [,, 0 + [,, In Examle 3..7, The secet asswod is a vecto ˆ ove GF ()... the human must esond with the dot-oduct a ˆ. The secet asswod is a vecto ˆx ove GF ()... the human must esond with the dot-oduct a ˆx. Examle 3.3.0: This line can be eesented as San {[,, } This line can be eesented as San {[,, } In Examle 3.5., Thee is one lane though the oints u = [, 0, 4.4, u = [0,, 4, and u = [0, 0, 3 Thee is one lane though the oints u = [, 0, 4.4, u = [0,, 4, and u 3 = [0, 0, 3. Section 4..4: The etty-inted fom of M >>> int(m) # @? --------- a 3 b 0 0 30 3
fo some ode of the columns. Quiz 4..9: The given imlementation of matowdict will not wok until you have imlemented the getitem ocedue in mat.y. Quiz 4.3.: The etty-inted fom of matvec(m) >>> int(matvec(m)) ( a, # ) ( a,? ) ( a, @ ) ( b, # ) ( b,? ) ( b, @ ) ------------------------------------------------------------------ 3 0 30 0 fo some ode of the columns. Quiz 4.4.: The etty-inted fom of tansose(m) >>> int(tansose(m)) a b ------ # 0 @ 0? 3 30 fo some ode of the ows. lowe-case f. Also, in the solution, the ue-case F elaced with a Examle 4.6.6: The matix-vecto oduct [, 3,, 4,,,, 0,, 0. Definition 4.6.9: An n n ue-tiangula matix A is a matix with the oety that A ij = 0 fo j > i fo i > j. Section 4.7.: Alying Lemma 4.7.4 with v = u Lemma 4.7.4 with v = u and z = u u and z = u u Alying Section 4.7.4: because it is the same as H c, which she can comute because it is the same as H c, which she can comute Section 4.9.3: The URL htt://xkcd.com/84 tts://xkcd.com/84/. Section 4..: and hee is the same diagam with the walk 3 c e 4 shown and hee is the same diagam with the walk 3 c e 4 e shown Examle 4..9: g f([x, x ) [x + x, x + x. Examle 4..5: The last matix (in the thid ow) indicating tansose: = [ 7 4 9 8 Examle 4.3.5: xvec x and xvec x. T [ 7 9 4 8. a suescit T The descition of Task 4.4. comes befoe the heading Task 4.4.. Section 4.5 (Geomety Lab): osition is used synonymously with location. Section 4.4.6: Hint: this uses the secial oety of the ode of H s ows Hint: this uses the secial oety of the ode of H s columns. 4
Poblem 4.7.0 is the same as Poblem 4.7.5. Poblem 4.7.8: Fo this ocedue, the only oeation you ae allowed to do on A is vecto-matix multilication, using the * oeato: v*a. Fo this ocedue, the only oeation you ae allowed to do on B is vecto-matix multilication, using the * oeato: v*b. Poblem 4.7.: xvec x. Section 5.3.: The Gow algoithm : def Gow(V) B = eeat while ossible: find a vecto v in V that is not in San B, and ut it in B. Examle 5.3.: Finally, note that San B = R and that neithe v no v alone could geneate R R 3. Section 5.4.3: Let D be the set of nodes, e.g. D = {Pemboke, Athletic, Main, Keeney, Wiston} D = {Pemboke, Athletic, Bio-Med, Main, Keeney, Wiston, Gegoian} Section 5.9.: The fist vecto a goes hoizontally fom the to-left cone of the whiteboad element to the to-ight cone The fist vecto a goes hoizontally fom the toleft cone of the to-left senso element to the to-ight cone and The second vecto a goes vetically fom the to-left cone of whiteboad to the bottom-left cone The second vecto a goes vetically fom the to-left cone of the to-left senso element to the bottom-left cone. L = [[0,0,0,[,0,0,[0,,0,[,,0,[0,0,,[,0,,[0,,,[,, L = [[0,0,0,[,0,0,[0,,0,[,,0,[0,0,,[,0,,[0,,,[,, Section 5.9., diagam: The oint in the bottom-left-back of the cube labeled (0,,) but is labeled (0,,0). Section 5.9.5: In Fo the thid basis vecto a... and Remembe that a oints fom the camea cente to the to-left cone of the senso aay, so a = (.5,.5, ), a a 3, and a 3 = [0, 0,. The thid vecto in cb has an exta 0. The thid vecto c 3 goes fom the oigin (the camea cente) to the to-ight cone of whiteboad. The thid vecto c 3 goes fom the oigin (the camea cente) to the to-left cone of the whiteboad. Section 5..: Section 5..6: The vecto x xvec Section 5..6: Afte Task 5.., Let [y, y, y 3 = Hx Let [y, y, y 3 = Ĥx. Poblem 5.4.8: Wite and test a ocedue sueset basis(s, L) Wite and test a ocedue sueset basis(t, L). Lemma 6..3 (Sueset-Basis Lemma) states x x 5
Fo any vecto sace V and any linealy indeendent set A of vectos, V has a basis that contains all of A. but should state Fo any vecto sace V and any linealy indeendent set A of vectos belonging to V, V has a basis that contains all of A. [ 0 0 Examle 6.3.3: V is defined to be the null sace of but defined to 0 0 be the null sace of [ 0 0 0 0. Poblem 6.7.3: The outut condition says fo i =,,..., k, but should say fo i =,,..., k, San S = San S {z, z,..., z i } {w, w,..., w k } San S = San S {z, z,..., z i } {w, w,..., w i } Section 7.7.: xvec and xvec x and x Section 7.7.4: Geneating mathbf u Geneating u. Section 7.8.3: We can eesent the factoization of 76 by the list [(, 3), (5, ), indicating that 76 is obtained by multiying togethe thee s and two 5 s We can eesent the factoization of 76 by the list [(, 3), (3, ), (7, ), indicating that 76 is obtained by multilying togethe thee s, one 3 and two 7 s, and 76 = 3 5 76 = 3 3 7. Task 7.8.7: Fo x = 6, the factoed enty has 3 7 3. This 3 7 3. Task 7.8.9: gcd(a, b) gcd(a b, N). Section 9.: In new sec fo oject othogonal(b, vlist), outut the ojection b of b othogonal to the vectos in vlist Examle 9.4.: The math is misfomatted; thee a line-beak just befoe b. That is, the math should state that b = [, 3.5, 0.5 and that b = b b0,v v,v v = b [0, 3, 3 = [,,. Section 9.6.6: These vectos san the same sace as inut vectos u,..., u k, w,..., w n... The * in w n should not be thee. Section 9.6.6: In the seudocode fo find othogonal comlement, the last line Retun [ Poof of Lemma 0.6.: The fist line of the last seuence of euations, ω c = ((ω c ) 0 + (ω c ) + (ω c ) + + (ω c ) n + (ω c ) n ) ω c z = ω c ((ω c ) 0 + (ω c ) + (ω c ) + + (ω c ) n + (ω c ) n ) Task 0.9.6: The ocedue image ound should also ensue the numbes ae between 0 and 55. Poof of Lemma.3.6: Let V be the sace dual to V Let V be the annihilato of V, and the dual of the dual the annihilato of the annihilato. 6
Section.3.3:...we ovide a module svd with a ocedue facto(a) that, given a Mat A, etuns a tile (U, Sigma, V) such that A = U * Sigma * V.tansose should end such that A = U * Sigma * V.tansose() Poof of Lemma.3.: which euals ( a + + a m ) + be which euals ( a + + a m ) ( a V + + a V m ) ( a V + + a V m ) should Section.3.5, Poof of Theoem.3.: Thee is a coected oof at htt://codingthematix.com/oof-that-fist-k-ight-singula-vectos-san-closest-sace0. df Section.3.0: Thee is a coected oof at htt://codingthematix.com/oof-that-u-is-column-othogonal0.df. Task.6.6, To hel you debug, alying the ocedue to with To hel you debug, alying the ocedue with Section.4.: The ocedue SVD solve(a) should take the vecto b as a second agument: SVD solve(a, b). Section.6 (Eigenfaces Lab): {x,y fo x in ange(66) fo y in ange(89)} {(x,y) fo x in ange(66) fo y in ange(89)}. Section..: The diagonal matix Λ is used shotly befoe it is defined. Poblem.4.8: Eo in statement of Lemma.4. The eigenvalue of A having smallest asolute value is the eciocal of the eigenvalue of A having lagest absolute value. Section.8.: xvec (t) just x (t). Section.8.: In the euation λ Λ. [ x (t) x (t) = ( SλS ) t [ x (0) x (0) Section.8.: xvec (t) x (t) and xvec (0) x (0). Section.8.4: Once consecutive addesses have been euested in timestes t and t +, it is vey likely that the addess euested in timeste t + is also consecutive should end that the addess euested in timeste t + is also consecutive. Section..: The theoem in Section.8... Thee is no theoem in that section; the theoem (the Peon-Fobenius Theoem) is not stated in the text. Section..3: The eigenvecto given fo the test case fo Task..3 is wong; the coect eigenvecto is oughly {: 0.5, : 0.68, 3: 0.5738, 4: 0.0705, 5: 0.0783, 6: 0.0705}. 7