Results 1 to 3 of 3

Math Help - A numerical problem in matlab

  1. #1
    Newbie
    Joined
    Sep 2007
    Posts
    3

    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!!
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by seekor View Post
    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
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Sep 2007
    Posts
    3
    Quote Originally Posted by CaptainBlack View Post
    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

    Thanks for your attention! RonL.

    However, I am still not very clear why 1+x-1 can give better result than x. I thought that when x is very small, then 1+x will become 1 and then 1+x-1 will become 0....
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. How to change the numerical boundary in Matlab?
    Posted in the Math Software Forum
    Replies: 1
    Last Post: August 18th 2010, 06:51 AM
  2. Numerical Solutions in Diffy Q with Matlab
    Posted in the Differential Equations Forum
    Replies: 0
    Last Post: March 8th 2010, 11:27 AM
  3. how to use MATLAB to do this numerical double integral
    Posted in the Math Software Forum
    Replies: 0
    Last Post: March 2nd 2010, 09:25 PM
  4. numerical methods using matlab
    Posted in the Advanced Applied Math Forum
    Replies: 0
    Last Post: October 20th 2008, 05:05 PM
  5. Numerical integration with MATLAB
    Posted in the Calculus Forum
    Replies: 0
    Last Post: September 2nd 2008, 04:47 AM

Search Tags


/mathhelpforum @mathhelpforum