[comp.sys.handhelds] Two questions...

b3300876@rick.cs.ubc.ca (george kai yee chow) (09/25/90)

I have two questions. The first is really minor but I'm sure
most people would want an answer: How do I speed up Tetris
for the 48sx. Right now, the game is so slow that I can
take notes and play a game very comfortably. Not that I don't
like this but I really would like a more challenging game.

The second is wrt the cosine function. I was doing some 
geometry problem and needed to evaluate cos(pi/3) (I know, I 
know, I should know it but I thought I might as well fire up
my 48 just for fun). My 48sx returned 0.4999..., not 0.5. 
sin(pi/6) does return 0.5 though. Why is this? 

George Chow

bson@rice-chex.ai.mit.edu (Jan Brittenson) (09/25/90)

In article <1990Sep24.183934.575@rick.cs.ubc.ca>
   b3300876@rick.cs.ubc.ca (george kai yee chow) writes:

 > I was doing some geometry problem and needed to evaluate cos(pi/3) (I
 > know, I know, I should know it but I thought I might as well fire up
 > my 48 just for fun). My 48sx returned 0.4999..., not 0.5.  sin(pi/6)
 > does return 0.5 though. Why is this?

If you do

	pi 3 / ->NUM
	pi 6 / ->NUM /

you get "2.00000000001", i.e. a rounding error.

My guess is that there is more of a rounding error when dividing pi
with the prime 3 than when dividing with the even number 6.

Now, I personally would like 'cos(pi/3)' ->EVAL (as opposed to ->NUM)
to pass the algebraic 'pi/3' to cos, and cos to recognize this as
a know special form. (But only when the numerical-results flag is clear.)

It would be nice if typing pi 3 / cos resulted in the same - the
precise answer 0.5. (There are plenty of good algorithms yielding the
precise answer of fractions of pi.)

Hmm... this could be done with ^MATCH... Write a function cospi so
that 'cospi(3)' is the precise answer of 'cos(pi/3)' and do

	{ 'cos(pi/&piD)' 'cospi(&piD)' } ^MATCH 

Does anyone know how to use the third list entry, the 'conditional'?
It seems you can't refer to the variables in the patterns, for
instance.

SLSW2@cc.usu.edu (Roger Ivie) (09/25/90)

In article <1990Sep24.183934.575@rick.cs.ubc.ca>, b3300876@rick.cs.ubc.ca (george kai yee chow) writes:
> 
> The second is wrt the cosine function. I was doing some 
> geometry problem and needed to evaluate cos(pi/3) (I know, I 
> know, I should know it but I thought I might as well fire up
> my 48 just for fun). My 48sx returned 0.4999..., not 0.5. 
> sin(pi/6) does return 0.5 though. Why is this? 
> 
One of the more interesting things I encountered when I bought my first
HP calculator (a 31E) was a long discussion in the manual about this sort
of problem (I've still got the manual, but it's not handy. If anyone's
interested, I can find a direct quote).

The gist of the discussion was that since the calculator could not really
use pi but only a 10-digit approximation of pi, the result of the calculator
is accurate. It is returning the cosine of precisely that 10-digit
approximation of (pi/3).
-- 
===============================================================================
Roger Ivie

35 S 300 W
Logan, Ut.  84321
(801) 752-8633
===============================================================================

b3300876@rick.cs.ubc.ca (george kai yee chow) (09/26/90)

In article <36159@cc.usu.edu> SLSW2@cc.usu.edu (Roger Ivie) writes:
>In article <1990Sep24.183934.575@rick.cs.ubc.ca>, b3300876@rick.cs.ubc.ca (george kai yee chow) writes:
>> 
>> The second is wrt the cosine function. I was doing some 
>> geometry problem and needed to evaluate cos(pi/3) (I know, I 
>> know, I should know it but I thought I might as well fire up
>> my 48 just for fun). My 48sx returned 0.4999..., not 0.5. 
>> sin(pi/6) does return 0.5 though. Why is this? 
>> 
>One of the more interesting things I encountered when I bought my first
>HP calculator (a 31E) was a long discussion in the manual about this sort
>of problem (I've still got the manual, but it's not handy. If anyone's
>interested, I can find a direct quote).
>
>The gist of the discussion was that since the calculator could not really
>use pi but only a 10-digit approximation of pi, the result of the calculator
>is accurate. It is returning the cosine of precisely that 10-digit
>approximation of (pi/3).

Yes, I'm aware of the problem of calculating with pi. But as I recall reading
in the 48sx's manual, the symbol modes was suppose to elminate that. On the 
48sx, you can ask to keep pi as a symbol to avoid the rounding error.

