Post Reply 
Ans and ^ (1/3)
03-30-2015, 04:08 PM
Post: #1
Ans and ^ (1/3)
I ran into this a while back, but didn't get around to posting

Let's say some calculation results in a negative number, like 7-8.2 = -1.2

Pressing x^y (1/3), using built-in Ans, results in one of the two complex roots of the polynomial x^3+1.2 being returned.

But . . . typing -1.2^ (1/3) results in the real root being returned.

How come this different behavior of Ans^(1/3) vis-a-vis the explicit, typed result?

CAS settings: simplify min, exact, use sqrt, principal, use i.
Find all posts by this user
Quote this message in a reply
03-30-2015, 06:08 PM
Post: #2
RE: Ans and ^ (1/3)
Operator precedence : -a^b is -(a^b) not (-a)^b
Find all posts by this user
Quote this message in a reply
03-30-2015, 06:15 PM
Post: #3
RE: Ans and ^ (1/3)
(03-30-2015 04:08 PM)Helge Gabert Wrote:  I ran into this a while back, but didn't get around to posting

Let's say some calculation results in a negative number, like 7-8.2 = -1.2

Pressing x^y (1/3), using built-in Ans, results in one of the two complex roots of the polynomial x^3+1.2 being returned.

But . . . typing -1.2^ (1/3) results in the real root being returned.

How come this different behavior of Ans^(1/3) vis-a-vis the explicit, typed result?

CAS settings: simplify min, exact, use sqrt, principal, use i.

This inconsistency also occurs in RPN mode. It might be something to do with raising the number to the 1/3 power vs. taking the cube root. For example if I place -8 on the stack and then 1/3 on the stack and hit the x^y key I get a complex root, but if I place -8^(1/3) on the stack I get -2 after pressing eval.
Find all posts by this user
Quote this message in a reply
03-30-2015, 08:36 PM
Post: #4
RE: Ans and ^ (1/3)
(03-30-2015 06:08 PM)parisse Wrote:  Operator precedence : -a^b is -(a^b) not (-a)^b

No, I'm sorry if I wasn't clear enough

Ans^(1/3) returns a different root than (-1.2)^(1/3). That's all.
Find all posts by this user
Quote this message in a reply
03-30-2015, 08:42 PM
Post: #5
RE: Ans and ^ (1/3)
(03-30-2015 06:15 PM)John Colvin Wrote:  
(03-30-2015 04:08 PM)Helge Gabert Wrote:  I ran into this a while back, but didn't get around to posting

Let's say some calculation results in a negative number, like 7-8.2 = -1.2

Pressing x^y (1/3), using built-in Ans, results in one of the two complex roots of the polynomial x^3+1.2 being returned.

But . . . typing -1.2^ (1/3) results in the real root being returned.

How come this different behavior of Ans^(1/3) vis-a-vis the explicit, typed result?

CAS settings: simplify min, exact, use sqrt, principal, use i.

This inconsistency also occurs in RPN mode. It might be something to do with raising the number to the 1/3 power vs. taking the cube root. For example if I place -8 on the stack and then 1/3 on the stack and hit the x^y key I get a complex root, but if I place -8^(1/3) on the stack I get -2 after pressing eval.

Yes, exactly!
Find all posts by this user
Quote this message in a reply
03-31-2015, 09:37 AM (This post was last modified: 03-31-2015 10:23 AM by BartDB.)
Post: #6
RE: Ans and ^ (1/3)
(03-30-2015 08:36 PM)Helge Gabert Wrote:  
(03-30-2015 06:08 PM)parisse Wrote:  Operator precedence : -a^b is -(a^b) not (-a)^b

No, I'm sorry if I wasn't clear enough

Ans^(1/3) returns a different root than (-1.2)^(1/3). That's all.

Mr Parisse gave the correct answer:

When you type -1.2^(1/3) operator precedence evaluates the power before the negative (on old calculators, a negative from +/- key was seen as part of the number, but some far eastern country* decided to treat it as 0-1.2^(1/3) and now all are following suit).

However, Ans is a variable containing the last calculated result. Thus Ans^(1/3) is the same as e.g. B^(1/3) where -1/2 is stored in B. Therefore it is evaluated as (-1/2)^(1/3) because the value of the variable as a whole is -1/2.

