# Thread: A numerical problem in matlab

1. ## A numerical problem in matlab

In matlab,

ezplot('log(1+x)/x',[-10^(-15),10^(-15)])

and

ezplot('log(1+x)/(1+x-1)',[-10^(-15),10^(-15)])

will give different plot. Why? I know there may be because of the representation erro of the range -10^(-15). But I don't know exactly. Could anyone tell? Thanks a lot!!

2. Originally Posted by seekor
In matlab,

ezplot('log(1+x)/x',[-10^(-15),10^(-15)])

and

ezplot('log(1+x)/(1+x-1)',[-10^(-15),10^(-15)])

will give different plot. Why? I know there may be because of the representation erro of the range -10^(-15). But I don't know exactly. Could anyone tell? Thanks a lot!!
Floating point arithmetic is non associative, so x != 1+x-1, this is
particularly pronounced near the limit of the prescission of a double
(which is the Matlab default floating type)

RonL

3. Originally Posted by CaptainBlack
Floating point arithmetic is non associative, so x != 1+x-1, this is
particularly pronounced near the limit of the prescission of a double
(which is the Matlab default floating type)

RonL