{"id":220,"date":"2010-03-04T14:44:18","date_gmt":"2010-03-04T14:44:18","guid":{"rendered":"https:\/\/blogs.mathworks.com\/loren\/2010\/03\/04\/nichomachuss-theorem\/"},"modified":"2010-03-04T18:10:50","modified_gmt":"2010-03-04T18:10:50","slug":"nichomachuss-theorem","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/loren\/2010\/03\/04\/nichomachuss-theorem\/","title":{"rendered":"Nicomachus&#8217;s Theorem"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction>\r\n      <p>Ned Gulley is stepping in as guest blogger this week. You may remember an earlier guest entry from him on <a href=\"https:\/\/blogs.mathworks.com\/loren\/2007\/01\/26\/calendars-and-leap-years\/\">calendars and leap years<\/a>. Ned has been working at MathWorks almost as long as I have, and as we were chatting the other day, he reminded me of an\r\n         episode from long ago.\r\n      <\/p>\r\n   <\/introduction>\r\n   <h3>Contents<\/h3>\r\n   <div>\r\n      <ul>\r\n         <li><a href=\"#1\">Nicomachus's Theorem<\/a><\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <h3>Nicomachus's Theorem<a name=\"1\"><\/a><\/h3>\r\n   <p>One day, not long after I started working at MathWorks, Loren presented me with a puzzle. She gave me a piece of graph paper\r\n      with some lines drawn on it so it looked something like this.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/220\/graph1.png\"> <\/p>\r\n   <p>Then she asked: What mathematical statement is this making?<\/p>\r\n   <p>It's an appealing pattern and a curious question, so I took it up with great interest. After a while, I worked it out. Do\r\n      you see it?\r\n   <\/p>\r\n   <p>The first thing I noticed is that the block length along the bottom and left edges increases like so: 1, 2, 3, 4, and so on.\r\n      Let's call this the edge sequence. It looks like we can interpret the blocks in terms of the extra area added with each number\r\n      in the edge sequence. When the edge sequence reaches 3, then three blocks of size 3x3 are added to the area (blue). Similarly\r\n      with 5, there are five blocks of size 5x5 (red). Four follows the same pattern, provided we stitch together the two rectangles\r\n      along the edges (green).\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/220\/graph2.png\"> <\/p>\r\n   <p>More generally, for every number n that we add to the edge sequence, we add an area equal to n squares of size nxn. Thus<\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/loren\/220\/nicomachus_eq55177.png\"> <\/p>\r\n   <p>I thought that picture was a beautiful way to say a beautiful thing that I hadn't known before, and I always remembered it.\r\n      This result is sometimes known as <a href=\"http:\/\/en.wikipedia.org\/wiki\/Squared_triangular_number\">Nicomachus's theorem<\/a>. Stated compactly, the square of the nth triangular number is equal to the sum of the first n cubes.\r\n   <\/p>\r\n   <p>Since this is a MATLAB blog, I should include some code. Let's represent the left-hand side using the <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010a\/toolbox\/symbolic\/symsum.html\">symsum<\/a> like so (after creating a few symbolic objects).\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">syms <span style=\"color: #A020F0\">n<\/span> <span style=\"color: #A020F0\">k<\/span>\r\nnsqr = symsum(n,n,1,k)^2<\/pre><pre style=\"font-style:oblique\">nsqr =\r\n(k^2*(k + 1)^2)\/4\r\n<\/pre><p>The right-hand side, which is the sum of the first k cubes, looks like this.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">ncube = symsum(n^3,n,1,k)<\/pre><pre style=\"font-style:oblique\">ncube =\r\n(k^2*(k + 1)^2)\/4\r\n<\/pre><p>Are they the same?<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">isequal(nsqr, ncube)<\/pre><pre style=\"font-style:oblique\">ans =\r\n     1\r\n<\/pre><p>Yes! So the premise appears to be true.<\/p>\r\n   <p>I was reminded of Loren's visual proof by a post that my fellow MathWorker Matt McDonnell tweeted about a few weeks ago: <a title=\"http:\/\/www.billthelizard.com\/2009\/07\/six-visual-proofs_25.html (link no longer works)\">Six Visual Proofs<\/a>.\r\n   <\/p>\r\n   <p>A little more rooting around turned up this book, which looks like it would be fun if you, like me, are tickled by wholly\r\n      visual proofs. <a href=\"http:\/\/www.amazon.com\/dp\/0883857006\/\">Proofs without Words: Exercises in Visual Thinking<\/a> by Roger B. Nelsen\r\n   <\/p>\r\n   <p>Are you aware of any other nice visual proofs out there? Tell us <a href=\"https:\/\/blogs.mathworks.com\/loren\/?p=220#respond\">here<\/a>.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_a8c043e6318e4c398b46d3b7069a6603() {\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='a8c043e6318e4c398b46d3b7069a6603 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' a8c043e6318e4c398b46d3b7069a6603';\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        author = 'Loren Shure';\r\n        copyright = 'Copyright 2010 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 author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\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      \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_a8c043e6318e4c398b46d3b7069a6603()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 7.9<br><\/p>\r\n<\/div>\r\n<!--\r\na8c043e6318e4c398b46d3b7069a6603 ##### SOURCE BEGIN #####\r\n%%\r\n% Ned Gulley is stepping in as guest blogger this week. You may remember an\r\n% earlier guest entry from him on\r\n% <https:\/\/blogs.mathworks.com\/loren\/2007\/01\/26\/calendars-and-leap-years\/ calendars and leap years>. \r\n% Ned has been working at MathWorks almost as\r\n% long as I have, and as we were chatting the other day, he reminded me of\r\n% an episode from long ago.\r\n\r\n%% Nicomachus's Theorem\r\n% One day, not long after I started working at MathWorks, Loren presented\r\n% me with a puzzle. She gave me a piece of graph paper with some lines\r\n% drawn on it so it looked something like this.\r\n%\r\n% <<graph1.png>>\r\n%\r\n\r\n%%\r\n% Then she asked: What mathematical statement is this making? \r\n\r\n%%\r\n% It's an appealing pattern and a curious question, so I took it up with\r\n% great interest. After a while, I worked it out. Do you see it? \r\n\r\n%%\r\n% The first thing I noticed is that the block length along the bottom and\r\n% left edges increases like so: 1, 2, 3, 4, and so on. Let's call this the\r\n% edge sequence. It looks like we can interpret the blocks in terms of the\r\n% extra area added with each number in the edge sequence. When the edge\r\n% sequence reaches 3, then three blocks of size 3x3 are added to the area\r\n% (blue). Similarly with 5, there are five blocks of size 5x5 (red). Four\r\n% follows the same pattern, provided we stitch together the two rectangles\r\n% along the edges (green).\r\n%\r\n% <<graph2.png>>\r\n%\r\n\r\n%%\r\n% More generally, for every number n that we add to the edge sequence, we\r\n% add an area equal to n squares of size nxn. Thus\r\n%\r\n% $$ \\Bigl(\\sum_{n=1}^k n \\Bigr)^2 = \\sum_{n=1}^k n^3 $$\r\n%\r\n% I thought that picture was a beautiful way to say a beautiful thing that\r\n% I hadn't known before, and I always remembered it. This result is sometimes \r\n% known as <http:\/\/en.wikipedia.org\/wiki\/Squared_triangular_number Nicomachus's theorem>. \r\n% Stated compactly, the square of the nth triangular number is equal to the\r\n% sum of the first n cubes.\r\n%\r\n% Since this is a MATLAB blog, I should include some code. Let's represent\r\n% the left-hand side using the\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2010a\/toolbox\/symbolic\/symsum.html symsum> \r\n% like so (after creating a few symbolic objects).\r\n\r\nsyms n k\r\nnsqr = symsum(n,n,1,k)^2\r\n\r\n%%\r\n% The right-hand side, which is the sum of the first k cubes, looks like\r\n% this.\r\n\r\nncube = symsum(n^3,n,1,k)\r\n\r\n%%\r\n% Are they the same?\r\n\r\nisequal(nsqr, ncube)\r\n\r\n%%\r\n% Yes! So the premise appears to be true.\r\n\r\n%%\r\n% I was reminded of Loren's visual proof by a post that my fellow \r\n% MathWorker Matt McDonnell tweeted about a few weeks ago: \r\n% <http:\/\/www.billthelizard.com\/2009\/07\/six-visual-proofs_25.html Six Visual Proofs>.\r\n%\r\n% A little more rooting around turned up this book, which looks like it\r\n% would be fun if you, like me, are tickled by wholly visual proofs.\r\n% <http:\/\/www.amazon.com\/dp\/0883857006\/ Proofs without Words: Exercises in Visual Thinking> \r\n% by Roger B. Nelsen\r\n% \r\n% Are you aware of any other nice visual proofs out there? Tell us \r\n% <https:\/\/blogs.mathworks.com\/loren\/?p=220#respond here>.\r\n##### SOURCE END ##### a8c043e6318e4c398b46d3b7069a6603\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   \r\n      Ned Gulley is stepping in as guest blogger this week. You may remember an earlier guest entry from him on calendars and leap years. Ned has been working at MathWorks almost as long as I... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/loren\/2010\/03\/04\/nichomachuss-theorem\/\">read more >><\/a><\/p>","protected":false},"author":39,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[33,38],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/220"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/users\/39"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/comments?post=220"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/220\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/media?parent=220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/categories?post=220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/tags?post=220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}