Post Reply 
Incorrect results and quirks
03-30-2015, 10:03 PM
Post: #1
Incorrect results and quirks
First off, I am not a calculator, nor math buff,... but I have been getting some very strange and inconsistent results out of my HP prime, and I would like to see if anyone can help me figure out why (or at least how to work around the issues).

Issue#1: When I graph the function:
F1(X)=(X^2-4)^(2/3)

It does not graph -2 < X < 2,... it returns "NaN" for that region.

When I graph the same function using this form:
F1(X)=(3 NTHROOT (X^2-4))^2
(either using the NTHROOT command, or using the NTHROOT symbol to get the cube root in textbook entry mode)

it does graph the middle region,....

I'm not sure why it evaluates these two expressions differently, my TI-nSpire handles it correctly

Issue #2: Incorrect result returned when passing a matrix containing a negative number to an expression.
I will use the variable quirk to use in several forms of function (on the screen, and written as programs) and evaluate it for the value of "-1" and for 2 matrices, one with a -1 in the first position, the other with 1 in the first position.

The expression is: (screenshot attached since I can't type it easily here)
2-2/(3 NROOT quirk)

quirk:=-1
returns: 4 (correct)

quirk:={-1, .5 , 2}
returns: 1+1.73205080757*i, -0.51984209979, 0.412598948032 (first value is incorrect)

quirk:={1, .5 , 2}
returns: 0, -0.51984209979, 0.412598948032 (correct)

To explore a little further, I wrote two programs, the first, testeval:
EXPORT testeval(quirk)
BEGIN
RETURN (2-2/(3 NTHROOT quirk));
END;

quirk:={-1, .5 , 2}
testeval(quirk)
returns: 4, -0.51984209979, 0.412598948032 (ALL CORRECT!!! WTF)
and returns the same values as the previous expression for the other two values of quirk

The second program I wrote, testeval2
EXPORT testeval2(quirk)
BEGIN
RETURN (2-2/quirk^(1/3));
END;

returns the same value for the matrix with all positive numbers, but returns an error when quirk=-1 or a matrix with a negative number in it
"Error:(X<0)^(∉Z)"

So,.... I'm totally confused and feel like I can't rely on my HP Prime,... sigh,... I hope someone here has a little insight.
   
Find all posts by this user
Quote this message in a reply
03-30-2015, 11:54 PM
Post: #2
RE: Incorrect results and quirks
My opinion on your question is a bit mathematical:

The function F1(X) is a multivalued function (i.e. 1/3 power) that has singularities at X=2 and X=-2, which are commonly called Branch Points.

Your function has 3 branches (i.e., that is to properly plot F1(X) you need 3 graphs with a Branch Cut between -2 to 2) and to completely analyze it you need to consider the function in terms of complex variable Z. HP Prime does not do this unless you write a program to do it.

Your first plot of F1(X) is corrrect in the the First Branch of the function, since for magnitude of X<2 in enters another branch.

The plot of F1(X) using NTHROOT seem to be combining the answer from two branches, since the HELP says that NTHROOT returns the primary root value (which is real in F1(X). So it is also evaluating the function for magnitude of X<2, but that part of the graph is really in another branch..

I had these things happening with multivalued function.
Find all posts by this user
Quote this message in a reply
03-31-2015, 01:02 AM
Post: #3
RE: Incorrect results and quirks
(03-30-2015 10:03 PM)B1nary0 Wrote:  I'm not sure why it evaluates these two expressions differently, my TI-nSpire handles it correctly

Change the domain from "real" to "rectangular/polar" and give is a look. The results will change. The heritage from the HP side is that the power will give the primary branch as stated, while the NTHROOT will return the real solution only.

Quote:and written as programs) and evaluate it for the value of "-1" and for 2 matrices, one with a -1 in the first position, the other with 1 in the first position.

Try turning on the "allow complex result from real input" setting in your Home Settings screen. Guessing that will resolve it for you. This was specifically put in there because so many educators don't want sqrt(-1) to return complex results too early. Unfortunate that rather then viewing that as a teaching moment they just want an error ...

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
03-31-2015, 02:23 AM
Post: #4
RE: Incorrect results and quirks
(03-31-2015 01:02 AM)Tim Wessman Wrote:  
(03-30-2015 10:03 PM)B1nary0 Wrote:  I'm not sure why it evaluates these two expressions differently, my TI-nSpire handles it correctly

Change the domain from "real" to "rectangular/polar" and give is a look. The results will change. The heritage from the HP side is that the power will give the primary branch as stated, while the NTHROOT will return the real solution only.

I was unable to find this option, but I only want real number solutions.

Quote:and written as programs) and evaluate it for the value of "-1" and for 2 matrices, one with a -1 in the first position, the other with 1 in the first position.

Try turning on the "allow complex result from real input" setting in your Home Settings screen. Guessing that will resolve it for you. This was specifically put in there because so many educators don't want sqrt(-1) to return complex results too early. Unfortunate that rather then viewing that as a teaching moment they just want an error ...