>===============================================================================
>Roger Ivie
>
>35 S 300 W
>Logan, Ut.  84321
>(801) 752-8633
>===============================================================================

George

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

In article <1990Sep26.160424.12956@rick.cs.ubc.ca>, b3300876@rick.cs.ubc.ca
(george kai yee chow) writes:

>Yes, I'm aware of the problem of calculating with pi. But as I recall reading
>in the 48sx's manual, the symbol modes was suppose to elminate that. On the 
>48sx, you can ask to keep pi as a symbol to avoid the rounding error.

There's a limit to how far the calculator can go with symbolic manipulation. 
The calculator will preserve 'pi' as a symbolic in expressions.  When taking
sines or cosines, it will recognize pi and pi/2 and return exact results.  In
other cases, it does not have exact results prepared for fractions of pi.  So,
to complete the calculation and return a number, it must convert the symbolic
'pi' to a number and perform numeric calculations.


				-- edp

b3300876@rick.cs.ubc.ca (george kai yee chow) (09/28/90)

In article <15643@shlump.nac.dec.com> edp@jareth.enet.dec.com (Eric Postpischil (Always mount a scratch monkey.)) writes:
>In article <1990Sep26.160424.12956@rick.cs.ubc.ca>, b3300876@rick.cs.ubc.ca
>(george kai yee chow) writes:
>
>>Yes, I'm aware of the problem of calculating with pi. But as I recall reading
>>in the 48sx's manual, the symbol modes was suppose to elminate that. On the 
>>48sx, you can ask to keep pi as a symbol to avoid the rounding error.
>
>There's a limit to how far the calculator can go with symbolic manipulation. 
>The calculator will preserve 'pi' as a symbolic in expressions.  When taking
>sines or cosines, it will recognize pi and pi/2 and return exact results.  In
>other cases, it does not have exact results prepared for fractions of pi.  So,
>to complete the calculation and return a number, it must convert the symbolic
>'pi' to a number and perform numeric calculations.

Another reason why I mentioned it is because both of my Casio's (fx-451M and
fx-8000G) return cos(pi/6) correctly and clearly they only use an approximation
of pi.

>
>
>				-- edp

George

lishka@uwslh.slh.wisc.edu (a.k.a. Chri) (09/28/90)

b3300876@rick.cs.ubc.ca (george kai yee chow) writes:
>I have two questions. The first is really minor but I'm sure
>most people would want an answer: How do I speed up Tetris
>for the 48sx. Right now, the game is so slow that I can
>take notes and play a game very comfortably. Not that I don't
>like this but I really would like a more challenging game.

I would think that the way to speed it up is to write it in the CHIP48
language.  This would bypass the slowness associated with interpreted
RPL and garbage collection, because CHIP48 is written in machine code
and its language is much easier to interpret.  With a little ingenuity
and planning, I don't think tetris would be too hard to accomplish
with CHIP48.

					.oO Chris Oo.
-- 
Christopher Lishka 608-262-4485  "Dad, don't give in to mob mentality!"
Wisconsin State Lab. of Hygiene                                -- Bart Simpson
   lishka@uwslh.slh.wisc.edu     "I'm not, Son.  I'm jumping on the bandwagon."
   uunet!uwvax!uwslh!lishka                                    -- Homer Simpson

b3300876@rick.cs.ubc.ca (george kai yee chow) (09/30/90)

In article <1990Sep28.141706.24027@uwslh.slh.wisc.edu> lishka@uwslh.slh.wisc.edu (a.k.a. Chri) writes:
>I would think that the way to speed it up is to write it in the CHIP48
>language.  This would bypass the slowness associated with interpreted
>RPL and garbage collection, because CHIP48 is written in machine code
>and its language is much easier to interpret.  With a little ingenuity
>and planning, I don't think tetris would be too hard to accomplish
>with CHIP48.

Could anyone explain to me what CHIP48 is? I was off of c.s.h from the last
week of August and I seem to have missed everything wrt CHIP48. Is is an
alternative language for the HP? Is it still an interpreter? Where is it 
documented? Ie, how do I go about learning it?

>					.oO Chris Oo.
>-- 
>Christopher Lishka 608-262-4485  "Dad, don't give in to mob mentality!"
>Wisconsin State Lab. of Hygiene                                -- Bart Simpson
>   lishka@uwslh.slh.wisc.edu     "I'm not, Son.  I'm jumping on the bandwagon."
>   uunet!uwvax!uwslh!lishka                                    -- Homer Simpson

George Chow