Skip to content

Commit 6a2ab1c

Browse files
committed
Update 3.6 to latest JupyterCards
1 parent a3e4ff0 commit 6a2ab1c

File tree

1 file changed

+98
-75
lines changed

1 file changed

+98
-75
lines changed

03-matrices/6-eigen.ipynb

Lines changed: 98 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Eigenvalues and Eigenvectors\n"
7+
"# Eigenvalues and Eigenvectors\n",
8+
"\n",
9+
"$~$"
810
]
911
},
1012
{
@@ -369,7 +371,7 @@
369371
{
370372
"data": {
371373
"text/html": [
372-
"<div style=\"height:40px\"></div><div class=\"flip-container\" id=\"NwVPXDktrHPg\" tabindex=\"0\" style=\"outline:none;\"></div><div style=\"height:40px\"></div><div class=\"next\" id=\"NwVPXDktrHPg-next\" onclick=\"window.checkFlip('NwVPXDktrHPg')\"> </div> <div style=\"height:40px\"></div>"
374+
"<div style=\"height:40px\"></div><div class=\"flip-container\" id=\"FairJEVINolE\" tabindex=\"0\" style=\"outline:none;\"></div><div style=\"height:40px\"></div><div class=\"next\" id=\"FairJEVINolE-next\" onclick=\"window.checkFlip('FairJEVINolE')\"> </div> <div style=\"height:40px\"></div>"
373375
],
374376
"text/plain": [
375377
"<IPython.core.display.HTML object>"
@@ -499,12 +501,14 @@
499501
" next.classList.add('hide');\n",
500502
"\n",
501503
" //container.classList.add(\"prepare\");\n",
502-
" \n",
504+
"\n",
503505
" container.className=\"flip-container slide\";\n",
506+
"\n",
504507
" backcard.parentElement.removeChild(frontcard);\n",
505508
" backcard.parentElement.appendChild(frontcard);\n",
509+
"\n",
506510
" setTimeout(slideback, 600, container, frontcard, backcard, next);\n",
507-
" \n",
511+
"\n",
508512
"}\n",
509513
"\n",
510514
"\n",
@@ -536,15 +540,16 @@
536540
"\n",
537541
" let cardOrder = JSON.parse(container.dataset.cardOrder);\n",
538542
"\n",
539-
" var cards=eval('cards'+container.id);\n",
543+
" //var cards=eval('cards'+container.id);\n",
544+
" var cards=JSON.parse(container.dataset.cards);\n",
540545
"\n",
541546
" var flipper=createOneCard(container, false, cards, cardOrder[cardnum], cardnum);\n",
542547
" container.append(flipper);\n",
543548
" cardnum= (cardnum+1) % parseInt(container.dataset.numCards);\n",
544-
" if ((cardnum == 0) && (container.dataset.shuffleCards == \"True\")) {\n",
549+
" if ((cardnum == 0) && (container.dataset.shuffleCards == \"true\")) {\n",
545550
" cardOrder = randomOrderArray(parseInt(container.dataset.numCards));\n",
546551
" container.dataset.cardOrder = JSON.stringify(cardOrder);\n",
547-
" console.log(cardOrder);\n",
552+
" //console.log(cardOrder);\n",
548553
" }\n",
549554
"\n",
550555
" container.dataset.cardnum=cardnum;\n",
@@ -599,9 +604,15 @@
599604
"\n",
600605
"\n",
601606
"function createOneCard (mydiv, frontCard, cards, cardnum, seq) {\n",
607+
" /*\n",
602608
" var colors=eval('frontColors'+mydiv.id);\n",
603609
" var backColors=eval('backColors'+mydiv.id);\n",
604610
" var textColors=eval('textColors'+mydiv.id);\n",
611+
" */\n",
612+
" var colors = JSON.parse(mydiv.dataset.frontColors);\n",
613+
" var backColors = JSON.parse(mydiv.dataset.backColors);\n",
614+
" var textColors = JSON.parse(mydiv.dataset.textColors);\n",
615+
"\n",
605616
" //console.log(backColors)\n",
606617
"\n",
607618
" var flipper = document.createElement('div');\n",
@@ -701,38 +712,44 @@
701712
"\n",
702713
"\n",
703714
"\n",
704-
"function createCards(id, keyControl, grabFocus, shuffleCards, title, subject) {\n",
715+
"function createCards(id, cards, keyControl, grabFocus, shuffleCards, title, subject,\n",
716+
" frontColors, backColors, textColors) {\n",
705717
" console.log(id);\n",
706718
"\n",
707719
" var mydiv=document.getElementById(id);\n",
708720
" /*mydiv.onclick = window.flipCard(mydiv);*/\n",
709721
" /*\n",
710-
" mydiv.addEventListener('click', function(){window.flipCard(mydiv);}, false);\n",
711-
" mydiv.addEventListener('keydown', function(event){window.checkKey(mydiv,event);}, true);\n",
722+
" mydiv.addEventListener('click', function(){window.flipCard(mydiv);}, false);\n",
723+
" mydiv.addEventListener('keydown', function(event){window.checkKey(mydiv,event);}, true);\n",
712724
" */\n",
713725
" mydiv.onclick = function(){window.flipCard(mydiv);};\n",
714-
" //console.log(keyControl);\n",
715-
" if (keyControl == \"True\"){\n",
726+
" if (keyControl == true){\n",
716727
" mydiv.onkeydown = function(event){window.checkKey(mydiv,event);};\n",
717728
" }\n",
718729
" /* mydiv.addEventListener('keydown', function(event){event.stopPropagation(); console.log(event); event.preventDefault();}, true); */\n",
719730
" /*mydiv.onkeypress = function(event){console.log(event); event.preventDefault();};*/\n",
720731
"\n",
721732
" //console.log(mydiv);\n",
722733
"\n",
723-
" var cards=eval('cards'+id);\n",
734+
" // var cards=eval('cards'+id);\n",
735+
" // Store cards and color data in the container's dataset for later access in cleanup()\n",
736+
" mydiv.dataset.cards = JSON.stringify(cards);\n",
737+
" mydiv.dataset.frontColors = JSON.stringify(frontColors);\n",
738+
" mydiv.dataset.backColors = JSON.stringify(backColors);\n",
739+
" mydiv.dataset.textColors = JSON.stringify(textColors);\n",
740+
"\n",
724741
" mydiv.dataset.cardnum=0;\n",
725742
" mydiv.dataset.numCards=cards.length;\n",
726743
"\n",
727744
" mydiv.dataset.shuffleCards = shuffleCards;\n",
728745
" var cardOrder;\n",
729-
" if (shuffleCards == \"True\"){\n",
746+
" if (shuffleCards == true){\n",
730747
" cardOrder = randomOrderArray(cards.length);\n",
731748
" } else {\n",
732749
" cardOrder = Array.from({ length: cards.length }, (_, index) => index);\n",
733750
" }\n",
734751
" mydiv.dataset.cardOrder = JSON.stringify(cardOrder);\n",
735-
" console.log(mydiv.dataset.cardOrder);\n",
752+
" //console.log(mydiv.dataset.cardOrder);\n",
736753
"\n",
737754
"\n",
738755
" mydiv.addEventListener('swiped-left', function(e) {\n",
@@ -844,7 +861,7 @@
844861
" next.innerHTML=\"Next >\";\n",
845862
" }\n",
846863
"\n",
847-
" if (grabFocus == \"True\" )\n",
864+
" if (grabFocus == true )\n",
848865
" mydiv.focus();\n",
849866
"\n",
850867
" return flipper;\n",
@@ -853,20 +870,20 @@
853870
"\n",
854871
"\n",
855872
"\n",
856-
"\n",
857-
" function try_create() {\n",
858-
" if(document.getElementById(\"NwVPXDktrHPg\")) {\n",
859-
" createCards(\"NwVPXDktrHPg\", \"True\", \"False\", \"False\", \"\", \"\");\n",
860-
" } else {\n",
861-
" setTimeout(try_create, 200);\n",
862-
" }\n",
863-
" };\n",
864-
" \n",
865-
"var cardsNwVPXDktrHPg=[{\"front\": \"eigenvector\", \"back\": \"Given a square $n \\\\times n$ matrix $\\\\mathbf{M}$, a non-zero $n$-vector $\\\\mathbf{u}$ is an <I>eigenvector</I> of $\\\\mathbf{M}$ if there exists a constant $\\\\lambda$ such that \\\\begin{equation} \\\\mathbf{Mu} = \\\\lambda \\\\mathbf{u}. \\\\end{equation}\"}, {\"front\": \"eigenvalue\", \"back\": \"Given a square $n \\\\times n$ matrix $\\\\mathbf{M}$, a constant $\\\\lambda$ is an <I>eigenvalue</I> of $\\\\mathbf{M}$ if there exists a non-zero vector $\\\\mathbf{u}$ such that \\\\[ \\\\mathbf{Mu} = \\\\lambda \\\\mathbf{u}. \\\\]\"}, {\"front\": \"modal matrix\", \"back\": \"For a square matrix \\\\(\\\\mathbf{M}\\\\), the modal matrix is a matrix whose columns are the unit eigenvectors of \\\\(\\\\mathbf{M}\\\\).\"}];\n",
866-
"var frontColorsNwVPXDktrHPg= [\"var(--asparagus)\", \"var(--terra-cotta)\", \"var(--cyan-process)\" ];\n",
867-
"var backColorsNwVPXDktrHPg= [\"var(--dark-blue-gray)\" ];\n",
868-
"var textColorsNwVPXDktrHPg= [\"var(--snow)\" ];\n",
869-
"try_create(); "
873+
"var cardsFairJEVINolE = [{\"front\": \"eigenvector\", \"back\": \"Given a square $n \\\\times n$ matrix $\\\\mathbf{M}$, a non-zero $n$-vector $\\\\mathbf{u}$ is an <I>eigenvector</I> of $\\\\mathbf{M}$ if there exists a constant $\\\\lambda$ such that \\\\begin{equation} \\\\mathbf{Mu} = \\\\lambda \\\\mathbf{u}. \\\\end{equation}\"}, {\"front\": \"eigenvalue\", \"back\": \"Given a square $n \\\\times n$ matrix $\\\\mathbf{M}$, a constant $\\\\lambda$ is an <I>eigenvalue</I> of $\\\\mathbf{M}$ if there exists a non-zero vector $\\\\mathbf{u}$ such that \\\\[ \\\\mathbf{Mu} = \\\\lambda \\\\mathbf{u}. \\\\]\"}, {\"front\": \"modal matrix\", \"back\": \"For a square matrix \\\\(\\\\mathbf{M}\\\\), the modal matrix is a matrix whose columns are the unit eigenvectors of \\\\(\\\\mathbf{M}\\\\).\"}];\n",
874+
"var frontColorsFairJEVINolE = [\"var(--asparagus)\", \"var(--terra-cotta)\", \"var(--cyan-process)\"];\n",
875+
"var backColorsFairJEVINolE = [\"var(--dark-blue-gray)\"];\n",
876+
"var textColorsFairJEVINolE = [\"var(--snow)\"];\n",
877+
"(function() {\n",
878+
" var observer = new MutationObserver(function(mutations, obs) {\n",
879+
" var el = document.getElementById(\"FairJEVINolE\");\n",
880+
" if (el) {\n",
881+
" createCards(\"FairJEVINolE\", cardsFairJEVINolE, true, false, false, \"\", \"\", frontColorsFairJEVINolE, backColorsFairJEVINolE, textColorsFairJEVINolE);\n",
882+
" obs.disconnect();\n",
883+
" }\n",
884+
" });\n",
885+
" observer.observe(document.body, { childList: true, subtree: true });\n",
886+
" })();"
870887
],
871888
"text/plain": [
872889
"<IPython.core.display.Javascript object>"
@@ -1172,7 +1189,7 @@
11721189
{
11731190
"data": {
11741191
"text/html": [
1175-
"<div style=\"height:40px\"></div><div class=\"flip-container\" id=\"GdkuSvByJKyr\" tabindex=\"0\" style=\"outline:none;\"></div><div style=\"height:40px\"></div><div class=\"next\" id=\"GdkuSvByJKyr-next\" onclick=\"window.checkFlip('GdkuSvByJKyr')\"> </div> <div style=\"height:40px\"></div>"
1192+
"<div style=\"height:40px\"></div><div class=\"flip-container\" id=\"tIRlIqMiYAZw\" tabindex=\"0\" style=\"outline:none;\"></div><div style=\"height:40px\"></div><div class=\"next\" id=\"tIRlIqMiYAZw-next\" onclick=\"window.checkFlip('tIRlIqMiYAZw')\"> </div> <div style=\"height:40px\"></div>"
11761193
],
11771194
"text/plain": [
11781195
"<IPython.core.display.HTML object>"
@@ -1302,12 +1319,14 @@
13021319
" next.classList.add('hide');\n",
13031320
"\n",
13041321
" //container.classList.add(\"prepare\");\n",
1305-
" \n",
1322+
"\n",
13061323
" container.className=\"flip-container slide\";\n",
1324+
"\n",
13071325
" backcard.parentElement.removeChild(frontcard);\n",
13081326
" backcard.parentElement.appendChild(frontcard);\n",
1327+
"\n",
13091328
" setTimeout(slideback, 600, container, frontcard, backcard, next);\n",
1310-
" \n",
1329+
"\n",
13111330
"}\n",
13121331
"\n",
13131332
"\n",
@@ -1339,15 +1358,16 @@
13391358
"\n",
13401359
" let cardOrder = JSON.parse(container.dataset.cardOrder);\n",
13411360
"\n",
1342-
" var cards=eval('cards'+container.id);\n",
1361+
" //var cards=eval('cards'+container.id);\n",
1362+
" var cards=JSON.parse(container.dataset.cards);\n",
13431363
"\n",
13441364
" var flipper=createOneCard(container, false, cards, cardOrder[cardnum], cardnum);\n",
13451365
" container.append(flipper);\n",
13461366
" cardnum= (cardnum+1) % parseInt(container.dataset.numCards);\n",
1347-
" if ((cardnum == 0) && (container.dataset.shuffleCards == \"True\")) {\n",
1367+
" if ((cardnum == 0) && (container.dataset.shuffleCards == \"true\")) {\n",
13481368
" cardOrder = randomOrderArray(parseInt(container.dataset.numCards));\n",
13491369
" container.dataset.cardOrder = JSON.stringify(cardOrder);\n",
1350-
" console.log(cardOrder);\n",
1370+
" //console.log(cardOrder);\n",
13511371
" }\n",
13521372
"\n",
13531373
" container.dataset.cardnum=cardnum;\n",
@@ -1402,9 +1422,15 @@
14021422
"\n",
14031423
"\n",
14041424
"function createOneCard (mydiv, frontCard, cards, cardnum, seq) {\n",
1425+
" /*\n",
14051426
" var colors=eval('frontColors'+mydiv.id);\n",
14061427
" var backColors=eval('backColors'+mydiv.id);\n",
14071428
" var textColors=eval('textColors'+mydiv.id);\n",
1429+
" */\n",
1430+
" var colors = JSON.parse(mydiv.dataset.frontColors);\n",
1431+
" var backColors = JSON.parse(mydiv.dataset.backColors);\n",
1432+
" var textColors = JSON.parse(mydiv.dataset.textColors);\n",
1433+
"\n",
14081434
" //console.log(backColors)\n",
14091435
"\n",
14101436
" var flipper = document.createElement('div');\n",
@@ -1504,38 +1530,44 @@
15041530
"\n",
15051531
"\n",
15061532
"\n",
1507-
"function createCards(id, keyControl, grabFocus, shuffleCards, title, subject) {\n",
1533+
"function createCards(id, cards, keyControl, grabFocus, shuffleCards, title, subject,\n",
1534+
" frontColors, backColors, textColors) {\n",
15081535
" console.log(id);\n",
15091536
"\n",
15101537
" var mydiv=document.getElementById(id);\n",
15111538
" /*mydiv.onclick = window.flipCard(mydiv);*/\n",
15121539
" /*\n",
1513-
" mydiv.addEventListener('click', function(){window.flipCard(mydiv);}, false);\n",
1514-
" mydiv.addEventListener('keydown', function(event){window.checkKey(mydiv,event);}, true);\n",
1540+
" mydiv.addEventListener('click', function(){window.flipCard(mydiv);}, false);\n",
1541+
" mydiv.addEventListener('keydown', function(event){window.checkKey(mydiv,event);}, true);\n",
15151542
" */\n",
15161543
" mydiv.onclick = function(){window.flipCard(mydiv);};\n",
1517-
" //console.log(keyControl);\n",
1518-
" if (keyControl == \"True\"){\n",
1544+
" if (keyControl == true){\n",
15191545
" mydiv.onkeydown = function(event){window.checkKey(mydiv,event);};\n",
15201546
" }\n",
15211547
" /* mydiv.addEventListener('keydown', function(event){event.stopPropagation(); console.log(event); event.preventDefault();}, true); */\n",
15221548
" /*mydiv.onkeypress = function(event){console.log(event); event.preventDefault();};*/\n",
15231549
"\n",
15241550
" //console.log(mydiv);\n",
15251551
"\n",
1526-
" var cards=eval('cards'+id);\n",
1552+
" // var cards=eval('cards'+id);\n",
1553+
" // Store cards and color data in the container's dataset for later access in cleanup()\n",
1554+
" mydiv.dataset.cards = JSON.stringify(cards);\n",
1555+
" mydiv.dataset.frontColors = JSON.stringify(frontColors);\n",
1556+
" mydiv.dataset.backColors = JSON.stringify(backColors);\n",
1557+
" mydiv.dataset.textColors = JSON.stringify(textColors);\n",
1558+
"\n",
15271559
" mydiv.dataset.cardnum=0;\n",
15281560
" mydiv.dataset.numCards=cards.length;\n",
15291561
"\n",
15301562
" mydiv.dataset.shuffleCards = shuffleCards;\n",
15311563
" var cardOrder;\n",
1532-
" if (shuffleCards == \"True\"){\n",
1564+
" if (shuffleCards == true){\n",
15331565
" cardOrder = randomOrderArray(cards.length);\n",
15341566
" } else {\n",
15351567
" cardOrder = Array.from({ length: cards.length }, (_, index) => index);\n",
15361568
" }\n",
15371569
" mydiv.dataset.cardOrder = JSON.stringify(cardOrder);\n",
1538-
" console.log(mydiv.dataset.cardOrder);\n",
1570+
" //console.log(mydiv.dataset.cardOrder);\n",
15391571
"\n",
15401572
"\n",
15411573
" mydiv.addEventListener('swiped-left', function(e) {\n",
@@ -1647,7 +1679,7 @@
16471679
" next.innerHTML=\"Next >\";\n",
16481680
" }\n",
16491681
"\n",
1650-
" if (grabFocus == \"True\" )\n",
1682+
" if (grabFocus == true )\n",
16511683
" mydiv.focus();\n",
16521684
"\n",
16531685
" return flipper;\n",
@@ -1656,36 +1688,20 @@
16561688
"\n",
16571689
"\n",
16581690
"\n",
1659-
"\n",
1660-
" function try_create() {\n",
1661-
" if(document.getElementById(\"GdkuSvByJKyr\")) {\n",
1662-
" createCards(\"GdkuSvByJKyr\", \"True\", \"False\", \"False\", \"\", \"\");\n",
1663-
" } else {\n",
1664-
" setTimeout(try_create, 200);\n",
1665-
" }\n",
1666-
" };\n",
1667-
" \n",
1668-
"var cardsGdkuSvByJKyr=[{\"front\": \"eigenvector\", \"back\": \"Given a square $n \\\\times n$ matrix $\\\\mathbf{M}$, a non-zero $n$-vector $\\\\mathbf{u}$ is an <I>eigenvector</I> of $\\\\mathbf{M}$ if there exists a constant $\\\\lambda$ such that \\\\begin{equation} \\\\mathbf{Mu} = \\\\lambda \\\\mathbf{u}. \\\\end{equation}\"}, {\"front\": \"eigenvalue\", \"back\": \"Given a square $n \\\\times n$ matrix $\\\\mathbf{M}$, a constant $\\\\lambda$ is an <I>eigenvalue</I> of $\\\\mathbf{M}$ if there exists a non-zero vector $\\\\mathbf{u}$ such that \\\\[ \\\\mathbf{Mu} = \\\\lambda \\\\mathbf{u}. \\\\]\"}, {\"front\": \"modal matrix\", \"back\": \"For a square matrix \\\\(\\\\mathbf{M}\\\\), the modal matrix is a matrix whose columns are the unit eigenvectors of \\\\(\\\\mathbf{M}\\\\).\"}];\n",
1669-
"var frontColorsGdkuSvByJKyr= [\"var(--asparagus)\", \"var(--terra-cotta)\", \"var(--cyan-process)\" ];\n",
1670-
"var backColorsGdkuSvByJKyr= [\"var(--dark-blue-gray)\" ];\n",
1671-
"var textColorsGdkuSvByJKyr= [\"var(--snow)\" ];\n",
1672-
"\n",
1673-
"\n",
1674-
" {\n",
1675-
" const jmscontroller = new AbortController();\n",
1676-
" const signal = jmscontroller.signal;\n",
1677-
"\n",
1678-
" setTimeout(() => jmscontroller.abort(), 5000);\n",
1679-
"\n",
1680-
" fetch(\"https://raw.githubusercontent.com/jmshea/Linear-Algebra-for-Data-Science-with-Python/main/03-matrices/flashcards/6-eigen.json\", {signal})\n",
1681-
" .then(response => response.json())\n",
1682-
" .then(json => createCards(\"GdkuSvByJKyr\", \"True\", \"False\", \"False\", \"\", \"\"))\n",
1683-
" .catch(err => {\n",
1684-
" console.log(\"Fetch error or timeout\");\n",
1685-
" try_create(); \n",
1686-
" });\n",
1687-
" }\n",
1688-
" "
1691+
"var cardstIRlIqMiYAZw = [{\"front\": \"eigenvector\", \"back\": \"Given a square $n \\\\times n$ matrix $\\\\mathbf{M}$, a non-zero $n$-vector $\\\\mathbf{u}$ is an <I>eigenvector</I> of $\\\\mathbf{M}$ if there exists a constant $\\\\lambda$ such that \\\\begin{equation} \\\\mathbf{Mu} = \\\\lambda \\\\mathbf{u}. \\\\end{equation}\"}, {\"front\": \"eigenvalue\", \"back\": \"Given a square $n \\\\times n$ matrix $\\\\mathbf{M}$, a constant $\\\\lambda$ is an <I>eigenvalue</I> of $\\\\mathbf{M}$ if there exists a non-zero vector $\\\\mathbf{u}$ such that \\\\[ \\\\mathbf{Mu} = \\\\lambda \\\\mathbf{u}. \\\\]\"}, {\"front\": \"modal matrix\", \"back\": \"For a square matrix \\\\(\\\\mathbf{M}\\\\), the modal matrix is a matrix whose columns are the unit eigenvectors of \\\\(\\\\mathbf{M}\\\\).\"}];\n",
1692+
"var frontColorstIRlIqMiYAZw = [\"var(--asparagus)\", \"var(--terra-cotta)\", \"var(--cyan-process)\"];\n",
1693+
"var backColorstIRlIqMiYAZw = [\"var(--dark-blue-gray)\"];\n",
1694+
"var textColorstIRlIqMiYAZw = [\"var(--snow)\"];\n",
1695+
"(function() {\n",
1696+
" var observer = new MutationObserver(function(mutations, obs) {\n",
1697+
" var el = document.getElementById(\"tIRlIqMiYAZw\");\n",
1698+
" if (el) {\n",
1699+
" createCards(\"tIRlIqMiYAZw\", cardstIRlIqMiYAZw, true, false, false, \"\", \"\", frontColorstIRlIqMiYAZw, backColorstIRlIqMiYAZw, textColorstIRlIqMiYAZw);\n",
1700+
" obs.disconnect();\n",
1701+
" }\n",
1702+
" });\n",
1703+
" observer.observe(document.body, { childList: true, subtree: true });\n",
1704+
" })();"
16891705
],
16901706
"text/plain": [
16911707
"<IPython.core.display.Javascript object>"
@@ -1701,6 +1717,13 @@
17011717
"display_flashcards(git_url + git_dir + file)"
17021718
]
17031719
},
1720+
{
1721+
"cell_type": "code",
1722+
"execution_count": null,
1723+
"metadata": {},
1724+
"outputs": [],
1725+
"source": []
1726+
},
17041727
{
17051728
"cell_type": "code",
17061729
"execution_count": null,

0 commit comments

Comments
 (0)