{"id":10694,"date":"2023-09-25T13:57:28","date_gmt":"2023-09-25T17:57:28","guid":{"rendered":"https:\/\/blogs.mathworks.com\/cleve\/?p=10694"},"modified":"2023-10-24T16:10:11","modified_gmt":"2023-10-24T20:10:11","slug":"exploring-matrices-exercises","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/cleve\/2023\/09\/25\/exploring-matrices-exercises\/","title":{"rendered":"Exploring Matrices Exercises"},"content":{"rendered":"\r\n\r\n<div class=\"content\"><!--introduction--><p>Try you hand at a few exercises involving <a href=\"https:\/\/blogs.mathworks.com\/cleve\/2023\/09\/11\/exploring-matrices\">Exploring Matrices<\/a>.<\/p><!--\/introduction--><h3>Contents<\/h3><div><ul><li><a href=\"#9a31c167-b03b-46b5-a72a-532c3c909d42\">Qube Simplified<\/a><\/li><li><a href=\"#f136428c-5bcf-4b83-a2c3-82cc90fc6755\">Exploring Matrices Exercises<\/a><\/li><li><a href=\"#1b362098-66e1-4e9c-8095-697383233aeb\">Matrix Multiplication<\/a><\/li><li><a href=\"#3e047c2f-d7b8-406d-b063-43b29d3efc99\">Rotations and Scaling<\/a><\/li><li><a href=\"#75fe37b9-fa6a-471d-b67d-b4f613edba39\">Computer Graphics<\/a><\/li><li><a href=\"#d526d9a5-94d4-4abe-9e04-355eb8395ecf\">Matrices and Cubes<\/a><\/li><\/ul><\/div><h4>Qube Simplified<a name=\"9a31c167-b03b-46b5-a72a-532c3c909d42\"><\/a><\/h4><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/Qube_simplified.png\" alt=\"\"> <\/p><p>I have simplified the <tt>Qube<\/tt> app by removing these four buttons.<\/p><div><ul><li><tt>solve<\/tt>.  The &lt;== key now controls the unscrambling   operation.<\/li><\/ul><\/div><div><ul><li><tt>scramble<\/tt>.  The ==&gt; key now does six random rotations.<\/li><\/ul><\/div><div><ul><li><tt>order<\/tt>.  I never found a satisfactory reference for   the group theory of Rubik's cube.<\/li><\/ul><\/div><div><ul><li><tt>score<\/tt>.  I never found a use for the nuclear norm.<\/li><\/ul><\/div><p>Code for <tt>Qube<\/tt> dated 9\/24\/2023 is included in the <a href=\"https:\/\/blogs.mathworks.com\/cleve\/files\/Apps_mzip.m\">Apps mzip archive<\/a>.<\/p><h4>Exploring Matrices Exercises<a name=\"f136428c-5bcf-4b83-a2c3-82cc90fc6755\"><\/a><\/h4><p>Here are a few exercises for <a href=\"https:\/\/blogs.mathworks.com\/cleve\/2023\/09\/11\/exploring-matrices\">Exploring Matrices<\/a>. The answers are available at <a href=\"https:\/\/blogs.mathworks.com\/cleve\/files\/ExMatAnswers.pdf\">ExMatAnswers<\/a>.<\/p><h4>Matrix Multiplication<a name=\"1b362098-66e1-4e9c-8095-697383233aeb\"><\/a><\/h4><p><b>1.<\/b> Compute by rows, and by columns.<\/p><p>$$\r\n  \\left(\r\n  \\begin{array}{rrr}\r\n     8 &amp; 1 &amp; 6 \\\\\r\n     3 &amp; 5 &amp; 7 \\\\\r\n     4 &amp; 9 &amp; 2\r\n  \\end{array}\r\n  \\right)\r\n  \\left(\r\n  \\begin{array}{r}\r\n     1  \\\\\r\n     1  \\\\\r\n     1\r\n  \\end{array}\r\n  \\right)\r\n$$<\/p><p><b>2.<\/b> Solve for $z$ using inner products of rows, and using linear combinations of columns.<\/p><p>$$\r\n  \\left(\r\n  \\begin{array}{rrr}\r\n     1 &amp; 2 &amp; 3 \\\\\r\n     4 &amp; 5 &amp; 6 \\\\\r\n     7 &amp; 8 &amp; 9\r\n  \\end{array}\r\n  \\right)\r\n  \\left(\r\n  \\begin{array}{r}\r\n     1  \\\\\r\n     z  \\\\\r\n     1\r\n  \\end{array}\r\n  \\right)\r\n  \\ = \\\r\n  \\left(\r\n  \\begin{array}{r}\r\n     0  \\\\\r\n     0  \\\\\r\n     0\r\n  \\end{array}\r\n  \\right)\r\n$$<\/p><p><b>3.<\/b> What do the <tt>m<\/tt>, <tt>n<\/tt> and <tt>p<\/tt> buttons on the <tt>Multiply<\/tt> app do? What are the other buttons and what do they do?<\/p><p><b>4.<\/b> If <i>A<\/i> is n-by-n and <i>x<\/i> is n-by-1, how many multiplications are required to compute <i>A x<\/i> ?<\/p><p><b>5.<\/b> If <i>A<\/i> is m-by-n and <i>B<\/i> is n-by-p, how many multiplications are required to compute <i>A B<\/i> ?<\/p><h4>Rotations and Scaling<a name=\"3e047c2f-d7b8-406d-b063-43b29d3efc99\"><\/a><\/h4><p><b>1.<\/b> What is <i>R<\/i>(30&ordm;)?<\/p><p>$$\r\nR(\\theta) \\ = \\\r\n\\left(\r\n  \\begin{array}{rr}\r\n     \\cos{\\theta} &amp; \\sin{\\theta} \\\\\r\n    -\\sin{\\theta} &amp; \\cos{\\theta}\r\n  \\end{array}\r\n  \\right)\r\n$$<\/p><p><b>2.<\/b> Explain <a href=\"https:\/\/xkcd.com\/184\">https:\/\/xkcd.com\/184<\/a>.<\/p><p><b>3.<\/b> What is the value of $\\theta$ ?<\/p><p>$$\r\nR(\\theta) \\ = \\\r\n\\left(\r\n  \\begin{array}{rr}\r\n     0.8 &amp; 0.6 \\\\\r\n    -0.6 &amp; 0.8\r\n  \\end{array}\r\n  \\right)\r\n$$<\/p><p><b>4.<\/b> What is the value of $\\theta$ ?<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/theta_exer.png\" alt=\"\"> <\/p><p><b>5.<\/b> Edit a copy of <tt>Rotate.m<\/tt> and replace the house with a hand.  You can <a href=\"https:\/\/blogs.mathworks.com\/cleve\/files\/myhand.m\">use my hand<\/a> or your own hand; see exercise 3.4 in <a href=\"https:\/\/www.mathworks.com\/content\/dam\/mathworks\/mathworks-dot-com\/moler\/interp.pdf\">Numerical Computing with MATLAB<\/a> .<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/hand_exer.png\" alt=\"\"> <\/p><h4>Computer Graphics<a name=\"75fe37b9-fa6a-471d-b67d-b4f613edba39\"><\/a><\/h4><p><b>1.<\/b> Show how homogeneous coordinates and matrix-vector multiplication by <tt>Tx<\/tt>, <tt>Ty<\/tt> or <tt>Tz<\/tt> produce translation.<\/p><p><b>2.<\/b> What is the range of the rotations used by the pitch, roll, and yaw buttons on the <tt>Grafix<\/tt> app?<\/p><p><b>3.<\/b> What color in the beacon on top of the plane? How would you change the beacon's color?<\/p><p><b>4,<\/b> What is the function of the resolution and offset sliders for the teapot?<\/p><p><b>5,<\/b> How many times does the bucky ball bounce off the sides of the plot window?<\/p><h4>Matrices and Cubes<a name=\"d526d9a5-94d4-4abe-9e04-355eb8395ecf\"><\/a><\/h4><p><b>1.<\/b> What is the color of central cubelet in the Color Cube?<\/p><p><b>2.<\/b> What do the \"&lt;=\" , \"&lt;==\" , \"=&gt;\" and  \"==&gt;\" buttons on <tt>Qube<\/tt> do?<\/p><p><b>3.<\/b> What is \"God's Number\" for a 3-by-3-by-3 Rubik's Cube? What are <tt>Q20<\/tt> and <tt>Q26<\/tt>? See <a href=\"https:\/\/blogs.mathworks.com\/cleve\/2022\/09\/05\/rubiks-cube-superflips-and-gods-number\">Cleve's Corner 2022\/09\/05<\/a>.<\/p><p><b>4.<\/b> Can you restore the following scrambled cubes with fewer moves than <tt>&lt;==<\/tt>, the unscramble key?  Use the quarter-turn metric and reset the cube with <tt>start<\/tt> or by clicking on <tt>stack<\/tt> and <tt>Q0<\/tt>. You might also want to set <tt>speed<\/tt> to 30 or 45,<\/p><div><ul><li><tt>LRUDFB<\/tt><\/li><\/ul><\/div><div><ul><li><tt>LRL'R'<\/tt><\/li><\/ul><\/div><div><ul><li><tt>FLLLRB<\/tt><\/li><\/ul><\/div><div><ul><li><tt>Q26<\/tt><\/li><\/ul><\/div><div><ul><li>Reset the random number generator by entering  <tt>rng(r)<\/tt>  for some   small integer <tt>r<\/tt> in the command window and then generate six   random rotations with the   <tt>==&gt;<\/tt> key.<\/li><\/ul><\/div><script language=\"JavaScript\"> <!-- \r\n    function grabCode_df8fd0cdc22947b5854c0cfaa2ea0256() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='df8fd0cdc22947b5854c0cfaa2ea0256 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' df8fd0cdc22947b5854c0cfaa2ea0256';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2023 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_df8fd0cdc22947b5854c0cfaa2ea0256()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2023a<br><\/p><\/div><!--\r\ndf8fd0cdc22947b5854c0cfaa2ea0256 ##### SOURCE BEGIN #####\r\n%% Exploring Matrices Exercises\r\n% Try you hand at a few exercises involving\r\n% <https:\/\/blogs.mathworks.com\/cleve\/2023\/09\/11\/exploring-matrices\r\n% Exploring Matrices>.\r\n\r\n%% Qube Simplified\r\n%\r\n% <<Qube_simplified.png>>\r\n%\r\n% I have simplified the |Qube| app by removing these four buttons.\r\n% \r\n% * |solve|.  The <== key now controls the unscrambling\r\n%   operation.\r\n%\r\n% * |scramble|.  The ==> key now does six random rotations.\r\n%\r\n% * |order|.  I never found a satisfactory reference for  \r\n%   the group theory of Rubik's cube. \r\n%\r\n% * |score|.  I never found a use for the nuclear norm.\r\n%\r\n% Code for |Qube| dated 9\/24\/2023 is included in the\r\n% <https:\/\/blogs.mathworks.com\/cleve\/files\/Apps_mzip.m\r\n% Apps mzip archive>.\r\n\r\n%% Exploring Matrices Exercises\r\n%\r\n% Here are a few exercises for \r\n% <https:\/\/blogs.mathworks.com\/cleve\/2023\/09\/11\/exploring-matrices\r\n% Exploring Matrices>.\r\n% The answers are available at \r\n% <https:\/\/blogs.mathworks.com\/cleve\/files\/ExMatAnswers.pdf\r\n% ExMatAnswers>.\r\n\r\n%% Matrix Multiplication\r\n%\r\n% *1.* \r\n% Compute by rows, and by columns.\r\n%\r\n% $$\r\n%   \\left(\r\n%   \\begin{array}{rrr}\r\n%      8 & 1 & 6 \\\\\r\n%      3 & 5 & 7 \\\\\r\n%      4 & 9 & 2\r\n%   \\end{array}\r\n%   \\right)     \r\n%   \\left(\r\n%   \\begin{array}{r}\r\n%      1  \\\\\r\n%      1  \\\\\r\n%      1\r\n%   \\end{array}\r\n%   \\right) \r\n% $$\r\n%\r\n%\r\n% *2.*\r\n% Solve for $z$ using inner products of rows, and\r\n% using linear combinations of columns.\r\n%\r\n% $$ \r\n%   \\left(\r\n%   \\begin{array}{rrr}\r\n%      1 & 2 & 3 \\\\\r\n%      4 & 5 & 6 \\\\\r\n%      7 & 8 & 9\r\n%   \\end{array}\r\n%   \\right) \r\n%   \\left(\r\n%   \\begin{array}{r}\r\n%      1  \\\\\r\n%      z  \\\\\r\n%      1\r\n%   \\end{array}\r\n%   \\right) \r\n%   \\ = \\\r\n%   \\left(\r\n%   \\begin{array}{r}\r\n%      0  \\\\\r\n%      0  \\\\\r\n%      0\r\n%   \\end{array}\r\n%   \\right) \r\n% $$\r\n%\r\n%\r\n% *3.*\r\n% What do the |m|, |n| and |p| buttons on the |Multiply| app do?\r\n% What are the other buttons and what do they do?\r\n%\r\n%\r\n% *4.* \r\n% If _A_ is n-by-n and _x_ is n-by-1,\r\n% how many multiplications are required to compute _A x_ ?\r\n%\r\n% *5.* \r\n% If _A_ is m-by-n and _B_ is n-by-p,\r\n% how many multiplications are required to compute _A B_ ?\r\n\r\n%% Rotations and Scaling\r\n%\r\n% *1.*\r\n% What is _R_(30\u00ba)?\r\n%\r\n% $$ \r\n% R(\\theta) \\ = \\\r\n% \\left(\r\n%   \\begin{array}{rr}\r\n%      \\cos{\\theta} & \\sin{\\theta} \\\\\r\n%     -\\sin{\\theta} & \\cos{\\theta}\r\n%   \\end{array}\r\n%   \\right)\r\n% $$\r\n%\r\n% *2.*\r\n% Explain <https:\/\/xkcd.com\/184>.\r\n%\r\n% *3.*\r\n% What is the value of $\\theta$ ?\r\n%\r\n% $$ \r\n% R(\\theta) \\ = \\\r\n% \\left(\r\n%   \\begin{array}{rr}\r\n%      0.8 & 0.6 \\\\\r\n%     -0.6 & 0.8\r\n%   \\end{array}\r\n%   \\right) \r\n% $$\r\n%\r\n%\r\n% *4.*\r\n% What is the value of $\\theta$ ?\r\n%\r\n% <<theta_exer.png>>\r\n%\r\n%\r\n% *5.* \r\n% Edit a copy of |Rotate.m| and replace the house with a hand.  You can\r\n% <https:\/\/blogs.mathworks.com\/cleve\/files\/myhand.m  use my hand>\r\n% or your own hand; see exercise 3.4 in\r\n% <https:\/\/www.mathworks.com\/content\/dam\/mathworks\/mathworks-dot-com\/moler\/interp.pdf\r\n% Numerical Computing with MATLAB> .\r\n%\r\n% <<hand_exer.png>>\r\n%\r\n\r\n%% Computer Graphics\r\n%\r\n% *1.*\r\n% Show how homogeneous coordinates and matrix-vector multiplication by\r\n% |Tx|, |Ty| or |Tz| produce translation.\r\n%\r\n%\r\n% *2.*\r\n% What is the range of the rotations used by the pitch, roll, and yaw\r\n% buttons on the |Grafix| app?\r\n%\r\n% *3.*\r\n% What color in the beacon on top of the plane?\r\n% How would you change the beacon's color?\r\n%\r\n%\r\n% *4,*\r\n% What is the function of the resolution and offset sliders for the teapot?\r\n%\r\n%\r\n% *5,*\r\n% How many times does the bucky ball bounce off the sides of the plot\r\n% window?\r\n%\r\n\r\n\r\n%% Matrices and Cubes\r\n%\r\n% *1.*\r\n% What is the color of central cubelet in the Color Cube?\r\n%\r\n%\r\n% *2.*\r\n% What do the \"<=\" , \"<==\" , \"=>\" and  \"==>\" buttons on |Qube| do?\r\n%\r\n%\r\n% *3.* \r\n% What is \"God's Number\" for a 3-by-3-by-3 Rubik's Cube?\r\n% What are |Q20| and |Q26|?\r\n% See <https:\/\/blogs.mathworks.com\/cleve\/2022\/09\/05\/rubiks-cube-superflips-and-gods-number\r\n% Cleve's Corner 2022\/09\/05>.\r\n%\r\n%\r\n% *4.*\r\n% Can you restore the following scrambled cubes with fewer moves than |<==|,\r\n% the unscramble key?  Use the quarter-turn metric and\r\n% reset the cube with |start| or by clicking on |stack| and |Q0|.\r\n% You might also want to set |speed| to 30 or 45,\r\n%\r\n% * |LRUDFB|\r\n% \r\n% * |LRL'R'|\r\n% \r\n% * |FLLLRB|\r\n% \r\n% * |Q26|\r\n%\r\n% * Reset the random number generator by entering  |rng(r)|  for some\r\n%   small integer |r| in the command window and then generate six \r\n%   random rotations with the   |==>| key.\r\n\r\n\r\n##### SOURCE END ##### df8fd0cdc22947b5854c0cfaa2ea0256\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/Qubie.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><!--introduction--><p>Try you hand at a few exercises involving <a href=\"https:\/\/blogs.mathworks.com\/cleve\/2023\/09\/11\/exploring-matrices\">Exploring Matrices<\/a>.... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/cleve\/2023\/09\/25\/exploring-matrices-exercises\/\">read more >><\/a><\/p>","protected":false},"author":78,"featured_media":10772,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[32,5,23,6,47],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/10694"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/users\/78"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/comments?post=10694"}],"version-history":[{"count":7,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/10694\/revisions"}],"predecessor-version":[{"id":10794,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/10694\/revisions\/10794"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media\/10772"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media?parent=10694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/categories?post=10694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/tags?post=10694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}