An AI skill that turns books into animated, narrated, interactive web experiences
JavaScript ai-agentsai-educationanimationclaudeclaude-codeclaude-skillsedtecheducationinteractive-textbookscormtext-to-video
feat(linear-algebra): Unit 4 begins: chapters 29-31 (undoing elimination, A = LU, why L is clean)
yzre5c3784cc830
diff --git a/site/linear-algebra/ch29/audio/en/e32.mp3 b/site/linear-algebra/ch29/audio/en/e32.mp3new file mode 100644index 0000000..39e9352Binary files /dev/null and b/site/linear-algebra/ch29/audio/en/e32.mp3 differdiff --git a/site/linear-algebra/ch29/audio/en/ex2.mp3 b/site/linear-algebra/ch29/audio/en/ex2.mp3new file mode 100644index 0000000..4a3c981Binary files /dev/null and b/site/linear-algebra/ch29/audio/en/ex2.mp3 differdiff --git a/site/linear-algebra/ch29/audio/en/final1.mp3 b/site/linear-algebra/ch29/audio/en/final1.mp3new file mode 100644index 0000000..b09d506Binary files /dev/null and b/site/linear-algebra/ch29/audio/en/final1.mp3 differdiff --git a/site/linear-algebra/ch29/audio/en/final2.mp3 b/site/linear-algebra/ch29/audio/en/final2.mp3new file mode 100644index 0000000..1828416Binary files /dev/null and b/site/linear-algebra/ch29/audio/en/final2.mp3 differdiff --git a/site/linear-algebra/ch29/audio/en/final3.mp3 b/site/linear-algebra/ch29/audio/en/final3.mp3new file mode 100644index 0000000..6b02376Binary files /dev/null and b/site/linear-algebra/ch29/audio/en/final3.mp3 differdiff --git a/site/linear-algebra/ch29/audio/en/final4.mp3 b/site/linear-algebra/ch29/audio/en/final4.mp3new file mode 100644index 0000000..f3c3abeBinary files /dev/null and b/site/linear-algebra/ch29/audio/en/final4.mp3 differdiff --git a/site/linear-algebra/ch29/audio/en/finish.mp3 b/site/linear-algebra/ch29/audio/en/finish.mp3new file mode 100644index 0000000..fc29970Binary files /dev/null and b/site/linear-algebra/ch29/audio/en/finish.mp3 differdiff --git a/site/linear-algebra/ch29/audio/en/intro.mp3 b/site/linear-algebra/ch29/audio/en/intro.mp3new file mode 100644index 0000000..fd57a25Binary files /dev/null and b/site/linear-algebra/ch29/audio/en/intro.mp3 differdiff --git a/site/linear-algebra/ch29/audio/en/inverse.mp3 b/site/linear-algebra/ch29/audio/en/inverse.mp3new file mode 100644index 0000000..90b113dBinary files /dev/null and b/site/linear-algebra/ch29/audio/en/inverse.mp3 differdiff --git a/site/linear-algebra/ch29/audio/en/play.mp3 b/site/linear-algebra/ch29/audio/en/play.mp3new file mode 100644index 0000000..d6e276bBinary files /dev/null and b/site/linear-algebra/ch29/audio/en/play.mp3 differdiff --git a/site/linear-algebra/ch29/audio/en/q1.mp3 b/site/linear-algebra/ch29/audio/en/q1.mp3new file mode 100644index 0000000..04089f2Binary files /dev/null and b/site/linear-algebra/ch29/audio/en/q1.mp3 differdiff --git a/site/linear-algebra/ch29/audio/en/q2.mp3 b/site/linear-algebra/ch29/audio/en/q2.mp3new file mode 100644index 0000000..4f4bbe9Binary files /dev/null and b/site/linear-algebra/ch29/audio/en/q2.mp3 differdiff --git a/site/linear-algebra/ch29/audio/en/q3.mp3 b/site/linear-algebra/ch29/audio/en/q3.mp3new file mode 100644index 0000000..fc10187Binary files /dev/null and b/site/linear-algebra/ch29/audio/en/q3.mp3 differdiff --git a/site/linear-algebra/ch29/audio/en/q4.mp3 b/site/linear-algebra/ch29/audio/en/q4.mp3new file mode 100644index 0000000..a94f821Binary files /dev/null and b/site/linear-algebra/ch29/audio/en/q4.mp3 differdiff --git a/site/linear-algebra/ch29/audio/en/recall.mp3 b/site/linear-algebra/ch29/audio/en/recall.mp3new file mode 100644index 0000000..5c80442Binary files /dev/null and b/site/linear-algebra/ch29/audio/en/recall.mp3 differdiff --git a/site/linear-algebra/ch29/audio/en/three.mp3 b/site/linear-algebra/ch29/audio/en/three.mp3new file mode 100644index 0000000..633a108Binary files /dev/null and b/site/linear-algebra/ch29/audio/en/three.mp3 differdiff --git a/site/linear-algebra/ch29/audio/en/timings.js b/site/linear-algebra/ch29/audio/en/timings.jsnew file mode 100644index 0000000..ee7f716--- /dev/null+++ b/site/linear-algebra/ch29/audio/en/timings.js@@ -0,0 +1,642 @@+window.TIMINGS = {+ "intro": {+ "dur": 13.128,+ "marks": {+ "sub": 4.727,+ "move": 9.557+ },+ "cues": [+ [+ 0.104,+ "Unit four, chapter twenty-nine."+ ],+ [+ 2.721,+ "Undoing elimination."+ ],+ [+ 4.727,+ "Every step of elimination can be undone, by adding back what it took away."+ ],+ [+ 9.557,+ "Take a step, then take it back, and the line comes home."+ ]+ ]+ },+ "recall": {+ "dur": 45.984,+ "marks": {+ "sys": 4.583,+ "e": 14.896,+ "go": 24.271,+ "w": 25.299,+ "res": 30.456,+ "flat": 33.346,+ "ask": 39.531+ },+ "cues": [+ [+ 0.091,+ "In chapter twenty-one, each step of elimination became a matrix."+ ],+ [+ 4.583,+ "Here is chapter sixteen's system again: x plus two y equals five, and three x plus four y equals eleven."+ ],+ [+ 12.695,+ "The two lines meet at one, two."+ ],+ [+ 14.896,+ "The step row two minus three times row one is the matrix E two one: the identity, with minus three in row two, column one."+ ],+ [+ 24.271,+ "Multiply."+ ],+ [+ 25.299,+ "Row two of the answer is minus three times row one, plus row two: zero, minus two, minus four."+ ],+ [+ 33.346,+ "The x is gone, and the coral line turns about the meeting point until it lies flat."+ ],+ [+ 39.531,+ "Now the question of this chapter."+ ],+ [+ 41.497,+ "How do we get back?"+ ],+ [+ 42.682,+ "Which matrix turns the flat line back to where it was?"+ ]+ ]+ },+ "undo": {+ "dur": 43.512,+ "marks": {+ "took": 1.471,+ "kept": 4.622,+ "back": 8.385,+ "carry": 12.917,+ "e": 16.966,+ "w": 20.547,+ "res": 28.685,+ "line": 32.266,+ "pin": 38.646+ },+ "cues": [+ [+ 0.091,+ "Look at what the step did."+ ],+ [+ 1.471,+ "It took three times row one away from row two."+ ],+ [+ 4.622,+ "Row one was not touched: it is still one, two, five."+ ],+ [+ 8.385,+ "So to undo the step, add three times row one back to row two."+ ],+ [+ 12.917,+ "Start from the answer, and put a new matrix in front of it."+ ],+ [+ 16.966,+ "It has plus three in row two, column one."+ ],+ [+ 20.547,+ "Three times row one is three, six, fifteen."+ ],+ [+ 23.932,+ "Add the new row two, zero, minus two, minus four, and you get three, four, eleven."+ ],+ [+ 30.612,+ "That's the old row two."+ ],+ [+ 32.266,+ "In the picture, the flat line turns back about the meeting point, onto exactly where it started."+ ],+ [+ 38.646,+ "The meeting point never moved: not on the way out, and not on the way back."+ ]+ ]+ },+ "inverse": {+ "dur": 61.992,+ "marks": {+ "name": 3.763,+ "cmp": 11.393,+ "why": 18.776,+ "ii": 24.062,+ "calc": 30.677,+ "r1": 39.453,+ "r2": 40.677,+ "res": 52.461,+ "eye": 53.958+ },+ "cues": [+ [+ 0.104,+ "The matrix that undoes E is called E inverse."+ ],+ [+ 3.763,+ "It's written E with a small minus one, as in chapter twenty-six, where the inverse of a matrix undoes it."+ ],+ [+ 11.393,+ "Put the two side by side."+ ],+ [+ 13.203,+ "E has minus three."+ ],+ [+ 14.661,+ "E inverse has plus three."+ ],+ [+ 16.458,+ "Everything else is the identity."+ ],+ [+ 18.776,+ "E takes three times row one away."+ ],+ [+ 21.172,+ "E inverse puts three times row one back."+ ],+ [+ 24.062,+ "So E, and then E inverse, changes nothing at all."+ ],+ [+ 28.086,+ "The line goes flat, and comes back."+ ],+ [+ 30.677,+ "Check it by multiplying E inverse times E, row by row."+ ],+ [+ 35.078,+ "Row one of E inverse is one, zero: it copies row one of E, one, zero."+ ],+ [+ 40.677,+ "Row two is three, one: three times row one of E, plus row two of E."+ ],+ [+ 46.315,+ "Three times one, zero is three, zero."+ ],+ [+ 50.117,+ "Add minus three, one, and you get zero, one."+ ],+ [+ 53.958,+ "The answer is one, zero, and zero, one: the identity."+ ],+ [+ 59.141,+ "E inverse times E equals I."+ ]+ ]+ },+ "q1": {+ "dur": 2.4,+ "marks": {},+ "cues": [+ [+ 0.091,+ "Quick check."+ ],+ [+ 1.107,+ "Undo this step."+ ]+ ]+ },+ "ex2": {+ "dur": 51.072,+ "marks": {+ "sys": 3.138,+ "e": 10.443,+ "go": 17.214,+ "carry": 22.591,+ "inv": 25.208,+ "w": 28.659,+ "res": 36.107,+ "line": 39.479,+ "rule": 41.901+ },+ "cues": [+ [+ 0.104,+ "Another example, from chapter seventeen."+ ],+ [+ 3.138,+ "x plus two y equals three, and minus two x plus y equals four."+ ],+ [+ 8.516,+ "They meet at minus one, two."+ ],+ [+ 10.443,+ "Here the multiplier was minus two, so E two one has plus two: it adds two times row one."+ ],+ [+ 17.214,+ "Row two becomes zero, five, ten, and the coral line lies flat."+ ],+ [+ 22.591,+ "To undo an addition, we subtract."+ ],+ [+ 25.208,+ "E inverse has minus two, in the same spot."+ ],+ [+ 28.659,+ "Minus two times row one is minus two, minus four, minus six."+ ],+ [+ 33.659,+ "Add zero, five, ten, and you get minus two, one, four: the old row two."+ ],+ [+ 39.479,+ "The line turns back about the same point."+ ],+ [+ 41.901,+ "So the rule is short."+ ],+ [+ 43.516,+ "To undo a step, change the sign of its one number."+ ],+ [+ 47.214,+ "Minus ell becomes plus ell, and plus becomes minus."+ ]+ ]+ },+ "twice": {+ "dur": 42.192,+ "marks": {+ "first": 1.51,+ "pic": 9.414,+ "calc": 13.151,+ "r2": 18.346,+ "res": 29.167,+ "eye": 30.742,+ "both": 32.214+ },+ "cues": [+ [+ 0.091,+ "Does the order matter here?"+ ],+ [+ 1.51,+ "Try it the other way round: E inverse first, then E."+ ],+ [+ 5.846,+ "Subtract two times row one, then add it back."+ ],+ [+ 9.414,+ "The line tips the other way, and comes back again."+ ],+ [+ 13.151,+ "As a product, that's E times E inverse."+ ],+ [+ 16.237,+ "Row one is one, zero."+ ],+ [+ 18.346,+ "Row two is two times row one of E inverse, plus row two of E inverse."+ ],+ [+ 23.529,+ "Two times one, zero is two, zero."+ ],+ [+ 26.979,+ "Add minus two, one, and you get zero, one."+ ],+ [+ 30.742,+ "The identity again."+ ],+ [+ 32.214,+ "E inverse times E, and E times E inverse: both are I."+ ],+ [+ 37.865,+ "Taking away and putting back undo each other, in either order."+ ]+ ]+ },+ "q2": {+ "dur": 3.888,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Your turn."+ ],+ [+ 1.003,+ "Turn the coral line back onto the dashed line."+ ]+ ]+ },+ "three": {+ "dur": 48.96,+ "marks": {+ "sys": 2.747,+ "e": 6.628,+ "go": 10.781,+ "carry": 21.237,+ "inv": 22.448,+ "w": 28.88,+ "res": 37.448,+ "back": 41.393,+ "same": 44.31+ },+ "cues": [+ [+ 0.117,+ "The same works in three dimensions."+ ],+ [+ 2.747,+ "Here are the lecture's three equations, from chapter eighteen."+ ],+ [+ 6.628,+ "E two one has minus three in row two, column one."+ ],+ [+ 10.781,+ "Multiply, and the coral plane turns on its hinge, the line where it meets the blue plane."+ ],+ [+ 17.148,+ "Row two becomes zero, two, minus two, six."+ ],+ [+ 21.237,+ "Now undo it."+ ],+ [+ 22.448,+ "E two one inverse is the three by three identity, with plus three in the same spot."+ ],+ [+ 28.88,+ "Row two of the answer is three times row one, three, six, three, six, plus zero, two, minus two, six."+ ],+ [+ 37.448,+ "That's three, eight, one, twelve: the old row two."+ ],+ [+ 41.393,+ "The coral plane turns back on the same hinge."+ ],+ [+ 44.31,+ "Rows one and three were never touched, so their planes never moved."+ ]+ ]+ },+ "e32": {+ "dur": 28.872,+ "marks": {+ "e": 4.492,+ "go": 9.18,+ "inv": 11.159,+ "w": 14.427,+ "back": 17.839,+ "rule": 21.289+ },+ "cues": [+ [+ 0.104,+ "The second step was row three minus two times row two."+ ],+ [+ 4.492,+ "E three two has minus two in row three, column two, and the yellow plane lies flat."+ ],+ [+ 11.159,+ "Its inverse has plus two in the same spot."+ ],+ [+ 14.427,+ "It adds two times row two back to row three, and the yellow plane stands up again, just where it was."+ ],+ [+ 21.289,+ "Every elimination matrix works this way."+ ],+ [+ 24.154,+ "Its inverse is the same matrix, with the sign of its one number changed."+ ]+ ]+ },+ "q3": {+ "dur": 3.168,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Quick check."+ ],+ [+ 1.133,+ "Which matrix undoes this one?"+ ]+ ]+ },+ "q4": {+ "dur": 6.6,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Your turn, in three dimensions."+ ],+ [+ 3.398,+ "Undo the step, and bring the yellow plane back."+ ]+ ]+ },+ "wrap": {+ "dur": 29.568,+ "marks": {+ "w1": 1.003,+ "w2": 5.56,+ "w3": 12.292,+ "w4": 23.359,+ "end": 27.565+ },+ "cues": [+ [+ 0.104,+ "Let's sum up."+ ],+ [+ 1.003,+ "Each step of elimination can be undone, by adding back what it took away."+ ],+ [+ 5.56,+ "Its inverse is the same matrix with the sign of its one number changed: minus ell becomes plus ell."+ ],+ [+ 12.292,+ "E inverse times E is the identity, and so is E times E inverse."+ ],+ [+ 18.424,+ "The line or plane turns away, and comes back, about the same point."+ ],+ [+ 23.359,+ "It works because the row a step uses is not changed by that step."+ ],+ [+ 27.565,+ "Now try the chapter practice."+ ]+ ]+ },+ "final1": {+ "dur": 4.608,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Chapter practice."+ ],+ [+ 1.497,+ "Find the number that undoes each step."+ ]+ ]+ },+ "final2": {+ "dur": 3.672,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Set two."+ ],+ [+ 1.068,+ "Undo a step, and find the old row."+ ]+ ]+ },+ "final3": {+ "dur": 3.816,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Set three."+ ],+ [+ 1.211,+ "True or false, and two products."+ ]+ ]+ },+ "final4": {+ "dur": 6.096,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Last set."+ ],+ [+ 1.198,+ "Change the numbers of E inverse with your own hands, until the planes are back."+ ]+ ]+ },+ "play": {+ "dur": 8.064,+ "marks": {+ "go": 3.971+ },+ "cues": [+ [+ 0.104,+ "Playground."+ ],+ [+ 1.068,+ "Nothing here is marked right or wrong."+ ],+ [+ 3.971,+ "Make the line flat with E, then find the number that brings it back."+ ]+ ]+ },+ "finish": {+ "dur": 11.352,+ "marks": {},+ "cues": [+ [+ 0.091,+ "Well done."+ ],+ [+ 1.12,+ "That's the end of chapter twenty-nine, Undoing Elimination."+ ],+ [+ 5.794,+ "Next: we put all the undo steps together, and A becomes L times U."+ ]+ ]+ }+};diff --git a/site/linear-algebra/ch29/audio/en/twice.mp3 b/site/linear-algebra/ch29/audio/en/twice.mp3new file mode 100644index 0000000..2da3f38Binary files /dev/null and b/site/linear-algebra/ch29/audio/en/twice.mp3 differdiff --git a/site/linear-algebra/ch29/audio/en/undo.mp3 b/site/linear-algebra/ch29/audio/en/undo.mp3new file mode 100644index 0000000..8bc2fc8Binary files /dev/null and b/site/linear-algebra/ch29/audio/en/undo.mp3 differdiff --git a/site/linear-algebra/ch29/audio/en/wrap.mp3 b/site/linear-algebra/ch29/audio/en/wrap.mp3new file mode 100644index 0000000..1d767faBinary files /dev/null and b/site/linear-algebra/ch29/audio/en/wrap.mp3 differdiff --git a/site/linear-algebra/ch29/index.html b/site/linear-algebra/ch29/index.htmlnew file mode 100644index 0000000..b3a130f--- /dev/null+++ b/site/linear-algebra/ch29/index.html@@ -0,0 +1,435 @@+<!doctype html>+<html lang="en">+<head>+<meta charset="utf-8">+<meta name="viewport" content="width=device-width, initial-scale=1">+<title>Undoing Elimination</title>+<link rel="stylesheet" href="../lib/engine.css">+<link rel="expect" href="#bar" blocking="render"><!-- hold the first frame until the player exists, so the page transition can run -->+</head>+<body>+<script src="../lib/engine.js"></script>+<script src="../lib/math.js"></script>+<script src="../lib/linsys.js"></script>+<script src="../lib/space3.js"></script>+<script src="../lib/elim.js"></script>+<script src="../lib/emat.js"></script>+<script src="../lib/play.js"></script>+<script src="audio/en/timings.js"></script>+<script>+'use strict';+const CHAPTER = { number: 29, title: 'Undoing Elimination', minutes: 10, language: 'en' };++/* ---------- chapter drawing helpers ---------- */+const BLUE = LS_ROW[0], CORAL = LS_ROW[1], YELLOW = S3_ROW[2];+const CH16 = { A: [[1, 2], [3, 4]], b: [5, 11] }; // chapter 16's system, meets at (1, 2)+const CH17 = { A: [[1, 2], [-2, 1]], b: [3, 4] }; // chapter 17's, meets at (−1, 2)+const LEC = { A: [[1, 2, 1], [3, 8, 1], [0, 4, 1]], b: [2, 12, 2] }; // the lecture's system (OCW 18.06, lecture 2)+const AFTER1 = { A: [[1, 2, 1], [0, 2, -2], [0, 4, 1]], b: [2, 6, 2] }; // after column 1+const U_LEC = { A: [[1, 2, 1], [0, 2, -2], [0, 0, 5]], b: [2, 6, -10] }; // after both steps+const OWN = { A: [[1, 1, 1], [2, 3, 1], [-1, 1, 2]], b: [3, 6, 2] }, OWN1 = { A: [[1, 1, 1], [0, 1, -1], [0, 2, 3]], b: [3, 0, 5] };+const E21 = [[1, 0], [-3, 1]];+const AT2 = [70, 290], AT3 = [64, 262];+const CARD2 = { x: 40, y: 600, w: 760, cls: 'side' }, CARD3 = { x: 40, y: 640, w: 800, cls: 'side' };+const say = (p, parts, x, y, t0, { size = 40, fill = COL.chalk, anchor = 'start' } = {}) => { const e = M(p, [].concat(parts), { x, y, size, fill, anchor, o: 0 }); show(e, t0); return e; };+const text = (p, str, x, y, t0, { size = 30, fill = COL.chalk, anchor = 'start', weight = 500 } = {}) => { const e = T(p, str, { x, y, size, fill, anchor, weight, o: 0 }); show(e, t0); return e; };+const thick = (sys, i, t0) => { tw(sys.lines[i].l, { 'a_stroke-width': 10 }, t0, .35); tw(sys.lines[i].l, { 'a_stroke-width': 5 }, t0 + .9, .6); };+// 2D: the plane on the right, E · [A | b] = [EA | Eb] on the left (chapter 21's layout); the product is the system drawn+// (with E given, the lines start as E's answer).+const two = (p, { A, b }, caption, { t0 = .1, E = null } = {}) => {+ const sys = linsys(p, { A, b, eq: [90, 200], mat: null, sol: false, plane: { cx: 1215, u: 50 }, t0 });+ sys.E.style.visibility = 'hidden'; // hidden, yet measured (display: none measures as 0 and replays differ)+ if (caption) say(p, [caption], 70, 175, t0 + .1, { size: 28, fill: COL.dim });+ const em = emat(p, sys, { A, b, E, at: AT2, size: 38, cw: 64, ecw: 56, rh: 62, gap: 66, t0 });+ return { sys, em };+};+// 3D: the space on the right, three 3 × 3 tables on the left.+const three = (p, { A, b }, caption, { t0 = .1, E = null, view = { yaw: -40, pitch: 20 } } = {}) => {+ const sys = lin3(p, { A, b, eq: [90, 190], mat: null, sol: false, space: { cx: 1262, size: 520, ...view }, t0 });+ sys.E.style.visibility = 'hidden'; // hidden, yet measured (display: none measures as 0 and replays differ)+ if (caption) say(p, [caption], 64, 160, t0 + .1, { size: 26, fill: COL.dim });+ const em = emat(p, sys, { A, b, E, at: AT3, size: 32, cw: 52, ecw: 44, rh: 54, gap: 64, t0 });+ return { sys, em, V: sys.space };+};+// A matrix times a matrix with no picture (E⁻¹E = I): emat on a bare system, the b columns hidden.+const bare = A => {+ const v = {}, fs = [];+ A.forEach((r, i) => { r.forEach((x, j) => { v[`a${i}${j}`] = x; }); v[`b${i}`] = 0; });+ return { v, set(to) { Object.assign(v, to); fs.forEach(f => f(v)); }, onChange: f => fs.push(f), solve: () => ({}), live() {}, to() {} };+};+const mm2 = (p, Ebig, Bm, names, nameE, t0) => emat(p, bare(Bm), { A: Bm, b: [0, 0], E: Ebig, at: AT2, size: 38, cw: 64, ecw: 56, rh: 62, gap: 66, t0, noB: true, names, name: nameE });+// The old line of row 2 (dashed): a x + b y through (sx, sy); a ring round the point that never moves (chapter 16).+const ghost = (sys, a, b, sx, sy, t0) => { const l = sys.P.line(sx, sy, sx + b, sy - a, CORAL, t0, { dash: '10 10', w: 3, into: sys.stage }); tw(l, { o: .45 }, t0 + .6, .4); return l; };+const pin = (sys, x, y, t0) => { const g = G(sys.stage, { x: sys.P.PX(x), y: sys.P.PY(y), o: 0 }); mk('circle', { r: 20, fill: 'none', stroke: COL.chalk, 'stroke-width': 3.5, 'stroke-dasharray': '6 5' }, g); show(g, t0, .4); return g; };+const hinge = (sys, n, t0, dur = 1.6) => prog(q => sys.lines[n].e.setAttribute('stroke-width', 2.5 + 5 * Math.sin(Math.PI * q)), t0, dur, lin);+const nameAt = (em, nm, at) => prog(q => { if (q > 0) em.setName(nm); }, at, 0, lin);+const namesAt = (em, nm, at) => prog(q => { if (q > 0) em.names(nm); }, at, 0, lin);+// Three words of a row step: "row 2", "+ 3 ×", "row 1", coloured by row.+const stepWords = (p, i, sign, j, x, y, t0, { size = 32 } = {}) => {+ const g = G(p, { o: 0 }), RC = [BLUE, CORAL, YELLOW];+ M(g, [`row ${i + 1}`], { x, y, size, fill: RC[i], anchor: 'start' });+ M(g, [sign], { x: x + size * 3.3, y, size, fill: COL.chalk, anchor: 'start' });+ M(g, [`row ${j + 1}`], { x: x + size * 3.3 + mathW([sign], size) + size * .4, y, size, fill: RC[j], anchor: 'start' });+ show(g, t0, .4);+ return g;+};+const keysOf = ({ A, b }, E = null) => {+ const o = {}, n = A.length;+ A.forEach((r, i) => { r.forEach((x, j) => { o[`a${i}${j}`] = x; o[`e${i}${j}`] = E ? E[i][j] : +(i === j); }); o[`b${i}`] = b[i]; });+ return o;+};+// inside a question: the answer becomes the new [A | b] at once and E the identity (em.carry without the flight)+const carryNow = em => { const o = { ...em.prod() }; for (let i = 0; i < em.n; i++) for (let j = 0; j < em.n; j++) o[`e${i}${j}`] = +(i === j); em.set(o); };+const same = (pr, { A, b }) => A.every((r, i) => r.every((x, j) => Math.abs(pr[`a${i}${j}`] - x) < 1e-9) && Math.abs(pr[`b${i}`] - b[i]) < 1e-9);+const r1 = x => num(Math.round(x * 10) / 10);+const rowTxt = (pr, i, n) => `(${[...Array(n).keys()].map(j => r1(pr[`a${i}${j}`])).join(', ')} | ${r1(pr[`b${i}`])})`;++/* ---------- practice data (every answer worked twice: by the sign rule, and by multiplying back) ---------- */+const UNDOQ = [+ { parts: ['2 × 2: E₂₁ has −4. E₂₁⁻¹ has ', { box: '4' }, ' in row 2, column 1'], why: 'E took 4 × row 1 away; E⁻¹ adds 4 × row 1 back.', hint: 'Change the sign.' },+ { parts: ['2 × 2: E₂₁ has 2. E₂₁⁻¹ has ', { box: '-2' }], why: 'E added 2 × row 1; E⁻¹ takes it away again: −2.', hint: 'E added. To undo an addition, subtract.' },+ { parts: ['3 × 3: E₃₁ has −5 in row 3, column 1. E₃₁⁻¹ has ', { box: '5' }, ' in row ', { box: '3' }, ', column ', { box: '1' }], why: 'The same spot, the other sign: 5 in row 3, column 1.', hint: 'The inverse keeps the spot and changes the sign.' },+ { parts: ['3 × 3: E₃₂ has −½. E₃₂⁻¹ has ', { box: '1/2' }, ' in row 3, column 2'], why: '−½ becomes +½: add half of row 2 back.', hint: 'A fraction works the same way: change its sign.' },+ { parts: ['The step row 2 − 6 × row 1 is undone by: row 2 + ', { box: '6' }, ' × row 1'], why: 'Put back the 6 × row 1 that was taken away.', hint: 'Add back exactly what was taken away.' },+ { parts: ['E⁻¹ has 7 in row 2, column 1. So E has ', { box: '-7' }, ' there'], why: 'E and E⁻¹ undo each other: each is the other with the sign changed.', hint: 'Undoing E⁻¹ gives E back.' },+ { parts: ['x + y = 2, 4x + 3y = 9: elimination takes row 2 − 4 × row 1. E₂₁⁻¹ has ', { box: '4' }], why: 'ℓ = 4 ÷ 1 = 4, E₂₁ has −4, and E₂₁⁻¹ has +4.', hint: 'First the multiplier ℓ = 4 ÷ 1. E has −ℓ; E⁻¹ has +ℓ.' },+];+const ROWQ = [+ { parts: ['E⁻¹: (1, 0), (2, 1); answer: (1, 3 | 4), (0, −1 | 1): old row 2 = (', { box: '2' }, ', ', { box: '5' }, ' | ', { box: '9' }, ')'], why: '2 × (1, 3 | 4) + (0, −1 | 1) = (2, 6 − 1 | 8 + 1).', hint: 'Row 2 of E⁻¹ says: 2 of row 1, plus 1 of row 2.' },+ { parts: ['E⁻¹: (1, 0), (−3, 1); answer: (1, −1 | 2), (0, 1 | 7): old row 2 = (', { box: '-3' }, ', ', { box: '4' }, ' | ', { box: '1' }, ')'], why: '−3 × (1, −1 | 2) = (−3, 3 | −6); add (0, 1 | 7).', hint: '−3 × row 1 is (−3, 3 | −6).' },+ { parts: ['E⁻¹: (1, 0), (4, 1); answer: (2, 1 | 3), (0, −2 | 2): old row 2 = (', { box: '8' }, ', ', { box: '2' }, ' | ', { box: '14' }, ')'], why: '4 × (2, 1 | 3) = (8, 4 | 12); add (0, −2 | 2).', hint: '4 × row 1 is (8, 4 | 12).' },+ { parts: ['row 3 of E⁻¹: (0, 2, 1); rows 2, 3 of the answer: (0, 1, −1 | 0), (0, 0, 5 | 5): old row 3 = (', { box: '0' }, ', ', { box: '2' }, ', ', { box: '3' }, ' | ', { box: '5' }, ')'], why: '2 × (0, 1, −1 | 0) + (0, 0, 5 | 5) = (0, 2, 3 | 5). Row 1 is not used (amount 0).', hint: 'Row 3 of E⁻¹: none of row 1, 2 of row 2, 1 of row 3.' },+ { parts: ['row 2 of E⁻¹: (−1, 1, 0); rows 1, 2 of the answer: (2, 1, 1 | 4), (0, 3, −1 | 2): old row 2 = (', { box: '-2' }, ', ', { box: '2' }, ', ', { box: '-2' }, ' | ', { box: '-2' }, ')'], why: '−1 × (2, 1, 1 | 4) + (0, 3, −1 | 2) = (−2, 2, −2 | −2).', hint: '−1 × row 1 is (−2, −1, −1 | −4).' },+];+const TFQ = [+ { parts: [$m('E⁻¹E = I')], ans: ['t'], why: 'Take away, then put back: nothing has changed.' },+ { parts: [$m('EE⁻¹ = I')], ans: ['t'], why: 'Put back first, then take away: nothing has changed either.' },+ { parts: ['E has rows (1, 0), (3, 1). Its inverse has rows (1, 0), (', $m(F(1, 3)), ', 1).'], ans: ['f'], why: 'Undoing an addition of 3 × row 1 is a subtraction: (1, 0), (−3, 1).' },+ { parts: ['Undoing a step moves the meeting point.'], ans: ['f'], why: 'Every step and its undo keep the solution: the line turns about the meeting point.' },+ { parts: ['The inverse of E⁻¹ is E.'], ans: ['t'], why: 'Each undoes the other.' },+ { parts: ['E₂₁⁻¹ changes row 1.'], ans: ['f'], why: 'It adds a multiple of row 1 to row 2; row 1 stays as it is.' },+];+const PRODQ = [+ { parts: ['E⁻¹ = (1, 0), (5, 1) times E = (1, 0), (−5, 1): row 2 = (', { box: '0' }, ', ', { box: '1' }, ')'], why: '5 × (1, 0) + (−5, 1) = (0, 1): the identity’s row 2.', hint: 'Row 2 of E⁻¹: 5 of row 1 of E, plus row 2 of E.' },+ { parts: ['3 × 3: row 3 of E⁻¹ is (0, 2, 1); rows 2, 3 of E are (0, 1, 0), (0, −2, 1): row 3 of E⁻¹E = (', { box: '0' }, ', ', { box: '0' }, ', ', { box: '1' }, ')'], why: '2 × (0, 1, 0) + (0, −2, 1) = (0, 0, 1).', hint: '2 of row 2 of E, plus row 3 of E.' },+];+// Hands-on in 3D: each starts from the answer of a step; E⁻¹ (the identity at first) must bring the old system back.+const HANDS = [+ { from: AFTER1, to: LEC, only: ['e10'], ans: { e10: 3 }, prompt: 'The step was row 2 − 3 × row 1. Bring row 2 back to (3, 8, 1 | 12).',+ why: '3 in row 2, column 1: row 2 + 3 × row 1 = (3, 8, 1 | 12). The coral plane is back.' },+ { from: U_LEC, to: AFTER1, only: ['e21'], ans: { e21: 2 }, prompt: 'The step was row 3 − 2 × row 2. Bring row 3 back to (0, 4, 1 | 2).',+ why: '2 in row 3, column 2: row 3 + 2 × row 2 = (0, 4, 1 | 2). The yellow plane stands up again.' },+ { from: OWN1, to: OWN, only: ['e10', 'e20'], ans: { e10: 2, e20: -1 }, prompt: 'One E did row 2 − 2 × row 1 and row 3 + row 1. Undo both: rows 2 and 3 back to (2, 3, 1 | 6) and (−1, 1, 2 | 2).',+ why: '2 and −1: row 2 + 2 × row 1 and row 3 − row 1. Each number changes sign.' },+];+const handHint = h => (v, pr) => {+ const bad = [1, 2].filter(i => rowTxt(pr, i, 3) !== rowTxt(h.to, i, 3) && (i === 1 || h.to.A[i]));+ const i = bad[0] ?? 1;+ return `Row ${i + 1} is ${rowTxt(pr, i, 3)}, not ${rowTxt(h.to, i, 3)}. What did the step take away from it?`;+};++/* ---------- beats ---------- */+const BEATS = [+ ['intro', 'Undoing elimination', (m, D) => {+ const g = G(scene, { o: 0, y: 24 });+ T(g, 'Unit 4 · Factorization into A = LU', { x: 800, y: 205, size: 24, fill: COL.faint, anchor: 'middle' });+ T(g, 'Unit 4, Chapter 29', { x: 800, y: 250, size: 28, fill: COL.dim, anchor: 'middle' });+ T(g, 'Undoing Elimination', { x: 800, y: 360, size: 88, weight: 600, anchor: 'middle' });+ tw(g, { o: 1, y: 0 }, .2, 1.1, out);+ const r = text(scene, 'every step can be undone: add back what it took away', 800, 460, m('sub'), { size: 34, fill: COL.dim, anchor: 'middle' });+ const lg = G(scene, { o: 0 });+ const s = bare([[1, 2], [3, 4]]); s.v.b0 = 5; s.v.b1 = 11;+ const em = emat(lg, s, { A: [[1, 2], [3, 4]], b: [5, 11], at: [380, 640], size: 36, cw: 62, ecw: 54, rh: 56, t0: 0 });+ show(lg, m('sub') + 1.2, .5);+ em.ringE(1, 0, m('move'));+ em.to({ e10: -3 }, m('move') + .2, 1.2);+ em.to({ e10: 0 }, m('move') + 2.2, 1.2); // and back: the answer is A again+ tw(g, { o: 0, y: -24 }, D - .9, .8); hide(r, D - .9, .8); hide(lg, D - .9, .8);+ }],++ ['recall', 'One step, as a matrix', (m) => {+ const p = panel(0);+ text(p, 'One step, as a matrix', 60, 110, .2, { size: 40, weight: 600 });+ const { sys, em } = two(p, CH16, 'x + 2y = 5, 3x + 4y = 11', { t0: .4 });+ em.setName('E₂₁');+ [0, 1].forEach(i => { em.B.flash(i, m('sys') + 2.3 + 2.5 * i); thick(sys, i, m('sys') + 2.3 + 2.5 * i); });+ pin(sys, 1, 2, m('e') - 2.4); pulse(sys.meet, m('e') - 2.2);+ stepWords(p, 1, '− 3 ×', 0, 70, 650, m('e') + .6);+ em.flashE(0, m('e') + 5.4); em.flashE(1, m('e') + 5.9);+ em.ringE(1, 0, m('e') + 7.4);+ em.focusE(1, m('go')); em.Pt.focus(1, m('go'));+ ghost(sys, 3, 4, 1, 2, m('go'));+ em.to({ e10: -3 }, m('go') + .2, Math.max(1.6, m('res') - m('go')));+ em.work(1, 0, { times: [m('w'), m('w') + 1.6, m('res')] });+ em.Pt.flash(1, m('res') + .2);+ thick(sys, 1, m('flat') + .4);+ em.focusE(null, m('ask')); em.Pt.focus(null, m('ask'));+ text(p, 'How do we get back?', 70, 730, m('ask') + .3, { size: 36, weight: 600 });+ text(p, 'which matrix turns the flat line back?', 70, 780, m('ask') + 2.8, { size: 28, fill: COL.dim, weight: 600 });+ }],++ ['undo', 'Add it back', (m) => {+ const p = panel(0);+ text(p, 'Add it back', 60, 110, .2, { size: 40, weight: 600 });+ const { sys, em } = two(p, CH16, 'x + 2y = 5, 3x + 4y = 11', { E: E21 });+ em.setName('E₂₁');+ ghost(sys, 3, 4, 1, 2, .4); pin(sys, 1, 2, .6);+ em.flashE(1, m('took') + .3, 0);+ stepWords(p, 1, '− 3 ×', 0, 70, 640, m('took'));+ em.Pt.flash(0, m('kept') + .5); em.B.flash(0, m('kept') + 1.2);+ text(p, 'row 1 is not touched: (1, 2 | 5)', 70, 700, m('kept'), { size: 28, fill: COL.dim, weight: 600 });+ stepWords(p, 1, '+ 3 ×', 0, 70, 770, m('back'));+ em.carry(m('carry'), 1.3, { names: ['EA', 'Eb', '', ''] });+ nameAt(em, '', m('carry') + 1.3);+ em.ringE(1, 0, m('e'));+ em.focusE(1, m('e')); em.Pt.focus(1, m('e'));+ em.work(1, 0, { times: [m('w'), m('w') + 2.6, m('res')] });+ em.to({ e10: 3 }, m('w') + .2, Math.max(1.8, m('res') - m('w')));+ namesAt(em, ['EA', 'Eb', 'A', 'b'], m('res'));+ em.Pt.flash(1, m('res') + .2);+ thick(sys, 1, m('line') + .3);+ pulse(sys.meet, m('pin') + .3);+ }],++ ['inverse', 'E inverse', (m) => {+ const p = panel(0);+ text(p, 'E inverse', 60, 110, .2, { size: 40, weight: 600 });+ const sys = linsys(p, { A: CH16.A, b: CH16.b, eq: [90, 200], mat: null, sol: false, plane: { cx: 1215, u: 50 } });+ sys.E.style.visibility = 'hidden'; // hidden, yet measured (display: none measures as 0 and replays differ)+ pin(sys, 1, 2, .6);+ const part = G(p, { o: 0 }); show(part, m('name'), .5);+ const em = mm2(part, [[1, 0], [3, 1]], E21, ['E', '', 'E⁻¹E', ''], 'E⁻¹', 0);+ put(em.Pt.g, { o: 0 }); put(em.eqSign, { o: 0 }); show(em.Pt.g, m('calc'), .5); show(em.eqSign, m('calc'), .4);+ const c26 = text(p, 'chapter 26: the inverse of a matrix undoes it', 70, 600, m('name') + 3.4, { size: 26, fill: COL.dim, weight: 600 });+ hide(c26, m('why') - .3, .4);+ em.ringE(1, 0, m('cmp') + 1.6); em.B.ring(1, 0, m('cmp') + .4);+ stepWords(p, 1, '− 3 ×', 0, 150, 640, m('why')); say(p, ['E:'], 120, 640, m('why'), { size: 32, anchor: 'end' });+ stepWords(p, 1, '+ 3 ×', 0, 150, 700, m('why') + 2.4); say(p, ['E⁻¹:'], 120, 700, m('why') + 2.4, { size: 32, anchor: 'end' });+ // the round trip on the plane: E, then E⁻¹+ const tag = G(p, { o: 0 }); M(tag, ['E'], { x: 1400, y: 215, size: 34, fill: COL.chalk, anchor: 'middle' });+ const tag2 = G(p, { o: 0 }); M(tag2, ['then E⁻¹'], { x: 1400, y: 215, size: 34, fill: COL.chalk, anchor: 'middle' });+ show(tag, m('ii'), .3); hide(tag, m('ii') + 2, .3); show(tag2, m('ii') + 2.2, .3); hide(tag2, m('calc'), .4);+ sys.to({ a10: 0, a11: -2, b1: -4 }, m('ii') + .3, 1.5);+ sys.to({ a10: 3, a11: 4, b1: 11 }, m('ii') + 2.5, 1.5);+ em.work(0, 0, { times: [m('calc') + 3.4, m('calc') + 4.2, m('r1')] }); em.Pt.flash(0, m('r1') + .2);+ em.work(1, 0, { times: [m('r2') + 1.8, m('r2') + 4.4, m('res')] }); em.Pt.flash(1, m('res') + .2);+ em.B.flash(0, m('r2') + 5.6); em.B.flash(1, m('r2') + 8.6);+ em.Pt.diag(m('eye'), { color: COL.good });+ say(p, ['E⁻¹E = I'], 70, 780, m('eye') + 2.6, { size: 40 });+ }],++ ['q1', 'Quick check', () => {+ const p = panel(0);+ text(p, 'Quick check', 60, 110, .2, { size: 40, weight: 600 });+ const t = two(p, { A: [[1, 1], [0, -2]], b: [2, -2] }, 'after row 2 − 5 × row 1: x + y = 2, −2y = −2');+ t.em.setName('E⁻¹');+ t.em.names(['EA', 'Eb', '', '']);+ ghost(t.sys, 5, 3, 1, 1, .4);+ S.em = t.em;+ }, { ask: done => quiz({ x: 40, y: 518, w: 760, cls: 'side' }, [{+ id: 'c-undo', prompt: ['The step was row 2 − 5 × row 1. Undo it.'],+ build: blanks([+ { parts: ['E₂₁⁻¹ has ', { box: '5' }, ' in row 2, column 1'], why: 'E₂₁ had −5. The inverse has +5: add 5 × row 1 back.', hint: 'Change the sign of E₂₁’s number.',+ fx: () => fxp(q => S.em.set({ e10: 5 * q }), 0, 1.6) },+ { parts: ['the old row 2 comes back: (', { box: '5' }, ', ', { box: '3' }, ' | ', { box: '8' }, ')'], why: '5 × (1, 1 | 2) + (0, −2 | −2) = (5, 3 | 8): 5x + 3y = 8, the dashed line.', hint: '5 × row 1 is (5, 5 | 10). Add the new row 2.' },+ ]),+ }], done) }],++ ['ex2', 'A plus sign', (m) => {+ const p = panel(0);+ text(p, 'Undoing a plus sign', 60, 110, .2, { size: 40, weight: 600 });+ const { sys, em } = two(p, CH17, 'x + 2y = 3, −2x + y = 4', { t0: m('sys') - .3 });+ em.setName('E₂₁');+ pin(sys, -1, 2, m('sys') + 4); ghost(sys, -2, 1, -1, 2, m('go'));+ em.ringE(1, 0, m('e') + 2);+ em.focusE(1, m('go')); em.Pt.focus(1, m('go'));+ em.work(1, m('go'));+ em.to({ e10: 2 }, m('go') + .2, 1.8);+ thick(sys, 1, m('go') + 2.2);+ em.work(null, m('carry'), .3);+ em.carry(m('carry') + .2, 1.2, { names: ['EA', 'Eb', '', ''] });+ nameAt(em, 'E⁻¹', m('inv'));+ em.ringE(1, 0, m('inv') + .3);+ em.work(1, 0, { times: [m('w'), m('w') + 2.6, m('res')] });+ em.to({ e10: -2 }, m('w') + .2, Math.max(1.8, m('res') - m('w')));+ namesAt(em, ['EA', 'Eb', 'A', 'b'], m('res'));+ em.Pt.flash(1, m('res') + .2);+ thick(sys, 1, m('line') + .2);+ em.focusE(null, m('rule')); em.Pt.focus(null, m('rule'));+ text(p, 'to undo a step, change the sign of its one number:', 70, 680, m('rule') + .6, { size: 28, weight: 600 });+ say(p, ['−ℓ → +ℓ'], 70, 740, m('rule') + 3.4, { size: 36 });+ }],++ ['twice', 'Either order', (m) => {+ const p = panel(0);+ text(p, 'The other order', 60, 110, .2, { size: 40, weight: 600 });+ const sys = linsys(p, { A: CH17.A, b: CH17.b, eq: [90, 200], mat: null, sol: false, plane: { cx: 1215, u: 50 } });+ sys.E.style.visibility = 'hidden'; // hidden, yet measured (display: none measures as 0 and replays differ)+ pin(sys, -1, 2, .6);+ const em = mm2(p, [[1, 0], [2, 1]], [[1, 0], [-2, 1]], ['E⁻¹', '', 'EE⁻¹', ''], 'E', .3);+ put(em.Pt.g, { o: 0 }); put(em.eqSign, { o: 0 }); show(em.Pt.g, m('calc'), .5); show(em.eqSign, m('calc'), .4);+ em.B.ring(1, 0, m('first') + 1.6); em.ringE(1, 0, m('first') + 3.6);+ const tag = G(p, { o: 0 }); M(tag, ['E⁻¹'], { x: 1400, y: 215, size: 34, fill: COL.chalk, anchor: 'middle' });+ const tag2 = G(p, { o: 0 }); M(tag2, ['then E'], { x: 1400, y: 215, size: 34, fill: COL.chalk, anchor: 'middle' });+ show(tag, m('pic'), .3); hide(tag, m('pic') + 2, .3); show(tag2, m('pic') + 2.2, .3); hide(tag2, m('calc'), .4);+ sys.to({ a10: -4, a11: -3, b1: -2 }, m('pic') + .2, 1.5);+ sys.to({ a10: -2, a11: 1, b1: 4 }, m('pic') + 2.4, 1.5);+ em.work(0, 0, { times: [m('calc') + 2.4, m('calc') + 2.8, m('r2') - .3] }); em.Pt.flash(0, m('r2') - .2);+ em.work(1, 0, { times: [m('r2') + 2.4, m('r2') + 5.2, m('res')] }); em.Pt.flash(1, m('res') + .2);+ em.Pt.diag(m('eye'), { color: COL.good });+ say(p, ['E⁻¹E = I'], 70, 720, m('both') + .3, { size: 40 });+ say(p, ['EE⁻¹ = I'], 400, 720, m('both') + 1.8, { size: 40 });+ text(p, 'taking away and putting back undo each other, in either order', 70, 790, m('both') + 4, { size: 26, fill: COL.dim, weight: 600 });+ }],++ ['q2', 'Your turn', () => {+ const p = panel(0);+ text(p, 'Your turn', 60, 110, .2, { size: 40, weight: 600 });+ const t = two(p, { A: [[2, 1], [0, 1]], b: [4, 2] }, 'after row 2 − 3 × row 1: 2x + y = 4, y = 2');+ t.em.setName('E⁻¹'); t.em.names(['EA', 'Eb', '', '']);+ ghost(t.sys, 6, 4, 1, 2, .4); pin(t.sys, 1, 2, .5);+ t.em.work(1, .3);+ S.em = t.em;+ }, { ask: done => quiz(CARD2, [{+ id: 'c-back', prompt: ['Change the number in row 2, column 1 of E⁻¹ until the coral line lies on the dashed line, 6x + 4y = 14.'],+ build: emTask(S.em, (v, pr) => Math.abs(pr.a10 - 6) < 1e-9, '3: row 2 + 3 × row 1 = (6, 4 | 14). The step took 3 × row 1 away; E⁻¹ puts it back.',+ (v, pr) => `Row 2 is now ${rowTxt(pr, 1, 2)}. The step was row 2 − 3 × row 1: what puts it back?`, () => S.em.set({ e10: 3 }), { only: ['e10'] }),+ }], done) }],++ ['three', 'Three equations', (m) => {+ const p = panel(0);+ text(p, 'Undo in three dimensions', 60, 110, .2, { size: 40, weight: 600 });+ const { sys, em, V } = three(p, LEC, 'x + 2y + z = 2, 3x + 8y + z = 12, 4y + z = 2', { t0: m('sys') - .3 });+ em.setName('E₂₁');+ [0, 1, 2].forEach(i => em.B.flash(i, m('sys') + .6 + 1.6 * i));+ em.ringE(1, 0, m('e') + .6);+ em.focusE(1, m('go')); em.Pt.focus(1, m('go'));+ em.work(1, m('go') + 4);+ em.to({ e10: -3 }, m('go') + .2, 2.6);+ hinge(sys, 0, m('go') + 2, 2);+ V.turn({ yaw: -15 }, m('go'), 6);+ em.work(null, m('carry'), .3);+ em.carry(m('carry') + .2, 1.2, { names: ['EA', 'Eb', '', ''] });+ nameAt(em, 'E₂₁⁻¹', m('inv'));+ em.ringE(1, 0, m('inv') + .4);+ em.flashE(1, m('inv') + 3.2, 0); em.Pt.flash(1, m('inv') + 4.6);+ V.turn({ yaw: -28, pitch: 26 }, m('inv'), 6);+ em.work(1, 0, { times: [m('w') + 1.6, m('w') + 5.6, m('w') + 6.2, m('res')] });+ em.to({ e10: 3 }, m('w') + 1.4, Math.max(2, m('res') - m('w') - 1.4));+ namesAt(em, ['EA', 'Eb', 'A', 'b'], m('res'));+ em.Pt.flash(1, m('res') + .2);+ hinge(sys, 0, m('back') + .2, 2);+ V.turn({ yaw: -45 }, m('back'), 5);+ em.focusE(null, m('same')); em.Pt.focus(null, m('same'));+ [0, 2].forEach((i, k) => { em.Pt.flash(i, m('same') + .5 + 1.4 * k); sys.focus(i, m('same') + .5 + 1.4 * k); });+ sys.focus(null, m('same') + 3.6);+ }],++ ['e32', 'Undo E₃₂', (m, D) => {+ const p = panel(0);+ text(p, 'Undo the second step', 60, 110, .2, { size: 40, weight: 600 });+ const { sys, em, V } = three(p, AFTER1, 'after column 1: x + 2y + z = 2, 2y − 2z = 6, 4y + z = 2', { view: { yaw: -20, pitch: 20 } });+ em.setName('E₃₂');+ em.ringE(2, 1, m('e') + 1.4);+ em.focusE(2, m('e')); em.Pt.focus(2, m('e'));+ em.work(2, m('go'));+ em.to({ e21: -2 }, m('go'), 2);+ sys.focus(2, m('go') + 1);+ V.turn({ yaw: 0, pitch: 34 }, m('go') - .5, 3);+ em.work(null, m('inv') - .3, .3);+ em.carry(m('inv'), 1.2, { names: ['EA', 'Eb', '', ''] });+ nameAt(em, 'E₃₂⁻¹', m('inv') + 1.2);+ em.ringE(2, 1, m('inv') + 1.4);+ em.work(2, 0, { times: [m('w'), m('w') + .5, m('w') + 1, m('back')] });+ em.to({ e21: 2 }, m('w') + .3, Math.max(1.8, m('back') - m('w')));+ namesAt(em, ['EA', 'Eb', 'A', 'b'], m('back'));+ em.Pt.flash(2, m('back') + .2);+ V.turn({ yaw: -30, pitch: 20 }, m('back'), 3);+ sys.focus(null, m('rule'));+ em.focusE(null, m('rule')); em.Pt.focus(null, m('rule'));+ text(p, 'E⁻¹ = E with the sign of its one number changed', 64, 690, m('rule') + 1, { size: 28, weight: 600 });+ em.flashE(2, m('rule') + 3.4, 1); V.turn({ yaw: -45, pitch: 24 }, m('rule'), Math.max(2, D - m('rule')));+ }],++ ['q3', 'Quick check', () => {+ const p = panel(0);+ text(p, 'Quick check', 60, 110, .2, { size: 40, weight: 600 });+ const t = two(p, { A: [[1, 1], [-4, -2]], b: [3, -10] }, 'x + y = 3, −4x − 2y = −10', { E: [[1, 0], [4, 1]] });+ ghost(t.sys, -4, -2, 2, 1, .4);+ S.em = t.em;+ }, { ask: done => quiz({ x: 40, y: 560, w: 760, cls: 'side' }, [{+ id: 'c-which', prompt: ['E has rows (1, 0) and (4, 1): it adds 4 × row 1 to row 2. Which matrix undoes it?'],+ build: choice(['rows (1, 0) and (−4, 1)', ['rows (1, 0) and (', $m(F(1, 4)), ', 1)'], 'rows (1, 0) and (4, 1)', 'rows (−1, 0) and (−4, −1)'], 0,+ 'Take 4 × row 1 away again: −4. Row 2 of the product is −4 × (1, 0) + (4, 1) = (0, 1).',+ [null, 'Undoing an addition is a subtraction, not a division: ¼ × row 1 would leave 4¼ of row 1 added.', 'That is E itself: it would add 4 × row 1 a second time.', 'Only the one number changes sign. A −1 on the diagonal would turn whole rows upside down.'],+ () => { carryNow(S.em); fxp(q => S.em.set({ e10: -4 * q }), 0, 1.6); }),+ }], done) }],++ ['q4', 'Your turn', () => {+ const p = panel(0);+ text(p, 'Your turn', 60, 110, .2, { size: 40, weight: 600 });+ const t = three(p, { A: [[1, 1, 1], [2, 3, 1], [0, 2, 3]], b: [3, 6, 5] }, 'after row 3 + row 1: x + y + z = 3, 2x + 3y + z = 6, 2y + 3z = 5');+ t.em.setName('E⁻¹'); t.em.names(['EA', 'Eb', '', '']);+ t.em.work(2, .3);+ S.em = t.em;+ }, { ask: done => quiz(CARD3, [{+ id: 'c-back3', prompt: ['The step was row 3 + row 1. Change E⁻¹’s number in row 3, column 1 until row 3 is (−1, 1, 2 | 2) again.'],+ build: emTask(S.em, (v, pr) => Math.abs(pr.a20 + 1) < 1e-9, '−1: row 3 − row 1 = (−1, 1, 2 | 2). The step added row 1; its inverse takes it away.',+ (v, pr) => `Row 3 is now ${rowTxt(pr, 2, 3)}. The step added 1 × row 1. Undo that.`, () => S.em.set({ e20: -1 }), { only: ['e20'] }),+ }], done) }],++ ['wrap', 'Summary', (m) => {+ const p = panel(0);+ [['Each step of elimination can be undone: add back what it took away.', 'w1'], ['E⁻¹ is E with the sign of its one number changed: −ℓ becomes +ℓ.', 'w2'],+ ['E⁻¹E = I and EE⁻¹ = I: the line turns away and back, about the same point.', 'w3'], ['It works because a step never changes the row it uses.', 'w4']].forEach(([str, mark], i) => {+ const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });+ mk('circle', { cx: 120, cy: -12, r: 26, fill: COL.chalk }, g);+ T(g, String(i + 1), { x: 120, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });+ T(g, str, { x: 170, size: 34, weight: 600 });+ tw(g, { o: 1, x: 0 }, m(mark), .6);+ });+ }],+ ['final1', 'Chapter practice', () => { panel(0); }, { ask: done => quiz(SCREEN, [{+ id: 'p-undo', prompt: ['Find the number that undoes each step.'],+ build: blanks(UNDOQ),+ }], done, 'Chapter practice · set 1 of 4') }],+ ['final2', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{+ id: 'p-row', prompt: ['E⁻¹ times the answer gives back the old rows. Rows are written (numbers of A | right side).'],+ build: blanks(ROWQ.slice(0, 3)),+ }, {+ id: 'p-row3', prompt: ['Three equations now. Each row of E⁻¹ says how much of each row of the answer to take.'],+ build: blanks(ROWQ.slice(3)),+ }], done, 'Chapter practice · set 2 of 4') }],+ ['final3', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{+ id: 'p-tf', prompt: ['True or false?'],+ build: grid(TFQ, TF, { text: true }),+ }, {+ id: 'p-prod', prompt: ['Multiply E⁻¹ times E, one row. Each row of the left matrix mixes the rows of the right one.'],+ build: blanks(PRODQ),+ }], done, 'Chapter practice · set 3 of 4') }],+ ['final4', 'Chapter practice', () => {+ const p = panel(0);+ text(p, 'Undo the steps with E⁻¹', 60, 110, .2, { size: 40, weight: 600 });+ const t = three(p, AFTER1, '');+ t.em.setName('E⁻¹'); t.em.names(['EA', 'Eb', '', '']);+ S.em = t.em;+ }, { ask: done => quiz(CARD3, HANDS.map((h, k) => ({+ id: `p-hand${k + 1}`, prompt: [h.prompt],+ build: (body, api) => { S.em.set(keysOf(h.from)); S.em.work(+h.only[h.only.length - 1][1], 0); return emTask(S.em, (v, pr) => same(pr, h.to), h.why, handHint(h), () => S.em.set(h.ans), { only: h.only })(body, api); },+ })), done, 'Chapter practice · set 4 of 4') }],+ ['play', 'Playground', (m) => {+ const p = panel(0);+ text(p, 'Playground', 60, 110, .2, { size: 40, weight: 600 });+ const t = two(p, CH16, '');+ ghost(t.sys, 3, 4, 1, 2, .3);+ S.em = t.em;+ t.em.work(1, .3);+ text(p, 'try: −3 in E makes the line flat; type the flat row into A | b, then find the E that turns it back', 70, 175, m('go'), { size: 24, fill: COL.dim });+ }, { ask: playAsk(() => S.em, { pos: { x: 40, y: 586, w: 760, cls: 'side' }, tip: 'Your matrices. Change any number of E or of A | b, drag a line, or draw on the board. Nothing is marked.' }) }],+ ['finish', 'Finished', () => { panel(0); }, { ask: finishCard }],+].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));++boot();+</script>+</body>+</html>diff --git a/site/linear-algebra/ch30/audio/en/back.mp3 b/site/linear-algebra/ch30/audio/en/back.mp3new file mode 100644index 0000000..0b7e9a4Binary files /dev/null and b/site/linear-algebra/ch30/audio/en/back.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/check3.mp3 b/site/linear-algebra/ch30/audio/en/check3.mp3new file mode 100644index 0000000..a4fa139Binary files /dev/null and b/site/linear-algebra/ch30/audio/en/check3.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/ex2.mp3 b/site/linear-algebra/ch30/audio/en/ex2.mp3new file mode 100644index 0000000..c8e09e4Binary files /dev/null and b/site/linear-algebra/ch30/audio/en/ex2.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/ex3.mp3 b/site/linear-algebra/ch30/audio/en/ex3.mp3new file mode 100644index 0000000..8dcf1d1Binary files /dev/null and b/site/linear-algebra/ch30/audio/en/ex3.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/final1.mp3 b/site/linear-algebra/ch30/audio/en/final1.mp3new file mode 100644index 0000000..4455758Binary files /dev/null and b/site/linear-algebra/ch30/audio/en/final1.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/final2.mp3 b/site/linear-algebra/ch30/audio/en/final2.mp3new file mode 100644index 0000000..1e3ba57Binary files /dev/null and b/site/linear-algebra/ch30/audio/en/final2.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/final3.mp3 b/site/linear-algebra/ch30/audio/en/final3.mp3new file mode 100644index 0000000..3920e8cBinary files /dev/null and b/site/linear-algebra/ch30/audio/en/final3.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/final4.mp3 b/site/linear-algebra/ch30/audio/en/final4.mp3new file mode 100644index 0000000..515caa3Binary files /dev/null and b/site/linear-algebra/ch30/audio/en/final4.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/finish.mp3 b/site/linear-algebra/ch30/audio/en/finish.mp3new file mode 100644index 0000000..d064297Binary files /dev/null and b/site/linear-algebra/ch30/audio/en/finish.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/intro.mp3 b/site/linear-algebra/ch30/audio/en/intro.mp3new file mode 100644index 0000000..9cfdad8Binary files /dev/null and b/site/linear-algebra/ch30/audio/en/intro.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/play.mp3 b/site/linear-algebra/ch30/audio/en/play.mp3new file mode 100644index 0000000..1884039Binary files /dev/null and b/site/linear-algebra/ch30/audio/en/play.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/q1.mp3 b/site/linear-algebra/ch30/audio/en/q1.mp3new file mode 100644index 0000000..1a77769Binary files /dev/null and b/site/linear-algebra/ch30/audio/en/q1.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/q2.mp3 b/site/linear-algebra/ch30/audio/en/q2.mp3new file mode 100644index 0000000..16aa2bbBinary files /dev/null and b/site/linear-algebra/ch30/audio/en/q2.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/q3.mp3 b/site/linear-algebra/ch30/audio/en/q3.mp3new file mode 100644index 0000000..e4f9ce9Binary files /dev/null and b/site/linear-algebra/ch30/audio/en/q3.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/q4.mp3 b/site/linear-algebra/ch30/audio/en/q4.mp3new file mode 100644index 0000000..826bf57Binary files /dev/null and b/site/linear-algebra/ch30/audio/en/q4.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/recall.mp3 b/site/linear-algebra/ch30/audio/en/recall.mp3new file mode 100644index 0000000..6e258bfBinary files /dev/null and b/site/linear-algebra/ch30/audio/en/recall.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/shape.mp3 b/site/linear-algebra/ch30/audio/en/shape.mp3new file mode 100644index 0000000..31bad7eBinary files /dev/null and b/site/linear-algebra/ch30/audio/en/shape.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/three.mp3 b/site/linear-algebra/ch30/audio/en/three.mp3new file mode 100644index 0000000..94017b7Binary files /dev/null and b/site/linear-algebra/ch30/audio/en/three.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/times.mp3 b/site/linear-algebra/ch30/audio/en/times.mp3new file mode 100644index 0000000..0a70903Binary files /dev/null and b/site/linear-algebra/ch30/audio/en/times.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/timings.js b/site/linear-algebra/ch30/audio/en/timings.jsnew file mode 100644index 0000000..4471526--- /dev/null+++ b/site/linear-algebra/ch30/audio/en/timings.js@@ -0,0 +1,731 @@+window.TIMINGS = {+ "intro": {+ "dur": 11.4,+ "marks": {+ "sub": 3.086,+ "move": 8.906+ },+ "cues": [+ [+ 0.104,+ "Chapter thirty."+ ],+ [+ 1.445,+ "A equals L U."+ ],+ [+ 3.086,+ "Elimination takes A to U."+ ],+ [+ 5.547,+ "Run it backwards, and A becomes L times U."+ ],+ [+ 8.906,+ "L puts back what elimination took away."+ ]+ ]+ },+ "recall": {+ "dur": 49.104,+ "marks": {+ "sys": 2.292,+ "piv": 9.323,+ "l": 13.047,+ "e": 17.331,+ "go": 21.25,+ "res": 26.549,+ "flat": 28.984,+ "u": 31.055,+ "c": 41.641,+ "eau": 45.99+ },+ "cues": [+ [+ 0.13,+ "Here is the lecture's example."+ ],+ [+ 2.292,+ "Two x plus y equals three, and eight x plus seven y equals fifteen."+ ],+ [+ 7.943,+ "They meet at one, one."+ ],+ [+ 9.323,+ "The pivot is two."+ ],+ [+ 10.911,+ "The number to remove is eight."+ ],+ [+ 13.047,+ "Eight divided by two is four: that's the multiplier."+ ],+ [+ 17.331,+ "So E two one has minus four in row two, column one."+ ],+ [+ 21.25,+ "Multiply."+ ],+ [+ 22.266,+ "Row two becomes minus four times row one, plus row two: zero, three, three."+ ],+ [+ 28.984,+ "The coral line lies flat."+ ],+ [+ 31.055,+ "What's left of A has a zero below its diagonal: two, one, and zero, three."+ ],+ [+ 37.018,+ "A matrix like this is called upper triangular, and we call it U."+ ],+ [+ 41.641,+ "The right side changed too, to three, three."+ ],+ [+ 44.818,+ "We call that c."+ ],+ [+ 45.99,+ "In symbols: E times A equals U."+ ]+ ]+ },+ "back": {+ "dur": 31.944,+ "marks": {+ "start": 3.203,+ "mul": 5.26,+ "left": 8.997,+ "right": 16.966,+ "res": 19.583,+ "pic": 22.188,+ "name": 27.005,+ "lu": 30.091+ },+ "cues": [+ [+ 0.104,+ "Now go the other way, from U back to A."+ ],+ [+ 3.203,+ "Start from E A equals U."+ ],+ [+ 5.26,+ "Multiply both sides by E inverse, on the left."+ ],+ [+ 8.997,+ "On the left, E inverse times E is the identity, from chapter twenty-nine, and the identity times A is just A."+ ],+ [+ 16.966,+ "On the right, we get E inverse times U."+ ],+ [+ 19.583,+ "So A equals E inverse times U."+ ],+ [+ 22.188,+ "In the picture: E made the line flat, and E inverse turns it back."+ ],+ [+ 27.005,+ "This E inverse gets its own name: L."+ ],+ [+ 30.091,+ "A equals L times U."+ ]+ ]+ },+ "times": {+ "dur": 42.216,+ "marks": {+ "set": 1.914,+ "l": 6.797,+ "r1": 13.19,+ "r2": 20.13,+ "res": 30.208,+ "back": 33.034,+ "lu": 38.346+ },+ "cues": [+ [+ 0.104,+ "Let's check it by multiplying."+ ],+ [+ 1.914,+ "Here is U, with c beside it, and in front of them, L."+ ],+ [+ 6.797,+ "L is E inverse: the identity, with plus four in row two, column one."+ ],+ [+ 13.19,+ "Row one of L is one, zero, so row one of the answer is row one of U: two, one, three."+ ],+ [+ 20.13,+ "Row two of L is four, one."+ ],+ [+ 22.565,+ "Four times row one of U is eight, four, twelve."+ ],+ [+ 26.25,+ "Add row two of U, zero, three, three, and you get eight, seven, fifteen."+ ],+ [+ 33.034,+ "That's the second row of A, and of b."+ ],+ [+ 36.081,+ "The line has turned back onto where it started."+ ],+ [+ 38.346,+ "L times U is A."+ ],+ [+ 39.974,+ "And L times c is b."+ ]+ ]+ },+ "shape": {+ "dur": 34.344,+ "marks": {+ "u": 2.539,+ "piv": 6.615,+ "l": 10.404,+ "one": 14.609,+ "m": 19.727,+ "name": 27.279+ },+ "cues": [+ [+ 0.091,+ "Look at the shapes of L and U."+ ],+ [+ 2.539,+ "U has a zero below its diagonal: it's upper triangular."+ ],+ [+ 6.615,+ "On its diagonal sit the pivots, two and three."+ ],+ [+ 10.404,+ "L has a zero above its diagonal: it's lower triangular."+ ],+ [+ 14.609,+ "On its diagonal are ones: each row keeps one copy of itself."+ ],+ [+ 19.727,+ "And below the diagonal sits the multiplier, four, in row two, column one: the spot of the eight it removed."+ ],+ [+ 27.279,+ "So A equals L U means: A equals a lower triangular matrix times an upper triangular one."+ ]+ ]+ },+ "q1": {+ "dur": 4.92,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Quick check."+ ],+ [+ 1.159,+ "Find the multiplier, U and L for this system."+ ]+ ]+ },+ "ex2": {+ "dur": 43.992,+ "marks": {+ "sys": 3.242,+ "l": 8.737,+ "go": 12.487,+ "u": 20.469,+ "carry": 24.492,+ "lmat": 25.664,+ "w": 30.286,+ "res": 37.565,+ "back": 39.57+ },+ "cues": [+ [+ 0.091,+ "A second example: chapter sixteen's system."+ ],+ [+ 3.242,+ "x plus two y equals five, and three x plus four y equals eleven."+ ],+ [+ 8.737,+ "The multiplier is three divided by one: three."+ ],+ [+ 12.487,+ "Elimination subtracts three times row one, and row two becomes zero, minus two, minus four."+ ],+ [+ 20.469,+ "So U is one, two, and zero, minus two."+ ],+ [+ 24.492,+ "Now go back."+ ],+ [+ 25.664,+ "L has the multiplier, three, in row two, column one."+ ],+ [+ 30.286,+ "Three times row one of U is three, six, fifteen."+ ],+ [+ 34.232,+ "Add zero, minus two, minus four, and you get three, four, eleven."+ ],+ [+ 39.57,+ "The line is back where it started, and L times U equals A."+ ]+ ]+ },+ "ex3": {+ "dur": 43.656,+ "marks": {+ "sys": 2.37,+ "l": 8.164,+ "go": 12.8,+ "u": 20.625,+ "carry": 23.919,+ "lmat": 24.922,+ "e": 28.398,+ "w": 36.302,+ "res": 39.922,+ "back": 42.76+ },+ "cues": [+ [+ 0.104,+ "One more, with a minus sign."+ ],+ [+ 2.37,+ "Two x plus y equals three, and minus six x plus y equals minus five."+ ],+ [+ 8.164,+ "The multiplier is minus six divided by two: minus three."+ ],+ [+ 12.8,+ "Row two minus minus three times row one is row two plus three times row one: zero, four, four."+ ],+ [+ 20.625,+ "U is two, one, and zero, four."+ ],+ [+ 23.919,+ "Now back."+ ],+ [+ 24.922,+ "L holds the multiplier itself: minus three."+ ],+ [+ 28.398,+ "Careful here."+ ],+ [+ 29.492,+ "E had plus three, and L has minus three."+ ],+ [+ 32.826,+ "E takes ell times a row away; L puts it back."+ ],+ [+ 36.302,+ "Minus three times row one of U, plus row two of U, gives minus six, one, minus five."+ ],+ [+ 42.76,+ "A again."+ ]+ ]+ },+ "q2": {+ "dur": 5.376,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Your turn."+ ],+ [+ 1.094,+ "Find the multiplier that makes the line flat, and watch where it goes."+ ]+ ]+ },+ "three": {+ "dur": 67.248,+ "marks": {+ "sys": 3.503,+ "l": 12.773,+ "s1": 17.591,+ "w1": 25.182,+ "s2": 31.862,+ "w2": 40.99,+ "s3": 44.349,+ "w3": 50.391,+ "u": 53.255,+ "done": 55.404+ },+ "cues": [+ [+ 0.104,+ "Now three equations, from chapter twenty-one."+ ],+ [+ 3.503,+ "x plus y plus z equals three, two x plus three y plus z equals six, and minus x plus y plus two z equals two."+ ],+ [+ 12.773,+ "Beside the table is L, still empty below its diagonal."+ ],+ [+ 17.591,+ "First, row two minus two times row one."+ ],+ [+ 21.341,+ "Row two becomes zero, one, minus one, zero."+ ],+ [+ 25.182,+ "Write the two into L, in row two, column one: the row we changed, and the row we used."+ ],+ [+ 31.862,+ "Next, row three minus minus one times row one, which is row three plus row one: zero, two, three, five."+ ],+ [+ 40.99,+ "Minus one goes into row three, column one."+ ],+ [+ 44.349,+ "Last, row three minus two times row two: zero, zero, five, five."+ ],+ [+ 50.391,+ "Two goes into row three, column two."+ ],+ [+ 53.255,+ "The table is now U and c."+ ],+ [+ 55.404,+ "And L is finished: one, zero, zero; two, one, zero; minus one, two, one."+ ],+ [+ 63.203,+ "Each multiplier sits in its own spot, just as it was used."+ ]+ ]+ },+ "check3": {+ "dur": 46.32,+ "marks": {+ "set": 1.849,+ "go": 7.565,+ "r2": 11.966,+ "res2": 18.932,+ "r3": 20.99,+ "res3": 37.943,+ "lu": 44.675+ },+ "cues": [+ [+ 0.104,+ "Does L times U give back A?"+ ],+ [+ 1.849,+ "Put L in front of U and c."+ ],+ [+ 3.893,+ "At first L is the identity, and the planes are U's."+ ],+ [+ 7.565,+ "Now L's three numbers slide in, and the planes turn back."+ ],+ [+ 11.966,+ "Row two of the answer: two times row one of U, one, one, one, three, plus row two of U, zero, one, minus one, zero, gives two, three, one, six."+ ],+ [+ 20.99,+ "Row three: minus one times row one, plus two times row two, plus row three."+ ],+ [+ 27.552,+ "Minus one, minus one, minus one, minus three; plus zero, two, minus two, zero; plus zero, zero, five, five."+ ],+ [+ 37.943,+ "That's minus one, one, two, two: row three of A, and of b."+ ],+ [+ 44.675,+ "L times U is A."+ ]+ ]+ },+ "q3": {+ "dur": 3.192,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Quick check."+ ],+ [+ 1.198,+ "Write L from the multipliers."+ ]+ ]+ },+ "why": {+ "dur": 31.2,+ "marks": {+ "rec": 2.721,+ "next": 10.846,+ "e": 17.487,+ "l": 24.401+ },+ "cues": [+ [+ 0.104,+ "Why write A as L times U?"+ ],+ [+ 2.721,+ "Because L is a record of elimination: every multiplier, written down in its place, while the work is done."+ ],+ [+ 10.846,+ "And here is something surprising."+ ],+ [+ 12.604,+ "The single matrix E that does all three steps at once is messier."+ ],+ [+ 17.487,+ "For this example, E has a five in row three, column one, a number elimination never used."+ ],+ [+ 24.401,+ "L has nothing like that: just the multipliers."+ ],+ [+ 27.643,+ "Why L is clean and E is not is the next chapter."+ ]+ ]+ },+ "q4": {+ "dur": 2.664,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Quick check."+ ],+ [+ 1.172,+ "Which matrix is L?"+ ]+ ]+ },+ "wrap": {+ "dur": 28.848,+ "marks": {+ "w1": 1.016,+ "w2": 9.258,+ "w3": 16.641,+ "w4": 20.378,+ "end": 26.654+ },+ "cues": [+ [+ 0.104,+ "To sum up."+ ],+ [+ 1.016,+ "Elimination gives E A equals U."+ ],+ [+ 4.05,+ "Undo it, and A equals E inverse times U, which we write L U."+ ],+ [+ 9.258,+ "L is lower triangular, with ones on its diagonal, and each multiplier below it, in the spot where it was used."+ ],+ [+ 16.641,+ "U is upper triangular, with the pivots on its diagonal."+ ],+ [+ 20.378,+ "L times U gives back A, and the lines and planes turn back to where they started."+ ],+ [+ 24.948,+ "L times c gives back b."+ ],+ [+ 26.654,+ "Now try the chapter practice."+ ]+ ]+ },+ "final1": {+ "dur": 3.0,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Chapter practice."+ ],+ [+ 1.576,+ "Find L and U."+ ]+ ]+ },+ "final2": {+ "dur": 3.12,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Set two."+ ],+ [+ 1.081,+ "Write L from the multipliers."+ ]+ ]+ },+ "final3": {+ "dur": 4.344,+ "marks": {},+ "cues": [+ [+ 0.091,+ "Set three."+ ],+ [+ 1.198,+ "Multiply L times U, and true or false."+ ]+ ]+ },+ "final4": {+ "dur": 4.656,+ "marks": {},+ "cues": [+ [+ 0.091,+ "Last set."+ ],+ [+ 1.224,+ "Build L with your own hands, until the planes are back."+ ]+ ]+ },+ "play": {+ "dur": 9.048,+ "marks": {+ "go": 4.036+ },+ "cues": [+ [+ 0.117,+ "Playground."+ ],+ [+ 1.081,+ "Nothing here is marked right or wrong."+ ],+ [+ 4.036,+ "Change L, U or c, and watch A and the lines follow."+ ]+ ]+ },+ "finish": {+ "dur": 8.088,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Well done."+ ],+ [+ 1.094,+ "That's the end of chapter thirty, A equals L U."+ ],+ [+ 4.557,+ "Next: why L is clean, and E is not."+ ]+ ]+ }+};diff --git a/site/linear-algebra/ch30/audio/en/why.mp3 b/site/linear-algebra/ch30/audio/en/why.mp3new file mode 100644index 0000000..34377e6Binary files /dev/null and b/site/linear-algebra/ch30/audio/en/why.mp3 differdiff --git a/site/linear-algebra/ch30/audio/en/wrap.mp3 b/site/linear-algebra/ch30/audio/en/wrap.mp3new file mode 100644index 0000000..2830881Binary files /dev/null and b/site/linear-algebra/ch30/audio/en/wrap.mp3 differdiff --git a/site/linear-algebra/ch30/index.html b/site/linear-algebra/ch30/index.htmlnew file mode 100644index 0000000..f973b2d--- /dev/null+++ b/site/linear-algebra/ch30/index.html@@ -0,0 +1,480 @@+<!doctype html>+<html lang="en">+<head>+<meta charset="utf-8">+<meta name="viewport" content="width=device-width, initial-scale=1">+<title>A = LU</title>+<link rel="stylesheet" href="../lib/engine.css">+<link rel="expect" href="#bar" blocking="render"><!-- hold the first frame until the player exists, so the page transition can run -->+</head>+<body>+<script src="../lib/engine.js"></script>+<script src="../lib/math.js"></script>+<script src="../lib/linsys.js"></script>+<script src="../lib/space3.js"></script>+<script src="../lib/elim.js"></script>+<script src="../lib/emat.js"></script>+<script src="../lib/play.js"></script>+<script src="audio/en/timings.js"></script>+<script>+'use strict';+const CHAPTER = { number: 30, title: 'A = LU', minutes: 10, language: 'en' };++/* ---------- chapter drawing helpers ---------- */+const BLUE = LS_ROW[0], CORAL = LS_ROW[1], YELLOW = S3_ROW[2];+const LEC2 = { A: [[2, 1], [8, 7]], b: [3, 15] }; // the lecture's 2 × 2 (OCW 18.06, lecture 4), b for (1, 1)+const U2 = { A: [[2, 1], [0, 3]], b: [3, 3] }, L2 = [[1, 0], [4, 1]]; // its U | c and L+const CH16 = { A: [[1, 2], [3, 4]], b: [5, 11] };+const NEGL = { A: [[2, 1], [-6, 1]], b: [3, -5] }; // a negative multiplier, meets at (1, 1)+const OWN = { A: [[1, 1, 1], [2, 3, 1], [-1, 1, 2]], b: [3, 6, 2] }; // chapter 21's system, (1, 1, 1)+const OWNU = { A: [[1, 1, 1], [0, 1, -1], [0, 0, 5]], b: [3, 0, 5] }, OWNL = [[1, 0, 0], [2, 1, 0], [-1, 2, 1]];+const U3 = { A: [[1, 1, 1], [0, 1, 2], [0, 0, 1]], b: [3, 3, 1] }; // q3: L = (3, −2, 4) below the diagonal+const AT2 = [70, 290], AT3 = [64, 262];+const CARD2 = { x: 40, y: 600, w: 760, cls: 'side' }, CARD3 = { x: 40, y: 640, w: 800, cls: 'side' };+const say = (p, parts, x, y, t0, { size = 40, fill = COL.chalk, anchor = 'start' } = {}) => { const e = M(p, [].concat(parts), { x, y, size, fill, anchor, o: 0 }); show(e, t0); return e; };+const text = (p, str, x, y, t0, { size = 30, fill = COL.chalk, anchor = 'start', weight = 500 } = {}) => { const e = T(p, str, { x, y, size, fill, anchor, weight, o: 0 }); show(e, t0); return e; };+const thick = (sys, i, t0) => { tw(sys.lines[i].l, { 'a_stroke-width': 10 }, t0, .35); tw(sys.lines[i].l, { 'a_stroke-width': 5 }, t0 + .9, .6); };+// 2D: the plane on the right, E · [A | b] = [EA | Eb] on the left (chapter 21's layout); the product is the system drawn+// (with E given, the lines start as E's answer).+const two = (p, { A, b }, caption, { t0 = .1, E = null } = {}) => {+ const sys = linsys(p, { A, b, eq: [90, 200], mat: null, sol: false, plane: { cx: 1215, u: 50 }, t0 });+ sys.E.style.visibility = 'hidden'; // hidden, yet measured (display: none measures as 0 and replays differ)+ if (caption) say(p, [caption], 70, 175, t0 + .1, { size: 28, fill: COL.dim });+ const em = emat(p, sys, { A, b, E, at: AT2, size: 38, cw: 64, ecw: 56, rh: 62, gap: 66, t0 });+ return { sys, em };+};+// 3D: the space on the right, three 3 × 3 tables on the left.+const three = (p, { A, b }, caption, { t0 = .1, E = null, view = { yaw: -40, pitch: 20 } } = {}) => {+ const sys = lin3(p, { A, b, eq: [90, 190], mat: null, sol: false, space: { cx: 1262, size: 520, ...view }, t0 });+ sys.E.style.visibility = 'hidden'; // hidden, yet measured (display: none measures as 0 and replays differ)+ if (caption) say(p, [caption], 64, 160, t0 + .1, { size: 26, fill: COL.dim });+ const em = emat(p, sys, { A, b, E, at: AT3, size: 32, cw: 52, ecw: 44, rh: 54, gap: 64, t0 });+ return { sys, em, V: sys.space };+};+// A matrix times a matrix with no picture (E⁻¹E = I): emat on a bare system, the b columns hidden.+const bare = A => {+ const v = {}, fs = [];+ A.forEach((r, i) => { r.forEach((x, j) => { v[`a${i}${j}`] = x; }); v[`b${i}`] = 0; });+ return { v, set(to) { Object.assign(v, to); fs.forEach(f => f(v)); }, onChange: f => fs.push(f), solve: () => ({}), live() {}, to() {} };+};+const mm2 = (p, Ebig, Bm, names, nameE, t0) => emat(p, bare(Bm), { A: Bm, b: [0, 0], E: Ebig, at: AT2, size: 38, cw: 64, ecw: 56, rh: 62, gap: 66, t0, noB: true, names, name: nameE });+// The old line of row 2 (dashed): a x + b y through (sx, sy); a ring round the point that never moves (chapter 16).+const ghost = (sys, a, b, sx, sy, t0) => { const l = sys.P.line(sx, sy, sx + b, sy - a, CORAL, t0, { dash: '10 10', w: 3, into: sys.stage }); tw(l, { o: .45 }, t0 + .6, .4); return l; };+const pin = (sys, x, y, t0) => { const g = G(sys.stage, { x: sys.P.PX(x), y: sys.P.PY(y), o: 0 }); mk('circle', { r: 20, fill: 'none', stroke: COL.chalk, 'stroke-width': 3.5, 'stroke-dasharray': '6 5' }, g); show(g, t0, .4); return g; };+const hinge = (sys, n, t0, dur = 1.6) => prog(q => sys.lines[n].e.setAttribute('stroke-width', 2.5 + 5 * Math.sin(Math.PI * q)), t0, dur, lin);+const nameAt = (em, nm, at) => prog(q => { if (q > 0) em.setName(nm); }, at, 0, lin);+const namesAt = (em, nm, at) => prog(q => { if (q > 0) em.names(nm); }, at, 0, lin);+// Three words of a row step: "row 2", "+ 3 ×", "row 1", coloured by row.+const stepWords = (p, i, sign, j, x, y, t0, { size = 32 } = {}) => {+ const g = G(p, { o: 0 }), RC = [BLUE, CORAL, YELLOW];+ M(g, [`row ${i + 1}`], { x, y, size, fill: RC[i], anchor: 'start' });+ M(g, [sign], { x: x + size * 3.3, y, size, fill: COL.chalk, anchor: 'start' });+ M(g, [`row ${j + 1}`], { x: x + size * 3.3 + mathW([sign], size) + size * .4, y, size, fill: RC[j], anchor: 'start' });+ show(g, t0, .4);+ return g;+};+const keysOf = ({ A, b }, E = null) => {+ const o = {}, n = A.length;+ A.forEach((r, i) => { r.forEach((x, j) => { o[`a${i}${j}`] = x; o[`e${i}${j}`] = E ? E[i][j] : +(i === j); }); o[`b${i}`] = b[i]; });+ return o;+};+// inside a question: the answer becomes the new [A | b] at once and E the identity (em.carry without the flight)+const carryNow = em => { const o = { ...em.prod() }; for (let i = 0; i < em.n; i++) for (let j = 0; j < em.n; j++) o[`e${i}${j}`] = +(i === j); em.set(o); };+const same = (pr, { A, b }) => A.every((r, i) => r.every((x, j) => Math.abs(pr[`a${i}${j}`] - x) < 1e-9) && Math.abs(pr[`b${i}`] - b[i]) < 1e-9);+const r1 = x => num(Math.round(x * 10) / 10);+const rowTxt = (pr, i, n) => `(${[...Array(n).keys()].map(j => r1(pr[`a${i}${j}`])).join(', ')} | ${r1(pr[`b${i}`])})`;++// A small matrix drawn as numbers in brackets; .at(i, j) is the centre of an entry (for rings).+const matDraw = (p, rows, x, y, t0, { size = 34, cw = 50, rh = 46, name = '' } = {}) => {+ const g = G(p, { o: 0 }), n = rows.length, w = rows[0].length * cw, top = y - size * .95, bot = y + (n - 1) * rh + size * .35;+ path(g, `M${x + 12} ${top}H${x}V${bot}H${x + 12}M${x + w - 12} ${top}H${x + w}V${bot}H${x + w - 12}`, { stroke: COL.chalk, 'stroke-width': 3, fill: 'none' });+ rows.forEach((r, i) => r.forEach((v, j) => M(g, [num(v)], { x: x + cw * (j + .5), y: y + i * rh, size, fill: COL.chalk, anchor: 'middle' })));+ if (name) M(g, [].concat(name), { x: x - 18, y: y + (n - 1) * rh / 2 + 10, size: size * 1.05, fill: COL.chalk, anchor: 'end' });+ show(g, t0, .5);+ g.at = (i, j) => [x + cw * (j + .5), y + i * rh - size * .32];+ g.ring = (i, j, at, { dash = false, color = COL.chalk } = {}) => { const [cx, cy] = g.at(i, j), e = mk('ellipse', { cx, cy, rx: cw * .48, ry: size * .62, fill: 'none', stroke: color, 'stroke-width': 3, ...(dash ? { 'stroke-dasharray': '7 6' } : {}) }, p); put(e, { o: 0 }); show(e, at, .35); return e; };+ return g;+};+const emL = (em, Lm) => { const o = {}; Lm.forEach((r, i) => r.forEach((x, j) => { o[`e${i}${j}`] = x; })); return o; };++/* ---------- practice data (every answer worked twice: by elimination, and by multiplying L U back) ---------- */+const LU2Q = [+ { parts: ['A = (1, 2), (4, 9): ℓ = ', { box: '4' }, ', U row 2 = (0, ', { box: '1' }, '), L row 2 = (', { box: '4' }, ', 1)'], why: '4 ÷ 1 = 4; 9 − 4 × 2 = 1. L keeps the 4.', hint: 'ℓ = number to remove ÷ pivot. Then row 2 − ℓ × row 1.' },+ { parts: ['A = (2, 4), (6, 13): ℓ = ', { box: '3' }, ', U row 2 = (0, ', { box: '1' }, '), L row 2 = (', { box: '3' }, ', 1)'], why: '6 ÷ 2 = 3; 13 − 3 × 4 = 1.', hint: 'The pivot is 2.' },+ { parts: ['A = (3, 1), (−6, 2): ℓ = ', { box: '-2' }, ', U row 2 = (0, ', { box: '4' }, '), L row 2 = (', { box: '-2' }, ', 1)'], why: '−6 ÷ 3 = −2; 2 − (−2) × 1 = 4. L holds ℓ itself, −2.', hint: 'A negative number to remove gives a negative ℓ.' },+];+const LU2Q2 = [+ { parts: ['A = (2, 1), (1, 3): ℓ = ', { box: '1/2' }, ', U row 2 = (0, ', { box: '5/2' }, '), L row 2 = (', { box: '1/2' }, ', 1)'], why: '1 ÷ 2 = ½; 3 − ½ × 1 = 5⁄2.', hint: 'ℓ can be a fraction: 1 ÷ 2.' },+ { parts: ['A = (1, −1), (5, −2): ℓ = ', { box: '5' }, ', U row 2 = (0, ', { box: '3' }, '), L row 2 = (', { box: '5' }, ', 1)'], why: '5 ÷ 1 = 5; −2 − 5 × (−1) = 3.', hint: 'Mind the sign: −2 − 5 × (−1).' },+];+const LFROMQ = [+ { parts: ['ℓ₂₁ = 2, ℓ₃₁ = 3, ℓ₃₂ = −1: L row 2 = (', { box: '2' }, ', 1, 0), L row 3 = (', { box: '3' }, ', ', { box: '-1' }, ', 1)'], why: 'Each ℓᵢⱼ goes into row i, column j.', hint: 'ℓ₃₁ sits in row 3, column 1.' },+ { parts: ['A = (1, 2, 0), (3, 7, 1), (0, 2, 5): L row 2 = (', { box: '3' }, ', 1, 0), L row 3 = (', { box: '0' }, ', ', { box: '2' }, ', 1), U row 3 = (0, 0, ', { box: '3' }, ')'],+ why: 'ℓ₂₁ = 3 → (0, 1, 1); row 3 already starts with 0, so ℓ₃₁ = 0; ℓ₃₂ = 2 ÷ 1 = 2 → (0, 0, 3).', hint: 'Do the steps: row 2 − 3 × row 1 first. Row 3 needs no step for column 1.' },+ { parts: ['A = (2, 1, 1), (4, 1, 0), (−2, 2, 1): L row 3 = (', { box: '-1' }, ', ', { box: '-3' }, ', 1), U’s pivots: 2, ', { box: '-1' }, ', ', { box: '-4' }],+ why: 'ℓ₂₁ = 2 → (0, −1, −2); ℓ₃₁ = −1 → (0, 3, 2); ℓ₃₂ = 3 ÷ (−1) = −3 → (0, 0, −4).', hint: 'Column 1 first (ℓ₂₁ = 4 ÷ 2, ℓ₃₁ = −2 ÷ 2), then column 2 with the new rows.' },+];+const LUMULQ = [+ { parts: ['L = (1, 0), (4, 1); U = (2, 1), (0, 3): row 2 of LU = (', { box: '8' }, ', ', { box: '7' }, ')'], why: '4 × (2, 1) + (0, 3) = (8, 7): the lecture’s A.', hint: 'Row 2 of L: 4 of row 1 of U, plus row 2 of U.' },+ { parts: ['L = (1, 0), (−2, 1); U = (3, 1), (0, 4): row 2 of LU = (', { box: '-6' }, ', ', { box: '2' }, ')'], why: '−2 × (3, 1) + (0, 4) = (−6, 2).', hint: '−2 × row 1 of U is (−6, −2).' },+ { parts: ['L row 3 = (−1, 2, 1); U = (1, 1, 1), (0, 1, −1), (0, 0, 5): row 3 of LU = (', { box: '-1' }, ', ', { box: '1' }, ', ', { box: '2' }, ')'], why: '(−1, −1, −1) + (0, 2, −2) + (0, 0, 5) = (−1, 1, 2).', hint: '−1 of row 1, 2 of row 2, 1 of row 3 of U.' },+ { parts: ['L row 3 = (0, 5, 1); U rows 2, 3 = (0, 1, 1), (0, 0, 2): row 3 of LU = (', { box: '0' }, ', ', { box: '5' }, ', ', { box: '7' }, ')'], why: '5 × (0, 1, 1) + (0, 0, 2) = (0, 5, 7).', hint: 'Row 1 of U is not used (amount 0).' },+];+const TFQ = [+ { parts: ['L is lower triangular: zeros above its diagonal.'], ans: ['t'], why: 'Each step only adds a multiple of an upper row to a lower one.' },+ { parts: ['U has ones on its diagonal.'], ans: ['f'], why: 'U has the pivots on its diagonal; L has the ones.' },+ { parts: ['L holds −ℓ, the numbers of E.'], ans: ['f'], why: 'E has −ℓ; L = E⁻¹ has ℓ itself.' },+ { parts: [$m('L = E⁻¹')], ans: ['t'], why: 'From EA = U: A = E⁻¹U, and E⁻¹ is called L.' },+ { parts: [$m('Lc = b')], ans: ['t'], why: 'Elimination turned b into c = Eb. Multiply by L = E⁻¹: Lc = b.' },+ { parts: [$m('LU = UL')], ans: ['f'], why: 'The order matters (chapter 25): L on the left mixes the rows of U.' },+];+// Hands-on in 3D: L starts as I in front of U | c; its numbers below the diagonal must rebuild A | b.+const OWN3 = { A: [[2, 1, 0], [2, 2, 1], [4, 1, 2]], b: [3, 5, 7] }, OWN3U = { A: [[2, 1, 0], [0, 1, 1], [0, 0, 3]], b: [3, 2, 3] };+const LEC3 = { A: [[1, 2, 1], [3, 8, 1], [0, 4, 1]], b: [2, 12, 2] }, LEC3U = { A: [[1, 2, 1], [0, 2, -2], [0, 0, 5]], b: [2, 6, -10] };+const rowsTxt = s => s.A.map((r, i) => `(${r.map(num).join(', ')} | ${num(s.b[i])})`).join(', ');+const HANDS = [+ { from: OWNU, to: OWN, ans: { e10: 2, e20: -1, e21: 2 } },+ { from: LEC3U, to: LEC3, ans: { e10: 3, e20: 0, e21: 2 } },+ { from: OWN3U, to: OWN3, ans: { e10: 1, e20: 2, e21: -1 } },+];+const handHint = h => (v, pr) => {+ const i = [1, 2].find(i => rowTxt(pr, i, 3) !== rowTxt(h.to, i, 3)) ?? 1;+ return `Row ${i + 1} is ${rowTxt(pr, i, 3)}, not ${rowTxt(h.to, i, 3)}. Row ${i + 1} of L says how much of each row of U to take.`;+};++/* ---------- beats ---------- */+const BEATS = [+ ['intro', 'A = LU', (m, D) => {+ const g = G(scene, { o: 0, y: 24 });+ T(g, 'Unit 4 · Factorization into A = LU', { x: 800, y: 205, size: 24, fill: COL.faint, anchor: 'middle' });+ T(g, 'Unit 4, Chapter 30', { x: 800, y: 250, size: 28, fill: COL.dim, anchor: 'middle' });+ M(g, ['A = LU'], { x: 800, y: 360, size: 92, fill: COL.chalk, anchor: 'middle' });+ tw(g, { o: 1, y: 0 }, .2, 1.1, out);+ const r = text(scene, 'elimination, run backwards: A is L times U', 800, 460, m('sub'), { size: 34, fill: COL.dim, anchor: 'middle' });+ const lg = G(scene, { o: 0 });+ const em = emat(lg, bare(U2.A), { A: U2.A, b: [0, 0], at: [460, 640], size: 36, cw: 62, ecw: 54, rh: 56, t0: 0, noB: true, name: 'L', names: ['U', '', 'LU', ''] });+ show(lg, m('sub') + 1.2, .5);+ em.ringE(1, 0, m('move'));+ em.to({ e10: 4 }, m('move') + .2, 1.4);+ namesAt(em, ['U', '', 'A', ''], m('move') + 1.6);+ tw(g, { o: 0, y: -24 }, D - .9, .8); hide(r, D - .9, .8); hide(lg, D - .9, .8);+ }],++ ['recall', 'From A to U', (m) => {+ const p = panel(0);+ text(p, 'From A to U', 60, 110, .2, { size: 40, weight: 600 });+ const { sys, em } = two(p, LEC2, '2x + y = 3, 8x + 7y = 15', { t0: .4 });+ em.setName('E₂₁');+ [0, 1].forEach(i => { em.B.flash(i, m('sys') + .6 + 2.6 * i); thick(sys, i, m('sys') + .6 + 2.6 * i); });+ pin(sys, 1, 1, m('sys') + 5.4); pulse(sys.meet, m('sys') + 5.6);+ em.B.ring(0, 0, m('piv')); em.B.ring(1, 0, m('piv') + 1.6, { dash: true });+ say(p, ['ℓ = 8 ÷ 2 = 4'], 70, 640, m('l'), { size: 34 });+ em.ringE(1, 0, m('e') + 1);+ em.focusE(1, m('go')); em.Pt.focus(1, m('go'));+ ghost(sys, 8, 7, 1, 1, m('go'));+ em.to({ e10: -4 }, m('go') + .3, Math.max(1.6, m('res') - m('go')));+ em.work(1, 0, { times: [m('go') + 1.6, m('go') + 3.4, m('res')] });+ em.Pt.flash(1, m('res') + .2);+ thick(sys, 1, m('flat'));+ em.focusE(null, m('u')); em.Pt.focus(null, m('u'));+ namesAt(em, ['A', 'b', 'U', 'Eb'], m('u') + .3);+ em.Pt.upper(m('u') + 2);+ text(p, 'upper triangular: zero below the diagonal', 70, 700, m('u') + 6, { size: 28, weight: 600 });+ namesAt(em, ['A', 'b', 'U', 'c'], m('c') + 1.5);+ em.Pt.flash(0, m('c') + .3, 2); em.Pt.flash(1, m('c') + .6, 2);+ say(p, ['EA = U'], 70, 780, m('eau') + .3, { size: 44 });+ }],++ ['back', 'Turn it around', (m) => {+ const p = panel(0);+ text(p, 'Turn it around', 60, 110, .2, { size: 40, weight: 600 });+ const sys = linsys(p, { A: LEC2.A, b: LEC2.b, eq: [90, 200], mat: null, sol: false, plane: { cx: 1215, u: 50 } });+ sys.E.style.visibility = 'hidden'; // hidden, yet measured (display: none measures as 0 and replays differ)+ pin(sys, 1, 1, .6);+ sys.set({ a10: 0, a11: 3, b1: 3 }); // the plane starts as U | c: the flat line+ ghost(sys, 8, 7, 1, 1, .5);+ const X = 90, NOTE = 600;+ say(p, ['EA = U'], X, 250, m('start'), { size: 46 });+ say(p, ['E⁻¹EA = E⁻¹U'], X, 345, m('mul'), { size: 46 });+ text(p, 'both sides times E⁻¹, on the left', NOTE, 335, m('mul') + .6, { size: 24, fill: COL.dim, weight: 600 });+ say(p, ['I A = E⁻¹U'], X, 440, m('left') + 1, { size: 46 });+ text(p, 'E⁻¹E = I (chapter 29)', NOTE, 430, m('left') + 1, { size: 24, fill: COL.dim, weight: 600 });+ text(p, 'I A = A', NOTE, 520, m('left') + 5, { size: 24, fill: COL.dim, weight: 600 });+ say(p, ['A = E⁻¹U'], X, 535, m('res'), { size: 46 });+ const tag = G(p, { o: 0 }); M(tag, ['E⁻¹'], { x: 1400, y: 215, size: 34, fill: COL.chalk, anchor: 'middle' });+ show(tag, m('pic') + 1.5, .3);+ sys.to({ a10: 8, a11: 7, b1: 15 }, m('pic') + 1.8, 1.6);+ thick(sys, 1, m('pic') + 3.6);+ say(p, ['L = E⁻¹'], X, 640, m('name'), { size: 46 });+ const lu = say(p, ['A = LU'], X, 760, m('lu'), { size: 64 });+ pulse(lu, m('lu') + .6, 1.15);+ }],++ ['times', 'L times U', (m) => {+ const p = panel(0);+ text(p, 'L times U', 60, 110, .2, { size: 40, weight: 600 });+ const { sys, em } = two(p, U2, 'U and c, from 2x + y = 3, 8x + 7y = 15', { t0: m('set') - .3 });+ em.setName('L'); em.names(['U', 'c', 'LU', 'Lc']);+ ghost(sys, 8, 7, 1, 1, m('set') + 1); pin(sys, 1, 1, m('set') + 1.2);+ [0, 1].forEach(i => em.B.flash(i, m('set') + .4 + .4 * i));+ em.ringE(1, 0, m('l') + 1.2);+ em.to({ e10: 4 }, m('l') + 2.4, 2);+ em.focusE(0, m('r1')); em.Pt.focus(0, m('r1'));+ em.work(0, 0, { times: [m('r1') + 1.2, m('r1') + 1.8, m('r1') + 4.2] }); em.Pt.flash(0, m('r1') + 4.4);+ em.focusE(1, m('r2')); em.Pt.focus(1, m('r2'));+ em.work(1, 0, { times: [m('r2') + 1.6, m('r2') + 5.8, m('res')] }); em.Pt.flash(1, m('res') + .2);+ em.focusE(null, m('back')); em.Pt.focus(null, m('back'));+ namesAt(em, ['U', 'c', 'A', 'b'], m('back') + .2);+ thick(sys, 1, m('back') + 2.4);+ say(p, ['LU = A'], 70, 700, m('lu'), { size: 44 });+ say(p, ['Lc = b'], 330, 700, m('lu') + 1.8, { size: 44 });+ }],++ ['shape', 'Lower and upper', (m) => {+ const p = panel(0);+ text(p, 'Lower and upper', 60, 110, .2, { size: 40, weight: 600 });+ const { sys, em } = two(p, U2, '', { E: L2 });+ em.setName('L'); em.names(['U', 'c', 'A', 'b']);+ pin(sys, 1, 1, .5);+ em.B.upper(m('u'));+ text(p, 'U: upper triangular, zero below the diagonal', 70, 470, m('u') + .3, { size: 28, weight: 600 });+ em.B.ring(0, 0, m('piv') + 1.2); em.B.ring(1, 1, m('piv') + 2);+ text(p, 'its diagonal holds the pivots, 2 and 3', 70, 520, m('piv') + 1.2, { size: 28, fill: COL.dim, weight: 600 });+ em.triE(m('l'));+ text(p, 'L: lower triangular, zero above the diagonal', 70, 600, m('l') + .3, { size: 28, weight: 600 });+ em.flashE(0, m('one') + 1, 0); em.flashE(1, m('one') + 1.5, 1);+ text(p, 'ones on its diagonal', 70, 650, m('one') + .8, { size: 28, fill: COL.dim, weight: 600 });+ em.ringE(1, 0, m('m') + 1.6); em.Pt.ring(1, 0, m('m') + 4.4, { dash: true });+ text(p, 'the multiplier 4 below, in row 2, column 1: where the 8 was', 70, 700, m('m') + 1.6, { size: 28, fill: COL.dim, weight: 600 });+ say(p, ['A = LU'], 70, 790, m('name'), { size: 44 });+ text(p, '= lower triangular × upper triangular', 290, 785, m('name') + 2, { size: 28, weight: 600 });+ }],++ ['q1', 'Quick check', () => {+ const p = panel(0);+ text(p, 'Quick check', 60, 110, .2, { size: 40, weight: 600 });+ const t = two(p, { A: [[3, 1], [6, 5]], b: [4, 11] }, '3x + y = 4, 6x + 5y = 11');+ t.em.setName('E₂₁');+ S.em = t.em;+ }, { ask: done => quiz({ x: 40, y: 410, w: 760, cls: 'side' }, [{+ id: 'c-lu', prompt: ['Eliminate x from row 2. Then write U and L.'],+ build: blanks([+ { parts: ['the multiplier ℓ = ', { box: '2' }], why: '6 ÷ 3 = 2.', hint: 'Number to remove ÷ pivot.', fx: () => fxp(q => S.em.set({ e10: -2 * q }), 0, 1.6) },+ { parts: ['U = (3, 1), (', { box: '0' }, ', ', { box: '3' }, ')'], why: '(6, 5) − 2 × (3, 1) = (0, 3). U keeps row 1 as it is.', hint: 'Row 2 − 2 × row 1.' },+ { parts: ['L = (1, 0), (', { box: '2' }, ', 1)'], why: 'L holds the multiplier 2 in row 2, column 1. Check: 2 × (3, 1) + (0, 3) = (6, 5).', hint: 'L holds ℓ itself, in the spot it was used.' },+ ]),+ }], done) }],++ ['ex2', 'Chapter 16’s matrix', (m) => {+ const p = panel(0);+ text(p, 'A second example', 60, 110, .2, { size: 40, weight: 600 });+ const { sys, em } = two(p, CH16, 'x + 2y = 5, 3x + 4y = 11', { t0: m('sys') - .3 });+ em.setName('E₂₁');+ pin(sys, 1, 2, m('sys') + 3);+ say(p, ['ℓ = 3 ÷ 1 = 3'], 70, 680, m('l'), { size: 34 });+ ghost(sys, 3, 4, 1, 2, m('go'));+ em.work(1, m('go'));+ em.to({ e10: -3 }, m('go') + .3, 2);+ namesAt(em, ['A', 'b', 'U', 'c'], m('u'));+ const up = em.Pt.upper(m('u') + .3); hide(up, m('carry'), .3);+ em.work(null, m('carry') - .3, .3);+ em.carry(m('carry'), 1.2, { names: ['U', 'c', '', ''] });+ nameAt(em, 'L', m('lmat'));+ em.ringE(1, 0, m('lmat') + .5);+ em.triE(m('lmat') + 1.5);+ em.work(1, 0, { times: [m('w'), m('w') + 3, m('res')] });+ em.to({ e10: 3 }, m('w') + .2, Math.max(1.8, m('res') - m('w')));+ namesAt(em, ['U', 'c', 'A', 'b'], m('res'));+ em.Pt.flash(1, m('res') + .2);+ thick(sys, 1, m('back') + .2);+ say(p, ['LU = A'], 400, 680, m('back') + 1.4, { size: 34 });+ }],++ ['ex3', 'A minus sign', (m) => {+ const p = panel(0);+ text(p, 'A negative multiplier', 60, 110, .2, { size: 40, weight: 600 });+ const { sys, em } = two(p, NEGL, '2x + y = 3, −6x + y = −5', { t0: m('sys') - .3 });+ em.setName('E₂₁');+ pin(sys, 1, 1, m('sys') + 3);+ say(p, ['ℓ = −6 ÷ 2 = −3'], 70, 680, m('l'), { size: 34 });+ ghost(sys, -6, 1, 1, 1, m('go'));+ em.ringE(1, 0, m('go') + .3);+ em.work(1, m('go'));+ em.to({ e10: 3 }, m('go') + .3, 2.4);+ namesAt(em, ['A', 'b', 'U', 'c'], m('u'));+ const up = em.Pt.upper(m('u') + .3); hide(up, m('carry'), .3);+ em.work(null, m('carry') - .3, .3);+ em.carry(m('carry'), 1, { names: ['U', 'c', '', ''] });+ nameAt(em, 'L', m('lmat'));+ em.ringE(1, 0, m('lmat') + .6);+ say(p, ['E: +3'], 70, 750, m('e') + 1, { size: 34 });+ say(p, ['L: −3 = ℓ'], 260, 750, m('e') + 2.2, { size: 34 });+ em.to({ e10: -3 }, m('lmat') + .4, 2);+ em.flashE(1, m('e') + 3.6, 0); em.B.flash(0, m('e') + 5);+ em.work(1, 0, { times: [m('w'), m('w') + 2, m('res')] });+ namesAt(em, ['U', 'c', 'A', 'b'], m('res'));+ em.Pt.flash(1, m('res') + .2);+ thick(sys, 1, m('back'));+ }],++ ['q2', 'Your turn', () => {+ const p = panel(0);+ text(p, 'Your turn', 60, 110, .2, { size: 40, weight: 600 });+ const sys = linsys(p, { A: [[1, 1], [4, 6]], b: [2, 10], eq: [90, 200], mat: null, sol: false });+ sys.E.style.visibility = 'hidden'; // hidden, yet measured (display: none measures as 0 and replays differ)+ say(p, ['x + y = 2, 4x + 6y = 10'], 90, 182, .2, { size: 32, fill: COL.dim });+ const el = elim(p, sys, { at: [120, 290], size: 50, cw: 92, rh: 78, labelX: 466 });+ el.ring(0, 0, .3);+ el.op(1, 0, 0, .3);+ S.el = el; S.L = elL(p, el, { at: [160, 500], size: 38, cw: 60, rh: 56 });+ }, { ask: done => quiz({ x: 40, y: 610, w: 760, cls: 'side' }, [{+ id: 'c-flat', prompt: ['Find the multiplier that makes the coral line flat. Watch L.'],+ build: (body, api) => { S.L.follow(true); return elTask(S.el, v => Math.abs(v.a10) < 1e-9, '4: row 2 − 4 × row 1 = (0, 2 | 2), so y = 1 and x = 1. The 4 now sits in L, row 2, column 1.',+ v => `Row 2 still has ${r1(v.a10)}x. ℓ = 4 ÷ 1.`, () => S.el.set({ l: 4 }))(body, api); },+ }], done) }],++ ['three', 'L fills in', (m) => {+ const p = panel(0);+ text(p, 'Three equations: L fills in', 60, 110, .2, { size: 40, weight: 600 });+ const sys = lin3(p, { A: OWN.A, b: OWN.b, eq: [90, 190], mat: null, sol: false, space: { cx: 1250, size: 540, yaw: -35, pitch: 20 }, t0: m('sys') - .3 });+ sys.E.style.visibility = 'hidden'; // hidden, yet measured (display: none measures as 0 and replays differ)+ say(p, ['x + y + z = 3, 2x + 3y + z = 6, −x + y + 2z = 2'], 90, 172, m('sys'), { size: 28, fill: COL.dim });+ const el = elim(p, sys, { at: [120, 260], size: 44, cw: 84, rh: 66, t0: m('sys') - .3, labelX: 520 });+ const L = elL(p, el, { at: [150, 590], size: 38, cw: 60, rh: 56, t0: m('l') - .2 });+ [0, 1, 2].forEach(i => el.flash(i, m('sys') + 1 + 2.2 * i));+ el.ring(0, 0, m('s1'));+ const SD = 3.4, lag = (k, s) => m(k) - (m(s) + .3 + .8 + SD); // slow steps: each row changes while the voice reads it+ L.step(1, 0, 2, m('s1') + .3, SD, { lag: lag('w1', 's1') });+ sys.space.turn({ yaw: -15 }, m('s1'), 8);+ L.step(2, 0, -1, m('s2') + .3, SD, { lag: lag('w2', 's2') });+ el.ring(1, 1, m('s3'));+ L.step(2, 1, 2, m('s3') + .3, SD, { lag: lag('w3', 's3') });+ sys.space.turn({ yaw: 5, pitch: 30 }, m('s3'), 6);+ el.flash(1, m('s1') + 4.6); el.flash(2, m('s2') + 5); el.flash(2, m('s3') + 4.6);+ el.upper(m('u'));+ text(p, 'the table is now U | c', 120, 450, m('u'), { size: 26, fill: COL.dim, weight: 600 });+ L.tri(m('done'));+ [0, 1, 2].forEach(i => L.flash(i, 0, m('done') + .8 + 1.5 * i));+ L.flash(1, 0, m('done') + 6); L.flash(2, 0, m('done') + 6.6); L.flash(2, 1, m('done') + 7.2);+ }],++ ['check3', 'L times U, in three dimensions', (m) => {+ const p = panel(0);+ text(p, 'L times U gives A', 60, 110, .2, { size: 40, weight: 600 });+ const { sys, em, V } = three(p, OWNU, 'U and c of x + y + z = 3, 2x + 3y + z = 6, −x + y + 2z = 2', { t0: m('set') - .3 });+ em.setName('L'); em.names(['U', 'c', 'LU', 'Lc']);+ em.to(emL(em, OWNL), m('go') + .2, 3);+ hinge(sys, 0, m('go') + 3.2, 1.6);+ V.turn({ yaw: -15 }, m('go'), 8);+ em.focusE(1, m('r2')); em.Pt.focus(1, m('r2'));+ em.work(1, 0, { times: [m('r2') + 1.4, m('r2') + 4.6, m('r2') + 4.9, m('res2')] }); em.Pt.flash(1, m('res2') + .2);+ em.focusE(2, m('r3')); em.Pt.focus(2, m('r3'));+ em.work(2, 0, { times: [m('r3') + 5, m('r3') + 9, m('r3') + 13, m('res3')] }); em.Pt.flash(2, m('res3') + .2);+ em.focusE(null, m('lu')); em.Pt.focus(null, m('lu'));+ namesAt(em, ['U', 'c', 'A', 'b'], m('lu'));+ em.triE(m('lu') + .3);+ V.turn({ yaw: -40 }, m('res3'), 5);+ }],++ ['q3', 'Quick check', () => {+ const p = panel(0);+ text(p, 'Quick check', 60, 110, .2, { size: 40, weight: 600 });+ const t = three(p, U3, 'U and c');+ t.em.setName('L'); t.em.names(['U', 'c', 'LU', 'Lc']);+ S.em = t.em;+ }, { ask: done => quiz({ x: 40, y: 470, w: 800, cls: 'side' }, [{+ id: 'c-l3', prompt: ['Elimination used ℓ₂₁ = 3, ℓ₃₁ = −2 and ℓ₃₂ = 4. Fill in L.'],+ build: blanks([+ { parts: ['L row 2 = (', { box: '3' }, ', 1, 0)'], why: 'ℓ₂₁ = 3 goes into row 2, column 1.', hint: 'ℓᵢⱼ sits in row i, column j.' },+ { parts: ['L row 3 = (', { box: '-2' }, ', ', { box: '4' }, ', 1)'], why: 'ℓ₃₁ = −2 in column 1, ℓ₃₂ = 4 in column 2. The planes come back to A.', hint: 'Row 3 holds ℓ₃₁, then ℓ₃₂.',+ fx: () => fxp(q => S.em.set({ e10: 3 * q, e20: -2 * q, e21: 4 * q }), 0, 2) },+ ]),+ }], done) }],++ ['why', 'A record of elimination', (m) => {+ const p = panel(0);+ text(p, 'A record of elimination', 60, 110, .2, { size: 40, weight: 600 });+ const { sys, em, V } = three(p, OWN, 'x + y + z = 3, 2x + 3y + z = 6, −x + y + 2z = 2', { t0: .3 });+ em.setName('E'); em.names(['A', 'b', 'EA', 'Eb']);+ const Lm = matDraw(p, OWNL, 150, 650, m('rec'), { size: 32, cw: 52, rh: 48, name: 'L =' });+ [[1, 0], [2, 0], [2, 1]].forEach(([i, j], k) => Lm.ring(i, j, m('rec') + 2 + .6 * k));+ em.to(emL(em, [[1, 0, 0], [-2, 1, 0], [5, -2, 1]]), m('next') + 2, 3);+ hinge(sys, 0, m('next') + 4, 1.6);+ V.turn({ yaw: 0, pitch: 34 }, m('next') + 2, 6);+ em.ringE(2, 0, m('e'), { dash: true });+ em.Pt.flash(2, m('e') + 2.6); em.flashE(2, m('e') + 4.2, 0);+ text(p, 'E = E₃₂E₃₁E₂₁: a 5 that elimination never used', 360, 700, m('e') + .6, { size: 26, weight: 600 });+ [[1, 0], [2, 0], [2, 1]].forEach(([i, j], k) => Lm.ring(i, j, m('l') + .4 * k, { color: COL.good }));+ text(p, 'L: just the multipliers 2, −1, 2', 360, 760, m('l') + .8, { size: 26, weight: 600 });+ text(p, 'why: chapter 31', 360, 810, m('l') + 4, { size: 26, fill: COL.dim, weight: 600 });+ }],++ ['q4', 'Quick check', () => {+ const p = panel(0);+ text(p, 'Quick check', 60, 110, .2, { size: 40, weight: 600 });+ const t = two(p, { A: [[2, 1], [6, 8]], b: [3, 14] }, '2x + y = 3, 6x + 8y = 14');+ t.em.setName('E₂₁');+ S.em = t.em;+ }, { ask: done => quiz({ x: 40, y: 540, w: 760, cls: 'side' }, [{+ id: 'c-whichL', prompt: ['A = (2, 1), (6, 8). Which matrix is L?'],+ build: choice(['rows (1, 0) and (3, 1)', 'rows (1, 0) and (−3, 1)', 'rows (2, 0) and (6, 1)', 'rows (1, 3) and (0, 1)'], 0,+ 'ℓ = 6 ÷ 2 = 3, and L holds it in row 2, column 1. Check: 3 × (2, 1) + (0, 5) = (6, 8).',+ [null, 'That is E₂₁: it takes 3 × row 1 away. L puts it back: +3.', 'L has ones on its diagonal; the pivot 2 stays in U.', 'That is upper triangular. L’s number sits below the diagonal, in row 2, column 1.'],+ () => fxp(q => S.em.set({ e10: -3 * q }), 0, 1.6)),+ }], done) }],++ ['wrap', 'Summary', (m) => {+ const p = panel(0);+ [['Elimination: EA = U. Undo it: A = E⁻¹U = LU.', 'w1'], ['L is lower triangular: ones on its diagonal, each multiplier ℓ below, where it was used.', 'w2'],+ ['U is upper triangular, with the pivots on its diagonal.', 'w3'], ['LU gives back A (the lines turn back), and Lc gives back b.', 'w4']].forEach(([str, mark], i) => {+ const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });+ mk('circle', { cx: 120, cy: -12, r: 26, fill: COL.chalk }, g);+ T(g, String(i + 1), { x: 120, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });+ T(g, str, { x: 170, size: 34, weight: 600 });+ tw(g, { o: 1, x: 0 }, m(mark), .6);+ });+ }],+ ['final1', 'Chapter practice', () => { panel(0); }, { ask: done => quiz(SCREEN, [{+ id: 'p-lu', prompt: ['For each A: the multiplier, row 2 of U, and row 2 of L.'],+ build: blanks(LU2Q),+ }, {+ id: 'p-lu2', prompt: ['Two more. A fraction is fine.'],+ build: blanks(LU2Q2),+ }], done, 'Chapter practice · set 1 of 4') }],+ ['final2', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{+ id: 'p-lfrom', prompt: ['Write L from the multipliers (do the elimination where A is given).'],+ build: blanks(LFROMQ),+ }], done, 'Chapter practice · set 2 of 4') }],+ ['final3', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{+ id: 'p-mul', prompt: ['Multiply L times U, one row. Each row of L mixes the rows of U.'],+ build: blanks(LUMULQ),+ }, {+ id: 'p-tf', prompt: ['True or false?'],+ build: grid(TFQ, TF, { text: true }),+ }], done, 'Chapter practice · set 3 of 4') }],+ ['final4', 'Chapter practice', () => {+ const p = panel(0);+ text(p, 'Build L', 60, 110, .2, { size: 40, weight: 600 });+ const t = three(p, OWNU, '');+ t.em.setName('L'); t.em.names(['U', 'c', 'LU', 'Lc']);+ S.em = t.em;+ }, { ask: done => quiz(CARD3, HANDS.map((h, k) => ({+ id: `p-hand${k + 1}`, prompt: [`Change L’s numbers below the diagonal until LU | Lc is A | b: ${rowsTxt(h.to)}.`],+ build: (body, api) => { S.em.set(keysOf(h.from)); S.em.work(2, 0); return emTask(S.em, (v, pr) => same(pr, h.to), 'L = rows (1, 0, 0), (' + [h.ans.e10, 1, 0].map(num).join(', ') + '), (' + [h.ans.e20, h.ans.e21, 1].map(num).join(', ') + '): the multipliers in their places.', handHint(h), () => S.em.set(h.ans), { only: ['e10', 'e20', 'e21'] })(body, api); },+ })), done, 'Chapter practice · set 4 of 4') }],+ ['play', 'Playground', (m) => {+ const p = panel(0);+ text(p, 'Playground', 60, 110, .2, { size: 40, weight: 600 });+ const t = two(p, U2, '', { E: L2 });+ t.em.setName('L'); t.em.names(['U', 'c', 'A', 'b']);+ S.em = t.em;+ t.em.work(1, .3);+ text(p, 'try: put 0 in L (A becomes U: the line goes flat); change U’s pivot 3; drag a line', 70, 175, m('go'), { size: 24, fill: COL.dim });+ }, { ask: playAsk(() => S.em, { pos: { x: 40, y: 586, w: 760, cls: 'side' }, tip: 'L, U and c are yours. Change any number, drag a line, or draw on the board. Nothing is marked.' }) }],+ ['finish', 'Finished', () => { panel(0); }, { ask: finishCard }],+].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));++boot();+</script>+</body>+</html>diff --git a/site/linear-algebra/ch31/audio/en/emat.mp3 b/site/linear-algebra/ch31/audio/en/emat.mp3new file mode 100644index 0000000..9bae987Binary files /dev/null and b/site/linear-algebra/ch31/audio/en/emat.mp3 differdiff --git a/site/linear-algebra/ch31/audio/en/ex2.mp3 b/site/linear-algebra/ch31/audio/en/ex2.mp3new file mode 100644index 0000000..5ca159cBinary files /dev/null and b/site/linear-algebra/ch31/audio/en/ex2.mp3 differdiff --git a/site/linear-algebra/ch31/audio/en/final1.mp3 b/site/linear-algebra/ch31/audio/en/final1.mp3new file mode 100644index 0000000..8a79edaBinary files /dev/null and b/site/linear-algebra/ch31/audio/en/final1.mp3 differdiff --git a/site/linear-algebra/ch31/audio/en/final2.mp3 b/site/linear-algebra/ch31/audio/en/final2.mp3new file mode 100644index 0000000..1e427f7Binary files /dev/null and b/site/linear-algebra/ch31/audio/en/final2.mp3 differdiff --git a/site/linear-algebra/ch31/audio/en/final3.mp3 b/site/linear-algebra/ch31/audio/en/final3.mp3new file mode 100644index 0000000..190c156Binary files /dev/null and b/site/linear-algebra/ch31/audio/en/final3.mp3 differdiff --git a/site/linear-algebra/ch31/audio/en/final4.mp3 b/site/linear-algebra/ch31/audio/en/final4.mp3new file mode 100644index 0000000..927105aBinary files /dev/null and b/site/linear-algebra/ch31/audio/en/final4.mp3 differdiff --git a/site/linear-algebra/ch31/audio/en/finish.mp3 b/site/linear-algebra/ch31/audio/en/finish.mp3new file mode 100644index 0000000..82c504dBinary files /dev/null and b/site/linear-algebra/ch31/audio/en/finish.mp3 differdiff --git a/site/linear-algebra/ch31/audio/en/intro.mp3 b/site/linear-algebra/ch31/audio/en/intro.mp3new file mode 100644index 0000000..33eea42Binary files /dev/null and b/site/linear-algebra/ch31/audio/en/intro.mp3 differdiff --git a/site/linear-algebra/ch31/audio/en/lmat.mp3 b/site/linear-algebra/ch31/audio/en/lmat.mp3new file mode 100644index 0000000..d3ade64Binary files /dev/null and b/site/linear-algebra/ch31/audio/en/lmat.mp3 differdiff --git a/site/linear-algebra/ch31/audio/en/onego.mp3 b/site/linear-algebra/ch31/audio/en/onego.mp3new file mode 100644index 0000000..bb5675aBinary files /dev/null and b/site/linear-algebra/ch31/audio/en/onego.mp3 differdiff --git a/site/linear-algebra/ch31/audio/en/order.mp3 b/site/linear-algebra/ch31/audio/en/order.mp3new file mode 100644index 0000000..ebe0cabBinary files /dev/null and b/site/linear-algebra/ch31/audio/en/order.mp3 differdiff --git a/site/linear-algebra/ch31/audio/en/play.mp3 b/site/linear-algebra/ch31/audio/en/play.mp3new file mode 100644index 0000000..385c51aBinary files /dev/null and b/site/linear-algebra/ch31/audio/en/play.mp3 differdiff --git a/site/linear-algebra/ch31/audio/en/q1.mp3 b/site/linear-algebra/ch31/audio/en/q1.mp3new file mode 100644index 0000000..1233425Binary files /dev/null and b/site/linear-algebra/ch31/audio/en/q1.mp3 differdiff --git a/site/linear-algebra/ch31/audio/en/q2.mp3 b/site/linear-algebra/ch31/audio/en/q2.mp3new file mode 100644index 0000000..0f41d43Binary files /dev/null and b/site/linear-algebra/ch31/audio/en/q2.mp3 differdiff --git a/site/linear-algebra/ch31/audio/en/q3.mp3 b/site/linear-algebra/ch31/audio/en/q3.mp3new file mode 100644index 0000000..02237c6Binary files /dev/null and b/site/linear-algebra/ch31/audio/en/q3.mp3 differdiff --git a/site/linear-algebra/ch31/audio/en/rule.mp3 b/site/linear-algebra/ch31/audio/en/rule.mp3new file mode 100644index 0000000..88b2fb2Binary files /dev/null and b/site/linear-algebra/ch31/audio/en/rule.mp3 differdiff --git a/site/linear-algebra/ch31/audio/en/steps.mp3 b/site/linear-algebra/ch31/audio/en/steps.mp3new file mode 100644index 0000000..04689ebBinary files /dev/null and b/site/linear-algebra/ch31/audio/en/steps.mp3 differdiff --git a/site/linear-algebra/ch31/audio/en/timings.js b/site/linear-algebra/ch31/audio/en/timings.jsnew file mode 100644index 0000000..ad75c23--- /dev/null+++ b/site/linear-algebra/ch31/audio/en/timings.js@@ -0,0 +1,655 @@+window.TIMINGS = {+ "intro": {+ "dur": 16.056,+ "marks": {+ "sub": 4.362,+ "move": 14.401+ },+ "cues": [+ [+ 0.104,+ "Chapter thirty-one."+ ],+ [+ 1.55,+ "Why L is clean, and E is not."+ ],+ [+ 4.362,+ "Put all the steps of elimination into one matrix, and the numbers get mixed."+ ],+ [+ 9.974,+ "Put all the undo steps into one matrix, and they stay clean."+ ],+ [+ 14.401,+ "This chapter shows why."+ ]+ ]+ },+ "steps": {+ "dur": 46.968,+ "marks": {+ "sys": 1.94,+ "s1": 14.167,+ "skip": 20.951,+ "s2": 26.12,+ "u": 34.089,+ "l": 35.378+ },+ "cues": [+ [+ 0.117,+ "Here is a new system."+ ],+ [+ 1.94,+ "x plus two y plus z equals four, two x plus five y plus three z equals ten, and five y plus seven z equals twelve."+ ],+ [+ 11.029,+ "The three planes meet at one, one, one."+ ],+ [+ 14.167,+ "Step one: row two minus two times row one."+ ],+ [+ 18.06,+ "Row two becomes zero, one, one, two."+ ],+ [+ 20.951,+ "Row three already starts with zero, so column one needs no step there."+ ],+ [+ 26.12,+ "Step two: row three minus five times row two."+ ],+ [+ 30.078,+ "Row three becomes zero, zero, two, two."+ ],+ [+ 34.089,+ "That's U and c."+ ],+ [+ 35.378,+ "And beside it, L, as in chapter thirty: two in row two, column one; five in row three, column two; and zero where no step was needed."+ ]+ ]+ },+ "emat": {+ "dur": 46.704,+ "marks": {+ "write": 2.956,+ "calc": 12.904,+ "r3": 22.383,+ "res": 39.622,+ "ten": 42.344+ },+ "cues": [+ [+ 0.104,+ "Now put both steps into one matrix."+ ],+ [+ 2.956,+ "E three two times E two one times A is U."+ ],+ [+ 6.992,+ "So the one matrix is E equals E three two times E two one."+ ],+ [+ 12.904,+ "Multiply them, row by row."+ ],+ [+ 15.052,+ "Rows one and two of E three two are rows of the identity, so they copy rows one and two of E two one."+ ],+ [+ 22.383,+ "Row three of E three two is zero, minus five, one: minus five times row two of E two one, plus row three."+ ],+ [+ 31.094,+ "Minus five times minus two, one, zero is ten, minus five, zero."+ ],+ [+ 36.654,+ "Add zero, zero, one, and you get ten, minus five, one."+ ],+ [+ 42.344,+ "A ten!"+ ],+ [+ 43.216,+ "Elimination never used a ten."+ ],+ [+ 45.508,+ "Where did it come from?"+ ]+ ]+ },+ "where": {+ "dur": 37.752,+ "marks": {+ "recipe": 3.997,+ "step2": 10.3,+ "new": 14.818,+ "mix": 19.974,+ "take": 24.648,+ "ten": 32.487+ },+ "cues": [+ [+ 0.091,+ "Read row three of E as a recipe for the new row three."+ ],+ [+ 3.997,+ "Ten times row one, minus five times row two, plus row three, all rows of A."+ ],+ [+ 10.3,+ "Here is why."+ ],+ [+ 11.289,+ "Step two took away five times the new row two."+ ],+ [+ 14.818,+ "But the new row two was already row two minus two times row one."+ ],+ [+ 19.974,+ "So five times it is five times row two, minus ten times row one."+ ],+ [+ 24.648,+ "Taking that away from row three takes away five times row two, and adds back ten times row one."+ ],+ [+ 32.487,+ "The ten is the five times the two."+ ],+ [+ 34.909,+ "The second step reached back through the first one."+ ]+ ]+ },+ "onego": {+ "dur": 32.616,+ "marks": {+ "set": 1.367,+ "go": 4.583,+ "r3": 9.349,+ "res": 26.654,+ "u": 29.857+ },+ "cues": [+ [+ 0.104,+ "Let's watch E do it."+ ],+ [+ 1.367,+ "Here is E, in front of A and b."+ ],+ [+ 4.583,+ "Its three numbers slide in together, and both planes turn at once."+ ],+ [+ 9.349,+ "Row three of the answer: ten times row one is ten, twenty, ten, forty."+ ],+ [+ 14.792,+ "Minus five times row two is minus ten, minus twenty-five, minus fifteen, minus fifty."+ ],+ [+ 21.914,+ "Plus row three, zero, five, seven, twelve."+ ],+ [+ 26.654,+ "Together: zero, zero, two, two."+ ],+ [+ 29.857,+ "The same U as before, in one step."+ ]+ ]+ },+ "q1": {+ "dur": 4.128,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Quick check."+ ],+ [+ 1.12,+ "Multiply two elimination matrices."+ ]+ ]+ },+ "order": {+ "dur": 35.064,+ "marks": {+ "socks": 3.047,+ "inv": 11.107,+ "first": 19.557,+ "p1": 25.169,+ "second": 27.018,+ "p2": 31.888+ },+ "cues": [+ [+ 0.091,+ "Now go back, from U to A."+ ],+ [+ 3.047,+ "Chapter twenty-eight said: to undo two steps, undo them in reverse order, like taking off your shoes before your socks."+ ],+ [+ 11.107,+ "So the inverse of E three two times E two one is E two one inverse times E three two inverse."+ ],+ [+ 19.557,+ "First undo the last step: add five times row two back to row three."+ ],+ [+ 25.169,+ "The yellow plane turns back."+ ],+ [+ 27.018,+ "Then undo the first step: add two times row one back to row two."+ ],+ [+ 31.888,+ "The coral plane turns back, and we are at A again."+ ]+ ]+ },+ "lmat": {+ "dur": 42.984,+ "marks": {+ "write": 3.919,+ "r1": 8.503,+ "r2": 15.82,+ "r3": 22.917,+ "clean": 32.07+ },+ "cues": [+ [+ 0.104,+ "Multiply the two undo matrices into one."+ ],+ [+ 3.919,+ "L equals E two one inverse times E three two inverse."+ ],+ [+ 8.503,+ "Row one of E two one inverse is one, zero, zero: it copies row one: one, zero, zero."+ ],+ [+ 15.82,+ "Row two is two, one, zero: two times row one, plus row two."+ ],+ [+ 21.211,+ "That's two, one, zero."+ ],+ [+ 22.917,+ "Row three is zero, zero, one: it copies row three of E three two inverse, zero, five, one."+ ],+ [+ 32.07,+ "So L is one, zero, zero; two, one, zero; zero, five, one."+ ],+ [+ 38.75,+ "No ten."+ ],+ [+ 39.727,+ "Just the two and the five, each in its own spot."+ ]+ ]+ },+ "why": {+ "dur": 48.768,+ "marks": {+ "read": 1.263,+ "rows": 11.198,+ "used": 14.518,+ "chk": 26.003,+ "res": 34.232,+ "e": 39.232+ },+ "cues": [+ [+ 0.104,+ "Why is L clean?"+ ],+ [+ 1.263,+ "Read row three of L as a recipe too."+ ],+ [+ 4.062,+ "Row three of A is zero times row one of U, plus five times row two of U, plus row three of U."+ ],+ [+ 11.198,+ "It uses the rows of U: the finished rows."+ ],+ [+ 14.518,+ "And row two of U is exactly the row that step two subtracted, five times."+ ],+ [+ 20.0,+ "So adding it back five times gives row three of A at once, with nothing to correct."+ ],+ [+ 26.003,+ "Five times zero, one, one, two is zero, five, five, ten."+ ],+ [+ 30.846,+ "Add zero, zero, two, two, and you get zero, five, seven, twelve: row three of A."+ ],+ [+ 39.232,+ "E works the other way."+ ],+ [+ 40.625,+ "It has to build row three of U from the rows of A, and row two of A is not the row that was used."+ ],+ [+ 47.044,+ "That's where the ten came in."+ ]+ ]+ },+ "ex2": {+ "dur": 59.496,+ "marks": {+ "sys": 2.175,+ "l": 10.143,+ "e": 17.487,+ "rows": 20.833,+ "r3": 28.138,+ "then": 35.104,+ "res": 41.68,+ "five": 48.984,+ "go": 54.362,+ "back": 57.695+ },+ "cues": [+ [+ 0.104,+ "One more, with all three steps."+ ],+ [+ 2.175,+ "Here the multipliers are two for row two, one for row three, and then three for row three, column two."+ ],+ [+ 10.143,+ "L is just these: one, zero, zero; two, one, zero; one, three, one."+ ],+ [+ 17.487,+ "Now E, the product of the three steps."+ ],+ [+ 20.833,+ "Rows one and two are easy: one, zero, zero, and minus two, one, zero."+ ],+ [+ 28.138,+ "For row three, the first step takes away one times row one: minus one, zero, one."+ ],+ [+ 35.104,+ "Then the last step takes away three times the new row two, which is minus two, one, zero."+ ],+ [+ 41.68,+ "Minus one, zero, one, minus three times minus two, one, zero, gives five, minus three, one."+ ],+ [+ 48.984,+ "A five: minus one, plus three times two."+ ],+ [+ 52.917,+ "The steps mixed again."+ ],+ [+ 54.362,+ "On the planes, E does all three steps at once, and L brings them all back."+ ]+ ]+ },+ "q2": {+ "dur": 5.568,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Your turn."+ ],+ [+ 1.094,+ "Find the one matrix E that does all of elimination."+ ]+ ]+ },+ "rule": {+ "dur": 33.24,+ "marks": {+ "l": 2.839,+ "no": 12.305,+ "e": 17.982,+ "big": 26.875+ },+ "cues": [+ [+ 0.104,+ "So here is the rule, for any size."+ ],+ [+ 2.839,+ "L has ones on its diagonal, and the multiplier ell i j in row i, column j: how much of row j was taken from row i."+ ],+ [+ 12.305,+ "No multiplying needed."+ ],+ [+ 13.971,+ "Write each multiplier down as you go, and L is done."+ ],+ [+ 17.982,+ "E is different."+ ],+ [+ 19.076,+ "In row three, column one, it has minus ell three one, plus ell three two times ell two one."+ ],+ [+ 26.875,+ "Its numbers mix, and the mixing grows as the matrix grows."+ ],+ [+ 31.25,+ "That's why we keep L, not E."+ ]+ ]+ },+ "q3": {+ "dur": 2.856,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Quick check."+ ],+ [+ 1.146,+ "Find row three of E."+ ]+ ]+ },+ "wrap": {+ "dur": 34.44,+ "marks": {+ "w1": 1.003,+ "w2": 9.961,+ "w3": 20.69,+ "w4": 27.513,+ "end": 32.175+ },+ "cues": [+ [+ 0.104,+ "To sum up."+ ],+ [+ 1.003,+ "E, the product of the elimination steps, mixes them: a later step reaches back through an earlier one, and a stray number appears."+ ],+ [+ 9.961,+ "To undo the steps, undo them in reverse order: L equals E two one inverse, times E three one inverse, times E three two inverse."+ ],+ [+ 20.69,+ "L is clean: each multiplier ell i j sits in row i, column j."+ ],+ [+ 27.513,+ "That's because L builds A from the rows of U, the rows that were really used."+ ],+ [+ 32.175,+ "Now try the chapter practice."+ ]+ ]+ },+ "final1": {+ "dur": 3.192,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Chapter practice."+ ],+ [+ 1.576,+ "Find row three of E."+ ]+ ]+ },+ "final2": {+ "dur": 3.528,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Set two."+ ],+ [+ 1.107,+ "Write L from the same multipliers."+ ]+ ]+ },+ "final3": {+ "dur": 4.2,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Set three."+ ],+ [+ 1.172,+ "True or false, and the order of undoing."+ ]+ ]+ },+ "final4": {+ "dur": 4.104,+ "marks": {},+ "cues": [+ [+ 0.091,+ "Last set."+ ],+ [+ 1.198,+ "Build L and E with your own hands."+ ]+ ]+ },+ "play": {+ "dur": 7.752,+ "marks": {+ "go": 3.724+ },+ "cues": [+ [+ 0.104,+ "Playground."+ ],+ [+ 1.068,+ "Nothing here is marked right or wrong."+ ],+ [+ 3.724,+ "Change E's numbers, and look for the one that clears row three."+ ]+ ]+ },+ "finish": {+ "dur": 11.304,+ "marks": {},+ "cues": [+ [+ 0.104,+ "Well done."+ ],+ [+ 1.12,+ "That's the end of chapter thirty-one, Why L Is Clean and E Is Not."+ ],+ [+ 6.133,+ "Next: the pivots come out of U, and A becomes L times D times U."+ ]+ ]+ }+};diff --git a/site/linear-algebra/ch31/audio/en/where.mp3 b/site/linear-algebra/ch31/audio/en/where.mp3new file mode 100644index 0000000..2a433faBinary files /dev/null and b/site/linear-algebra/ch31/audio/en/where.mp3 differdiff --git a/site/linear-algebra/ch31/audio/en/why.mp3 b/site/linear-algebra/ch31/audio/en/why.mp3new file mode 100644index 0000000..9bf344cBinary files /dev/null and b/site/linear-algebra/ch31/audio/en/why.mp3 differdiff --git a/site/linear-algebra/ch31/audio/en/wrap.mp3 b/site/linear-algebra/ch31/audio/en/wrap.mp3new file mode 100644index 0000000..6a4ffe0Binary files /dev/null and b/site/linear-algebra/ch31/audio/en/wrap.mp3 differdiff --git a/site/linear-algebra/ch31/index.html b/site/linear-algebra/ch31/index.htmlnew file mode 100644index 0000000..fa4f4c9--- /dev/null+++ b/site/linear-algebra/ch31/index.html@@ -0,0 +1,443 @@+<!doctype html>+<html lang="en">+<head>+<meta charset="utf-8">+<meta name="viewport" content="width=device-width, initial-scale=1">+<title>Why L Is Clean and E Is Not</title>+<link rel="stylesheet" href="../lib/engine.css">+<link rel="expect" href="#bar" blocking="render"><!-- hold the first frame until the player exists, so the page transition can run -->+</head>+<body>+<script src="../lib/engine.js"></script>+<script src="../lib/math.js"></script>+<script src="../lib/linsys.js"></script>+<script src="../lib/space3.js"></script>+<script src="../lib/elim.js"></script>+<script src="../lib/emat.js"></script>+<script src="../lib/play.js"></script>+<script src="audio/en/timings.js"></script>+<script>+'use strict';+const CHAPTER = { number: 31, title: 'Why L Is Clean and E Is Not', minutes: 10, language: 'en' };++/* ---------- chapter drawing helpers ---------- */+const BLUE = LS_ROW[0], CORAL = LS_ROW[1], YELLOW = S3_ROW[2];+// The lecture's pattern (OCW 18.06, lecture 4): ℓ₂₁ = 2, no step for row 3, column 1, ℓ₃₂ = 5; E gets a 10, L does not.+const SYS1 = { A: [[1, 2, 1], [2, 5, 3], [0, 5, 7]], b: [4, 10, 12] }, SYS1U = { A: [[1, 2, 1], [0, 1, 1], [0, 0, 2]], b: [4, 2, 2] };+const E1 = [[1, 0, 0], [-2, 1, 0], [10, -5, 1]], L1 = [[1, 0, 0], [2, 1, 0], [0, 5, 1]];+const E21 = [[1, 0, 0], [-2, 1, 0], [0, 0, 1]], E32 = [[1, 0, 0], [0, 1, 0], [0, -5, 1]];+const E21i = [[1, 0, 0], [2, 1, 0], [0, 0, 1]], E32i = [[1, 0, 0], [0, 1, 0], [0, 5, 1]];+// All three steps: ℓ₂₁ = 2, ℓ₃₁ = 1, ℓ₃₂ = 3; E's stray number is −1 + 3 · 2 = 5.+const SYS2 = { A: [[1, 1, 2], [2, 3, 5], [1, 4, 6]], b: [4, 10, 11] }, SYS2U = { A: [[1, 1, 2], [0, 1, 1], [0, 0, 1]], b: [4, 2, 1] };+const E2 = [[1, 0, 0], [-2, 1, 0], [5, -3, 1]], L2 = [[1, 0, 0], [2, 1, 0], [1, 3, 1]];+const AT2 = [70, 290], AT3 = [64, 262];+const CARD3 = { x: 40, y: 640, w: 800, cls: 'side' };+const say = (p, parts, x, y, t0, { size = 40, fill = COL.chalk, anchor = 'start' } = {}) => { const e = M(p, [].concat(parts), { x, y, size, fill, anchor, o: 0 }); show(e, t0); return e; };+const text = (p, str, x, y, t0, { size = 30, fill = COL.chalk, anchor = 'start', weight = 500 } = {}) => { const e = T(p, str, { x, y, size, fill, anchor, weight, o: 0 }); show(e, t0); return e; };+const thick = (sys, i, t0) => { tw(sys.lines[i].l, { 'a_stroke-width': 10 }, t0, .35); tw(sys.lines[i].l, { 'a_stroke-width': 5 }, t0 + .9, .6); };+// 2D: the plane on the right, E · [A | b] = [EA | Eb] on the left (chapter 21's layout); the product is the system drawn+// (with E given, the lines start as E's answer).+const two = (p, { A, b }, caption, { t0 = .1, E = null } = {}) => {+ const sys = linsys(p, { A, b, eq: [90, 200], mat: null, sol: false, plane: { cx: 1215, u: 50 }, t0 });+ sys.E.style.visibility = 'hidden'; // hidden, yet measured (display: none measures as 0 and replays differ)+ if (caption) say(p, [caption], 70, 175, t0 + .1, { size: 28, fill: COL.dim });+ const em = emat(p, sys, { A, b, E, at: AT2, size: 38, cw: 64, ecw: 56, rh: 62, gap: 66, t0 });+ return { sys, em };+};+// 3D: the space on the right, three 3 × 3 tables on the left.+const three = (p, { A, b }, caption, { t0 = .1, E = null, view = { yaw: -40, pitch: 20 } } = {}) => {+ const sys = lin3(p, { A, b, eq: [90, 190], mat: null, sol: false, space: { cx: 1262, size: 520, ...view }, t0 });+ sys.E.style.visibility = 'hidden'; // hidden, yet measured (display: none measures as 0 and replays differ)+ if (caption) say(p, [caption], 64, 160, t0 + .1, { size: 26, fill: COL.dim });+ const em = emat(p, sys, { A, b, E, at: AT3, size: 32, cw: 52, ecw: 44, rh: 54, gap: 64, t0 });+ return { sys, em, V: sys.space };+};+// A matrix times a matrix with no picture (E⁻¹E = I): emat on a bare system, the b columns hidden.+const bare = A => {+ const v = {}, fs = [];+ A.forEach((r, i) => { r.forEach((x, j) => { v[`a${i}${j}`] = x; }); v[`b${i}`] = 0; });+ return { v, set(to) { Object.assign(v, to); fs.forEach(f => f(v)); }, onChange: f => fs.push(f), solve: () => ({}), live() {}, to() {} };+};+const mm2 = (p, Ebig, Bm, names, nameE, t0) => emat(p, bare(Bm), { A: Bm, b: [0, 0], E: Ebig, at: AT2, size: 38, cw: 64, ecw: 56, rh: 62, gap: 66, t0, noB: true, names, name: nameE });+// The old line of row 2 (dashed): a x + b y through (sx, sy); a ring round the point that never moves (chapter 16).+const ghost = (sys, a, b, sx, sy, t0) => { const l = sys.P.line(sx, sy, sx + b, sy - a, CORAL, t0, { dash: '10 10', w: 3, into: sys.stage }); tw(l, { o: .45 }, t0 + .6, .4); return l; };+const pin = (sys, x, y, t0) => { const g = G(sys.stage, { x: sys.P.PX(x), y: sys.P.PY(y), o: 0 }); mk('circle', { r: 20, fill: 'none', stroke: COL.chalk, 'stroke-width': 3.5, 'stroke-dasharray': '6 5' }, g); show(g, t0, .4); return g; };+const hinge = (sys, n, t0, dur = 1.6) => prog(q => sys.lines[n].e.setAttribute('stroke-width', 2.5 + 5 * Math.sin(Math.PI * q)), t0, dur, lin);+const nameAt = (em, nm, at) => prog(q => { if (q > 0) em.setName(nm); }, at, 0, lin);+const namesAt = (em, nm, at) => prog(q => { if (q > 0) em.names(nm); }, at, 0, lin);+// Three words of a row step: "row 2", "+ 3 ×", "row 1", coloured by row.+const stepWords = (p, i, sign, j, x, y, t0, { size = 32 } = {}) => {+ const g = G(p, { o: 0 }), RC = [BLUE, CORAL, YELLOW];+ M(g, [`row ${i + 1}`], { x, y, size, fill: RC[i], anchor: 'start' });+ M(g, [sign], { x: x + size * 3.3, y, size, fill: COL.chalk, anchor: 'start' });+ M(g, [`row ${j + 1}`], { x: x + size * 3.3 + mathW([sign], size) + size * .4, y, size, fill: RC[j], anchor: 'start' });+ show(g, t0, .4);+ return g;+};+const keysOf = ({ A, b }, E = null) => {+ const o = {}, n = A.length;+ A.forEach((r, i) => { r.forEach((x, j) => { o[`a${i}${j}`] = x; o[`e${i}${j}`] = E ? E[i][j] : +(i === j); }); o[`b${i}`] = b[i]; });+ return o;+};+// inside a question: the answer becomes the new [A | b] at once and E the identity (em.carry without the flight)+const carryNow = em => { const o = { ...em.prod() }; for (let i = 0; i < em.n; i++) for (let j = 0; j < em.n; j++) o[`e${i}${j}`] = +(i === j); em.set(o); };+const same = (pr, { A, b }) => A.every((r, i) => r.every((x, j) => Math.abs(pr[`a${i}${j}`] - x) < 1e-9) && Math.abs(pr[`b${i}`] - b[i]) < 1e-9);+const r1 = x => num(Math.round(x * 10) / 10);+const rowTxt = (pr, i, n) => `(${[...Array(n).keys()].map(j => r1(pr[`a${i}${j}`])).join(', ')} | ${r1(pr[`b${i}`])})`;++// A matrix times a matrix with no picture (E₃₂E₂₁): emat on a bare system, the b columns hidden (chapter 21).+const mm3 = (p, Ebig, Bm, names, nameE, t0) => emat(p, bare(Bm), { A: Bm, b: [0, 0, 0], E: Ebig, at: AT3, size: 32, cw: 52, ecw: 44, rh: 54, gap: 64, t0, noB: true, names, name: nameE });+// A matrix of math parts (letters allowed); .ring(i, j, at) circles an entry. cws: one width per column.+const symMat = (p, rows, x, y, t0, { size = 34, cws = null, rh = 50, name = '' } = {}) => {+ const g = G(p, { o: 0 }), n = rows.length, W = cws || rows[0].map(() => 56), w = W.reduce((a, b) => a + b, 0), top = y - size * .95, bot = y + (n - 1) * rh + size * .35;+ const cx = j => x + W.slice(0, j).reduce((a, b) => a + b, 0) + W[j] / 2;+ path(g, `M${x + 12} ${top}H${x}V${bot}H${x + 12}M${x + w - 12} ${top}H${x + w}V${bot}H${x + w - 12}`, { stroke: COL.chalk, 'stroke-width': 3, fill: 'none' });+ rows.forEach((r, i) => r.forEach((v, j) => M(g, [].concat(typeof v === 'number' ? num(v) : v), { x: cx(j), y: y + i * rh, size, fill: COL.chalk, anchor: 'middle' })));+ if (name) M(g, [].concat(name), { x: x - 18, y: y + (n - 1) * rh / 2 + 10, size: size * 1.05, fill: COL.chalk, anchor: 'end' });+ show(g, t0, .5);+ g.ring = (i, j, at, { dash = false, color = COL.chalk } = {}) => { const e = mk('ellipse', { cx: cx(j), cy: y + i * rh - size * .32, rx: W[j] * .48, ry: size * .62, fill: 'none', stroke: color, 'stroke-width': 3, ...(dash ? { 'stroke-dasharray': '7 6' } : {}) }, p); put(e, { o: 0 }); show(e, at, .35); return e; };+ return g;+};+const emL = Lm => { const o = {}; Lm.forEach((r, i) => r.forEach((x, j) => { o[`e${i}${j}`] = x; })); return o; };+const upperOK = pr => [pr.a10, pr.a20, pr.a21].every(x => Math.abs(x) < 1e-9);++/* ---------- practice data (every answer worked twice: by multiplying the step matrices, and by −ℓ₃₁ + ℓ₃₂ℓ₂₁) ---------- */+const EROWQ = [+ { parts: ['ℓ₂₁ = 2, ℓ₃₂ = 5, no step for row 3, column 1: row 3 of E = (', { box: '10' }, ', ', { box: '-5' }, ', ', { box: '1' }, ')'], why: '−5 × (−2, 1, 0) + (0, 0, 1) = (10, −5, 1): the lecture’s 10.', hint: 'Row 3 of E₃₂ is (0, −5, 1); it mixes the rows of E₂₁.' },+ { parts: ['ℓ₂₁ = 3, ℓ₃₂ = 2, no step for row 3, column 1: row 3 of E = (', { box: '6' }, ', ', { box: '-2' }, ', ', { box: '1' }, ')'], why: '−2 × (−3, 1, 0) + (0, 0, 1) = (6, −2, 1).', hint: 'Row 2 of E₂₁ is (−3, 1, 0).' },+ { parts: ['ℓ₂₁ = −1, ℓ₃₂ = 3, no step for row 3, column 1: row 3 of E = (', { box: '-3' }, ', ', { box: '-3' }, ', ', { box: '1' }, ')'], why: '−3 × (1, 1, 0) + (0, 0, 1) = (−3, −3, 1). Check: 0 + 3 × (−1) = −3.', hint: 'ℓ₂₁ = −1, so row 2 of E₂₁ is (1, 1, 0).' },+];+const EROWQ2 = [+ { parts: ['ℓ₂₁ = 1, ℓ₃₁ = 2, ℓ₃₂ = 4: row 3 of E = (', { box: '2' }, ', ', { box: '-4' }, ', ', { box: '1' }, ')'], why: 'After the first two steps row 3 of the record is (−2, 0, 1); then − 4 × (−1, 1, 0): (2, −4, 1). Check: −2 + 4 × 1 = 2.', hint: 'Row 3: first (−ℓ₃₁, 0, 1), then take away ℓ₃₂ × (−ℓ₂₁, 1, 0).' },+ { parts: ['ℓ₂₁ = 2, ℓ₃₁ = 6, ℓ₃₂ = 3: row 3 of E = (', { box: '0' }, ', ', { box: '-3' }, ', ', { box: '1' }, ')'], why: '(−6, 0, 1) − 3 × (−2, 1, 0) = (0, −3, 1): here the mixing cancels.', hint: 'Use −ℓ₃₁ + ℓ₃₂ℓ₂₁ for the first number.' },+];+const LROWQ = [+ { parts: ['ℓ₂₁ = 2, ℓ₃₂ = 5, no step for row 3, column 1: L row 2 = (', { box: '2' }, ', 1, 0), L row 3 = (', { box: '0' }, ', ', { box: '5' }, ', 1)'], why: 'Each ℓ in its place, 0 where no step was needed. No 10.', hint: 'ℓᵢⱼ goes into row i, column j.' },+ { parts: ['ℓ₂₁ = 1, ℓ₃₁ = 2, ℓ₃₂ = 4: L row 3 = (', { box: '2' }, ', ', { box: '4' }, ', 1)'], why: 'ℓ₃₁ = 2, ℓ₃₂ = 4, untouched.', hint: 'Row 3 of L is (ℓ₃₁, ℓ₃₂, 1).' },+ { parts: ['ℓ₂₁ = −1, ℓ₃₂ = 3: L row 2 = (', { box: '-1' }, ', 1, 0), L row 3 = (', { box: '0' }, ', ', { box: '3' }, ', 1)'], why: 'The multipliers themselves, signs and all.', hint: 'L holds ℓ, not −ℓ.' },+ { parts: ['ℓ₂₁ = 2, ℓ₃₁ = 6, ℓ₃₂ = 3: L row 3 = (', { box: '6' }, ', ', { box: '3' }, ', 1)'], why: 'E’s row 3 had (0, −3, 1) here; L simply has 6 and 3.', hint: 'Nothing to compute: copy the multipliers.' },+];+const TFQ = [+ { parts: [$m('E = E₃₂E₃₁E₂₁'), ' has each multiplier in its place.'], ans: ['f'], why: 'Its row 3, column 1 holds −ℓ₃₁ + ℓ₃₂ℓ₂₁, a mix.' },+ { parts: [$m('L = E₂₁⁻¹E₃₁⁻¹E₃₂⁻¹')], ans: ['t'], why: 'The undo steps, in reverse order.' },+ { parts: [$m('(E₃₂E₂₁)⁻¹ = E₃₂⁻¹E₂₁⁻¹')], ans: ['f'], why: 'Reverse order: E₂₁⁻¹E₃₂⁻¹ (shoes off before socks).' },+ { parts: ['Row 3 of L says how much of each row of U makes row 3 of A.'], ans: ['t'], why: 'LU = A, row by row.' },+ { parts: ['If no step was needed in row 3, column 1, L has 0 there.'], ans: ['t'], why: 'ℓ₃₁ = 0, and L keeps it.' },+ { parts: ['If ℓ₃₁ = 0, E has 0 in row 3, column 1.'], ans: ['f'], why: 'E has ℓ₃₂ℓ₂₁ there: the lecture’s 10.' },+];+const SYS3 = { A: [[1, 1, 1], [2, 3, 4], [0, 3, 7]], b: [3, 9, 10] };+const LEC = { A: [[1, 2, 1], [3, 8, 1], [0, 4, 1]], b: [2, 12, 2] }, LECU = { A: [[1, 2, 1], [0, 2, -2], [0, 0, 5]], b: [2, 6, -10] };+const rowsTxt = s => s.A.map((r, i) => `(${r.map(num).join(', ')} | ${num(s.b[i])})`).join(', ');+const HANDS = [+ { kind: 'L', from: SYS2U, to: SYS2, ans: { e10: 2, e20: 1, e21: 3 }, prompt: `L in front of U | c: change L’s numbers below the diagonal until LU | Lc is ${rowsTxt(SYS2)}.`,+ why: 'L = (1, 0, 0), (2, 1, 0), (1, 3, 1): the three multipliers, untouched.' },+ { kind: 'E', from: SYS3, ans: { e10: -2, e20: 6, e21: -3 }, prompt: 'One E for all of elimination: change E’s numbers below the diagonal until EA is upper triangular (ℓ₂₁ = 2, ℓ₃₂ = 3).',+ why: 'E = (1, 0, 0), (−2, 1, 0), (6, −3, 1): the 6 is 3 × 2, the mix.' },+ { kind: 'L', from: LECU, to: LEC, ans: { e10: 3, e20: 0, e21: 2 }, prompt: `Chapter 18’s system: change L’s numbers until LU | Lc is ${rowsTxt(LEC)}.`,+ why: 'L = (1, 0, 0), (3, 1, 0), (0, 2, 1): ℓ₂₁ = 3, no step for row 3, column 1, ℓ₃₂ = 2.' },+];+const handTest = h => (v, pr) => h.kind === 'E' ? upperOK(pr) : same(pr, h.to);+const handHint = h => (v, pr) => {+ if (h.kind === 'E') return `The answer still has ${r1(pr.a10)}, ${r1(pr.a20)}, ${r1(pr.a21)} below the diagonal. Row 3 of E must undo row 3’s x after counting what the new row 2 brings: −ℓ₃₁ + ℓ₃₂ℓ₂₁.`;+ const i = [1, 2].find(i => rowTxt(pr, i, 3) !== rowTxt(h.to, i, 3)) ?? 1;+ return `Row ${i + 1} is ${rowTxt(pr, i, 3)}, not ${rowTxt(h.to, i, 3)}. L holds the multipliers themselves.`;+};++/* ---------- beats ---------- */+const BEATS = [+ ['intro', 'Why L is clean', (m, D) => {+ const g = G(scene, { o: 0, y: 24 });+ T(g, 'Unit 4 · Factorization into A = LU', { x: 800, y: 205, size: 24, fill: COL.faint, anchor: 'middle' });+ T(g, 'Unit 4, Chapter 31', { x: 800, y: 250, size: 28, fill: COL.dim, anchor: 'middle' });+ T(g, 'Why L Is Clean and E Is Not', { x: 800, y: 360, size: 80, weight: 600, anchor: 'middle' });+ tw(g, { o: 1, y: 0 }, .2, 1.1, out);+ const r = text(scene, 'the steps mix inside E; inside L each multiplier keeps its place', 800, 460, m('sub'), { size: 34, fill: COL.dim, anchor: 'middle' });+ const lg = G(scene, { o: 0 });+ const Em = symMat(lg, E1, 520, 610, 0, { size: 34, name: 'E =' }), Lm = symMat(lg, L1, 980, 610, 0, { size: 34, name: 'L =' });+ show(lg, m('sub') + 1.2, .5);+ Em.ring(2, 0, m('sub') + 3.6, { dash: true }); Lm.ring(1, 0, m('sub') + 7.2, { color: COL.good }); Lm.ring(2, 1, m('sub') + 7.6, { color: COL.good });+ pulse(lg, m('move') + .3, 1.06);+ tw(g, { o: 0, y: -24 }, D - .9, .8); hide(r, D - .9, .8); hide(lg, D - .9, .8);+ }],++ ['steps', 'Two steps', (m) => {+ const p = panel(0);+ text(p, 'Two steps, and L', 60, 110, .2, { size: 40, weight: 600 });+ const sys = lin3(p, { A: SYS1.A, b: SYS1.b, eq: [90, 190], mat: null, sol: false, space: { cx: 1250, size: 540, yaw: -35, pitch: 20 }, t0: m('sys') - .3 });+ sys.E.style.visibility = 'hidden';+ say(p, ['x + 2y + z = 4, 2x + 5y + 3z = 10, 5y + 7z = 12'], 90, 172, m('sys'), { size: 28, fill: COL.dim });+ const el = elim(p, sys, { at: [120, 260], size: 44, cw: 84, rh: 66, t0: m('sys') - .3, labelX: 520 });+ const L = elL(p, el, { at: [150, 590], size: 38, cw: 60, rh: 56, t0: m('s1') - .4 });+ [0, 1, 2].forEach(i => el.flash(i, m('sys') + .8 + 2.6 * i));+ sys.space.turn({ yaw: -10 }, m('sys') + 7, m('s1') - m('sys') - 6);+ el.ring(0, 0, m('s1'));+ L.step(1, 0, 2, m('s1') + .3, 3, { lag: .3 });+ el.flash(1, m('s1') + 4.4);+ el.ring(2, 0, m('skip'), { dash: true });+ L.put(2, 0, 0, m('skip') + 2);+ el.ring(1, 1, m('s2'));+ L.step(2, 1, 5, m('s2') + .3, 3, { lag: .3 });+ el.flash(2, m('s2') + 4.4);+ sys.space.turn({ yaw: 0, pitch: 32 }, m('s2'), 6);+ el.upper(m('u'));+ L.tri(m('l'));+ L.flash(1, 0, m('l') + 2.4); L.flash(2, 1, m('l') + 4.6); L.flash(2, 0, m('l') + 7);+ }],++ ['emat', 'One matrix', (m) => {+ const p = panel(0);+ text(p, 'One matrix for both steps', 60, 110, .2, { size: 40, weight: 600 });+ say(p, ['E₃₂ (E₂₁ A) = U'], 64, 175, m('write'), { size: 34 });+ say(p, ['E = E₃₂E₂₁'], 420, 175, m('write') + 3.6, { size: 34 });+ const em = mm3(p, E32, E21, ['E₂₁', '', 'E₃₂E₂₁', ''], 'E₃₂', m('write') + 3.4);+ put(em.Pt.g, { o: 0 }); put(em.eqSign, { o: 0 }); show(em.Pt.g, m('calc'), .5); show(em.eqSign, m('calc'), .4);+ em.ringE(2, 1, m('write') + 5); em.B.ring(1, 0, m('write') + 6.4);+ em.flashE(0, m('calc') + 1.5); em.flashE(1, m('calc') + 2.3);+ em.flashE(2, m('r3') + 1.5); em.B.flash(1, m('r3') + 7.5); em.B.flash(2, m('r3') + 14);+ em.work(0, 0, { times: [m('calc') + 4.4, m('calc') + 4.6, m('calc') + 4.8, m('calc') + 5.4] }); em.Pt.flash(0, m('calc') + 5.6);+ em.work(1, 0, { times: [m('calc') + 6.6, m('calc') + 6.8, m('calc') + 7, m('calc') + 7.6] }); em.Pt.flash(1, m('calc') + 7.8);+ em.focusE(2, m('r3'));+ em.work(2, 0, { times: [m('r3') + 5, m('r3') + 12, m('r3') + 15.5, m('res')] }); em.Pt.flash(2, m('res') + .2);+ em.focusE(null, m('ten'));+ em.Pt.ring(2, 0, m('ten'), { dash: true });+ text(p, 'elimination never used a 10', 64, 700, m('ten') + .8, { size: 30, weight: 600 });+ text(p, 'where did it come from?', 64, 750, m('ten') + 2.6, { size: 28, fill: COL.dim, weight: 600 });+ }],++ ['where', 'Where the 10 comes from', (m) => {+ const p = panel(0);+ text(p, 'Where the 10 comes from', 60, 110, .2, { size: 40, weight: 600 });+ const sys = lin3(p, { A: SYS1.A, b: SYS1.b, eq: [90, 190], mat: null, sol: false, space: { cx: 1262, size: 520, yaw: -30, pitch: 20 } });+ sys.E.style.visibility = 'hidden';+ sys.space.sway(4, 20);+ const line = (str, y, t0, { size = 30, fill = COL.chalk } = {}) => text(p, str, 64, y, t0, { size, fill, weight: 600 });+ symMat(p, [E1[2]], 330, 190, m('recipe') - .6, { size: 32, name: 'row 3 of E:' });+ line('new row 3 = 10 × row 1 − 5 × row 2 + row 3', 260, m('recipe') + .4);+ line('step 2: new row 3 = row 3 − 5 × (new row 2)', 370, m('step2') + .4);+ sys.focus(2, m('step2'));+ line('step 1: new row 2 = row 2 − 2 × row 1', 440, m('new') + .4);+ sys.focus(1, m('new'));+ line('5 × (new row 2) = 5 × row 2 − 10 × row 1', 510, m('mix') + .6);+ sys.focus(null, m('mix'));+ line('new row 3 = row 3 − 5 × row 2 + 10 × row 1', 580, m('take') + 1);+ const t10 = line('10 = 5 × 2', 670, m('ten') + .3, { size: 40 });+ pulse(t10, m('ten') + 1.6, 1.15);+ line('the second step reached back through the first', 730, m('ten') + 3, { size: 26, fill: COL.dim });+ }],++ ['onego', 'E in one go', (m) => {+ const p = panel(0);+ text(p, 'E does both steps at once', 60, 110, .2, { size: 40, weight: 600 });+ const { sys, em, V } = three(p, SYS1, 'x + 2y + z = 4, 2x + 5y + 3z = 10, 5y + 7z = 12', { t0: m('set') - .3 });+ em.setName('E');+ em.to(emL(E1), m('go') + .3, 3);+ hinge(sys, 0, m('go') + 3.4, 1.6); hinge(sys, 2, m('go') + 3.4, 1.6);+ V.turn({ yaw: -10, pitch: 28 }, m('go'), 7);+ em.focusE(2, m('r3')); em.Pt.focus(2, m('r3'));+ em.work(2, 0, { times: [m('r3') + .8, m('r3') + 5.5, m('r3') + 12.5, m('res')] }); em.Pt.flash(2, m('res') + .2);+ [0, 1, 2].forEach((i, k) => em.B.flash(i, m('r3') + [.8, 5.5, 12.5][k]));+ em.focusE(null, m('u')); em.Pt.focus(null, m('u'));+ namesAt(em, ['A', 'b', 'U', 'c'], m('u'));+ em.Pt.upper(m('u') + .4);+ }],++ ['q1', 'Quick check', () => {+ const p = panel(0);+ text(p, 'Quick check', 60, 110, .2, { size: 40, weight: 600 });+ say(p, ['ℓ₂₁ = 3, ℓ₃₂ = 2, no step for row 3, column 1'], 64, 175, .3, { size: 30, fill: COL.dim });+ const em = mm3(p, [[1, 0, 0], [0, 1, 0], [0, -2, 1]], [[1, 0, 0], [-3, 1, 0], [0, 0, 1]], ['E₂₁', '', 'E₃₂E₂₁', ''], 'E₃₂', .2);+ put(em.Pt.g, { o: 0 });+ S.em = em;+ }, { ask: done => quiz({ x: 40, y: 470, w: 800, cls: 'side' }, [{+ id: 'c-erow', prompt: ['Row 3 of E = E₃₂E₂₁, and row 3 of L.'],+ build: blanks([+ { parts: ['row 3 of E = (', { box: '6' }, ', ', { box: '-2' }, ', ', { box: '1' }, ')'], why: '−2 × (−3, 1, 0) + (0, 0, 1) = (6, −2, 1): a stray 6 = 2 × 3.', hint: 'Row 3 of E₃₂ is (0, −2, 1): −2 of row 2 of E₂₁, plus its row 3.',+ fx: () => fx(S.em.Pt.g, { o: 1 }, 0, .5) },+ { parts: ['row 3 of L = (', { box: '0' }, ', ', { box: '2' }, ', 1)'], why: 'L just holds ℓ₃₁ = 0 and ℓ₃₂ = 2.', hint: 'L holds the multipliers themselves.' },+ ]),+ }], done) }],++ ['order', 'Undo in reverse order', (m, D) => {+ const p = panel(0);+ text(p, 'Undo in reverse order', 60, 110, .2, { size: 40, weight: 600 });+ const { sys, em, V } = three(p, SYS1U, 'U and c', { view: { yaw: -20, pitch: 26 } });+ em.setName('E₃₂⁻¹'); em.names(['U', 'c', '', '']);+ text(p, 'on: socks, then shoes. off: shoes, then socks.', 64, 680, m('socks') + 1, { size: 26, fill: COL.dim, weight: 600 });+ say(p, ['on: E₂₁ first, then E₃₂'], 64, 730, m('socks') + 3.5, { size: 30 });+ const f = say(p, ['(E₃₂E₂₁)⁻¹ = E₂₁⁻¹E₃₂⁻¹'], 64, 800, m('inv') + .3, { size: 38 });+ pulse(f, m('inv') + 5, 1.1);+ em.ringE(2, 1, m('first') + .6);+ em.work(2, 0, { times: [m('first') + 1.5, m('first') + 2, m('first') + 2.5, m('p1')] });+ em.to({ e21: 5 }, m('first') + 1.6, 2.6);+ sys.focus(2, m('p1') - .5); sys.focus(null, m('second'));+ em.work(null, m('second') - .3, .3);+ em.carry(m('second'), 1, { names: ['', '', '', ''] });+ nameAt(em, 'E₂₁⁻¹', m('second') + 1);+ em.ringE(1, 0, m('second') + 1.2);+ em.work(1, 0, { times: [m('second') + 1.6, m('second') + 2, m('second') + 2.4, m('p2')] });+ em.to({ e10: 2 }, m('second') + 1.6, 2.4);+ sys.focus(1, m('p2') - .4);+ namesAt(em, ['', '', 'A', 'b'], m('p2'));+ V.turn({ yaw: -45, pitch: 20 }, .5, Math.max(4, D - .5));+ }],++ ['lmat', 'L in one matrix', (m) => {+ const p = panel(0);+ text(p, 'L = E₂₁⁻¹ E₃₂⁻¹', 60, 110, .2, { size: 40, weight: 600 });+ const em = mm3(p, E21i, E32i, ['E₃₂⁻¹', '', 'L', ''], 'E₂₁⁻¹', m('write'));+ em.ringE(1, 0, m('write') + 1.6, { color: COL.good }); em.B.ring(2, 1, m('write') + 2.6, { color: COL.good });+ [0, 1, 2].forEach(i => em.Pt.flash(i, m('clean') + .5 + 1.4 * i));+ em.Pt.ring(2, 0, m('clean') + 5.4, { dash: true, color: COL.dim });+ put(em.Pt.g, { o: 0 }); put(em.eqSign, { o: 0 }); show(em.Pt.g, m('r1'), .5); show(em.eqSign, m('r1'), .4);+ em.focusE(0, m('r1')); em.work(0, 0, { times: [m('r1') + 2.6, m('r1') + 3, m('r1') + 3.4, m('r1') + 4.2] }); em.Pt.flash(0, m('r1') + 4.4);+ em.focusE(1, m('r2')); em.work(1, 0, { times: [m('r2') + 2, m('r2') + 3.2, m('r2') + 3.6, m('r2') + 4.6] }); em.Pt.flash(1, m('r2') + 4.8);+ em.focusE(2, m('r3')); em.work(2, 0, { times: [m('r3') + 2, m('r3') + 2.4, m('r3') + 3, m('r3') + 4.4] }); em.Pt.flash(2, m('r3') + 4.6);+ em.focusE(null, m('clean'));+ em.Pt.ring(1, 0, m('clean') + 4, { color: COL.good }); em.Pt.ring(2, 1, m('clean') + 4.6, { color: COL.good });+ text(p, 'no 10: just the 2 and the 5, each in its own spot', 64, 700, m('clean') + 4, { size: 30, weight: 600 });+ }],++ ['why', 'Why nothing mixes', (m, D) => {+ const p = panel(0);+ text(p, 'Why nothing mixes', 60, 110, .2, { size: 40, weight: 600 });+ const { sys, em, V } = three(p, SYS1U, 'U and c', { view: { yaw: -20, pitch: 26 } });+ em.setName('L'); em.names(['U', 'c', 'LU', 'Lc']);+ em.to(emL(L1), m('read'), 2.4);+ em.focusE(2, m('read')); em.Pt.focus(2, m('read'));+ em.work(2, 0, { times: [m('read') + 4, m('chk') - .3, m('chk') + 4, m('res')] });+ em.B.flash(1, m('used') + 1); em.Pt.flash(2, m('used') + 8); em.B.flash(1, m('chk') + .3); em.B.flash(2, m('chk') + 4.2);+ [0, 1, 2].forEach(i => em.B.flash(i, m('rows') + .4 * i));+ em.B.ring(1, 1, m('used') + 1);+ em.Pt.flash(2, m('res') + .2);+ namesAt(em, ['U', 'c', 'A', 'b'], m('res'));+ em.focusE(null, m('e')); em.Pt.focus(null, m('e'));+ text(p, 'L builds A from the rows of U: the rows really used', 64, 700, m('rows') + .6, { size: 28, weight: 600 });+ text(p, 'E builds U from the rows of A: hence the 10', 64, 760, m('e') + 1, { size: 28, fill: COL.dim, weight: 600 });+ V.turn({ yaw: -45 }, m('read'), 8); V.turn({ yaw: -10, pitch: 30 }, m('rows'), Math.max(4, D - m('rows')));+ }],++ ['ex2', 'All three steps', (m, D) => {+ const p = panel(0);+ text(p, 'All three steps', 60, 110, .2, { size: 40, weight: 600 });+ const { sys, em, V } = three(p, SYS2, 'x + y + 2z = 4, 2x + 3y + 5z = 10, x + 4y + 6z = 11', { t0: .3 });+ em.setName('E');+ say(p, ['ℓ₂₁ = 2, ℓ₃₁ = 1, ℓ₃₂ = 3'], 64, 470, m('sys') + 1, { size: 32 });+ const Lm = symMat(p, L2, 700, 520, m('l'), { size: 32, cws: [50, 50, 50], rh: 46, name: 'L =' });+ Lm.ring(1, 0, m('l') + 2.4, { color: COL.good }); Lm.ring(2, 0, m('l') + 3, { color: COL.good }); Lm.ring(2, 1, m('l') + 3.6, { color: COL.good });+ say(p, ['E rows 1, 2: (1, 0, 0), (−2, 1, 0)'], 64, 540, m('rows'), { size: 28 });+ say(p, ['E row 3: (−1, 0, 1)'], 64, 600, m('r3') + .4, { size: 28 });+ say(p, ['− 3 × (−2, 1, 0)'], 64, 650, m('then') + 1.6, { size: 28 });+ say(p, ['= (5, −3, 1)'], 64, 700, m('res') + 4, { size: 28 });+ const r5 = G(p, { o: 0 }); mk('ellipse', { cx: 108, cy: 690, rx: 20, ry: 22, fill: 'none', stroke: COL.chalk, 'stroke-width': 3, 'stroke-dasharray': '7 6' }, r5); show(r5, m('five'), .3);+ text(p, '5 = −1 + 3 × 2', 260, 700, m('five') + .6, { size: 26, fill: COL.dim, weight: 600 });+ [0, 1, 2].forEach(i => em.B.flash(i, m('sys') + 1 + 2.4 * i));+ em.to({ e10: -2 }, m('rows') + 1, 1.5); // E built as the steps go: E₂₁, then E₃₁E₂₁, then all three+ em.to({ e20: -1 }, m('r3') + .6, 1.5);+ em.to({ e20: 5, e21: -3 }, m('res') + 4, 1.8);+ hide(em.ringE(2, 0, m('five'), { dash: true }), m('back'), .3);+ hinge(sys, 0, m('go') + .2, 1.4); hinge(sys, 2, m('go') + .2, 1.4);+ em.carry(m('back') + .1, .8, { names: ['U', 'c', '', ''] });+ nameAt(em, 'L', m('back') + .9);+ em.to(emL(L2), m('back') + 1, 1.8);+ namesAt(em, ['U', 'c', 'A', 'b'], m('back') + 2.8);+ V.turn({ yaw: 15, pitch: 26 }, 12, m('go') - 12); V.turn({ yaw: -15, pitch: 20 }, m('go'), Math.max(3, D - m('go')));+ }],++ ['q2', 'Your turn', () => {+ const p = panel(0);+ text(p, 'Your turn', 60, 110, .2, { size: 40, weight: 600 });+ const t = three(p, SYS2, 'x + y + 2z = 4, 2x + 3y + 5z = 10, x + 4y + 6z = 11');+ t.em.setName('E');+ S.em = t.em;+ }, { ask: done => quiz(CARD3, [{+ id: 'c-oneE', prompt: ['Change E’s three numbers below the diagonal until EA is upper triangular: U in one step.'],+ build: emTask(S.em, (v, pr) => upperOK(pr), 'E = (1, 0, 0), (−2, 1, 0), (5, −3, 1): the 5 is −1 + 3 × 2, the mix.',+ (v, pr) => `Below the diagonal the answer still has ${r1(pr.a10)}, ${r1(pr.a20)}, ${r1(pr.a21)}. Row 2 first; then row 3 must also undo what the new row 2 brings.`,+ () => S.em.set(emL(E2)), { only: ['e10', 'e20', 'e21'] }),+ }], done) }],++ ['rule', 'The rule', (m) => {+ const p = panel(0);+ text(p, 'The rule for L, and the trouble with E', 60, 110, .2, { size: 40, weight: 600 });+ const Lm = symMat(p, [['1', '0', '0'], ['ℓ₂₁', '1', '0'], ['ℓ₃₁', 'ℓ₃₂', '1']], 200, 300, m('l'), { size: 40, cws: [80, 80, 80], rh: 64, name: 'L =' });+ Lm.ring(1, 0, m('l') + 2.4); Lm.ring(2, 0, m('l') + 3); Lm.ring(2, 1, m('l') + 3.6);+ text(p, 'ℓᵢⱼ: how much of row j was taken from row i', 100, 520, m('l') + 4, { size: 28, weight: 600 });+ text(p, 'write each multiplier down as you go: L is done', 100, 580, m('no') + .5, { size: 28, fill: COL.dim, weight: 600 });+ const Em = symMat(p, [['1', '0', '0'], ['−ℓ₂₁', '1', '0'], ['−ℓ₃₁ + ℓ₃₂ℓ₂₁', '−ℓ₃₂', '1']], 900, 300, m('e'), { size: 40, cws: [250, 90, 70], rh: 64, name: 'E =' });+ Em.ring(2, 0, m('e') + 2.4, { dash: true });+ text(p, 'lecture: 0 + 5 × 2 = 10 all three steps: −1 + 3 × 2 = 5', 900, 520, m('e') + 5, { size: 26, fill: COL.dim, weight: 600 });+ text(p, 'bigger matrices: more mixing in E, none in L', 900, 580, m('big') + .5, { size: 28, weight: 600 });+ }],++ ['q3', 'Quick check', () => {+ const p = panel(0);+ text(p, 'Quick check', 60, 110, .2, { size: 40, weight: 600 });+ say(p, ['ℓ₂₁ = 4, ℓ₃₂ = 1, no step for row 3, column 1'], 64, 175, .3, { size: 30, fill: COL.dim });+ const em = mm3(p, [[1, 0, 0], [0, 1, 0], [0, -1, 1]], [[1, 0, 0], [-4, 1, 0], [0, 0, 1]], ['E₂₁', '', 'E₃₂E₂₁', ''], 'E₃₂', .2);+ put(em.Pt.g, { o: 0 });+ S.em = em;+ }, { ask: done => quiz({ x: 40, y: 470, w: 800, cls: 'side' }, [{+ id: 'c-row3', prompt: ['Row 3 of E = E₃₂E₂₁ is …'],+ build: choice(['(4, −1, 1)', '(0, −1, 1)', '(−4, −1, 1)', '(0, 1, 1)'], 0,+ '−1 × (−4, 1, 0) + (0, 0, 1) = (4, −1, 1): ℓ₃₂ℓ₂₁ = 1 × 4.',+ [null, 'That is row 3 of E₃₂ alone: it forgets that row 2 had already changed.', 'Minus times minus: −1 × (−4) = +4.', 'That is row 3 of L (with ℓ₃₂ = 1), not of E.'],+ () => fx(S.em.Pt.g, { o: 1 }, 0, .5)),+ }], done) }],++ ['wrap', 'Summary', (m) => {+ const p = panel(0);+ [['E = E₃₂E₃₁E₂₁ mixes the steps: a stray number appears (the 10).', 'w1'], ['Undo in reverse order: L = E₂₁⁻¹E₃₁⁻¹E₃₂⁻¹.', 'w2'],+ ['L is clean: each multiplier ℓᵢⱼ sits in row i, column j.', 'w3'], ['L builds A from the rows of U: the rows that were really used.', 'w4']].forEach(([str, mark], i) => {+ const g = G(p, { x: -16, y: 230 + i * 130, o: 0 });+ mk('circle', { cx: 120, cy: -12, r: 26, fill: COL.chalk }, g);+ T(g, String(i + 1), { x: 120, y: -1, size: 30, fill: COL.board, weight: 700, anchor: 'middle' });+ T(g, str, { x: 170, size: 34, weight: 600 });+ tw(g, { o: 1, x: 0 }, m(mark), .6);+ });+ }],+ ['final1', 'Chapter practice', () => { panel(0); }, { ask: done => quiz(SCREEN, [{+ id: 'p-erow', prompt: ['Row 3 of E, the product of the steps. (Multiply the step matrices, or use −ℓ₃₁ + ℓ₃₂ℓ₂₁.)'],+ build: blanks(EROWQ),+ }, {+ id: 'p-erow2', prompt: ['All three steps now.'],+ build: blanks(EROWQ2),+ }], done, 'Chapter practice · set 1 of 4') }],+ ['final2', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{+ id: 'p-lrow', prompt: ['The same multipliers, now into L.'],+ build: blanks(LROWQ),+ }], done, 'Chapter practice · set 2 of 4') }],+ ['final3', 'Chapter practice', () => {}, { ask: done => quiz(SCREEN, [{+ id: 'p-tf', prompt: ['True or false?'],+ build: grid(TFQ, TF, { text: true }),+ }, {+ id: 'p-first', prompt: ['Order of undoing.'],+ build: blanks([{ parts: ['E₃₂E₂₁ A = U. To get A back, first undo E', { box: '32' }, ', then E', { box: '21' }], why: 'The last step is undone first: A = E₂₁⁻¹(E₃₂⁻¹U).', hint: 'Shoes off before socks: which step was done last?' }]),+ }], done, 'Chapter practice · set 3 of 4') }],+ ['final4', 'Chapter practice', () => {+ const p = panel(0);+ text(p, 'Build L and E', 60, 110, .2, { size: 40, weight: 600 });+ const t = three(p, SYS2U, '');+ S.em = t.em;+ }, { ask: done => quiz(CARD3, HANDS.map((h, k) => ({+ id: `p-hand${k + 1}`, prompt: [h.prompt],+ build: (body, api) => {+ S.em.set(keysOf(h.from)); S.em.setName(h.kind);+ S.em.names(h.kind === 'L' ? ['U', 'c', 'LU', 'Lc'] : ['A', 'b', 'EA', 'Eb']);+ return emTask(S.em, handTest(h), h.why, handHint(h), () => S.em.set(h.ans), { only: ['e10', 'e20', 'e21'] })(body, api);+ },+ })), done, 'Chapter practice · set 4 of 4') }],+ ['play', 'Playground', (m) => {+ const p = panel(0);+ text(p, 'Playground', 60, 110, .2, { size: 40, weight: 600 });+ const t = three(p, SYS2, '');+ t.em.setName('E');+ S.em = t.em;+ text(p, 'try: −2 in row 2, column 1 and −3 in row 3, column 2; then find what row 3, column 1 needs', 64, 160, m('go'), { size: 24, fill: COL.dim });+ }, { ask: playAsk(() => S.em, { pos: { x: 40, y: 470, w: 800, cls: 'side' }, tip: 'Your E, A and b. Change any number, turn the space, or draw on the board. Nothing is marked.' }) }],+ ['finish', 'Finished', () => { panel(0); }, { ask: finishCard }],+].map(([id, title, run, extra]) => ({ id, title, run, ...extra }));++boot();+</script>+</body>+</html>diff --git a/site/linear-algebra/lib/elim.js b/site/linear-algebra/lib/elim.jsindex 0fb6b9d..5032f00 100644--- a/site/linear-algebra/lib/elim.js+++ b/site/linear-algebra/lib/elim.js@@ -13,6 +13,8 @@// el.opNow(2, 1) // inside a question: open "row 3 − ℓ × row 2" at once// el.swap(1, 2, at, dur, { label: [x, y] }) // rows 2 and 3 slide past each other (elSwap, below)// elim(p, sys, { noB: true }) // A alone: no divider, no b column (a matrix times a matrix)+// const L = elL(p, el, { at: [x, y] }) // (10-28) L beside the table: L.step(1, 0, 2, at) flies each multiplier into place+// el.onL(f) // (10-28) f(i, j, l) whenever the reader scrubs the multiplier//// While elim is attached, move the system through el.to(next, at, dur) (or el.step, el.mult): elim keeps the plan// that the next step starts from. Hands on: el.scrub(true) makes the open operation's multiplier a number to drag@@ -222,6 +224,7 @@ function elim(p, sys, { at: [x0, y0] = [130, 450], size = 46, cw = 96, rh = 70,cur.base = rowOf(plan, cur.i); cur.l = cur.shown = 0; lNow = 0;if (scrubOn) base = { ...cur.base };cur.lab.lay(0);+ lfs.forEach(f => f(cur.i, cur.j, 0));}/* ---------- hands on: the multiplier as a number to drag ---------- */@@ -230,7 +233,8 @@ function elim(p, sys, { at: [x0, y0] = [130, 450], size = 46, cw = 96, rh = 70,// The reader's state: the system's numbers and the multiplier. Row i of the open operation is always// base − l × row j; base follows whatever the reader changes in the system itself.let base = null, quiet = false;- const apply = () => { quiet = true; sys.set(minus(base, cur.i, cur.j, lNow, sys.v)); quiet = false; cur.lab.lay(lNow); };+ const lfs = []; // el.onL(f): f(i, j, l) whenever the reader's multiplier changes (elL follows it)+ const apply = () => { quiet = true; sys.set(minus(base, cur.i, cur.j, lNow, sys.v)); quiet = false; cur.lab.lay(lNow); lfs.forEach(f => f(cur.i, cur.j, lNow)); };const bind = () => {if (bound || !cur) return;bound = true;@@ -344,6 +348,7 @@ function elim(p, sys, { at: [x0, y0] = [130, 450], size = 46, cw = 96, rh = 70,scrub(on);},solve: () => sys.solve(),+ onL: f => lfs.push(f),swap: (i, j, at, dur, opts) => elSwap(api, sys, i, j, at, dur, opts),};return api;@@ -389,6 +394,93 @@ function elSwap(el, sys, i, j, at, dur = 1.4, { label = null, now = false } = {}return lab;}+// L beside an elimination (added 10-28, chapter 30): the matrix L that keeps the multipliers. It starts as the identity+// with an empty place under the diagonal for each step; L.step runs el.step and then flies the boxed multiplier into+// its place in L (row i, column j: the row it changed, the row it used). Draw it in the same parent as el.+//+// const L = elL(p, el, { at: [x, y] }); // size, cw, rh, name ('L'), dens+// L.step(1, 0, 2, at, dur) // row 2 − 2 × row 1 on the table; then the 2 lands in row 2, column 1 of L+// L.put(2, 0, 0, at) // a place filled at once (0: no step was needed there); null empties it+// L.tri(at); L.ring(i, j, at); L.flash(i, j, at)+// L.follow(true) // inside a question: the open operation's multiplier shows in its place+// L.clear() // every place under the diagonal empty again, at once+function elL(p, el, { at: [x0, y0] = [100, 600], size = 38, cw = 60, rh = 56, name = 'L', t0 = .1, o = 0, dens = [1, 2, 3, 4, 5] } = {}) {+ const n = el.n, I = [...Array(n).keys()];+ const g = G(p, { o });+ show(g, t0 + .2);+ const cx = j => x0 + cw * (j + .5), ry = i => y0 + i * rh;+ const top = y0 - size * .95, bot = y0 + (n - 1) * rh + size * .35, W = n * cw;+ path(g, `M${x0 + 12} ${top}H${x0}V${bot}H${x0 + 12}M${x0 + W - 12} ${top}H${x0 + W}V${bot}H${x0 + W - 12}`, { stroke: COL.chalk, 'stroke-width': 3, fill: 'none' });+ const nameG = M(g, [].concat(name), { x: x0 + W / 2, y: top - 16, size: 28, fill: COL.dim, anchor: 'middle' });+ const parts = v => {+ const r = Math.round(v);+ if (Math.abs(v - r) < 1e-9) return [num(r)];+ for (const d of dens) { const k = Math.round(v * d); if (d > 1 && Math.abs(v * d - k) < 1e-9) { const gg = gcd(Math.abs(k), d); return k < 0 ? ['−', F(Math.abs(k) / gg, d / gg)] : [F(k / gg, d / gg)]; } }+ return [num(Math.round(v * 10) / 10)];+ };+ const cells = I.map(i => I.map(j => {+ const c = G(g, { x: cx(j), y: ry(i) });+ const glow = mk('rect', { x: -cw / 2 + 4, y: -size * .9, width: cw - 8, height: size * 1.2, rx: 10, fill: COL.chalk }, c);+ put(glow, { o: 0 });+ let slot = null;+ if (i > j) { slot = mk('rect', { x: -cw / 2 + 8, y: -size * .82, width: cw - 16, height: size * 1.04, rx: 8, fill: 'none', stroke: COL.faint, 'stroke-width': 2, 'stroke-dasharray': '5 5' }, c); }+ const holder = G(c, {});+ if (i <= j) M(holder, [i === j ? '1' : '0'], { size, fill: i === j ? COL.chalk : COL.dim, anchor: 'middle' });+ return { c, glow, slot, holder, v: i === j ? 1 : i < j ? 0 : null };+ }));+ const setCell = (i, j, v) => {+ const cl = cells[i][j];+ if (i <= j || cl.v === v) return;+ cl.v = v;+ cl.holder.replaceChildren();+ cl.slot.setAttribute('stroke-opacity', v === null ? 1 : 0);+ if (v !== null) M(cl.holder, parts(v), { size, fill: COL.chalk, anchor: 'middle' });+ };+ const flash = (i, j, at) => { tw(cells[i][j].glow, { o: .3 }, at, .25); tw(cells[i][j].glow, { o: 0 }, at + 1.1, .6); };+ let following = false;+ el.onL((i, j, l) => { if (following) setCell(i, j, l); });+ const api = {+ g, cells, cx, ry, nameG, W,+ get v() { return cells.map(r => r.map(c => c.v)); },+ put(i, j, v, at) { prog(q => { if (q > 0) setCell(i, j, v); }, at, 0, lin); if (v !== null) flash(i, j, at); },+ // el.step, then the multiplier flies from its box into L: { fly } is the flight's length, { lag } its start after the step+ step(i, j, l, at, dur = 1.8, { fly = 1, lag = .2, ...opts } = {}) {+ const end = el.step(i, j, l, at, dur, opts), lab = el.op_.lab, f0 = end + lag;+ const fg = G(g, { o: 0 });+ M(fg, parts(l), { size: 36, fill: COL.chalk, anchor: 'middle' });+ let from = null;+ prog(q => {+ if (!from) { const w = +lab.mbox.getAttribute('width') || 38; from = [st(lab.g).x + st(lab.mult).x + (w - 18) / 2, st(lab.g).y]; }+ put(fg, { x: from[0] + (cx(j) - from[0]) * q, y: from[1] + (ry(i) - from[1]) * q, s: 1 + (size / 36 - 1) * q });+ }, f0, fly, io);+ tw(fg, { o: 1 }, f0, .15);+ tw(fg, { o: 0 }, f0 + fly, 0);+ api.put(i, j, l, f0 + fly);+ return f0 + fly;+ },+ tri(at, { color = COL.chalk, dur = .6 } = {}) {+ const L = j => cx(j) - cw / 2 + 2, R = j => cx(j) + cw / 2 - 2, mid = i => ry(i) - size * .32, T_ = i => mid(i) - rh / 2 + 3, B_ = i => mid(i) + rh / 2 - 3;+ let d = `M${L(0)} ${T_(0)}H${R(0)}`;+ for (let i = 0; i < n - 1; i++) d += `V${B_(i)}H${R(i + 1)}`;+ d += `V${B_(n - 1)}H${L(0)}Z`;+ const e = path(g, d, { fill: color, 'fill-opacity': .12, stroke: color, 'stroke-opacity': .75, 'stroke-width': 2.5, 'stroke-linejoin': 'round' }, { o: 0 });+ g.insertBefore(e, g.firstChild);+ show(e, at, dur);+ return e;+ },+ ring(i, j, at, { color = COL.chalk, dash = false } = {}) {+ const rg = G(g, { x: cx(j), y: ry(i) - size * .32, o: 0 });+ mk('ellipse', { rx: cw * .46, ry: size * .62, fill: 'none', stroke: color, 'stroke-width': 3.5, ...(dash ? { 'stroke-dasharray': '7 6' } : {}) }, rg);+ show(rg, at, .35);+ return rg;+ },+ flash,+ follow(on) { following = on; const c = el.op_; if (on && c) setCell(c.i, c.j, el.l); },+ clear() { I.forEach(i => I.forEach(j => { if (i > j) setCell(i, j, null); })); },+ };+ return api;+}+// A question on the multiplier: the reader scrubs it (and, with only, some of the system's numbers) until test holds.const elTask = (el, test, why, hint, reveal, { only = [] } = {}) => (body, api) => {el.live(true, { only });diff --git a/site/linear-algebra/lib/emat.js b/site/linear-algebra/lib/emat.jsindex 8d2e5b9..40acbc3 100644--- a/site/linear-algebra/lib/emat.js+++ b/site/linear-algebra/lib/emat.js@@ -17,6 +17,8 @@ const EM_ROW = [COL.whole, COL.nat, COL.int], EM_COL = [COL.irr, COL.real, COL.r// em.ringE(1, 0, at) // a circle round E's entry in row 2, column 1// em.live(true, { only: ['e10'] }) // the reader scrubs E's entry (drag sideways, or Tab and ↑/↓)//+// em.carry(at, dur, { E, names }) // (10-28) the answer flies back into [A | b]; E becomes I (or E): undo, or step again+// em.triE(at, { upper }) // (10-28) the lower (or upper) staircase behind E's numbers: L// em.v and em.set work for playAsk; emTask is the question type. Keys: e<i><j> for E, a<i><j> and b<i> for A and b.function emat(p, sys, { A, b, E = null, at: [x0, y0] = [70, 270], size = 40, cw = 70, ecw = 60, rh = 62, gap = 70, t0 = .1, dens = [1, 2], side = 'left', name = 'E', names = null, noB = false, step: eStep = 1, o = 0 } = {}) {const n = A.length, I = [...Array(n).keys()], svg = $('stage');@@ -121,7 +123,7 @@ function emat(p, sys, { A, b, E = null, at: [x0, y0] = [70, 270], size = 40, cwif (workN <= n) return;path(W, `M${bx - 10} ${y(n - 1) + size * .45}H${bx + (noB ? n * cw : B.W)}`, { stroke: COL.chalk, 'stroke-width': 2.5 });sum.forEach((v, j) => (j < n || !noB) && M(W, parts(v), { x: B.cx(j), y: y(n) + 8, size: size * .85, fill: j === n ? COL.task : COL.chalk, anchor: 'middle' }));- T(W, `row ${i + 1} of ${nm[2]}`, { x: bx - 36, y: y(n) + 4, size: 24, fill: EM_ROW[i], weight: 700, anchor: 'end' });+ T(W, `row ${i + 1} of ${nm[2] || 'the answer'}`, { x: bx - 36, y: y(n) + 4, size: 24, fill: EM_ROW[i], weight: 700, anchor: 'end' });}// Show the working for row i (null: hide it) at `at`; it stays live while the numbers move.// { times: [t1, …] } brings its lines in one at a time: the first row of A's share at t1, the next at t2, …, and@@ -218,6 +220,37 @@ function emat(p, sys, { A, b, E = null, at: [x0, y0] = [70, 270], size = 40, cw},// Dim all of E but row i (null: all rows back).focusE(i, at, dur = .4) { I.forEach(r => [Ebars[r], ...ecells[r].map(c => c.c)].forEach(e => tw(e, { o: i === null || i === r ? 1 : .3 }, at, dur))); },+ // Carry the answer back in (added 10-28, chapters 29–31): the product's numbers fly into the place of [A | b], which+ // takes them, and E becomes E2 (the identity by default), so the product and the picture stay where they are; the+ // next em.to on E then acts on the answer (an undo step, or the next step). names: the four names after it.+ carry(at, dur = 1.2, { E: E2 = null, names: nm2 = null } = {}) {+ const pr = prod(plan), next = { ...pr }, cols = right || noB ? I : [...I, n];+ I.forEach(i => I.forEach(j => { next[`e${i}${j}`] = E2 ? E2[i][j] : +(i === j); }));+ if (right) I.forEach(i => { next[`b${i}`] = plan[`b${i}`]; });+ const fly = G(g, { o: 0 });+ I.forEach(i => cols.forEach(j => { const k = j < n ? `a${i}${j}` : `b${i}`; M(fly, parts(pr[k]), { x: Pt.cx(j), y: ry(i), size, fill: j === n ? COL.task : COL.chalk, anchor: 'middle' }); }));+ put(fly, { x: 0, o: 0 });+ const olds = B.cells.flat().map(cl => cl.c);+ const dx = B.cx(0) - Pt.cx(0), dip = n * rh + size * .4; // under the tables, so the numbers never pass through each other+ tw(fly, { o: 1 }, at, .2); prog(q => put(fly, { x: dx * q, y: dip * Math.sin(Math.PI * q) }), at, dur, io);+ olds.forEach(e => tw(e, { o: 0 }, at, Math.min(.4, dur / 2)));+ api.to(next, at + dur, 0);+ olds.forEach(e => tw(e, { o: 1 }, at + dur, 0));+ tw(fly, { o: 0 }, at + dur, 0);+ if (nm2) prog(q => { if (q > 0) relabel(nm2); }, at + dur, 0, lin);+ return at + dur;+ },+ // A staircase behind E's numbers (added 10-28): the lower triangle (on and below the diagonal: L), or { upper: true }.+ triE(at, { upper = false, color = COL.chalk, dur = .6 } = {}) {+ const L = j => ecx(j) - ecw / 2 + 2, R = j => ecx(j) + ecw / 2 - 2, mid = i => ry(i) - size * .32, T_ = i => mid(i) - rh / 2 + 3, B_ = i => mid(i) + rh / 2 - 3;+ let d;+ if (upper) { d = `M${L(0)} ${T_(0)}H${R(n - 1)}V${B_(n - 1)}`; for (let i = n - 1; i > 0; i--) d += `H${L(i)}V${B_(i - 1)}`; d += `H${L(0)}Z`; }+ else { d = `M${L(0)} ${T_(0)}H${R(0)}`; for (let i = 0; i < n - 1; i++) d += `V${B_(i)}H${R(i + 1)}`; d += `V${B_(n - 1)}H${L(0)}Z`; }+ const e = path(Eg, d, { fill: color, 'fill-opacity': .12, stroke: color, 'stroke-opacity': .75, 'stroke-width': 2.5, 'stroke-linejoin': 'round' }, { o: 0 });+ Eg.insertBefore(e, Eg.firstChild);+ show(e, at, dur);+ return e;+ },get v() { return { ...s }; },set(vals) { edit(vals); },live(on, { only = null } = {}) {