Re: An interesting problem




"umar " <umarkhan_80@xxxxxxxxxxx> wrote in message
news:gu8ibm$jb9$1@xxxxxxxxxxxxxxxxxxxxx
hi,
I tried the following code

i=0;
x=0;

for i=1:10
x=x+0.1
end
x-1


at the end x-1 should be zero, but it turns out to be -1.1102e-016 , WHY?

See Q6.1 in the newsgroup FAQ for an explanation and links to a few papers
that go into more depth on floating-point computation:

http://matlabwiki.mathworks.com/MATLAB_FAQ

--
Steve Lord
slord@xxxxxxxxxxxxx


.



Relevant Pages

  • Re: Question on "" operator.
    ... vector is just a matrix that has size 1 in one of its dimensions. ... you can find an x such that a*x-b is exactly the zero ... Steve Lord ...
    (comp.soft-sys.matlab)
  • Re: Removing Imaginary numbers from a matrix
    ... If you want to extract the imaginary part, ... Steve Lord ... is there anyway of turning the whole element of the matrix to zero though? ...
    (comp.soft-sys.matlab)
  • Re: doubt on indeterminate forms
    ... raised to zero give 1 as the answer and that 0 raised to 0 is an ... but in matlab when 0^0 is typed 1 is returned as the answer instead ... Here's their FAQ article that explains why 0^0 is ... Steve Lord ...
    (comp.soft-sys.matlab)
  • Re: Airy pattern, how to plot?
    ... How does Z can be defined to get the airy intensity pattern plot ... centered at zero with its max peak at one? ... Steve Lord ...
    (comp.soft-sys.matlab)
  • Re: An interesting problem
    ... at the end x-1 should be zero, but it turns out to be -1.1102e-016, WHY? ... use symbolic computation. ...
    (comp.soft-sys.matlab)

Loading