help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to print this function?


From: marco atzeri
Subject: Re: How to print this function?
Date: Tue, 22 May 2012 23:53:20 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1

On 5/22/2012 10:50 PM, Max Brister wrote:

Actually, [-100000:1:100000;] is fine. Look at the code here
http://hg.savannah.gnu.org/hgweb/octave/file/d95e719ef108/liboctave/Range.cc#l59

Octave's algorithm for getting a matrix from a range works as folows
1) Determine the number of elements in a range
2) Compute each index of the matrix using the equation: result(i) =
base + i * increment; where i is integer and goes from 0 to the number
of elements.

So there will be some difference between [-1:0.00001:1;]-0.00001 and
[-100000:1:100000;] due to floating point roundoff errors. However,
this difference does not accumulate. If we look at

[a,b] = max(abs([-1:0.00001:1;]-0.00001*[-100000:1:100000;]))

We see that the greatest error occurs at the 150001 element out of
200001 elements total. If the error was accumulating, we would expect
for the largest difference to occur closer to the end. Furthermore, if
there was actually an accuracy issue we would expect to see a
different number of columns in each matrix.

very interesting Max,

in reality half of the values are equal around eps/2 and the rest
are smaller than that

  a = abs([-1:0.00001:1;]-0.00001*[-100000:1:100000;]);
  hist(a)


Regards
Marco


reply via email to

[Prev in Thread] Current Thread [Next in Thread]