I believe I've found a bug on the HP50g, and I'm hoping others can confirm this.

The calculator is in the following mode (non-approx mode):

DEG XYZ HEX C= 'X'

The program is entered into 'GSP' variable as follows (replace SQR with square root symbol):

<< -> V A W B << 'SQR(W^2+V^2-2*W*V*COS(180-B+A))' EVAL >> >>

'GSP'

STO

I enter the following values onto the stack and execute GSP:

4: 400

3: 45

2: 5

1: 180

GSP

The calculator hangs. After a second or two, I press CANCEL, and the stack is filled with garbage.

If I switch the calculator to approximate mode:

DEG XYZ HEX C~ 'X'

Then, the program returns a correct result: 396.48

I entered the same program into 'GS2' in full RPN-style (again, replace SQR with the square root symbol):

<< -> V A W B << 180 B - A + COS W * V * 2 * NEG V SQ + W SQ + SQR >> >>

I can run this program in either approximate or exact modes without problems.

It appears to be some sort of problem parsing the algebraic expression in the first program example; however, the problem didn't become apparent until I entered the exact test input above. If 180 - B + A = 45, the program crashes.

I'm hoping someone can reproduce the problem.

Thanks,

MikeO

*Edited: 4 Sept 2008, 2:36 a.m. *

Curious, it just happened to me too.

I tried with this slightly different set of input:

4: 400

3: 45

2: 5

1: 179.99

GSP

getting 396.480852718, which I assume is the right result.

ANy explanations? The problem seems to lie in the algebraic execution of COS.

-- Antonio

Quite strange.

Just tested the program with algebraic expression and got this result: 396.480230119

I did not get any problem at all.

Program runned on HP50g, rom 2.09, serial (sticker) CNA 715xxxxx.

Regards

Marco Polo

49g+ ROM 2.09 and 48gII ROM 1.23

V as Square Root function

I have narrowed the bug down to

CASCFG

'V(3-V7)' EVAL

Press [ON] after a second

setting flag -125 avoids evaluation error

and gives (when -114 is clear)

'V-(V7-3)'

In the ALG mode it evaluates to:

'(3*V2-V2*V7)*V(3+V7)/2'

THEN...after visiting the ALG mode

it begin to work in RPN, too! both calcs!

Even after warm-start [ON]&[F3 C] no change

it just works!! in both calcs 49g+ and 48gII

The original problem gives:

'5*V-(160*COS(45)-6401='

remember that V=Sqrt

*Edited: 4 Sept 2008, 5:29 a.m. *

Ok.

I tried to reproduce the error on my calculator.

If i press "ON" after 1 sec. i get some data on the stack, clearly coming from the EVALuation of the expression.

In the other cases, no errors at all.

The original ALG program runs for about 2 minutes and delivered the correct result on my 50G.

But then I took out the SQR from the program. Like so:

<< -> V A W B << '(W^2+V^2-2*W*V*COS(180-B+A))' EVAL >> >>

'GSP'

STO

and pressed SQR after I had the result from the above program on the stack. Then ->NUM and got the right result. Much faster than 2 minutes.

It will also work if I put the SQR back in after the ALG expression and EVAL. Like so:

<< -> V A W B << '(W^2+V^2-2*W*V*COS(180-B+A))' EVAL SQR >> >>

'GSP'

STO

*Edited: 4 Sept 2008, 10:56 a.m. after one or more responses were posted*

I have managed to narrow the expression causing the problem down to (replace SQR with the squareroot symbol):

'SQR(5^2+400^2-2*5*400*SQR2/2'

If I enter this expression into the calculator and EVAL it, I get the same behaviour as the example program.

The COS(180-B+45) expression evaluated to SQR2/2. On a hunch I simply put that back into the expression. So the problem is a little simpler now.

Thanks,

MikeO

*Edited: 4 Sept 2008, 10:58 a.m. *

Hi George,

See my post immediately above this one.

I have managed to narrow the expression causing the problem down to (replace SQR with the squareroot symbol):

'SQR(5^2+400^2-2*5*400*SQR2/2'

If I enter this expression into the calculator and EVAL it, I get the same behaviour as the example program.

Thanks!

MikeO

*Edited: 4 Sept 2008, 10:59 a.m. *

Hi MikeO,

just edited my post above. Have you tried to leave the original program run for 2 minutes? Should show the correct result.

Regards,

George

Quote:

'SQR(5^2+400^2-2*5*400*SQR2/2'

If I enter this expression into the calculator and EVAL it, I get the same behaviour as the example program.

Not so here. If I enter 'SQR(5^2+400^2-2*5*400*SQR2/2)' and press ->NUM I instantly get the right result.

Might really be some operator precedence issue.

*Edited: 4 Sept 2008, 11:10 a.m. *

I did, and it does eventually come back with an expression to evaluate. So, I guess the question is why does it take two minutes? We're probably looking at a CAS algorithm problem.

Thanks,

MikeO

George,

Make sure your calculator is in the same mode as mine, then try the expression again:

DEG XYZ HEX C= 'X'

Oh yes - to replicate the behavior I'm seeing, you have to enter the expression, then EVAL.

It's the EVAL which is hanging up for so long.

-MikeO

*Edited: 4 Sept 2008, 11:21 a.m. *

Quote:

X

I have managed to narrow the expression causing the problem down to (replace SQR with the squareroot symbol):
'SQR(5^2+400^2-2*5*400*SQR2/2'

If I enter this expression into the calculator and EVAL it, I get the same behaviour as the example program.

X

Ther is a bug in a sense:

the 'Algebraic' needs a huge time to be EVALuated symbolically

and if you interrupt it at the middle

it does not clean up the Virtual Stack at ATTN

That is the bug...

If you just let it finish, run for long enough time, about two minutes, it will be OK

Thanks all for verifying this. Yes, it does eventually finish, just unexpectedly slow (2 minutes!). I guess that's a good reason to put the calculator on approximate mode when looking for numerical results.

Thanks,

MikeO