EDIT: in your first post you were comparing Ans^(1/3) vs -1/2^(1/3). In your reply to Mr. Parisse you are comparing Ans^(1/3) vs (-1/2)^(1/3) ... this second case should give the same answer because of the bracket around -1/2.

Best regards.

*my personal observation: i first noticed this on Casio's


Visit this user's website Find all posts by this user
Quote this message in a reply
03-31-2015, 09:46 AM
Post: #7
RE: Ans and ^ (1/3)
(03-30-2015 06:15 PM)John Colvin Wrote:  
(03-30-2015 04:08 PM)Helge Gabert Wrote:  I ran into this a while back, but didn't get around to posting

Let's say some calculation results in a negative number, like 7-8.2 = -1.2

Pressing x^y (1/3), using built-in Ans, results in one of the two complex roots of the polynomial x^3+1.2 being returned.

But . . . typing -1.2^ (1/3) results in the real root being returned.

How come this different behavior of Ans^(1/3) vis-a-vis the explicit, typed result?

CAS settings: simplify min, exact, use sqrt, principal, use i.

This inconsistency also occurs in RPN mode. It might be something to do with raising the number to the 1/3 power vs. taking the cube root. For example if I place -8 on the stack and then 1/3 on the stack and hit the x^y key I get a complex root, but if I place -8^(1/3) on the stack I get -2 after pressing eval.

> It might be something to do with raising the number to the 1/3 power vs. taking the cube root.

No, it has to do with operator precedence of a typed in number vs. a variable. See my other post.

In RPN mode, in the first case you place -8 on level-2 and 1/3 on the level-1 and press x^y which results in (level-2)^(level-1), i.e. again -8 is the level-2 variable as a whole.
In the second case you are entering an equation like format so again power before minus.

Best regards.


Visit this user's website Find all posts by this user
Quote this message in a reply
03-31-2015, 09:51 AM
Post: #8
RE: Ans and ^ (1/3)
(03-30-2015 08:36 PM)Helge Gabert Wrote:  
(03-30-2015 06:08 PM)parisse Wrote:  Operator precedence : -a^b is -(a^b) not (-a)^b

No, I'm sorry if I wasn't clear enough

Ans^(1/3) returns a different root than (-1.2)^(1/3). That's all.

Both of those expressions yield 0.531329284592+0.920289316461*i in Home, and almost the same in CAS (real part differs by one ULP). Make sure that you're actually typing all the parentheses that you indicated above. Turning off Textbook Display mode (page 2 of Home Settings) may make it easier to see what's happening.

<0|ΙΈ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
03-31-2015, 03:32 PM
Post: #9
RE: Ans and ^ (1/3)
Okay, got it! Thanks so much.
Find all posts by this user
Quote this message in a reply
03-31-2015, 07:45 PM
Post: #10
RE: Ans and ^ (1/3)
(03-31-2015 09:46 AM)BartDB Wrote:  
(03-30-2015 06:15 PM)John Colvin Wrote:  This inconsistency also occurs in RPN mode. It might be something to do with raising the number to the 1/3 power vs. taking the cube root. For example if I place -8 on the stack and then 1/3 on the stack and hit the x^y key I get a complex root, but if I place -8^(1/3) on the stack I get -2 after pressing eval.

> It might be something to do with raising the number to the 1/3 power vs. taking the cube root.

No, it has to do with operator precedence of a typed in number vs. a variable. See my other post.

In RPN mode, in the first case you place -8 on level-2 and 1/3 on the level-1 and press x^y which results in (level-2)^(level-1), i.e. again -8 is the level-2 variable as a whole.
In the second case you are entering an equation like format so again power before minus.

Best regards.
I see your point, however if I use the nth root template(accessed from the C key) and take the cube root of -8, I get -2, not the complex root. So in this case I am actually taking the cube root of a negative number-not taking the cube root of a positive number and then negating it.
Find all posts by this user
Quote this message in a reply
03-31-2015, 08:31 PM (This post was last modified: 03-31-2015 08:33 PM by Han.)
Post: #11
RE: Ans and ^ (1/3)
(03-31-2015 07:45 PM)John Colvin Wrote:  
(03-31-2015 09:46 AM)BartDB Wrote:  > It might be something to do with raising the number to the 1/3 power vs. taking the cube root.

No, it has to do with operator precedence of a typed in number vs. a variable. See my other post.

In RPN mode, in the first case you place -8 on level-2 and 1/3 on the level-1 and press x^y which results in (level-2)^(level-1), i.e. again -8 is the level-2 variable as a whole.
In the second case you are entering an equation like format so again power before minus.

