The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

SINC function (WP 34S)
Message #1 Posted by Gerson W. Barbosa on 23 Aug 2013, 3:26 p.m.

I've noticed the SINC function on the WP 34S, at least in version 3.2r3382, is giving wrong results when in angles modes other than RAD, except when the argument is 1. This is something similar to the current implementation of the Gamma function on the Prime, which gives wrong results in Degrees mode. Sorry if this has been addressed already.

Gerson.

      
Re: SINC function (WP 34S)
Message #2 Posted by Marcus von Cube, Germany on 23 Aug 2013, 4:47 p.m.,
in response to message #1 by Gerson W. Barbosa

It seems to me that Pauli has to lock after this one.

We'll be fixing any bug, wont we?

            
Re: SINC function (WP 34S)
Message #3 Posted by Gerson W. Barbosa on 23 Aug 2013, 5:37 p.m.,
in response to message #2 by Marcus von Cube, Germany

Quote:
We'll be fixing any bug, wont we?

No complaint about the Bug Fixing Department, quite the contrary :-)

Not an important bug anyway. Too few people using this function, it appears.

      
Re: SINC function (WP 34S)
Message #4 Posted by Paul Dale on 23 Aug 2013, 7:50 p.m.,
in response to message #1 by Gerson W. Barbosa

Can you give an example where an error is occurring?

The numbers I'm seeing here are the same as executing:

    SIN
    RCL/ L

i.e. sin(x) / x

- Pauli

            
Re: SINC function (WP 34S)
Message #5 Posted by Didier Lachieze on 23 Aug 2013, 8:32 p.m.,
in response to message #4 by Paul Dale

As the argument of SINC is assumed to be in radians, I think it should be rather like:

LocR 001
STOM .00
RAD
SIN
RCL/ L
RCLM .00

Edited: 23 Aug 2013, 8:39 p.m.

                  
Re: SINC function (WP 34S)
Message #6 Posted by Paul Dale on 23 Aug 2013, 9:34 p.m.,
in response to message #5 by Didier Lachieze

Why should radians be assumed? We don't assume radians for SIN and the definition of SINC(x) is SIN(x) / x.

It is easy enough to change the behaviour but I wonder if it is necessary or desirable.

- Pauli

                        
Re: SINC function (WP 34S)
Message #7 Posted by Gerson W. Barbosa on 23 Aug 2013, 9:56 p.m.,
in response to message #6 by Paul Dale

When in degrees or grads there is a discontinuity in x = 0. For x = 1 the function returns 1 (in accordance with the definition), but for x + epsilon and x - epsilon the function returns pi/180 or pi/200, depending on the angle mode. It appears to me sinc doesn't make sense for arguments in degrees or grads, because sinc is a continuous function and sinc(0) = 1.

Gerson.

                              
Re: SINC function (WP 34S)
Message #8 Posted by Paul Dale on 23 Aug 2013, 10:04 p.m.,
in response to message #7 by Gerson W. Barbosa

I understand the problem now.

I see two fixes here:

  1. force radian mode for SINC or
  2. change the value returned for SINC(0) to maintain continuity.

Neither is difficult.

- Pauli

                                    
Re: SINC function (WP 34S)
Message #9 Posted by Gerson W. Barbosa on 23 Aug 2013, 10:23 p.m.,
in response to message #8 by Paul Dale

I don't remember ever seeing sinc using arguments in degrees, but further discussion might be necessary before either choice is made.

Here are two references:

http://mathworld.wolfram.com/SincFunction.html

http://en.wikipedia.org/wiki/Sinc_function

Gerson.

                                    
Re: SINC function (WP 34S)
Message #10 Posted by Gerson W. Barbosa on 24 Aug 2013, 10:31 p.m.,
in response to message #8 by Paul Dale

Quote:
  1. force radian mode for SINC

I see that's what has been implemented in the latest version (2013-8-25 3448), but now 0 is causing a Domain Error that wasn't there before.

Gerson.

Edited: 24 Aug 2013, 10:32 p.m.

                                          
Re: SINC function (WP 34S)
Message #11 Posted by Paul Dale on 24 Aug 2013, 11:56 p.m.,
in response to message #10 by Gerson W. Barbosa

Bummer, accidentally took out the small x guard code.

- Pauli

                                                
Re: SINC function (WP 34S)
Message #12 Posted by Paul Dale on 25 Aug 2013, 12:05 a.m.,
in response to message #11 by Paul Dale

And fixed in 3450.

- Pauli

                                                      
Re: SINC function (WP 34S)
Message #13 Posted by Gerson W. Barbosa on 25 Aug 2013, 10:30 p.m.,
in response to message #12 by Paul Dale

Case closed. Next! :-)

For those who missed the thread, here's an unusual problem involving SINC:

http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv020.cgi?read=177273

Gerson.

                        
Re: SINC function (WP 34S)
Message #14 Posted by Manolo Sobrino on 24 Aug 2013, 12:48 a.m.,
in response to message #6 by Paul Dale

