<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/263881</link>
    <title>MATLAB Central Newsreader - An interesting numerical problem</title>
    <description>Feed for thread: An interesting numerical problem</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 22 Oct 2009 17:27:22 -0400</pubDate>
      <title>An interesting numerical problem</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/263881#689080</link>
      <author>Yi Cao</author>
      <description>I have met an interesting numerical problem:&lt;br&gt;
&lt;br&gt;
Let's define a function first:&lt;br&gt;
&lt;br&gt;
function P=polyconvert(n)&lt;br&gt;
P = eye(n);&lt;br&gt;
for k=1:n&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;P(k,1:k) = fliplr(poly(ones(1,k-1)));&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
Then use the function as follows:&lt;br&gt;
&lt;br&gt;
P19 = polyconvert(19);&lt;br&gt;
&lt;br&gt;
This is a low triangular matrix with all diagonal elements equal to 1. Therefore, the determinant of the matrix should be 1, as well any product of P19 and P19'. However, in Matlab 2009b, I got the following results:&lt;br&gt;
&lt;br&gt;
det(P19)        % I got 1, it is fine.&lt;br&gt;
det(P19'*P19) % I also got 1.&lt;br&gt;
det(P19*P19') % I got -8!&lt;br&gt;
&lt;br&gt;
It is very strange, how can det(P19*P19') equal to -8? All elements of P19 are integers, hence should not have any error here. The maximum elements of P19*P19' is only about 1e10. Although it is slightly over the 2^32, but that should not be a problem for double floating point calculation, isn't it? Anyone can give a clue what is going wrong here?&lt;br&gt;
&lt;br&gt;
Thanks for help.&lt;br&gt;
&lt;br&gt;
Yi</description>
    </item>
    <item>
      <pubDate>Thu, 22 Oct 2009 17:48:19 -0400</pubDate>
      <title>Re: An interesting numerical problem</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/263881#689087</link>
      <author>Matt Fetterman</author>
      <description>&quot;Yi Cao&quot; &amp;lt;y.cao@cranfield.ac.uk&amp;gt; wrote in message &amp;lt;hbq4lq$4m1$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I have met an interesting numerical problem:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Let's define a function first:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; function P=polyconvert(n)&lt;br&gt;
&amp;gt; P = eye(n);&lt;br&gt;
&amp;gt; for k=1:n&lt;br&gt;
&amp;gt;      P(k,1:k) = fliplr(poly(ones(1,k-1)));&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Then use the function as follows:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; P19 = polyconvert(19);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; This is a low triangular matrix with all diagonal elements equal to 1. Therefore, the determinant of the matrix should be 1, as well any product of P19 and P19'. However, in Matlab 2009b, I got the following results:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; det(P19)        % I got 1, it is fine.&lt;br&gt;
&amp;gt; det(P19'*P19) % I also got 1.&lt;br&gt;
&amp;gt; det(P19*P19') % I got -8!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; It is very strange, how can det(P19*P19') equal to -8? All elements of P19 are integers, hence should not have any error here. The maximum elements of P19*P19' is only about 1e10. Although it is slightly over the 2^32, but that should not be a problem for double floating point calculation, isn't it? Anyone can give a clue what is going wrong here?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks for help.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Yi&lt;br&gt;
&lt;br&gt;
What happens with N less than 19? If it suddenly doesn't work at 19, that does suggest the memory size? Regards! Matt</description>
    </item>
    <item>
      <pubDate>Thu, 22 Oct 2009 17:59:07 -0400</pubDate>
      <title>Re: An interesting numerical problem</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/263881#689089</link>
      <author>Bruno Luong</author>
      <description>&quot;Yi Cao&quot; &amp;lt;y.cao@cranfield.ac.uk&amp;gt; wrote in message &amp;lt;hbq4lq$4m1$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I have met an interesting numerical problem:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Let's define a function first:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; function P=polyconvert(n)&lt;br&gt;
&amp;gt; P = eye(n);&lt;br&gt;
&amp;gt; for k=1:n&lt;br&gt;
&amp;gt;      P(k,1:k) = fliplr(poly(ones(1,k-1)));&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Then use the function as follows:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; P19 = polyconvert(19);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; This is a low triangular matrix with all diagonal elements equal to 1. Therefore, the determinant of the matrix should be 1, as well any product of P19 and P19'. However, in Matlab 2009b, I got the following results:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; det(P19)        % I got 1, it is fine.&lt;br&gt;
&amp;gt; det(P19'*P19) % I also got 1.&lt;br&gt;
&amp;gt; det(P19*P19') % I got -8!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; It is very strange, how can det(P19*P19') equal to -8? All elements of P19 are integers, hence should not have any error here. The maximum elements of P19*P19' is only about 1e10. Although it is slightly over the 2^32, but that should not be a problem for double floating point calculation, isn't it?&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt;Anyone can give a clue what is going wrong here?&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
cond(P19*P19') is larger than 10^20. Eigen-space are highly parallel. The fact that P19 contains integer does not matter IMO because DET calculation using LU factorization.&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; det(P19*P19')&lt;br&gt;
&lt;br&gt;
ans =&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-8&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; det(fliplr(P19*P19'))&lt;br&gt;
&lt;br&gt;
ans =&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-1&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; det(flipud(P19*P19'))&lt;br&gt;
&lt;br&gt;
ans =&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; det(fliplr(flipud(P19*P19')))&lt;br&gt;
&lt;br&gt;
ans =&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; </description>
    </item>
    <item>
      <pubDate>Thu, 22 Oct 2009 19:18:21 -0400</pubDate>
      <title>Re: An interesting numerical problem</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/263881#689109</link>
      <author>Yi Cao</author>
      <description>&quot;Bruno Luong&quot; &amp;lt;b.luong@fogale.findmycountry&amp;gt; wrote in message &amp;lt;hbq6hb$5me$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; cond(P19*P19') is larger than 10^20. Eigen-space are highly parallel. The fact that P19 contains integer does not matter IMO because DET calculation using LU factorization.&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
For L*U = P*P', theoretically, L should be P and U should be P' because P is low triangular and P' is upper triangular.  Clearly, LU factorization in Matlab is not so smart.&lt;br&gt;
&lt;br&gt;
Yi</description>
    </item>
    <item>
      <pubDate>Thu, 22 Oct 2009 19:35:23 -0400</pubDate>
      <title>Re: An interesting numerical problem</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/263881#689112</link>
      <author>someone </author>
      <description>&quot;Yi Cao&quot; &amp;lt;y.cao@cranfield.ac.uk&amp;gt; wrote in message &amp;lt;hbqb5s$9st$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Bruno Luong&quot; &amp;lt;b.luong@fogale.findmycountry&amp;gt; wrote in message &amp;lt;hbq6hb$5me$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; cond(P19*P19') is larger than 10^20. Eigen-space are highly parallel. The fact that P19 contains integer does not matter IMO because DET calculation using LU factorization.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; For L*U = P*P', theoretically, L should be P and U should be P' because P is low triangular and P' is upper triangular.  Clearly, LU factorization in Matlab is not so smart.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Yi&lt;br&gt;
&lt;br&gt;
IMO, its not so much that &quot;Matlab is not so smart&quot; as it is that due to &lt;br&gt;
floating point arithmetic, numerical problems and theoretical problems &lt;br&gt;
don't always agree.  In fact, you can even find &quot;simple&quot; cases where&lt;br&gt;
&lt;br&gt;
(a + b) + c ~= a + (b + c)</description>
    </item>
  </channel>
</rss>

