最近在学习MATLAB,中间在做矩阵的除法时,发现后面加了个eps,按照以往经验,不加eps就可以了,感觉很疑惑,所以查询了一下。
使用help eps得到了:
EPS Spacing of floating point numbers.
D = EPS(X), is the positive distance from ABS(X) to the next larger in
magnitude floating point number of the same precision as X.
X may be either double precision or single precision.
For all X, EPS(X) = EPS(-X) = EPS(ABS(X)).
EPS, with no arguments, is the distance from 1.0 to the next larger double
precision number, that is EPS = 2^(-52).
也就是eps表征的是浮点数的间隔值。
EPS(X)表示的是 ABS(X)到下一个更大的浮点数之间的间隔(因为浮点数是间断的,不连续)。而且EPS(X) = EPS(-X) = EPS(ABS(X)),都是X的绝对值到下一个浮点数的间隔长度。
不带参数的 EPS,是从1开始到下一个比原值大的浮点数与原值的距离。我的理解是这是一个随原值变化的精度。比如a+eps,如果a为浮点数,则a+eps==a;如果a在两个浮点数之间,则取比a大的那个浮点数替代。a+eps>