negative number raised to even power
|
05-04-2015, 08:24 AM
Post: #41
|
|||
|
|||
RE: negative number raised to even power | |||
05-04-2015, 02:51 PM
Post: #42
|
|||
|
|||
RE: negative number raised to even power
(05-04-2015 06:10 AM)Dirk. Wrote: So how do you explain your students that 2(+/-)² is -4 at the prime when entering it using the keyboard? It's quite simple, really. Notice that you typed it as "2(+/-)²", which shows that you are assuming that keystroke order should always matter, which is true in RPN... but it does not (and SHOULD not) always matter in command-line calculators (the reason follows shortly). Prime is a command line calculator, and the command line is not evaluated until Enter is pressed. At that time, the order in which the keys were pressed is totally immaterial; the ONLY thing that matters are the rules of parsing the algebraic syntax on the command line. In those rules, "-2²" means "start with 2, square it, then negate the result". In ANY command-line algebraic-notation calculator which follows standard algebraic notation rules of operator precedence, [2][+/-][x²] yields the same result as [+/-][2][x²], because both key sequences create identical command lines, namely, "-2²", which of course IN STANDARD ALGEBRAIC NOTATION equals -4. (05-04-2015 06:10 AM)Dirk. Wrote: In my opinion this is simply a bug which needs to get fixed as soon as possible. I'm half German, so I half understand. But my Irish half wants to write a sad song about how we algebraic users are so often misunderstood. Let's compromise by enjoying some Weihenstephaner Hefeweissbier and Guinness, and let the others fight it out. <0|ɸ|0> -Joe- |
|||
05-04-2015, 04:18 PM
Post: #43
|
|||
|
|||
RE: negative number raised to even power
Well, due to my home, I have to recommend Licher.
But anyway: One of the main points for me is the inconsistency. The calculator behaves differenty when processing a previously calculated result and when entering something leading to the same display. I think the way the algebraic SHARP-Calculators (SHARP EL-512S and SHARP EL-520V) behave is much more consistent. ... and now I'll go out for an Edinger Weißbier :-) |
|||
05-04-2015, 08:07 PM
Post: #44
|
|||
|
|||
RE: negative number raised to even power
To add to the confusion, even in C/C++, it gets weird:
int a = (-2)^2; printf("%d", a); gives -4 as an answer?? But int a = pow(-2, 2); printf("%d", a); gives 4 as an answer So it seems that precedence rules aren't always followed. |
|||
05-05-2015, 05:17 AM
Post: #45
|
|||
|
|||
RE: negative number raised to even power
In C/C++, ^ is exclusive or (xor). In C (but not in C++), from C99 onwards, when using the alternative spellings iso646.h header, xor is expanded to ^.
With 2's complement representation of negative numbers: * the binary representation of -1 is the pattern of 1 (0b11...111 in GCC and Clang for years, C++14 made the 0b syntax standard); * the binary representation of -2 is 0b11...110; * the binary representation of 2 is 0b00...010; * the binary representation of (-2)^2 is therefore 0b11...100, i.e. -4. |
|||
05-05-2015, 06:12 PM
(This post was last modified: 05-05-2015 06:24 PM by John Colvin.)
Post: #46
|
|||
|
|||
RE: negative number raised to even power
(05-05-2015 05:17 AM)debrouxl Wrote: In C/C++, ^ is exclusive or (xor). In C (but not in C++), from C99 onwards, when using the alternative spellings iso646.h header, xor is expanded to ^.That explains it. I knew ^ meant xor in the context of boolean operations, but that symbol is used so frequently to represent exponentiation, I just forgot about that quirk C. My bad. |
|||
05-05-2015, 07:11 PM
Post: #47
|
|||
|
|||
RE: negative number raised to even power | |||
05-05-2015, 07:16 PM
Post: #48
|
|||
|
|||
RE: negative number raised to even power
(05-05-2015 05:17 AM)debrouxl Wrote: In C/C++, ^ is exclusive or (xor). In C (but not in C++), from C99 onwards, when using the alternative spellings iso646.h header, xor is expanded to ^.(just for clarification) But in Standard C++, there's no need to include the header as xor is already a C++ keyword. |
|||
05-05-2015, 07:32 PM
Post: #49
|
|||
|
|||
RE: negative number raised to even power
I'm really baffled by all the discussion on this issue. Everyone agrees with the following two statements:
1) The square of negative two is four: (-2)^2 = 4 (In 41C rpn: 2 CHS ENTER 2 y^x) 2) The negative of the square of two is negative four: -(2^2) = -4 (In 41C rpn: 2 ENTER 2 y^x CHS) What people are disagreeing about is the meaning of -2^2. Even though some calculators and computer programs may not follow it, the standard algebra order of operations indicates that exponentiation proceeds negation, so -2^2 means -(2^2) = -4. |
|||
05-05-2015, 07:49 PM
Post: #50
|
|||
|
|||
RE: negative number raised to even power
(05-05-2015 07:11 PM)Thomas Klemm Wrote:(05-05-2015 06:12 PM)John Colvin Wrote: That explains it. I knew ^ meant xor in the context of boolean operations, but that symbol is used so frequently to represent exponentiation, I just forgot about that quirk C. My bad. I thought the same thing: I wish he hadn't clarified that it was a mistake. (-2)^2 = -4 was the smartest thing I read in the whole thread! The way it applies to the discussion makes it an excellent joke, could've caught a lot of people off-guard. |
|||
05-05-2015, 10:01 PM
Post: #51
|
|||
|
|||
RE: negative number raised to even power
(04-26-2015 06:57 PM)Marcus von Cube Wrote:(04-26-2015 06:22 PM)TASP Wrote: 2 2 chs ^ 2 y\x The original expression (-2)^2 yields 'error' too on HP-21 and HP-25, however HP-29C computes 4. 2 chs ^ 3 y\x shows -8 and works only for integer exponents (-2)*(-2)*(-2)=-8 Bernhard That's one small step for a man - one giant leap for mankind. |
|||
05-06-2015, 07:03 AM
Post: #52
|
|||
|
|||
RE: negative number raised to even power | |||
05-06-2015, 02:37 PM
Post: #53
|
|||
|
|||
RE: negative number raised to even power
(05-06-2015 07:03 AM)Thomas Radtke Wrote:I agree that -2^2 = 0-2^2, but someone could argue that these are different as the left side involves negation while the right side involves subtraction, two operators that use similar looking symbols.(05-05-2015 07:32 PM)Wes Loewer Wrote: What people are disagreeing about is the meaning of -2^2.But then 0-2^2 is clear again. It's the missing zero that confuses some people. I think I've got something that will convince any doubters... Consider the function f(x)=exp(-x^2) I think everyone will agree that the graph of this function is a bell curve, which means that the function is interpreted as exp(-(x^2)) and not exp((-x)^2). |
|||
05-06-2015, 03:40 PM
Post: #54
|
|||
|
|||
RE: negative number raised to even power
(05-06-2015 02:37 PM)Wes Loewer Wrote: I think I've got something that will convince any doubters...Interesting, but here we have a variable instead of a number. This leads me to this thought: I find it indeed difficult to realize we have no other representation of a negative number than a positive one subtracted from zero. An implicitly atomic expression -2 looks quite attrative to consider, but is unfortunately no convention. Hence a new symbol (raised minus) has been introduced on some calculators like the 32SII. |
|||
05-06-2015, 06:52 PM
Post: #55
|
|||
|
|||
RE: negative number raised to even power
(05-04-2015 02:51 PM)Joe Horn Wrote: In ANY command-line algebraic-notation calculator which follows standard algebraic notation rules of operator precedence, [2][+/-][x²] yields the same result as [+/-][2][x²], because both key sequences create identical command lines, namely, "-2²", which of course IN STANDARD ALGEBRAIC NOTATION equals -4.Maybe it has been mentioned before: Just found out the 32SII does it wrong. [EQN][-][2][y^x][2][ENTER] gives 4 as well as [EQN][2][+/-][y^x][2][ENTER]. It was a hard day and it has been some time since I last get into the details of this calculator, so what am I missing here? The 17BII equation solver does it right with [A][=][-][2][y^x][2][calc] resulting in -4. |
|||
05-06-2015, 07:56 PM
(This post was last modified: 05-07-2015 03:45 AM by Wes Loewer.)
Post: #56
|
|||
|
|||
RE: negative number raised to even power
(04-26-2015 07:20 AM)Thomas Radtke Wrote:(04-26-2015 06:38 AM)parisse Wrote: Could you give a list of softwares/calcs that evaluate -2^2 (algebraic notation) to 4?MS Excel. Check out https://support.microsoft.com/en-us/kb/kbview/132686 where Microsoft says "This order of precedence may mean that a formula returns a positive value when you expect it to return a negative value." Here's a table showing how various calculators/software handle the following order of operations issues: -2^2 = (a) -4 (b) 4 2^3^2 = (a) 512 (b) 64 1/2pi = (a) 1.57 (b) 0.159 Calculators aaa: HP Prime Algebraic Entry aab: HP Prime Textbook Entry/50g EQW (but 1/2pi is shown as stacked fraction and is not ambiguous) aaa: HP 50g Alg mode abb: Casio fx-9960G abb: TI 81/82/85/86 aba: TI 73/83/83+/84+(Classic Mode) aaa: TI 84+(MathPrint Mode)/89/Nspire Software bb-: Excel bb-: OpenOffice ba-: Google Docs Sheet ba-: Gnumeric (formula bar shows "(-2)^2" and "2^(3^2)") ab-: Corel Quattro Pro ba-: Corel WordPerfect Table aa-: Maxima aaa: Wolfram Alpha aaa: GeoGebra Legacy Software bb-: VisiCalc ??-: Lotus 123 (can someone test this) ab-: Lotus Improv (anybody remember this spreadsheet?) This is certainly not a complete list, just what I had handy to test. All the calculators I tested agreed that -2^2=-4, but the other issues were mixed. The more recent HP and TI calculators agree with -4, 512, and 1.57. |
|||
05-07-2015, 03:55 AM
(This post was last modified: 05-07-2015 04:02 AM by Wes Loewer.)
Post: #57
|
|||
|
|||
RE: negative number raised to even power
(05-06-2015 03:40 PM)Thomas Radtke Wrote:(05-06-2015 02:37 PM)Wes Loewer Wrote: Consider the function f(x)=exp(-x^2)Interesting, but here we have a variable instead of a number. True, but I figured that either negation precedes exponentiation or it doesn't. I'm curious, for those that say -2^2 = 4, what about -(2)^2 ? |
|||
05-07-2015, 06:04 AM
Post: #58
|
|||
|
|||
RE: negative number raised to even power
Well Wes,
Rule of thumb: negation as always higher priority when the calculator does it (Variable^2, Ans^2, ...) but not when you type it. |
|||
05-07-2015, 10:30 AM
Post: #59
|
|||
|
|||
RE: negative number raised to even power
A fascinating discussion.
From the HP 32S II Owner's Manual: Page 1-11. Making Numbers Negative The +/- key changes the sign of a number. To key in a negative number, type the number, then press +/-. To change the sign of a number that was entered previously, just press +/-. (If the number has an exponent, +/- affects only the mantissa - the non-exponent part of the number.) =================================== Note that last part. There is no mention of negation of the entire calculation, only negation of the mantissa. The Microsoft support article link on MS EXCEL in a previous post basically says the same thing. I come from a software environment and have written code since 1968, so I'm well aware of orders of precedence. In the software environment, -4 is the correct answer by virtue of the rules of precedence. But back to the original question of this thread: intuitively on a calculator, when I press the +/- key I want to change the sign of a single entity, not the entire subsequent calculation. For me at least, that was always the purpose of the +/- key. What I find interesting is how the calculator's role has changed over the last 40 years or so. Today it has assumed the role of a software device (read: computer), thus assuming the computer's methodology of doing things. User beware! Today's calculator user must have at least a rudimentary knowledge of computer-speak! Bill |
|||
05-07-2015, 10:40 AM
Post: #60
|
|||
|
|||
RE: negative number raised to even power
(05-06-2015 07:56 PM)Wes Loewer Wrote:(04-26-2015 07:20 AM)Thomas Radtke Wrote: MS Excel. Lotus 123, 2.4: aba |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 24 Guest(s)