# A numerical problem in matlab

• Sep 5th 2007, 05:25 AM
seekor
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!!
• Sep 5th 2007, 07:36 AM
CaptainBlack
Quote:

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
• Sep 5th 2007, 08:48 AM
seekor
Quote:

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