Advertisement Jump to content
Sign in to follow this  
gasto

Why is the odd integer rootof a negative number undefined?

This topic is 1753 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey mathematicians, why is (odd integer) root of a negative number undefined behaviour?

  _____
³?-27 = -3 ?
-3 · -3 = 9
9 · -3 = -27
 
Edited by gasto

Share this post


Link to post
Share on other sites
Advertisement

Why do you say it's undefined? My desktop calculator works fine with odd roots of negative numbers.

 

EDIT: FYI, you posted in the Math & Physics forum. Do you perhaps have a programming question, instead?

Edited by Buckeye

Share this post


Link to post
Share on other sites

What is the context of the undefined behavior?  Particular program or language? Calculator?

Share this post


Link to post
Share on other sites

 

Hey mathematicians, why is (odd integer) root of a negative number undefined behaviour?

  _____
³?-27 = -3 ?
-3 · -3 = 9
9 · -3 = -27
 

 

Is this becoming a hobby of yours? You ask why something is not the way it should be, but it actually IS the way it should be. You can initialize multi-dimensional arrays in C or C++ to zero by specifying only the first element, and the odd-integer root of a negative number is perfectly well defined.

Share this post


Link to post
Share on other sites

It is a problem of the Windows Vista Calculator then. In Windows 7 it works perfectly.

 

Just out of curiosity, try: (-27)^(1/3) in the calculator to see if you get an answer.

Share this post


Link to post
Share on other sites
The INV button is not meant to be used with the power buttons in calc.exe - It's more obvious on the Windows 8 desktop version because it re-labels the buttons which it applies to.

Do what Javier says and use a fractional power: -27 x^y (1/3) (or the new "y root x" button if you have a new enough version) Edited by Nypyren

Share this post


Link to post
Share on other sites

Good old Windows calculator:


Here's some advice on how to ask questions on these forums:
* Try to find the answer for yourself first. For instance, using Google. You do have an Internet connection, don't you?
* If you still can't find the answer, post enough detail that we know what the situation is, why you think it's wrong, etc.


Let me illustrate what "enough detail" means:
I tried to compute the cubic root of -27 in Windows Calculator [version blah] and I get an error message that would translate to "invalid value". Shouldn't the answer be -3? Is this a bug?

Share this post


Link to post
Share on other sites

It is a problem of the Windows Vista Calculator then. In Windows 7 it works perfectly.

 

Just out of curiosity, try: (-27)^(1/3) in the calculator to see if you get an answer.

I get the same "invalid value" message. I used 0,333333333333333333333333333333 instead of 1/3 (since otherwise it would raise it to the first and then divide by three)

(or the new "y root x" button if you have a new enough version)

If you check the gif I linked to, there is no "y root of x" option.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!