{"id":244,"date":"2012-08-13T12:37:06","date_gmt":"2012-08-13T17:37:06","guid":{"rendered":"https:\/\/blogs.mathworks.com\/cleve\/?p=244"},"modified":"2017-11-17T12:40:20","modified_gmt":"2017-11-17T17:40:20","slug":"can-one-hear-the-shape-of-a-drum-part-2-eigenfunctions","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/cleve\/2012\/08\/13\/can-one-hear-the-shape-of-a-drum-part-2-eigenfunctions\/","title":{"rendered":"Can One Hear the Shape of a Drum? Part 2, Eigenfunctions"},"content":{"rendered":"&nbsp;\r\n<div class=\"content\"><!--introduction-->This is the second part of a series of posts about Marc Kac's 1966 paper in the American Mathematical Monthly <a href=\"#7ce5a4e4-b0b6-4f6d-ac26-8ea514763f5a\">[1]<\/a>. This part is devoted to contour plots of the eigenfunctions.\r\n\r\n<!--\/introduction-->\r\n<h3>Contents<\/h3>\r\n<div>\r\n<ul>\r\n\t<li><a href=\"#2a02d00f-e40f-46ba-b0aa-18c1ac02db13\">Eigenfunctions<\/a><\/li>\r\n\t<li><a href=\"#c65087ad-1415-4e8a-8769-50ae27d2ddb3\">Continuous solution for ninth eigenfunction.<\/a><\/li>\r\n\t<li><a href=\"#7ce5a4e4-b0b6-4f6d-ac26-8ea514763f5a\">References<\/a><\/li>\r\n<\/ul>\r\n<\/div>\r\n<h4>Eigenfunctions<a name=\"2a02d00f-e40f-46ba-b0aa-18c1ac02db13\"><\/a><\/h4>\r\nI described the isospectral drums in part 1. Contour plots of the eigenfunctions are beautiful. Here are the first twenty. The detail increases as the frequency increases. Notice the triangles created by the ninth eigenfunction. These triangles play a central role in the next part of this article.\r\n<pre class=\"codeinput\">   <span class=\"comment\">% Vertices<\/span>\r\n   drum1 = [0 0 2 2 3 2 1 1 0\r\n            0 1 3 2 2 1 1 0 0];\r\n   drum2 = [1 0 0 2 2 3 2 1 1\r\n            0 1 2 2 3 2 1 1 0];\r\n   vertices = {drum1,drum2};\r\n\r\n   <span class=\"comment\">% Number of eigenvalues<\/span>\r\n\r\n   eignos = 20;\r\n\r\n   <span class=\"comment\">% Grid size<\/span>\r\n   ngrid = 32;\r\n\r\n   <span class=\"comment\">% Compute the eigenvalues and eigenfunctions<\/span>\r\n\r\n   h = 1\/ngrid;\r\n   [x,y] = meshgrid(0:h:3);\r\n\r\n   inpoints = (7*ngrid-2)*(ngrid-1)\/2;\r\n   lambda = zeros(eignos,2);\r\n   V = zeros(inpoints,eignos,2);\r\n\r\n   <span class=\"comment\">% Loop over the two drums<\/span>\r\n\r\n   <span class=\"keyword\">for<\/span> d = 1:2\r\n      vs = vertices{d};\r\n      [in,on] = inpolygon(x,y,vs(1,:),vs(2,:));\r\n      in = xor(in,on);\r\n\r\n      <span class=\"comment\">% Number the interior grid points.<\/span>\r\n\r\n      G = double(in);\r\n      p = find(G);\r\n      G(p) = (1:length(p))';\r\n      grid{d} = G;\r\n\r\n      <span class=\"comment\">% The discrete Laplacian<\/span>\r\n\r\n      A = delsq(G)\/h^2;\r\n\r\n      <span class=\"comment\">% Sparse matrix eigenvalues and vectors.<\/span>\r\n\r\n      [V(:,:,d),E] = eigs(A,eignos,0);\r\n      lambda(:,d) = diag(E);\r\n   <span class=\"keyword\">end<\/span>\r\n\r\n   <span class=\"comment\">% Plot the eigenfunctions.<\/span>\r\n\r\n   <span class=\"keyword\">for<\/span> d = 1:2\r\n      <span class=\"keyword\">for<\/span> k = 1:eignos\r\n         figure(ceil(k\/2))\r\n         set(gcf,<span class=\"string\">'color'<\/span>,<span class=\"string\">'white'<\/span>)\r\n         subplot(2,2,2*mod(k-1,2)+d)\r\n\r\n         <span class=\"comment\">% Insert the k-th eigenvector in the grid interior.<\/span>\r\n\r\n         G = grid{d};\r\n         p = find(G);\r\n         u = zeros(size(G));\r\n         u(p) = V(:,eignos+1-k,d);\r\n\r\n         <span class=\"comment\">% Make first eigenvector positive so its color matches the others.<\/span>\r\n\r\n         <span class=\"keyword\">if<\/span> k == 1\r\n            u = -u;\r\n         <span class=\"keyword\">end<\/span>\r\n\r\n         <span class=\"comment\">% Insert NaN's to make the exterior disappear.<\/span>\r\n\r\n         vs = vertices{d};\r\n         [in,on] = inpolygon(x,y,vs(1,:),vs(2,:));\r\n         u(~in) = NaN;\r\n\r\n         <span class=\"comment\">% A filled contour plot with a line on the boundary.<\/span>\r\n\r\n         s = max(abs(u(:)));\r\n         contourf(x,y,u,s*(-1:1\/4:1))\r\n         line(vs(1,:),vs(2,:),<span class=\"string\">'color'<\/span>,<span class=\"string\">'black'<\/span>,<span class=\"string\">'linewidth'<\/span>,2)\r\n         title(num2str(k))\r\n         axis([-0.1 3.1 -0.1 3.1])\r\n         axis <span class=\"string\">square<\/span> <span class=\"string\">off<\/span>\r\n      <span class=\"keyword\">end<\/span>\r\n   <span class=\"keyword\">end<\/span>\r\n<\/pre>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/drums_2_01.png\" alt=\"\" hspace=\"5\" vspace=\"5\" \/> <img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/drums_2_02.png\" alt=\"\" hspace=\"5\" vspace=\"5\" \/> <img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/drums_2_03.png\" alt=\"\" hspace=\"5\" vspace=\"5\" \/> <img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/drums_2_04.png\" alt=\"\" hspace=\"5\" vspace=\"5\" \/> <img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/drums_2_05.png\" alt=\"\" hspace=\"5\" vspace=\"5\" \/> <img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/drums_2_06.png\" alt=\"\" hspace=\"5\" vspace=\"5\" \/> <img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/drums_2_07.png\" alt=\"\" hspace=\"5\" vspace=\"5\" \/> <img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/drums_2_08.png\" alt=\"\" hspace=\"5\" vspace=\"5\" \/> <img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/drums_2_09.png\" alt=\"\" hspace=\"5\" vspace=\"5\" \/> <img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/drums_2_10.png\" alt=\"\" hspace=\"5\" vspace=\"5\" \/>\r\n<h4>Continuous solution for ninth eigenfunction.<a name=\"c65087ad-1415-4e8a-8769-50ae27d2ddb3\"><\/a><\/h4>\r\nThe ninth eigenfunction of either region is the first eigenfunction of the isosceles triangle subregion, reflected to fill out the entire region. The corresponding eigenvalue of the continuous problem is $5 \\pi^2$.\r\n\r\n$$ v_9 = \\sin{2 \\pi x} \\sin{\\pi y} - \\sin{\\pi x} \\sin{2 \\pi y} $$\r\n<pre class=\"codeinput\">   v9continuous = @(x,y) sin(2*pi*x).*sin(pi*y) - sin(pi*x).*sin(2*pi*y);\r\n\r\n   figure(gcf+1)\r\n   set(gcf,<span class=\"string\">'color'<\/span>,<span class=\"string\">'white'<\/span>)\r\n   <span class=\"keyword\">for<\/span> d = 1:2\r\n      u = v9continuous(x,flipud(y));\r\n      subplot(2,2,d)\r\n      vs = vertices{d};\r\n      [in,on] = inpolygon(x,y,vs(1,:),vs(2,:));\r\n      u(~in) = 0.5*u(~in);\r\n      s = max(abs(u(:)));\r\n      contourf(x,y,u,s*(-1:1\/4:1))\r\n      line(vs(1,:),vs(2,:),<span class=\"string\">'color'<\/span>,<span class=\"string\">'black'<\/span>,<span class=\"string\">'linewidth'<\/span>,3)\r\n      title(<span class=\"string\">'Continuous v9'<\/span>)\r\n      axis([-0.1 3.1 -0.1 3.1])\r\n      axis <span class=\"string\">square<\/span> <span class=\"string\">off<\/span>\r\n   <span class=\"keyword\">end<\/span>\r\n<\/pre>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/cleve\/drums_2_11.png\" alt=\"\" hspace=\"5\" vspace=\"5\" \/>\r\n<h4>References<a name=\"7ce5a4e4-b0b6-4f6d-ac26-8ea514763f5a\"><\/a><\/h4>\r\n<div>\r\n<ol>\r\n\t<li>Marc Kac, Can one hear the shape of a drum?, Amer. Math. Monthly 73 (1966), 1-23.<\/li>\r\n\t<li><a href=\"http:\/\/www.ams.org\/journals\/bull\/1992-27-01\/S0273-0979-1992-00289-6\">Carolyn Gordon, David Webb, Scott Wolpert, One cannot hear the shape of a drum, Bull. Amer. Math. Soc. 27 (1992), 134-138.<\/a><\/li>\r\n\t<li><a href=\"http:\/\/en.wikipedia.org\/wiki\/Hearing_the_shape_of_a_drum\">Wikipedia, Hearing the shape of a drum.<\/a><\/li>\r\n\t<li><a href=\"https:\/\/www.mathworks.com\/company\/newsletters\/articles\/the-mathworks-logo-is-an-eigenfunction-of-the-wave-equation.html\">Cleve Moler, The MathWorks logo is an eigenfunction of the wave equation (2003).<\/a><\/li>\r\n\t<li><a href=\"http:\/\/people.maths.ox.ac.uk\/trefethen\/publication\/PDF\/2006_116.pdf\">Lloyd N. Trefethen and Timo Betcke, Computed eigenmodes of planar regions (2005).<\/a><\/li>\r\n\t<li><a href=\"http:\/\/www.math.udel.edu\/~driscoll\/research\/drums.html\">Tobin Driscoll, Isospectral Drums.<\/a><\/li>\r\n\t<li>Tobin Driscoll, Eigenmodes of isospectral drums, SIAM Review 39 (1997), 1-17.<\/li>\r\n\t<li><a href=\"http:\/\/www.math.ucdavis.edu\/~saito\/courses\/ACHA.READ.F03\/drum-chapman.pdf\">S. J. Chapman, Drums that sound the same, Amer. Math. Monthly 102 (1995), 124-138.<\/a><\/li>\r\n\t<li><a href=\"http:\/\/www.springer.com\/mathematics\/journal\/208\">Pierre Berard, Transplantation et isospectralite, Math. Ann. 292 (1992), 547-559.<\/a><\/li>\r\n<\/ol>\r\n<\/div>\r\n<script>\/\/ <![CDATA[\r\nfunction grabCode_3288f69a96304262ac5127e732c79314() {\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='3288f69a96304262ac5127e732c79314 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 3288f69a96304262ac5127e732c79314';\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 2012 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('\r\n\r\n<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>\r\n\r\n\r\n\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }\r\n\/\/ ]]><\/script>\r\n<p style=\"text-align: right; font-size: xx-small; font-weight: lighter; font-style: italic; color: gray;\">\r\n<a><span style=\"font-size: x-small; font-style: italic;\">Get\r\nthe MATLAB code<noscript>(requires JavaScript)<\/noscript><\/span><\/a>\r\n\r\nPublished with MATLAB\u00ae 7.14<\/p>\r\n<p class=\"footer\">\r\nPublished with MATLAB\u00ae 7.14<\/p>\r\n\r\n<\/div>\r\n<!--\r\n3288f69a96304262ac5127e732c79314 ##### SOURCE BEGIN #####\r\n%% Can One Hear the Shape of a Drum? Part 2, Eigenfunctions\r\n% This is the second part of a series of posts about Marc Kac's 1966 paper\r\n% in the American Mathematical Monthly <#4 [1]>.\r\n% This part is devoted to contour plots of the eigenfunctions.\r\n\r\n%% Eigenfunctions\r\n% I described the isospectral drums in part 1.\r\n% Contour plots of the eigenfunctions are beautiful.\r\n% Here are the first twenty.\r\n% The detail increases as the frequency increases.\r\n% Notice the triangles created by the ninth eigenfunction.\r\n% These triangles play a central role in the next part of this article.\r\n\r\n% Vertices\r\ndrum1 = [0 0 2 2 3 2 1 1 0\r\n0 1 3 2 2 1 1 0 0];\r\ndrum2 = [1 0 0 2 2 3 2 1 1\r\n0 1 2 2 3 2 1 1 0];\r\nvertices = {drum1,drum2};\r\n\r\n% Number of eigenvalues\r\n\r\neignos = 20;\r\n\r\n% Grid size\r\nngrid = 32;\r\n\r\n% Compute the eigenvalues and eigenfunctions\r\n\r\nh = 1\/ngrid;\r\n[x,y] = meshgrid(0:h:3);\r\n\r\ninpoints = (7*ngrid-2)*(ngrid-1)\/2;\r\nlambda = zeros(eignos,2);\r\nV = zeros(inpoints,eignos,2);\r\n\r\n% Loop over the two drums\r\n\r\nfor d = 1:2\r\nvs = vertices{d};\r\n[in,on] = inpolygon(x,y,vs(1,:),vs(2,:));\r\nin = xor(in,on);\r\n\r\n% Number the interior grid points.\r\n\r\nG = double(in);\r\np = find(G);\r\nG(p) = (1:length(p))';\r\ngrid{d} = G;\r\n\r\n% The discrete Laplacian\r\n\r\nA = delsq(G)\/h^2;\r\n\r\n% Sparse matrix eigenvalues and vectors.\r\n\r\n[V(:,:,d),E] = eigs(A,eignos,0);\r\nlambda(:,d) = diag(E);\r\nend\r\n\r\n% Plot the eigenfunctions.\r\n\r\nfor d = 1:2\r\nfor k = 1:eignos\r\nfigure(ceil(k\/2))\r\nset(gcf,'color','white')\r\nsubplot(2,2,2*mod(k-1,2)+d)\r\n\r\n% Insert the k-th eigenvector in the grid interior.\r\n\r\nG = grid{d};\r\np = find(G);\r\nu = zeros(size(G));\r\nu(p) = V(:,eignos+1-k,d);\r\n\r\n% Make first eigenvector positive so its color matches the others.\r\n\r\nif k == 1\r\nu = -u;\r\nend\r\n\r\n% Insert NaN's to make the exterior disappear.\r\n\r\nvs = vertices{d};\r\n[in,on] = inpolygon(x,y,vs(1,:),vs(2,:));\r\nu(~in) = NaN;\r\n\r\n% A filled contour plot with a line on the boundary.\r\n\r\ns = max(abs(u(:)));\r\ncontourf(x,y,u,s*(-1:1\/4:1))\r\nline(vs(1,:),vs(2,:),'color','black','linewidth',2)\r\ntitle(num2str(k))\r\naxis([-0.1 3.1 -0.1 3.1])\r\naxis square off\r\nend\r\nend\r\n\r\n%% Continuous solution for ninth eigenfunction.\r\n% The ninth eigenfunction of either region is the first eigenfunction of the\r\n% isosceles triangle subregion, reflected to fill out the entire region.\r\n% The corresponding eigenvalue of the continuous problem is $5 \\pi^2$.\r\n%\r\n% $$ v_9 = \\sin{2 \\pi x} \\sin{\\pi y} - \\sin{\\pi x} \\sin{2 \\pi y} $$\r\n%\r\n\r\nv9continuous = @(x,y) sin(2*pi*x).*sin(pi*y) - sin(pi*x).*sin(2*pi*y);\r\n\r\nfigure(gcf+1)\r\nset(gcf,'color','white')\r\nfor d = 1:2\r\nu = v9continuous(x,flipud(y));\r\nsubplot(2,2,d)\r\nvs = vertices{d};\r\n[in,on] = inpolygon(x,y,vs(1,:),vs(2,:));\r\nu(~in) = 0.5*u(~in);\r\ns = max(abs(u(:)));\r\ncontourf(x,y,u,s*(-1:1\/4:1))\r\nline(vs(1,:),vs(2,:),'color','black','linewidth',3)\r\ntitle('Continuous v9')\r\naxis([-0.1 3.1 -0.1 3.1])\r\naxis square off\r\nend\r\n\r\n%% References\r\n% # <http:\/\/mathdl.maa.org\/images\/upload_library\/22\/Chauvenet\/Kac68chv.pdf % Marc Kac, Can one hear the shape of a drum?, Amer. Math. Monthly 73 (1966), % 1-23.>\r\n% # <http:\/\/www.ams.org\/journals\/bull\/1992-27-01\/S0273-0979-1992-00289-6 % Carolyn Gordon, David Webb, Scott Wolpert, % One cannot hear the shape of a drum, Bull. Amer. Math. Soc. 27 (1992), % 134-138.>\r\n% # <http:\/\/en.wikipedia.org\/wiki\/Hearing_the_shape_of_a_drum % Wikipedia, Hearing the shape of a drum.>\r\n% # <https:\/\/www.mathworks.com\/company\/newsletters\/articles\/the-mathworks-logo-is-an-eigenfunction-of-the-wave-equation.html % Cleve Moler, The MathWorks logo is an eigenfunction of the wave equation % (2003).>\r\n% # <http:\/\/people.maths.ox.ac.uk\/trefethen\/publication\/PDF\/2006_116.pdf % Lloyd N. Trefethen and Timo Betcke, Computed eigenmodes of planar regions % (2005).>\r\n% # <http:\/\/www.math.udel.edu\/~driscoll\/research\/drums.html % Tobin Driscoll, Isospectral Drums.>\r\n% # <http:\/\/www.math.udel.edu\/~driscoll\/pubs\/drums.pdf % Tobin Driscoll, Eigenmodes of isospectral drums, SIAM Review 39 (1997), % 1-17.>\r\n% # <http:\/\/www.math.ucdavis.edu\/~saito\/courses\/ACHA.READ.F03\/drum-chapman.pdf % S. J. Chapman, Drums that sound the same, Amer. Math. Monthly 102 (1995), % 124-138.>\r\n% # <http:\/\/www.springer.com\/mathematics\/journal\/208 % Pierre Berard, Transplantation et isospectralite, Math. Ann. 292 (1992), % 547-559.>\r\n\r\n##### SOURCE END ##### 3288f69a96304262ac5127e732c79314\r\n-->","protected":false},"excerpt":{"rendered":"<!--introduction-->This is the second part of a series of posts about Marc Kac's 1966 paper in the American Mathematical Monthly <a href=\"#7ce5a4e4-b0b6-4f6d-ac26-8ea514763f5a\">[1]<\/a>. This part is devoted to contour plots of the eigenfunctions.\r\n\r\n<!--\/introduction-->... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/cleve\/2012\/08\/13\/can-one-hear-the-shape-of-a-drum-part-2-eigenfunctions\/\">read more >><\/a><\/p>","protected":false},"author":78,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[13,23],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/244"}],"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=244"}],"version-history":[{"count":13,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/244\/revisions"}],"predecessor-version":[{"id":2864,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/244\/revisions\/2864"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media?parent=244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/categories?post=244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/tags?post=244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}