2012年11月2日金曜日

matlab: limitations for large/small numbers

Here are some limitations for large/small numbers in Matlab.
So it's about boundary and precision.
Examples below are results derived in Matlab R2007b (64bit) on Win7 x64 on Core i5 2500.
Just a list of examples; no summary or interpretation as of now.

**
>> help eps
will explain most of the following results
**

Large number limit

 

number:

>> realmax
ans =
  1.7977e+308

>> realmax+9.97e+291
ans =
  1.7977e+308

>> realmax+9.98e+291
ans =
  Inf

exp:

>> exp(709)
ans =
  8.2184e+307

>> exp(710)
ans =
  Inf

log:

>> log(realmax+9.97e+291)
ans =
  709.7827

>> log(realmax+9.98e+291)
ans =
  Inf

Small number limit


number:

>> realmin
ans =
  2.2251e-308

>> isequal(0,realmin)
ans =
     0

>> isequal(0,0+realmin)
ans =
     0

>> 1+realmin
ans =
     1

>> isequal(1,1+realmin)
ans =
     1

>> isequal(1,1+realmin*4.98e+291)
ans =
     1

>> isequal(1,1+realmin*4.99e+291)
ans =
     0

>> realmin*4.99e+291
ans =
  1.1103e-016

>> eps
ans =
  2.2204e-016

>> isequal(2,2+realmin*9.97e+291)
ans =
     1

>> isequal(2,2+realmin*9.98e+291)
ans =
     0

>> isequal(100,100+realmin*3.1e+293)
ans =
     1

>> isequal(100,100+realmin*3.2e+293)
ans =
     0

exp:

>> exp(-745)
ans =
  4.9407e-324

>> exp(-746)
ans =
     0

>> isequal(1,exp(realmin*4.98e+291))
ans =
     1

>> isequal(1,exp(realmin*4.99e+291))
ans =
     0

log:

>> log(realmin*1.0e-15)
ans =
 -742.8306

>> log(realmin*1.0e-16)
ans =
  -Inf

>> isequal(log(1),log(1+realmin*4.98e+291))
ans =
     1

>> isequal(log(1),log(1+realmin*4.99e+291))
ans =
     0

>> isequal(log(2),log(2+realmin*9.97e+291))
ans =
     1

>> isequal(log(2),log(2+realmin*9.98e+291))
ans =
     0

>> isequal(log(100),log(100+realmin*4.1e+294))
ans =
     1

>> isequal(log(100),log(100+realmin*4.2e+294))
ans =
     0

0 件のコメント:

コメントを投稿