Ahem... this... misconception... again.

Let's get this over with. Degrees are practical units of angular measurement. They only make sense as arguments of circular functions (with real domain). You could measure everything in degrees provided you scaled every other variable accordingly.

x --> x *Pi/180

In fact, you are scaling the variable too in the trigonometric function, it's just you're being quiet about it:

Let's consider the Taylor series for SIN(x). Everyone here will agree with:

SIN(x)= x - x^3/3! + x^5/5! + ...

You can use this to calculate, say SIN(30):

SIN(x=30)= 30 - 30^3/3! + 30^5/5! + ... = 0.5

Please, evaluate this expression taking 30 as just x=30 and see what happens. What's going on?

The series works for x in radians, and for x in degrees we can drop the degree () as long as we write it down as:

SIN(x)= x*Pi/180 - (x*Pi/180)^3/3! + (x*Pi/180)^5/5! + ...

Please evaluate:

SIN(30)= 30*Pi/180 - (30*Pi/180)^3/3! + (30*Pi/180)^5/5! + ...

Now you got it right!

You can "define" SINC in degrees as long as it is:

SINC(x) = (180/Pi)* SIN(x)/x

But you really don't want to use degrees for anything but real trigonometric functions... and then just to write the angles down.

                              
Re: SINC function (WP 34S)
Message #15 Posted by Paul Dale on 24 Aug 2013, 2:53 a.m.,
in response to message #14 by Manolo Sobrino

This makes sense. SINC is fixed. The documentation will need a minor update to match -- in degrees mode SINC(x) = SIN(x) / (PI * x / 180) and in gradians mode SINC(x) = SIN(x) / (PI * x / 200). SINC(30o) = 0.9549296585513720 = SINC(PI / 6 radians).

- Pauli

                                    
Re: SINC function (WP 34S)
Message #16 Posted by Andrew Nikitin on 24 Aug 2013, 10:42 a.m.,
in response to message #15 by Paul Dale

It seems that you missed the punchline of Manolo's explanation:

Quote:
But you really don't want to use degrees for anything but real trigonometric functions... and then just to write the angles down.

SINC argument should be always considered radians, independent on angle setting, just like complex trig functions.

There is simply no use case for this functions where it makes sense to treat input x=30 as 30^o

                                          
Re: SINC function (WP 34S)
Message #17 Posted by Gerson W. Barbosa on 24 Aug 2013, 2:11 p.m.,
in response to message #16 by Andrew Nikitin

Quote:
SINC argument should be always considered radians, independent on angle setting, just like complex trig functions.

That's my opinion as well. Probably people using SINC have their calculator set to radian most of the time, but we shoudn't count on this. SINC with arguments in degrees is just useless and inconvenient. Anyway, if someone has a good reason for that, I would like to know.

Gerson.

                                    
Re: SINC function (WP 34S)
Message #18 Posted by Walter B on 24 Aug 2013, 1:48 p.m.,
in response to message #15 by Paul Dale

I concur with Manolo's reasoning. There's simply no use using SINC in any angular mode but RAD.

d:-)

                                          
Re: SINC function (WP 34S)
Message #19 Posted by Gerson W. Barbosa on 24 Aug 2013, 2:32 p.m.,
in response to message #18 by Walter B

Quote:
There's simply no use using SINC in any angular mode but RAD.

Then why not assuming the arguments are always in radians, regardless of the angular mode? There's no inconsistency in this since the function is never used with practical angle units. A similar behavior occurs with the complex trigonometric functions, as Andrew Nikitin has reminded us. It would require a short note in page 113 of the manual, however.

                                                
Re: SINC function (WP 34S)
Message #20 Posted by Walter B on 25 Aug 2013, 1:53 a.m.,
in response to message #19 by Gerson W. Barbosa

Quote:
It would require a short note in page 113 of the manual, however.
Will be in next edition.

d:-)

                        
Re: SINC function (WP 34S)
Message #21 Posted by Didier Lachieze on 24 Aug 2013, 1:25 a.m.,
in response to message #6 by Paul Dale

Quote:
Why should radians be assumed?
This is explicitly said in the first link provided by Gerson on the SINC function (under details).

Edited: 24 Aug 2013, 1:35 a.m.

                              
Re: SINC function (WP 34S)
Message #22 Posted by Paul Dale on 24 Aug 2013, 2:13 a.m.,
in response to message #21 by Didier Lachieze

The same site's definition of SIN also says the argument is in radians. Following logically on from this, the trigonometric functions shouldn't support degrees and gradians at all.

- Pauli

                                    
Re: SINC function (WP 34S)
Message #23 Posted by Didier Lachieze on 24 Aug 2013, 3:05 a.m.,
in response to message #22 by Paul Dale

Good point, I've been too fast to a conclusion.

Manolo's explanation is the right one.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall