The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

Possible bug with sqrt function in the HP prime
Message #1 Posted by Michael de Estrada on 15 Nov 2013, 11:55 a.m.

I say "possible" bug in the title, because this may just be another case of me not understanding the subtleties of this calculator. I have found that if I pass a dummy variable x to a program and use it with sqrt(x), then I get a program halt with Error: wrong argument type. However, if I express it as v X, v(x), x^.5 or (x)^.5, where v is the square root symbol, then it works fine. I have no problems using other built-in functions such as SIN(x). I do not declare the variable as LOCAL in the program, as this causes it to evaluate to zero, regardless of the value passed to the program.

EXPORT Test(x)

BEGIN

X:=sqrt(x); //this fails with wrong argument type

X:=v x; //this works fine

X:=x^.5; //this also works fine

X:=SIN(x); //this also works fine

RETURN x,X;

END;

Edited: 15 Nov 2013, 11:59 a.m. after one or more responses were posted

      
Re: Possible bug with sqrt function in the HP prime
Message #2 Posted by Tim Wessman on 15 Nov 2013, 11:56 a.m.,
in response to message #1 by Michael de Estrada

Square root symbol? Or the word spelled out "sqrt"?

            
Re: Possible bug with sqrt function in the HP prime
Message #3 Posted by Michael de Estrada on 15 Nov 2013, 11:59 a.m.,
in response to message #2 by Tim Wessman

The square root symbol as inserted by the shift x^2 key and the expression sqrt() as inserted from the catalog.

                  
Re: Possible bug with sqrt function in the HP prime
Message #4 Posted by Tim Wessman on 15 Nov 2013, 12:02 p.m.,
in response to message #3 by Michael de Estrada

Ah. You are storing into real variable X. If you just return your sqrt(x), what do you see? (sqrt is a CAS command btw)

TW

Edited: 15 Nov 2013, 12:03 p.m.

                        
Re: Possible bug with sqrt function in the HP prime
Message #5 Posted by Michael de Estrada on 15 Nov 2013, 12:11 p.m.,
in response to message #4 by Tim Wessman

Yeah, it works now. I guess I should have realized that it was a CAS command, since it is lower case letters.

I also see that X:=CAS.sqrt(x) works

or CAS("X:=sqrt(x)")

Edited: 15 Nov 2013, 12:30 p.m.

                              
Re: Possible bug with sqrt function in the HP prime
Message #6 Posted by Tim Wessman on 15 Nov 2013, 12:32 p.m.,
in response to message #5 by Michael de Estrada

As would EVAL(sqrt(x)) I suspect. The issue is trying to store a symbolic into a real only variable.

TW

                                    
Re: Possible bug with sqrt function in the HP prime
Message #7 Posted by Michael de Estrada on 15 Nov 2013, 12:49 p.m.,
in response to message #6 by Tim Wessman

What I find very confusing is that if I'm in CAS and select and enter sqrt from the catalog it displays as sqrt() on the command line, but once I enter it as sqrt(x), it becomes v x. If I do the same with sqrt(X) in Home it becomes sqrt(X) on the input side of the history.

Edited: 15 Nov 2013, 12:49 p.m.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall