Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: computation precision and display
Posted:
Dec 4, 2012 12:32 PM
|
|
"Nasser M. Abbasi" <nma@12000.org> wrote in message news:k9jmbo$ila$1@speranza.aioe.org... > On 12/3/2012 7:01 PM, Jose wrote: >> Hi, >> >> It just happens in my linux 64 bits PC, running Matlab 2010a (on format >> long g) that when I calculate >> >>>> A=(0.714844838298060 + 0.699283102297360i)*conj(0.714844838298060 + >>>> 0.699283102297360i) >> >> A = >> >> 1.000000000000000 >> >> Now when I calculate >> >> >>>> B=(0.757342604591773 + 0.653017748051421i)*conj(0.757342604591773 + >>>> 0.653017748051421i) >> >> B = >> >> 1 >> >> And the difference is: >> >>>> A-B >> >> ans = >> >> -1.11022302462516e-16 >> >> This is important because when I try to plot A and B as elements of a >>matrix with a colormap using imagesc they get very different colors. > > that is strange, since (A-B) is less than eps
Why is that strange?
Remember that eps() [== eps(1)] is the smallest number such that 1+eps is greater than 1. It is perfectly fine to have numbers smaller than eps (for example, REALMIN is many orders of magnitude smaller) and in particular the difference between 1 and the next SMALLER number is eps/2.
format hex a = 1 b = 1-(eps/2) d = eps(b) (a == (b+d))
-- Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com
|
|
|
|