Post Reply 
POLYROOT does not always work inside a program [SOLVED]
01-06-2016, 08:45 PM (This post was last modified: 10-23-2016 09:08 AM by JMB.)
Post: #1
POLYROOT does not always work inside a program [SOLVED]
I have found a strange behavior (a bug?) while using the function POLYROOT inside a program. My firmware version is 2015 6 17 (8151).

The calculator's built-in help states that the argument of this function can be either a symbolic expression or a vector of coefficients, but I have found that a list of coefficients also works as the function's argument. So both POLYROOT([1 -3 2]) and POLYROOT({1, -3, 2}) return the same answer: {1, 2}, in Home and in CAS.

The problem arises when I use this function inside a program, for example:
EXPORT Test()
BEGIN
POLYROOT([1, -3, 2]);
END;

The first thing worth noting in that commas are needed inside [ ], otherwise you get a syntax error when you tap the Check button. Then when you run the program you get the following error message:

Test
"POLYROOT(ListToMat(EVAL
LIST({0,1,3,1-3,2})))
Error: Bad Argument
Value)"

After trying different numeric values, I have found that this error only happens inside a program, when using [ ] and at least one value is negative. So we have, for example:

POLYROOT({1, 3, 2}): correct answer {-2, -1}
POLYROOT([1, 3, 2]): correct answer {-2, -1}
POLYROOT({1, -3, 2}): correct answer {1, 2}
POLYROOT([1, -3, 2]): error, as stated before
Find all posts by this user
Quote this message in a reply
01-06-2016, 09:53 PM (This post was last modified: 01-06-2016 11:27 PM by DrD.)
Post: #2
RE: POLYROOT does not always work inside a program
That does seem to be a problem, and a possible work-around is to pre-assign the vector to a matrix variable:

Code:

EXPORT tmp()
BEGIN
  M0:=[1,-3,2];
  POLYROOT(M0);
END;

Also, if passed as a string object, it seems to work:

Code:

EXPORT tmp()
BEGIN  
  POLYROOT("[1,-3,2]");
END;

-Dale-
Find all posts by this user
Quote this message in a reply
01-11-2016, 05:34 PM
Post: #3
RE: POLYROOT does not always work inside a program
Hello,

I'm fairly sure this one has been caught already, but I will add a specific bug for this case and get it into our testing. Thanks!

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
04-30-2016, 09:55 AM (This post was last modified: 06-18-2016 07:23 PM by JMB.)
Post: #4
RE: POLYROOT does not always work inside a program
Corrected in firmware 10077.

Thanks to the HP Prime Team!
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)