help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Machine epsilon, Octave and Matlab


From: geraint . p . bevan . itar
Subject: Re: Machine epsilon, Octave and Matlab
Date: Wed, 29 Aug 2001 14:04:03 -0500

On Wed, 29 Aug 2001, Craig Stoudt wrote:

> I have a question about the way Octave handles
> arithmetic operations around machine epsilon.
>
> Consider the expression 1/(1-x) - 1/(1+x)
> Let x = eps/2.
>
> Since x < eps, when you evaluate this expression in
> Octave, the result is zero.  Not surprising.  However,
> if you evaluate the same expression in Matlab 6.1, you
> get 2.220446049250313e-016 which is eps, which is
> pretty close to the correct answer.  If one evaluates
> the expression at eps/4, Matlab yields zero, the same
> as Octave (the correct answer is approximately eps/2).
>
> I'm just curious about the difference in results
> between Matlab and Octave at x = eps/2
B>
> Craig Stoudt


I don't know what Matlab does, but on a SGI Octane (IRIX64), Octave-2.1.33
gives an answer of eps/2:


cat << EOF | octave
> x2 = eps/2
> y2 = 1/(1-x2) - 1/(1+x2)
> x4 = eps/4
> y4 = 1/(1-x4) - 1/(1+x4)
> EOF


GNU Octave, version 2.1.33 (mips-sgi-irix6.5).
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 John W. Eaton.
This is free software with ABSOLUTELY NO WARRANTY.
For details, type `warranty'.

*** This is a development version of Octave.  Development releases
*** are provided for people who want to help test, debug, and improve
*** Octave.
***
*** If you want a stable, well-tested version of Octave, you should be
*** using one of the stable releases (when this development release
*** was made, the latest stable version was 2.0.16).

x2 =  1.1102e-16
y2 =  2.2204e-16
x4 =  5.5511e-17
y4 = 0


-- 
Geraint.



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]