Best regards.
I see your point, however if I use the nth root template(accessed from the C key) and take the cube root of -8, I get -2, not the complex root. So in this case I am actually taking the cube root of a negative number-not taking the cube root of a positive number and then negating it.

Use Textbook mode and enter in -8 raised to the power of 1/3 via the template key. Then, after the calculator returns the result, change to algebraic entry. Tap the screen to copy the expression into the command line and you will see how it evaluates your original expression. The reason you got -2 was because it's parsed as -8^(1/3) and not (-8)^(1/3). Nevermind, you used nthroot and not the power template.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
03-31-2015, 08:41 PM (This post was last modified: 03-31-2015 09:00 PM by John Colvin.)
Post: #12
RE: Ans and ^ (1/3)
(03-31-2015 08:31 PM)Han Wrote:  
(03-31-2015 07:45 PM)John Colvin Wrote:  I see your point, however if I use the nth root template(accessed from the C key) and take the cube root of -8, I get -2, not the complex root. So in this case I am actually taking the cube root of a negative number-not taking the cube root of a positive number and then negating it.

Use Textbook mode and enter in -8 raised to the power of 1/3 via the template key. Then, after the calculator returns the result, change to algebraic entry. Tap the screen to copy the expression into the command line and you will see how it evaluates your original expression. The reason you got -2 was because it's parsed as -8^(1/3) and not (-8)^(1/3). Nevermind, you used nthroot and not the power template.

Then why does taking a negative number to the 1/3 power give the complex root as opposed to the real root when in many cases the only root of interest is the real one? This quirk also exists on the HP50.
Find all posts by this user
Quote this message in a reply
04-08-2015, 09:27 AM
Post: #13
RE: Ans and ^ (1/3)
(03-31-2015 07:45 PM)John Colvin Wrote:  
(03-31-2015 09:46 AM)BartDB Wrote:  > It might be something to do with raising the number to the 1/3 power vs. taking the cube root.

No, it has to do with operator precedence of a typed in number vs. a variable. See my other post.

In RPN mode, in the first case you place -8 on level-2 and 1/3 on the level-1 and press x^y which results in (level-2)^(level-1), i.e. again -8 is the level-2 variable as a whole.
In the second case you are entering an equation like format so again power before minus.

Best regards.
I see your point, however if I use the nth root template(accessed from the C key) and take the cube root of -8, I get -2, not the complex root. So in this case I am actually taking the cube root of a negative number-not taking the cube root of a positive number and then negating it.

Sorry, yes you are right, some cube-root and n-root functions have a bit of "cleverness" e.g. see comments in "displayed result" column of http://www.voidware.com/calcs/torture_powers.htm


Visit this user's website Find all posts by this user
Quote this message in a reply
04-10-2015, 06:05 PM (This post was last modified: 04-10-2015 06:06 PM by toml_12953.)
Post: #14
RE: Ans and ^ (1/3)
(03-30-2015 06:15 PM)John Colvin Wrote:  if I place -8^(1/3) on the stack I get -2 after pressing eval.

If you eval -8^(1/3) you get -(8^(1/3)) which is -2 of course.

If you want to raise -8 to the 1/3 power, you need to eval:

'(-8)^(1/3)'

to get

1+1.73205080757*i

Make sure "Allow complex output from real input" is checked in settings.

Tom L

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
04-10-2015, 06:34 PM
Post: #15
RE: Ans and ^ (1/3)
(04-10-2015 06:05 PM)toml_12953 Wrote:  
(03-30-2015 06:15 PM)John Colvin Wrote:  if I place -8^(1/3) on the stack I get -2 after pressing eval.

If you eval -8^(1/3) you get -(8^(1/3)) which is -2 of course.

If you want to raise -8 to the 1/3 power, you need to eval:

'(-8)^(1/3)'

to get

1+1.73205080757*i

Make sure "Allow complex output from real input" is checked in settings.

Tom L
I got that. I now understand that the Prime's nth root function and nth root template return the real root where as the y^x key returns the principle complex root. I was curious as to why (-8)^(1/3) returns the complex root as opposed to the real root(even in CAS mode), It's not a bug in the software, since this is the way it is handled on the 50G and in XCAS(1 + i*sqrt(3)).
Find all posts by this user
Quote this message in a reply
Post Reply 




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