<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240877</link>
    <title>MATLAB Central Newsreader - Incoerences in MATLAB</title>
    <description>Feed for thread: Incoerences in MATLAB</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, 11 Dec 2008 23:37:01 -0500</pubDate>
      <title>Incoerences in MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240877#616511</link>
      <author>Trouble Finders Costa</author>
      <description>I have discovered some incoerences and troubles in some commands of MATLAB. These problems caused me headaches by the time I have faced them for the first time, because of the loss of several minutes in work until the perception of the problem.&lt;br&gt;
&lt;br&gt;
One of this problems, an incoerence, is: try if [125000:125000:10/0.00001] and [125000:125000:1000000] are vectors of the same dimension when generated in MATLAB.&lt;br&gt;
&lt;br&gt;
Another problem, a trouble, has to do with the question of numerical precision. Try the following commands:&lt;br&gt;
time = 0; time_increment = 0.01; n = (a number of your choice);&lt;br&gt;
for i = 1:n&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;time = time  + time_increment;&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
You will notice that, for large values of &quot;n&quot;, some decimal numbers will appear after the second one. This shouldn't happen. I have observed this problem for values of &quot;time_increment&quot; less than 0.1&lt;br&gt;
&lt;br&gt;
Thank you for your attention.&lt;br&gt;
&lt;br&gt;
Dante Valen?a.</description>
    </item>
    <item>
      <pubDate>Thu, 11 Dec 2008 23:59:03 -0500</pubDate>
      <title>Re: Incoerences in MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240877#616514</link>
      <author>Roger Stafford</author>
      <description>&quot;Trouble Finders Costa&quot; &amp;lt;valencadante@hotmail.com&amp;gt; wrote in message &amp;lt;ghs86t$528$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I have discovered some incoerences and troubles in some commands of MATLAB. These problems caused me headaches by the time I have faced them for the first time, because of the loss of several minutes in work until the perception of the problem.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; One of this problems, an incoerence, is: try if [125000:125000:10/0.00001] and [125000:125000:1000000] are vectors of the same dimension when generated in MATLAB.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Another problem, a trouble, has to do with the question of numerical precision. Try the following commands:&lt;br&gt;
&amp;gt; time = 0; time_increment = 0.01; n = (a number of your choice);&lt;br&gt;
&amp;gt; for i = 1:n&lt;br&gt;
&amp;gt;     time = time  + time_increment;&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; You will notice that, for large values of &quot;n&quot;, some decimal numbers will appear after the second one. This shouldn't happen. I have observed this problem for values of &quot;time_increment&quot; less than 0.1&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thank you for your attention.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Dante Valen?a.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;What you are calling an &quot;incoerence&quot; actually represents a failure on the part of many users to understand that Matlab uses a binary number system.  It has no way to express such values as 0.01 and 0.00001 exactly and must necessarily make very small round off errors in the above calculations.  This has been discussed ad infinitum in previous threads.  It is a common characteristic of any computing system that uses binary number fractions, just as a failure to be able to express 1/3 exactly is a shortcoming of decimal machines.&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
    <item>
      <pubDate>Fri, 12 Dec 2008 00:00:33 -0500</pubDate>
      <title>Re: Incoerences in MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240877#616515</link>
      <author>NZTideMan</author>
      <description>On Dec 12, 12:37=A0pm, &quot;Trouble Finders Costa&quot;&lt;br&gt;
