[comp.sys.handhelds] A strange feature

hp48sx@wuarchive.wustl.edu (HP48SX Archive Maintainer) (10/10/90)

There are some problems using differentation/integration when in degrees
mode on the hp48sx. The manual says in many places that you should make
sure to switch to RADians mode if appropriate, but If I end up putting
degrees in the formulae then there is no reason why I should use radians
when calculating the derived function.

If I try to evaluate dX(sin(X)) then I get:
cos(x)*(dX(X)*(pi/180))
/* if the factor pi/180 should be applied, then it should be multiplied
   to the x in cox(x), but even this is not correct */
further EVAL gives:
cos(X)*(pi/180)

And we all know that cos(60) is 1/2  (the 60 is in degrees), and this is
the correct result. But we still get the factor (pi/180) which will give
me a wrong result.

As it looks like the hp48 is only capable of giving the correct results
in radians mode, the HP should have ensured that
integration/differentation is always carried out in radians mode, and
then switch back to the previous mode when done.

Povl

-- 
*******************************************************
Povl H. Pedersen             hp48sx@wuarchive.wustl.edu
HP48sx archive maintainer

edp@jareth.enet.dec.com (Eric Postpischil (Always mount a scratch monkey.)) (10/10/90)

In article <1990Oct10.093506.8848@wuarchive.wustl.edu>,
hp48sx@wuarchive.wustl.edu (HP48SX Archive Maintainer) writes:

>If I try to evaluate dX(sin(X)) then I get:
>cos(x)*(dX(X)*(pi/180))
>/* if the factor pi/180 should be applied, then it should be multiplied
>   to the x in cox(x), but even this is not correct */
>further EVAL gives:
>cos(X)*(pi/180)
>
>And we all know that cos(60) is 1/2  (the 60 is in degrees), and this is
>the correct result. But we still get the factor (pi/180) which will give
>me a wrong result.

I think the result given is correct.  If you plot sin(X) where X is measured in
degrees, the slope of that plot at X = 60 degrees will be pi/360.

The derivative of sin(x) is cos(x) only if x is in radians.  If the argument is
in degrees, then the derivative of sin(x) is cos(x)*(pi/180).


				-- edp

hoford@sequoia.upenn.edu (John Hoford) (10/10/90)

In article <1990Oct10.093506.8848@wuarchive.wustl.edu> hp48sx@wuarchive.wustl.edu (HP48SX Archive Maintainer) writes:

>If I try to evaluate dX(sin(X)) then I get:
>cos(x)*(dX(X)*(pi/180))
>/* if the factor pi/180 should be applied, then it should be multiplied
>   to the x in cox(x), but even this is not correct */
>further EVAL gives:
>cos(X)*(pi/180)
>
>As it looks like the hp48 is only capable of giving the correct results
>in radians mode, the HP should have ensured that


sin(x) in deg.    =  sin(x*(pi/180)) in rad.
since dx(sin(x)) = cos(x) is true for rad.


dx(sin(x(pi/180))) = cos(x)(pi/180)
using the rule  dx(f(g(x))) = (dx(f(x)))*(dx(g(x)))

It is not a bug it is math

John D. Hoford

hp48sx@wuarchive.wustl.edu (HP48SX Archive Maintainer) (10/10/90)

In article <15930@shlump.nac.dec.com> edp@jareth.enet.dec.com (Eric Postpischil (Always mount a scratch monkey.)) writes:
>In article <1990Oct10.093506.8848@wuarchive.wustl.edu>,
>hp48sx@wuarchive.wustl.edu (HP48SX Archive Maintainer) writes:
>
>>If I try to evaluate dX(sin(X)) then I get:
>>cos(x)*(dX(X)*(pi/180))
>>/* if the factor pi/180 should be applied, then it should be multiplied
>>   to the x in cox(x), but even this is not correct */
>>further EVAL gives:
>>cos(X)*(pi/180)
>>
>>And we all know that cos(60) is 1/2  (the 60 is in degrees), and this is
>>the correct result. But we still get the factor (pi/180) which will give
>>me a wrong result.
>
>I think the result given is correct.  If you plot sin(X) where X is measured in
>degrees, the slope of that plot at X = 60 degrees will be pi/360.
>
>The derivative of sin(x) is cos(x) only if x is in radians.  If the argument is
>in degrees, then the derivative of sin(x) is cos(x)*(pi/180).
>
>
>				-- edp

