help-octave
[Top][All Lists]
Advanced

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

Re: Numerical issues with sin()/cos()


From: Mike Miller
Subject: Re: Numerical issues with sin()/cos()
Date: Tue, 27 Mar 2018 11:29:54 -0700
User-agent: Mutt/1.9.4 (2018-02-28)

On Mon, Mar 26, 2018 at 16:01:04 +0000, vlad ionescu wrote:
> The simplest generator for this would be (sinc() works the same):
> 
> N=33; M=N/2; n=-M:1:M; h=sin(0.37*pi*n)./(pi*n); h(ceil((N+1)/2)=0.37;
> 
> Note that the code in Octave directly follows the one in wxMaxima, and
> both use the range -M:1:M. There is no cheating in wxMaxima, so
> sin(-1)=-sin(1), while in Octave it doesn't seem to be so.

Setting the fir function aside, I don't see any problems with this
particular example

    >> N = 33; M = N/2; n = (-M:M)'; h = sin (0.37 * pi * n) ./ (pi * n);
    >> assert (h, flipud (h))
    >> assert (h, x, 1e-15)

It doesn't look to me like the errors are in the sin function.

FWIW the h I obtain above is not equal to the h I get from the attached
fir function. The error is worst at index 18, the same as the error you
are seeing.

-- 
mike

Attachment: signature.asc
Description: PGP signature


reply via email to

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