{"id":12512,"date":"2025-03-07T11:21:56","date_gmt":"2025-03-07T16:21:56","guid":{"rendered":"https:\/\/blogs.mathworks.com\/cleve\/?p=12512"},"modified":"2025-03-07T11:21:56","modified_gmt":"2025-03-07T16:21:56","slug":"matrices-at-an-exposition","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/cleve\/2025\/03\/07\/matrices-at-an-exposition\/","title":{"rendered":"Matrices at an Exposition"},"content":{"rendered":"<div class=\"content\"><!--introduction-->\r\n<p>A look at the structure, and the eigenvalues and singular values of interesting test matrices.<\/p>\r\n<!--\/introduction-->\r\n<h3>Contents<\/h3>\r\n<div>\r\n<ul>\r\n<li>\r\n<a href=\"#f44a3f1b-f808-41d4-a66f-f2cce10287dd\">Wilkinson<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#54f8e32a-b6c4-4bff-805c-2fcf4cc01309\">Parter<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#8d7ed044-57b1-4c74-9e0a-fa30ff9194d2\">Bucky<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#608e9f99-1ae9-4496-b7dc-cf082abb6f08\">Checkerboard<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#0a2419d6-28c5-4683-974d-abc97d2388dc\">Companion<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#dfac2927-7f5b-4987-9dc3-3f8d41f6bb32\">Fiedler<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#9de50834-140d-4fdc-b016-4882204d9272\">Redheffer<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#e7db7d8c-8230-4dfb-bab9-255dabcae02d\">Permutation<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#99e3f6f0-feee-488c-9304-e95be2aa1486\">Random<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#791596eb-5f2d-415d-a61e-7c49a068db9c\">Software<\/a>\r\n<\/li>\r\n<\/ul>\r\n<\/div>\r\n<h4>Wilkinson<a name=\"f44a3f1b-f808-41d4-a66f-f2cce10287dd\"><\/a>\r\n<\/h4>\r\n<p>J. H. Wilkinson's most famous examples are <tt>Wn+<\/tt>, a family of symmetric, tridiagonal matrices with pairs of \"remarkably\" and \"pathologically\" close eigenvalues. The two largest eigenvalues of <tt>W20+<\/tt>,<\/p>\r\n<pre>   10.246194182902979 and\r\n   10.246194182903745,<\/pre>\r\n<p>agree to 12 decimal places.<\/p>\r\n<p>For more, see my blog post on <a href=\"https:\/\/blogs.mathworks.com\/cleve\/2013\/04\/15\/wilkinsons-matrices-2\">Wilkinson matrices<\/a>. And see page 308 of Wilkinson's <i>The Algebraic Eigenvalue Problem<\/i>.<\/p>\r\n<pre class=\"codeinput\">\r\n    n = 20;\r\n    m = (n-1)\/2;\r\n    D = diag(ones(n-1,1),1);\r\n    A = diag(abs(-m:m)) + D + D';\r\n    mat_expo(A,'wilkinson')\r\n<\/pre>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/mat_expo_blog_01.png\" alt=\"\"> <h4>Parter<a name=\"54f8e32a-b6c4-4bff-805c-2fcf4cc01309\"><\/a>\r\n<\/h4>\r\n<p>One of my favorite test matrices is this nonsymmetric cousin of the Hilbert matrix. I was surprised when I discovered that most of its singular values are equal to <tt>pi<\/tt>. Seymour Parter explained why. See <a href=\"https:\/\/blogs.mathworks.com\/cleve\/2014\/02\/03\/surprising-svd-square-waves-and-pi\/\">Surprising SVD, Square Waves and Pi<\/a>.<\/p>\r\n<pre class=\"codeinput\">\r\n    j = 1:n;\r\n    k = j';\r\n    A = 1.\/(k-j+1\/2);\r\n    mat_expo(A,'parter')\r\n<\/pre>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/mat_expo_blog_02.png\" alt=\"\"> <h4>Bucky<a name=\"8d7ed044-57b1-4c74-9e0a-fa30ff9194d2\"><\/a>\r\n<\/h4>\r\n<p>The leading 20-by-20 submatrix of the 60-by-60 Bucky Ball is symmetric, so its eigenvalues are real. But the matrix is not positive definite, so the eigenvalues do not equal the singular values. See <a href=\"https:\/\/blogs.mathworks.com\/cleve\/2021\/05\/12\/bringing-back-the-bucky-ball\/\">Bringing Back the Bucky Ball<\/a>.<\/p>\r\n<pre class=\"codeinput\">\r\n    B = bucky;\r\n    A = B(1:n,1:n);\r\n    mat_expo(A,'bucky')\r\n    \r\n<\/pre>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/mat_expo_blog_03.png\" alt=\"\"> <h4>Checkerboard<a name=\"608e9f99-1ae9-4496-b7dc-cf082abb6f08\"><\/a>\r\n<\/h4>\r\n<p>We introduced the Checkerboard family just two weeks ago; see <a href=\"https:\/\/blogs.mathworks.com\/cleve\/2025\/02\/23\/two-flavors-of-svd\">Two Flavors of SVD<\/a>. There are only two nonzero eigenvalues and singular values.<\/p>\r\n<pre class=\"codeinput\">\r\n    A = checkerboard(n\/4,2,2);\r\n    mat_expo(A,'checkerboard')\r\n<\/pre>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/mat_expo_blog_04.png\" alt=\"\"> <h4>Companion<a name=\"0a2419d6-28c5-4683-974d-abc97d2388dc\"><\/a>\r\n<\/h4>\r\n<p>Before 1965, the fact that the eigenvalues of a companion matrix are equal to the zeros of the polynomial with coefficients in the first row was often the basis of methods to compute matrix eigenvalues. But the discovery of modern QR methods allowed the first MATLAB to reverse this approach and compute polynomial zeros as matrix eigenvalues.<\/p>\r\n<p>In this example, the polynomial coefficients are 1:n+1 and the polynomial zeros lie on a nearly circular curve in the complex plane.<\/p>\r\n<pre class=\"codeinput\">\r\n    c = 2:n+1;\r\n    A = diag(ones(n-1,1),-1);\r\n    A(1,:) = -c;\r\n    mat_expo(A,'companion')\r\n<\/pre>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/mat_expo_blog_05.png\" alt=\"\"> <h4>Fiedler<a name=\"dfac2927-7f5b-4987-9dc3-3f8d41f6bb32\"><\/a>\r\n<\/h4>\r\n<p>Fiedler companion matrix. Discovered by a contemporary Czech mathematician, Miroslav Fiedler, this matrix distributes the polynomial coefficients along the diagonals of an elegant pentadiagonal matrix whose eigenvalues are equal to the zeros of the polynomial. See <a href=\"https:\/\/blogs.mathworks.com\/cleve\/2013\/12\/23\/fiedler-companion-matrix\">Fiedler companion matrix<\/a>.<\/p>\r\n<p>Here is the same polynomial as the traditional companion matrix.<\/p>\r\n<pre class=\"codeinput\">\r\n    A = fiedler(c);\r\n    mat_expo(A,'fiedler')\r\n    \r\n<\/pre>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/mat_expo_blog_06.png\" alt=\"\"> <h4>Redheffer<a name=\"9de50834-140d-4fdc-b016-4882204d9272\"><\/a>\r\n<\/h4>\r\n<p>The Redheffer matrix has been in the <tt>gallery<\/tt> for a long time, but I ignored it until last September. Then I began a long series of blog posts. See <a href=\"https:\/\/blogs.mathworks.com\/cleve\/2024\/09\/23\/redheffer-mertens-and-one-million-dollars\/\">Redheffer and One Million Dollars<\/a> and <a href=\"https:\/\/blogs.mathworks.com\/cleve\/2024\/10\/22\/mobius-mertens-and-redheffer\">M&ouml;bius, Mertens and Redheffer<\/a>.<\/p>\r\n<p>Most of the eigenvalues of the Redheffer matrix are equal to one. The product of all the eigenvalues, the determinant, is the Mertens function, which is related to the Riemann hypothesis.<\/p>\r\n<pre class=\"codeinput\">\r\n    A = gallery('redheff',n);\r\n    mat_expo(A,'redheffer')\r\n<\/pre>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/mat_expo_blog_07.png\" alt=\"\"> <h4>Permutation<a name=\"e7db7d8c-8230-4dfb-bab9-255dabcae02d\"><\/a>\r\n<\/h4>\r\n<p>A permutation matrix has a single 1 in each row and column and 0's elsewhere. The matrix is orthogonal, so all the eigenvalues lie on the unit circle and all the singular values are equal to one.<\/p>\r\n<pre class=\"codeinput\">\r\n    p = randperm(n);\r\n    A = sparse(p,1:n,1);\r\n    mat_expo(A,'permutation')\r\n    \r\n<\/pre>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/mat_expo_blog_08.png\" alt=\"\"> <h4>Random<a name=\"99e3f6f0-feee-488c-9304-e95be2aa1486\"><\/a>\r\n<\/h4>\r\n<p>This random matrix has about 1\/3 of its elements equal to zero and the remaining elements normally distributed about zero. I have included such a matrix in this exposition to represent matrices in general that do not have particularly remarkable eigenvalues and singular values.<\/p>\r\n<pre class=\"codeinput\">\r\n    A = sprandn(n,n,1\/3);\r\n    mat_expo(A,'sprandn')\r\n            \r\n<\/pre>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/mat_expo_blog_09.png\" alt=\"\"> <h4>Software<a name=\"791596eb-5f2d-415d-a61e-7c49a068db9c\"><\/a>\r\n<\/h4>\r\n<p>You can <tt>publish<\/tt> the source for this blog post if you also have the three functions in <a href=\"https:\/\/blogs.mathworks.com\/cleve\/files\/MatExpo_mzip.m\">Mat_Expo_mzip<\/a>.<\/p>\r\n<script language=\"JavaScript\"> <!-- \r\n    function grabCode_3f61369346ec476aa19ed9e1ce542433() {\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='3f61369346ec476aa19ed9e1ce542433 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 3f61369346ec476aa19ed9e1ce542433';\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 2025 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>\r\n<p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\">\r\n<br>\r\n<a href=\"javascript:grabCode_3f61369346ec476aa19ed9e1ce542433()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript>\r\n<\/span><\/a>\r\n<br>\r\n<br>\r\n      Published with MATLAB&reg; R2024b<br>\r\n<\/p>\r\n<\/div>\r\n<!--\r\n3f61369346ec476aa19ed9e1ce542433 ##### SOURCE BEGIN #####\r\n%% Matrices at an Exposition\r\n% A look at the structure, and the eigenvalues and singular values of\r\n% interesting test matrices.\r\n  \r\n%% Wilkinson\r\n% J. H. Wilkinson's most famous examples are |Wn+|, a family of symmetric, \r\n% tridiagonal matrices with pairs of \"remarkably\" and \"pathologically\" \r\n% close eigenvalues. The two largest eigenvalues of |W20+|,\r\n%\r\n%     10.246194182902979 and\r\n%     10.246194182903745,\r\n%\r\n% agree to 12 decimal places.\r\n%\r\n% For more, see my blog post on \r\n% <https:\/\/blogs.mathworks.com\/cleve\/2013\/04\/15\/wilkinsons-matrices-2\r\n% Wilkinson matrices>.\r\n% And see page 308 of Wilkinson's _The Algebraic Eigenvalue Problem_.\r\n\r\n    n = 20;\r\n    m = (n-1)\/2;\r\n    D = diag(ones(n-1,1),1);\r\n    A = diag(abs(-m:m)) + D + D';\r\n    mat_expo(A,'wilkinson')\r\n\r\n%% Parter\r\n% One of my favorite test matrices is this nonsymmetric cousin of the\r\n% Hilbert matrix.  I was surprised when I discovered that\r\n% most of its singular values are equal to |pi|. \r\n% Seymour Parter explained why.  See\r\n% <https:\/\/blogs.mathworks.com\/cleve\/2014\/02\/03\/surprising-svd-square-waves-and-pi\/\r\n% Surprising SVD, Square Waves and Pi>. \r\n\r\n    j = 1:n;\r\n    k = j';\r\n    A = 1.\/(k-j+1\/2);\r\n    mat_expo(A,'parter')\r\n\r\n%% Bucky\r\n% The leading 20-by-20 submatrix of the 60-by-60 Bucky Ball is symmetric,\r\n% so its eigenvalues are real.  But the matrix is not positive definite,\r\n% so the eigenvalues do not equal the singular values.  See\r\n% <https:\/\/blogs.mathworks.com\/cleve\/2021\/05\/12\/bringing-back-the-bucky-ball\/\r\n% Bringing Back the Bucky Ball>. \r\n\r\n    B = bucky;\r\n    A = B(1:n,1:n);\r\n    mat_expo(A,'bucky')\r\n    \r\n%% Checkerboard\r\n% We introduced the Checkerboard family just two weeks ago; see\r\n% <https:\/\/blogs.mathworks.com\/cleve\/2025\/02\/23\/two-flavors-of-svd\r\n% Two Flavors of SVD>.  There are only two nonzero eigenvalues and\r\n% singular values.\r\n\r\n    A = checkerboard(n\/4,2,2);\r\n    mat_expo(A,'checkerboard')\r\n\r\n%% Companion\r\n% Before 1965, the fact that the eigenvalues of a companion matrix are\r\n% equal to the zeros of the polynomial with coefficients in the\r\n% first row was often the basis of methods to compute matrix eigenvalues.\r\n% But the discovery of modern QR methods allowed the first MATLAB to\r\n% reverse this approach and compute polynomial zeros as matrix\r\n% eigenvalues.\r\n%\r\n% In this example, the polynomial coefficients are 1:n+1 and the \r\n% polynomial zeros lie on a nearly circular curve in the complex plane.\r\n\r\n    c = 2:n+1;\r\n    A = diag(ones(n-1,1),-1);\r\n    A(1,:) = -c;\r\n    mat_expo(A,'companion')\r\n\r\n%% Fiedler\r\n% Fiedler companion matrix.\r\n% Discovered by a contemporary Czech mathematician, Miroslav Fiedler,\r\n% this matrix distributes the polynomial coefficients along the\r\n% diagonals of an elegant pentadiagonal matrix whose eigenvalues are \r\n% equal to the zeros of the polynomial.  See\r\n% <https:\/\/blogs.mathworks.com\/cleve\/2013\/12\/23\/fiedler-companion-matrix\r\n% Fiedler companion matrix>.\r\n%\r\n% Here is the same polynomial as the traditional companion matrix.\r\n\r\n    A = fiedler(c);\r\n    mat_expo(A,'fiedler')\r\n    \r\n%% Redheffer\r\n% The Redheffer matrix has been in the |gallery| for a long time, but\r\n% I ignored it until last September.  Then  I began a long series of\r\n% blog posts.  See\r\n% <https:\/\/blogs.mathworks.com\/cleve\/2024\/09\/23\/redheffer-mertens-and-one-million-dollars\/\r\n% Redheffer and One Million Dollars> and\r\n% <https:\/\/blogs.mathworks.com\/cleve\/2024\/10\/22\/mobius-mertens-and-redheffer\r\n% M\u00f6bius, Mertens and Redheffer>.\r\n%\r\n% Most of the eigenvalues of the Redheffer matrix are equal to one.\r\n% The  product of all the eigenvalues, the determinant, is the Mertens \r\n% function, which is related to the Riemann hypothesis.\r\n\r\n    A = gallery('redheff',n);\r\n    mat_expo(A,'redheffer')\r\n\r\n%% Permutation\r\n% A permutation matrix has a single 1 in each row and column and 0's\r\n% elsewhere.  The matrix is orthogonal, so all the eigenvalues lie on\r\n% the unit circle and all the singular values are equal to one.\r\n\r\n    p = randperm(n);\r\n    A = sparse(p,1:n,1);\r\n    mat_expo(A,'permutation')\r\n    \r\n%% Random\r\n% This random matrix has about 1\/3 of its elements equal to zero\r\n% and the remaining elements normally distributed about zero.\r\n% I have included such a matrix in this exposition to represent matrices\r\n% in general that do not have particularly remarkable eigenvalues and\r\n% singular values.\r\n\r\n    A = sprandn(n,n,1\/3);\r\n    mat_expo(A,'sprandn')\r\n            \r\n%% Software\r\n% You can |publish| the source for this blog post if you also have\r\n% the three functions in\r\n% <https:\/\/blogs.mathworks.com\/cleve\/files\/MatExpo_mzip.m\r\n% Mat_Expo_mzip>.\r\n##### SOURCE END ##### 3f61369346ec476aa19ed9e1ce542433\r\n-->\r\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/W20.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><!--introduction-->\r\n<p>A look at the structure, and the eigenvalues and singular values of interesting test matrices.... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/cleve\/2025\/03\/07\/matrices-at-an-exposition\/\">read more >><\/a><\/p>","protected":false},"author":78,"featured_media":12503,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[13,23,4,6,16,30],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/12512"}],"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=12512"}],"version-history":[{"count":5,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/12512\/revisions"}],"predecessor-version":[{"id":12533,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/12512\/revisions\/12533"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media\/12503"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media?parent=12512"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/categories?post=12512"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/tags?post=12512"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}