60 degress = pi/3 radians. This is a FACT!
thus  sin( 60deg ) = sin( pi/3 RAD )
these two point are exactly at the same point on the curve, and thus
the derivative must also be the same. 

I think that the error is because of the possibility of writing
trigonometric functions in terms of the exponential function need the
arguments of tr igonometric functions to be in radians. So if you are in
degress mode, then the argument of a trigonometric function is
considered to be a function (pi/180)* the argument.

and if you take the derivative of a function on a function, then you get
the outher functions derived times the inner derived. I am not sure if
the results are correect for non real numbers. Like complex numbers.

Povl

-- 
*******************************************************
Povl H. Pedersen             hp48sx@wuarchive.wustl.edu
HP48sx archive maintainer

hoford@sequoia.upenn.edu (John Hoford) (10/11/90)

In article <1990Oct10.152505.2903@wuarchive.wustl.edu> hp48sx@wuarchive.wustl.edu (HP48SX Archive Maintainer) writes:
>In article <15930@shlump.nac.dec.com> edp@jareth.enet.dec.com (Eric Postpischi
>60 degress = pi/3 radians. This is a FACT!
>thus  sin( 60deg ) = sin( pi/3 RAD )
>these two point are exactly at the same point on the curve, and thus
>the derivative must also be the same. 
>

but the x axis has been scaled by a factor of 180/pi so the derivative (dy/dx)
must be also scaled



grap of sin(x) in rad
                            |
                            |     *  *  *
                            |  *          * 
                            |*              *
	-------------------*-----------------------
       -3.14             *  0                    3.14
            *          *    
              *  *  *  

at a point say x = 0 slope moves about 1 y unit for every 1 x unit 
hence slope is (dy/dx) 1/1 = 1.




grap of sin(x) in rad
                            |
                            |     *  *  *
                            |  *          * 
                            |*              *
	-------------------*-----------------------
        -180             *  0                    180
            *          *    
              *  *  *  

at a point say x = 0 slope moves about 1 y unit for every (180/pi) x unit 
hence slope is (dy/dx) 1/(180/pi) = 1 * pi/180.


John D. Hoford

alexw@mipos2.intel.com (Alex Witkowski) (10/11/90)

In article <1990Oct10.152505.2903@wuarchive.wustl.edu> hp48sx@wuarchive.wustl.edu (HP48SX Archive Maintainer) writes:
>>
>>>If I try to evaluate dX(sin(X)) then I get:
>>>cos(x)*(dX(X)*(pi/180))
>>>/* if the factor pi/180 should be applied, then it should be multiplied
>>>   to the x in cox(x), but even this is not correct */
>>>further EVAL gives:
>>>cos(X)*(pi/180)
>>>

THIS IS 100% CORRECT! This derivative can be performed using the chain rule
that we learned in first year calculus:

Y=sin(X) where X is in degrees
Y=sin(X*pi/180) where X*pi/180 is radians
dY/dX=dX((sin(X*pi/180))*dX(X*pi/180)
     =cos(X*pi/180)*pi/180  (radians)        
transforming back to degrees:
     =cos(X)*pi/180

>thus  sin( 60deg ) = sin( pi/3 RAD )
>these two point are exactly at the same point on the curve, and thus
>the derivative must also be the same. 

THIS IS WRONG! Remember that you are plotting on two different X co-ordinates.
Look at the average slope of the sine curve from 0 to pi/2 (or 90 degrees).
Whether in degrees or radians the function has the same value at both of the
endpoints - 0 and 1.  Thus the average slope is Dy/Dx or (1-0)/(Xf-0) or 1/Xf.
That translates to 2/pi or ~0.636 for the curve plotted in radians, but it
is 1/90 or ~0.011 for the curve plotted in degrees.  The radians curve
is just a compressed (by a factor of 180/pi) plot of the degrees curve so it
no surprise (for some of us) that the ratio of these two average slopes is
exactly pi/180.  This is also true for instantaneous slopes as the HP-48SX 
calculated.

>
>I think that the error is because of the possibility of writing
>trigonometric functions in terms of the exponential function need the
>arguments of tr igonometric functions to be in radians. So if you are in
>degress mode, then the argument of a trigonometric function is
>considered to be a function (pi/180)* the argument.

That is what the chain rule is for! 
 
>
>and if you take the derivative of a function on a function, then you get
>the outher functions derived times the inner derived. I am not sure if
>the results are correect for non real numbers. Like complex numbers.

Yes!  That's the chain rule.  Why not apply it to the problem as shown above?
The chain rule is number system independent.  As long as the functions you
generate make sense with complex numbers and so do their derivatives this
is not be a problem.

>
>Povl

-------------------------------
Alex Witkowski
Intel Corporation
Santa Clara, CA 95051

rcorless@uwovax.uwo.ca (10/11/90)

Povl Pedersen writes:

>Subject:A strange feature (a bug?)

>There are some problems using differentation/integration when in degrees
>mode on the hp48sx. The manual says in many places that you should make
>sure to switch to RADians mode if appropriate, but If I end up putting
>degrees in the formulae then there is no reason why I should use radians
>when calculating the derived function.


There is an _* excellent reason *_.  The reason is that

          d
          -- sin(x) = cos(x)
          dx

is true _* ONLY IF *_ x is measured in radians.  

You can go back to the definition of derivative to see this.  
(You can tell it is a math prof talking, can't you!).

At x=0, for example, the definition of the derivative of sin(x)
is 

        lim     sin(h) - sin(0)     lim    sin(h)
        h->0    ---------------   = h->0   ------
                      h                      h

and IF h is measured in radians, you can show this limit is 1.

(Incidentally, numerical experiments with limits are an excellent
use of the HP28/48 in class or for the student on his/her own).

If h is measured in degrees, you will find that this limit is
not 1, but rather some strange number (which turns out to be
pi/180).  Just put your calculator in degree mode, and enter
'SIN(H)/H' in the solver, and try a few values of H and see
what you get.  For H very small,  you should get almost exactly
pi/180.


This point is a real puzzle for most students and indeed it
isn't as easy as most profs make out, either, because
essentially we are using the same name "sin" for two different
functions - one where sin(pi) = 0 and another where sin(pi) is
about 0.0548.  This causes confusion.

This question is another candidate for the FAQ list, especially
as the troubleshooting guide in the 48 manual they muck it up
nicely, as follows:  on p 658 in their answers to common questions
they have

Q: When I take the sine of pi in Degrees mode, why do I get
   'SIN(pi)' instead of a number?

and the answer given addresses the issue of "symbolic results
mode" rather than the real answer "Why would you ever want to
take the sine of pi in degree mode?  In degrees, pi is not 
special and you should be taking the sine of 3-and-a-bit
degrees if you want the sine of 3-and-a-bit degrees".

Much the same comment applies with derivatives.  The formulas
for the derivatives of trig functions that everybody learns
are valid only for radian measure.  The HP28/48 cleverly gets
the right formula in the case of degrees, and this is a good
starting point for a discussion of the differences and the
definition of derivative.
-- 
========
Robert Corless, Applied Mathematics, University of Western Ontario
========               London, Ontario, Canada N6A 5B9
e-mail    : RCORLESS@uwovax.uwo.ca
-- 
========
Robert Corless, Applied Mathematics, University of Western Ontario
========               London, Ontario, Canada N6A 5B9
e-mail    : RCORLESS@uwovax.uwo.ca

edp@jareth.enet.dec.com (Eric Postpischil (Always mount a scratch monkey.)) (10/11/90)

In article <1990Oct10.152505.2903@wuarchive.wustl.edu> Povl writes:

>60 degress = pi/3 radians. This is a FACT!
>thus  sin( 60deg ) = sin( pi/3 RAD )
>these two point are exactly at the same point on the curve, and thus
>the derivative must also be the same. 

The last sentence is incorrect, and the sentence preceding it is imprecise.

If you plot y = sin(x degrees), you will get a different graph than if you plot
y=sin(x radians).
The former graph will be more spread out than the latter.  The slopes will be
lesser in magnitude.

On the plot of y=sin(x radians), pi/3 radians is represented at the coordinate
(pi/3, sqrt(3)/2).  On the plot of y=sin(x degrees), 60 degrees is represented
at the coordinate (60, sqrt(3)/2).

They are different points.  They are on different curves.  They have different
slopes.

Observe that when you take the derivative of sin(x degrees) or sin(x radians),
you are NOT taking the derivative with respect to an angle; you are taking the
derivative with respect to x -- a variable which is scaled by degrees or radians
before being fed to the sine function.

If you don't believe it, then actually physically draw the curves, plotting the
sine 0, 10, 20, 30, 40, 50, 60, 70, 80, and 90 degrees at places where x = 0,
10, 20, et cetera.  Then plot the sine for x in radians.  You'll get different
curves, and you will see the different slope.


				-- edp