&amp;lt;valencada...@hotmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; I have discovered some incoerences and troubles in some commands of MATLA=&lt;br&gt;
B. These problems caused me headaches by the time I have faced them for the=&lt;br&gt;
&amp;nbsp;first time, because of the loss of several minutes in work until the perce=&lt;br&gt;
ption of the problem.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; One of this problems, an incoerence, is: try if [125000:125000:10/0.00001=&lt;br&gt;
] and [125000:125000:1000000] are vectors of the same dimension when genera=&lt;br&gt;
ted in MATLAB.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Another problem, a trouble, has to do with the question of numerical prec=&lt;br&gt;
ision. Try the following commands:&lt;br&gt;
&amp;gt; time =3D 0; time_increment =3D 0.01; n =3D (a number of your choice);&lt;br&gt;
&amp;gt; for i =3D 1:n&lt;br&gt;
&amp;gt; =A0 =A0 time =3D time =A0+ time_increment;&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; You will notice that, for large values of &quot;n&quot;, some decimal numbers will =&lt;br&gt;
appear after the second one. This shouldn't happen. I have observed this pr=&lt;br&gt;
oblem for values of &quot;time_increment&quot; less than 0.1&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thank you for your attention.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Dante Valen?a.&lt;br&gt;
&lt;br&gt;
What do you mean by &quot;incoerence&quot;?  You've written it 3 times, so it&lt;br&gt;
cannot be a spelling mistake, but it is not an English word.  I&lt;br&gt;
suspect it is a malapropism, but I'm not sure which word you're&lt;br&gt;
getting at.&lt;br&gt;
&quot;incoherence&quot;, means a nonsense, but the fact that 10/0.00001 is not&lt;br&gt;
the same as 1000000 in floating point arithmetic is not a nonsense.&lt;br&gt;
The principle is well known and has been commented on many times in&lt;br&gt;
this forum.&lt;br&gt;
&lt;br&gt;
That these matters cause you headaches is a shame, but perhaps they&lt;br&gt;
would cause you less concern if you learned from your mistakes and in&lt;br&gt;
future refrained from trying to use floating point numbers as if they&lt;br&gt;
were integers.</description>
    </item>
    <item>
      <pubDate>Fri, 12 Dec 2008 15:42:59 -0500</pubDate>
      <title>Re: Incoerences in MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240877#616655</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;Trouble Finders Costa&quot; &amp;lt;valencadante@hotmail.com&amp;gt; wrote in message &lt;br&gt;