I tried changing this option, but I had the same results. But again,... I do not want any non-real results, nor should I get any. 2 - 2/(cube root(-1) is 4,.... cube root of -1 is -1, 2/-1 is -2, 2-(-2)=4,.... I shouldn't be getting any imaginary,.... complex,.... numbers if I am using odd number roots.

Also,... shouldn't I get the same result for X^(1/3) and cuberoot(X)?,....

Also also,... when I do the function -1^(1/3) I get -1,.... when I do the same function of a variable that I set to -1, I get an imaginary,...errrr "complex" number,.....
   
Find all posts by this user
Quote this message in a reply
03-31-2015, 02:41 AM
Post: #5
RE: Incorrect results and quirks
I also noticed that if I enter -1^(1/3) (using the +/- symbol to make it negative), I get -1 as the result,.... if I do (1*-1)^(1/3) with the same +/- symbol on the -1, I get an imaginary result

I also tried this with -1^(1/2),... which returns -1,.... now that is REALLY BS!!! and returns an imaginary result only for (1*-1)^1/2 (although it should just return i,.... not 5.39030285816E-15+i) which turns into i when I toggle between exact and approx,.... SIGH
Find all posts by this user
Quote this message in a reply
03-31-2015, 04:24 AM (This post was last modified: 03-31-2015 04:25 AM by Tim Wessman.)
Post: #6
RE: Incorrect results and quirks
Hello,

I would invite you to consider what wolfram alpha spits out here:
http://www.wolframalpha.com/input/?i=X^%281%2F3%29

You'll notice that your X^1/3 does not return a nice, real number like you want. This is because the principal root - the one that makes the most sense mathematically - *is* complex for X < 0. You must click "change to real valued root" on that site to change it. This is equivalent to using ^ vs NTHROOT on the calculator. NTHROOT will give the real root while ^ returns the principle root. I would say that matching what is considered generally to be considered the best math software in the world (mathematica) would normally be considered a good thing!

As for the (-) confusion, please remember that the negative operator is not the same as the minus operator in algebraic evaluation on calculators. Take a look at this output from the nspire. :-)

[Image: calc_screen.jpg]

On algebraic systems, the negative operator has a lower precedence then ^. So you are really evaluating -(1^1/3) not (-1)^1/3 as you might be thinking. Uh-oh! there is also that "non real root" error I mentioned in my first post.

When you have a stored variable such as in your program, the value is used directly and so it is like surrounding your variable with a set of parenthesis. When you pass a list, it applies the arguments to each element of the list. If you hit an error, the error will be returned for the whole evaluation.

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
03-31-2015, 05:02 AM
Post: #7
RE: Incorrect results and quirks
(03-31-2015 04:24 AM)Tim Wessman Wrote:  Hello,

I would invite you to consider what wolfram alpha spits out here:
http://www.wolframalpha.com/input/?i=X^%281%2F3%29

You'll notice that your X^1/3 does not return a nice, real number like you want. This is because the principal root - the one that makes the most sense mathematically - *is* complex for X < 0. You must click "change to real valued root" on that site to change it. This is equivalent to using ^ vs NTHROOT on the calculator. NTHROOT will give the real root while ^ returns the principle root. I would say that matching what is considered generally to be considered the best math software in the world (mathematica) would normally be considered a good thing!

As for the (-) confusion, please remember that the negative operator is not the same as the minus operator in algebraic evaluation on calculators. Take a look at this output from the nspire. :-)

[Image: calc_screen.jpg]

On algebraic systems, the negative operator has a lower precedence then ^. So you are really evaluating -(1^1/3) not (-1)^1/3 as you might be thinking. Uh-oh! there is also that "non real root" error I mentioned in my first post.

When you have a stored variable such as in your program, the value is used directly and so it is like surrounding your variable with a set of parenthesis. When you pass a list, it applies the arguments to each element of the list. If you hit an error, the error will be returned for the whole evaluation.

The difference is,... on the TI-nSpire and every other calculator I have ever used,.... (-1)^(1/3) returns -1,.... of course (-1)^(1/2) returns a non-real result, or an error.... is there some setting I can change to get the simple, straight forward -1 answer out of the program?,.... by the way,... if I then cube the exact version of the answer,... it returns another imaginary number rather than returning to -1
Find all posts by this user
Quote this message in a reply
03-31-2015, 07:43 AM
Post: #8
RE: Incorrect results and quirks
Hello Binary0,
thought I should give that a try, as I only own that Prime for one week and so need to play with it . I entered your equation:
>>Issue#1: When I graph the function:
>> F1(X)=(X^2-4)^(2/3)

>>It does not graph -2 < X < 2,... it returns "NaN" for that region.
and you are right. Then I did:
F1(X)=(X^2-4)^2, F2(X)=F1(X)^(1/3), F2 was correctly plotted.
Conclusion: the plotting system in the prime and the underlying CAS first evaluates log(x^2-4) which clearly is not a real number, then using the exponent and after that does alog(result), here Bill_G gave the answer.
So I started to look in the settings Switch Home Settings: Complex to "Checked", reentered your equation and : that was the solution, it is correctly plotted.
Hth Arno
Find all posts by this user
Quote this message in a reply
03-31-2015, 08:48 PM
Post: #9
RE: Incorrect results and quirks
(03-31-2015 05:02 AM)B1nary0 Wrote:  The difference is,... on the TI-nSpire and every other calculator I have ever used,.... (-1)^(1/3) returns -1

In Home your expression is evaluated as (-1)^0.333333333333 which is clearly different to 3 NROOT (-1)^2. In CAS, the result will be different because 1/3 can be treated symbolically. Home mode just can't do that.

Marcus von Cube
Wehrheim, Germany
http://www.mvcsys.de
http://wp34s.sf.net
http://mvcsys.de/doc/basic-compare.html
Find all posts by this user
Quote this message in a reply
04-01-2015, 12:27 AM
Post: #10
RE: Incorrect results and quirks
Ok,... so I figured out that I can use the command surd(expression, n) instead of nroot to have it return only the real result.

Is there any other way to achieve this? I disabled every box or option that offered i or complex results,... but I still seem to get complex results and graphs refuse to include sections that have non real principal roots. It seems that this would be a desirable mode of operation for a very large portion of the target audience for this calculator,... students (like me).

I have also tried turning on every box that mentioned complex, and am getting the same results,... X^1/3 will not plot values of X < 0.
Find all posts by this user
Quote this message in a reply
Post Reply 




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