help-octave
[Top][All Lists]
Advanced

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

Re: Same .m file: different results with different versions of Octave


From: Jaroslav Hajek
Subject: Re: Same .m file: different results with different versions of Octave
Date: Mon, 19 Apr 2010 09:55:42 +0200

On Mon, Apr 19, 2010 at 9:20 AM, Judd Storrs <address@hidden> wrote:
> On Mon, Apr 19, 2010 at 3:11 AM, Jaroslav Hajek <address@hidden> wrote:
>> One minor drawback I can immediately see is that these formulas don't
>> always reduce to plain tanh (R) when I = 0. Indeed, the result may be
>> a bit off even for small numbers:
>>
>> octave:1> tanh(complex(1,0)) - tanh(1)
>> ans = 0
>> octave:2> testgsltanh(complex(1,0)) - tanh(1)
>> ans =  1.1102e-16
>
> Isn't that less than machine precision:
>
>> tanh(1)*eps
> ans =  1.6911e-16
>

Yes, but it's not zero. Accordingly, in some circumstances an m-file
function may give slightly different results from an apparently
equivalent C++ implementation. This is because Octave will
automatically narrow down complex intermediate results with zero
imaginary part. It's not serious, but the current implementation
doesn't seem to suffer from this.

-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

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