news:ghs86t$528$1@fred.mathworks.com...&lt;br&gt;
&amp;gt;I have discovered some incoerences and troubles in some commands of MATLAB. &lt;br&gt;
&amp;gt;These problems caused me headaches by the time I have faced them for the &lt;br&gt;
&amp;gt;first time, because of the loss of several minutes in work until the &lt;br&gt;
&amp;gt;perception of the problem.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; One of this problems, an incoerence, is: try if [125000:125000:10/0.00001] &lt;br&gt;
&amp;gt; and [125000:125000:1000000] are vectors of the same dimension when &lt;br&gt;
&amp;gt; generated in MATLAB.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Another problem, a trouble, has to do with the question of numerical &lt;br&gt;
&amp;gt; precision. Try the following commands:&lt;br&gt;
&amp;gt; time = 0; time_increment = 0.01; n = (a number of your choice);&lt;br&gt;
&amp;gt; for i = 1:n&lt;br&gt;
&amp;gt;    time = time  + time_increment;&lt;br&gt;
&amp;gt; end&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; You will notice that, for large values of &quot;n&quot;, some decimal numbers will &lt;br&gt;
&amp;gt; appear after the second one. This shouldn't happen. I have observed this &lt;br&gt;
&amp;gt; problem for values of &quot;time_increment&quot; less than 0.1&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thank you for your attention.&lt;br&gt;
&lt;br&gt;
Welcome to the world of floating point arithmetic.  Read this document for &lt;br&gt;
an explanation of these two phenomena.&lt;br&gt;
&lt;br&gt;
&lt;a href=&quot;http://www.mathworks.com/company/newsletters/news_notes/pdf/Fall96Cleve.pdf&quot;&gt;http://www.mathworks.com/company/newsletters/news_notes/pdf/Fall96Cleve.pdf&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
Note that these &quot;troubles&quot; are not limited to MATLAB, but are present in all &lt;br&gt;
arithmetic performed in finite precision.  Take a pencil and paper and &lt;br&gt;
compute x = 1/3 to any finite number of decimal places you want.  Now &lt;br&gt;
compute y = 3*x (make sure to use the finite-precision representation of x &lt;br&gt;
you calculated previously; don't say (1/3) times 3 is 1.)  y will not be &lt;br&gt;
exactly 1; roundoff error in your computation of x to a finite number of &lt;br&gt;
decimal places will make it 0.999...999 for some number of 9's.&lt;br&gt;
&lt;br&gt;
Similarly, neither 0.00001 nor 0.01 can be exactly represented in binary, so &lt;br&gt;
in your first example the upper limit of your first colon expression is not &lt;br&gt;
exactly 10 divided by (one times ten to the -5th power)  and so the division &lt;br&gt;
does not result in exactly 1e6.  Similarly, adding together the IEEE double &lt;br&gt;
precision representation of 0.01 multiple times is not exactly the same as &lt;br&gt;
adding one one-hundredth together multiple times.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com </description>
    </item>
    <item>
      <pubDate>Fri, 12 Dec 2008 23:24:01 -0500</pubDate>
      <title>Re: IncoHerences in MATLAB</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/240877#616730</link>
      <author>Trouble Finders Costa</author>
      <description>NZTideMan &amp;lt;mulgor@gmail.com&amp;gt; wrote in message &amp;lt;cfb60b8d-f7ec-4606-a52f-60fa9dd60c33@r15g2000prh.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; On Dec 12, 12:37=A0pm, &quot;Trouble Finders Costa&quot;&lt;br&gt;
&amp;gt; &amp;lt;valencada...@hotmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; I have discovered some incoerences and troubles in some commands of MATLA=&lt;br&gt;
&amp;gt; B. These problems caused me headaches by the time I have faced them for the=&lt;br&gt;
&amp;gt;  first time, because of the loss of several minutes in work until the perce=&lt;br&gt;
&amp;gt; ption of the problem.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; One of this problems, an incoerence, is: try if [125000:125000:10/0.00001=&lt;br&gt;
&amp;gt; ] and [125000:125000:1000000] are vectors of the same dimension when genera=&lt;br&gt;
&amp;gt; ted in MATLAB.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Another problem, a trouble, has to do with the question of numerical prec=&lt;br&gt;
&amp;gt; ision. Try the following commands:&lt;br&gt;
&amp;gt; &amp;gt; time =3D 0; time_increment =3D 0.01; n =3D (a number of your choice);&lt;br&gt;
&amp;gt; &amp;gt; for i =3D 1:n&lt;br&gt;
&amp;gt; &amp;gt; =A0 =A0 time =3D time =A0+ time_increment;&lt;br&gt;
&amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; You will notice that, for large values of &quot;n&quot;, some decimal numbers will =&lt;br&gt;
&amp;gt; appear after the second one. This shouldn't happen. I have observed this pr=&lt;br&gt;
&amp;gt; oblem for values of &quot;time_increment&quot; less than 0.1&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Thank you for your attention.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Dante Valen?a.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; What do you mean by &quot;incoerence&quot;?  You've written it 3 times, so it&lt;br&gt;
&amp;gt; cannot be a spelling mistake, but it is not an English word.  I&lt;br&gt;
&amp;gt; suspect it is a malapropism, but I'm not sure which word you're&lt;br&gt;
&amp;gt; getting at.&lt;br&gt;
&amp;gt; &quot;incoherence&quot;, means a nonsense, but the fact that 10/0.00001 is not&lt;br&gt;
&amp;gt; the same as 1000000 in floating point arithmetic is not a nonsense.&lt;br&gt;
&amp;gt; The principle is well known and has been commented on many times in&lt;br&gt;
&amp;gt; this forum.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; That these matters cause you headaches is a shame, but perhaps they&lt;br&gt;
&amp;gt; would cause you less concern if you learned from your mistakes and in&lt;br&gt;
&amp;gt; future refrained from trying to use floating point numbers as if they&lt;br&gt;
&amp;gt; were integers.&lt;br&gt;
&lt;br&gt;
Thank you. I was having in mind the word &quot;incoer?ncia&quot; when I wrote &quot;incoerence&quot;. I will try to improve my English, it's not my first language. Is it yours?</description>
    </item>
  </channel>
</rss>

