Robot Battle Home Log In | Register
Welcome Guest
Help | Search | Members | Contest Calendar | Chat

Robot Battle Registry  Discussion Forums  Technical Support  -a^b
Pages: (4) 1 2 [3] 4  ( Go to first unread post )
-a^b Track this topic | Email this topic | Print this topic 
PhamNuwen
Posted: Sep 7 2007, 08:51 PM


Serious Player


Group: Members
Posts: 39 (2 robots)
Member No.: 1142
Joined: 9-June 07



QUOTE
I would like to go on record, as one of the less mathmatically inclined folks here as saying that I really enjoy cheese.


I absolutely love cheese. Add it to anything (well, almost)... it makes it better.
 
    Top

Silicon
Posted: Sep 8 2007, 02:28 AM


Grand Master


Group: Moderators
Posts: 213 (1 robots)
Member No.: 44
Joined: 20-August 03



Sorry I'm getting in on this a bit late...

While, mathematically, -x^y = -(x^y), in computer languages that support an exponentiation operator, it is actually traditional (don't ask me why) to give unary operations (such as a unary negation) a lower priority than said exponentiation operator. This is pointed out, in a rather unclear way on the already referenced Wikipedia entry, at the bottom of the "The standard order of operations" section -- by pointing out that the unary negation is oddly handled in Excel and an archaic language called bc, but completely glossing over why its like that (which is: because the programmers that wrote those things were really used to it being that way).

While this is technically a bug for people new to computer languages, it's pretty much what you're gonna have to get used to in other languages anyways, so, suck it up.

P.S. This is exactly why I did horribly bad on my AP Calculus exams in high school -- I forgot that mathematicians did it differently.

P.P.S. This isn't that big of a problem in most programming, since most languages lack an exponentiation operator (it's usually pushed into a function), since it is actually frowned upon in most language design philosophies to represent operations that aren't atomic on the hardware as an straight-up operator. A function at least tells you thats its probably going to be slow.

P.P.P.S. It was driving me crazy to not know why it was like that, so I did some research, and it basically turns out that it was easier to implement it that way than to do it correctly.

P.P.P.P.S. I just had to do a fourth.
 
        Top

PhamNuwen
Posted: Sep 8 2007, 05:59 AM


Serious Player


Group: Members
Posts: 39 (2 robots)
Member No.: 1142
Joined: 9-June 07



QUOTE
Why must we understand to this? When would I ever write "-2" to mean anything except "negative two?" When would I ever write it to mean "the negation of two?"


Why couldn't we write -2 to mean the negation of two? I'll admit I wouldn't ever do it ... unless maybe I was writing a programming language, but you have to be able to do it. (see below: (m)x, x=2, (m)2 = -2)

Anyway, lets seperate the 3 uses of the minus sign: - x becomes (m) x. a - b becomes a + (m) b. And -2, the number keeps the '-' (so that -2 is now identical to (-2)).

So - can mean either (m), or +(m) (with a number on left and right), or - as in part of a number.

-2^2 = 4
(m) x ^2 = (m) (x^2)
if we replace x by 2 and write the answer:
(m) 2^2 = (m) (2^2) = (m) 4 = -4.

but (m) is written as - in our math:
so if we go back to the normal way it is done:

- 2^2 = - (2^2) = - 4 = -4 that has to be correct. So does -2^2 = 4.

As Ichabod says, who would ever write -2 alone and mean the negation operator? Of course not, because (m) 2 = -2 so theres no reason to discriminate. But (m)2^2 not equal to (-2)^2 so someone might write -2^2 and mean either (m)2^2 or (-2)^2.
 
    Top

chess123mate
Posted: Sep 8 2007, 11:44 AM


Logical Programmer


Group: Members
Posts: 587 (24 robots)
Member No.: 936
Joined: 3-February 07



QUOTE
Why must we understand to this? When would I ever write "-2" to mean anything except "negative two?" When would I ever write it to mean "the negation of two?"

OK, PhamNuwen already addressed this, and I tried to show my example to explain this. As usual, I did a horrible job. You also said ""-2" might mean "minus two," but only if there is a number immediately preceding it.
", and so I am going to say this and it should answer both questions.
Have you ever seen "0-2^2"? Or
0-5*5
Very rarely! You might see
-5*5
Or
(-5)*5
But rarely
0-5*5
(at least, I haven't seen that, especially when computers are involved. Maybe in a math text book, but otherwise...)
So, I'm saying that we usually don't put "0" before a "-5" or "-2". If we did, then we could clearly note that it is obvious that "0-2" means "0 subtract 2". We just assume the 0 is there.

QUOTE
You're trying to compare natural languages and artificial symbol sets. The analogy does not hold. While they are both systems of assigning referents to auditory or visual symbols, they are created in entirely different ways which lead to vastly different properties.


When I was giving that example, I wondered if you'd say something like that. The point is, in the same way there can be the same English word meaning multiple things, there can be the same mathematical symbol that means multiple things. Here's a mathematical example that occurs when writing:
x = 2
5x2x
What does that mean? If the variable "x" isn't in cursive writing, it looks like it could be "five times two times x" OR "five times x times two times x", which simplified is "five times two times x squared". It can be hard to differentiate between the variable "x" and the multiplication sign, unless you use a dot or brackets.

QUOTE
You're also trying to disguise the switch you've made. What you really mean above is:

-2 = negative two
-2^2 = the negation of two squared

I'm saying that I see no reason why the meaning of the symbol should change between those two cases.


Disguise?? huh.gif
OK, now I see what you're saying after that last sentence (though I still don't get why you said "disguise"). That is what I tried to address in my "can" example, although as you said it doesn't mean there is a relationship. I understand it doesn't PROVE it, but I'm just trying to state what I'm saying.

In "-2", we have no other numbers and nothing else.
In "-2^2", we have extra numbers and an operator, which changes the sentence and how it's read. No longer is it "negative two", it is now, as you put it, "the negation of two squared".

QUOTE
No, the main problem is that we have no mathematical symbol to distinguish the negation operation from the negative sign. We don't even have to get to computers to have a problem.

True, (silly me laugh.gif ) but we do have brackets. We are supposed to use brackets to show that a "-#" is "negative ___" rather than "the negation of #..."

QUOTE
Yes, if you assume that the only resources we have are the order of operations, and thereby assume that the "-" is an operator and not a part of a number, then then "-" must be an operator and not part of the number. This is what's called a circular argument.

What else do we have, other than the order of operations? We have negative numbers and positive numbers, as well as variables, but in figuring out "-2^2" what do we have?

QUOTE
No. Negative numbers are not the same as negation operators applied to positive numbers.


I agree 100%. Unfortunately, in our case, they look the same because of the fact we don't have a difference between "negative" and "negation".

So, I guess the question that we are looking at is, is there a difference between "-2" by itself and "-2" in an expression? We've already proven/agreed upon that when x=2 "-x^2" is indeed -4, so all that is left is how we are going to differentiate between the two cases.
We can always use brackets, and that makes it clear no matter what, since brackets are the first thing that we are to complete.
Ex.
(-2)^2 = 4
-(2^2) = -4
Etc.
So, what happens when we don't have brackets? According to order of operations, without brackets you then do the exponents.
-2˛ ...I'd say that looks better.... got it from Microsoft Word and simply copied. Really looks good... smile.gif
That's the question.
-(2˛) should equal -2˛ because as we can see on the expression on the left, we are doing "the negation of 2 squared", and since order of operation says we do exponents before multiplication we needn't have the brackets!


I can see your point, Ichabod, and in a way I must admit I agree with it. Besides, it is very logical. Unfortunately, at least to me, so is the above paragraph that I put in bold.

QUOTE (PhamNuwen)
But (m)2^2 not equal to (-2)^2 so someone might write -2^2 and mean either (m)2^2 or (-2)^2.

The two things that are there are "-2˛" (as in minus/negation of 2˛) and "(-2)˛", but note the brackets in the 2nd one, and how it needs to extra explenation. So, I think that "-2˛" is -4, while "(-2)˛" is +4, since in "(-2)˛" we show that we are talking about negative two rather than the negation of two˛. That is why we are not having questions about (-2)˛, but just -2˛ .

According to my Grade 11 Text book, the logic I've heard, our discussions here, my math teachers, the explenations I've heard, I must conclude that -2˛ = -4.
 
     Top

Ichabod
Posted: Sep 8 2007, 03:40 PM


Grand Vizier


Group: Contest Hosts
Posts: 1238 (16 robots)
Member No.: 700
Joined: 2-May 06



QUOTE (chess123mate @ Sep 8 2007, 01:44 PM)
x = 2
5x2x

5x2x = 10x^2 = 40.
5*2x = 20

Note that if you wrote it out by hand, the multiplication sign would be off the baseline.
QUOTE
QUOTE
Yes, if you assume that the only resources we have are the order of operations, and thereby assume that the "-" is an operator and not a part of a number, then then "-" must be an operator and not part of the number. This is what's called a circular argument.

What else do we have, other than the order of operations? We have negative numbers and positive numbers, as well as variables, but in figuring out "-2^2" what do we have?

You just said it yourself. We have negative numbers. "-2" is a negative number. Therefore, "-2^2" is a negative number squared, which as we all know results in a positive number. What you have failed to explain is why "-2" should change from a negative number to an operator on a positive number when you slap an exponent on it.


--------------------
-Ichabod
Nils illegitimo carborundum

QUOTE (Cho Setsu)
By eliminating disturbances, we redouble the disease.


131,628,711 robots killed in the name of simulation
 
     Top

chess123mate
Posted: Sep 9 2007, 11:54 AM


Logical Programmer


Group: Members
Posts: 587 (24 robots)
Member No.: 936
Joined: 3-February 07



That first example, "5x2x", and you said the "x" as in multiplication sign would be above the baseline, and that is true. Unfortunately, if you are in a rush, it may not look that way. Another example is using "t", if you are sloppy a "t" (that isn't written out in cursive) could look like a "+" sign.

Why does "-2" become the negation of two "when you slap an exponent on it"? Because it is no longer "-2"! The "-" now changes to a negation sign! How else can I possibly explain it? You are saying that it stays as "-2" no matter what... but surely you agree that in
10 - 2˛
the answer is 10 - 4 and thus 6, not anything else? So, what about in this one...
10 - 10 - 2˛
You would then simplify it to
0 - 2˛
-2˛
-4

Wouldn't you? Or would you simplify 10 - 10 - 2˛ differently? If so, please show me!
 
     Top

Ichabod
Posted: Sep 9 2007, 12:28 PM


Grand Vizier


Group: Contest Hosts
Posts: 1238 (16 robots)
Member No.: 700
Joined: 2-May 06



QUOTE (chess123mate @ Sep 9 2007, 01:54 PM)
That first example, "5x2x", and you said the "x" as in multiplication sign would be above the baseline, and that is true. Unfortunately, if you are in a rush, it may not look that way. Another example is using "t", if you are sloppy a "t" (that isn't written out in cursive) could look like a "+" sign.
What does sloppy handwriting have to do with it? It's a different symbol and your analogy doesn't hold.

QUOTE
Why does "-2" become the negation of two "when you slap an exponent on it"? Because it is no longer "-2"! The "-" now changes to a negation sign! How else can I possibly explain it?

Well, for starters, YOU COULD STOP USING CIRCULAR REASONING! It changes to a negation because it changes to a negation?!?

QUOTE
You are saying that it stays as "-2" no matter what... but surely you agree that in
10 - 2˛
the answer is 10 - 4 and thus 6, not anything else?

Straw man arguments won't work either. I never said that it stays a negative number no matter what. What I said is that I see no reason that it should stop being a negative number just because you slap an exponent on it.


--------------------
-Ichabod
Nils illegitimo carborundum

QUOTE (Cho Setsu)
By eliminating disturbances, we redouble the disease.


131,628,711 robots killed in the name of simulation
 
     Top

chess123mate
Posted: Sep 9 2007, 05:51 PM


Logical Programmer


Group: Members
Posts: 587 (24 robots)
Member No.: 936
Joined: 3-February 07



Yes, you are correct, I'm not explaining well (good job biggrin.gif at tearing me down, and I mean that in a good way).

I note that you still haven't looked at my "10 - 10 - x^2" example. What do you have to say about that?


QUOTE
{Quote}Why does "-2" become the negation of two "when you slap an exponent on it"? Because it is no longer "-2"! The "-" now changes to a negation sign! How else can I possibly explain it?  {end quote}

Well, for starters, YOU COULD STOP USING CIRCULAR REASONING! It changes to a negation because it changes to a negation?!?


I can see that you are frustrated, I would be too, except I said "negative two is no longer negative two" because you you have other things to consider - like order of operations. I didn't actually say that, I was being rushed (hey what do you know, I'm still being rushed! laugh.gif ) but I'm saying it now. And please address the "10 - 10 - x^2" part, please.
 
     Top

Ichabod
Posted: Sep 10 2007, 03:10 AM


Grand Vizier


Group: Contest Hosts
Posts: 1238 (16 robots)
Member No.: 700
Joined: 2-May 06



QUOTE (chess123mate @ Sep 9 2007, 07:51 PM)
I can see that you are frustrated, I would be too, except I said "negative two is no longer negative two" because you you have other things to consider - like order of operations. I didn't actually say that, I was being rushed (hey what do you know, I'm still being rushed!  :lol: ) but I'm saying it now.

The order of operations is not relevant. There is only one operation in "-2^2," the exponent. There is nothing in the order of operations that tells you to change the -2 from a negative number into an operation on a positive number.

QUOTE
And please address the "10 - 10 - x^2" part, please.

I have addressed it. It is a straw man argument. I have never claimed that the "-2" in "10-2" is a negative number and not an operation on two positive numbers. I have explicitly stated that I understand the "-2" in "10-2" is an operation on two positive numbers and not a negative number.


--------------------
-Ichabod
Nils illegitimo carborundum

QUOTE (Cho Setsu)
By eliminating disturbances, we redouble the disease.


131,628,711 robots killed in the name of simulation
 
     Top

chess123mate
Posted: Sep 10 2007, 03:36 PM


Logical Programmer


Group: Members
Posts: 587 (24 robots)
Member No.: 936
Joined: 3-February 07



QUOTE
I have addressed it. It is a straw man argument. I have never claimed that the "-2" in "10-2" is a negative number and not an operation on two positive numbers. I have explicitly stated that I understand the "-2" in "10-2" is an operation on two positive numbers and not a negative number.


Yes, sorry about that. I realized it lastnight AFTER I posted that we really aren't talking about 10 subtact 2, just -2 by itself and when paired with 2. I'm now going to try showing you in a different way, and I thank you for continuing to respond to some of my worse ideas that make no sense. biggrin.gif

QUOTE
The order of operations is not relevant. There is only one operation in "-2^2," the exponent. There is nothing in the order of operations that tells you to change the -2 from a negative number into an operation on a positive number.


You just said that order of operations is irrelevant? I'm sorry, but that is the whole point. Order of operations is what makes "-2^2" -4 !!!

Say I have 2. That's it, just 2. Now, we add an exponent. 2˛, and as we know that is equal to 4. Now we get to the tricky part, we add a negative sign to the 2˛.

How, may I ask, does a negative sign, which is equivalent to multiplication or subtraction, I don't care how you want to look at it, going to take over that exponent?
2˛ = 4
Add a negative sign and all of a sudden we aren't going to look at the exponent first anymore?
-2˛ = 4 ???

It's still a negative, but it's not the negative of 2, it's the negative of 2˛ !

Really, we are discussing which sign has higher priority in the order of operations -- the negative sign, or the exponents? That's what it comes down to, since really if all we say is that "if you have -2, why is it not -2 when you put an exponent on it" vs "if you have 2˛, why isn't it still a positive 2 after you put a negative in front [though still negative 2˛]", we COULD go on for ever!

The negative sign isn't necessarily part of the number 2. If you want it to be part of the number two, then use brackets. Otherwise, it is extremely ambiguous, and so we must research the laws of math to decide how to treat "-2˛". ... oh look at that! We have order of operations. ohmy.gif Who knew, eh? Let's see... it says "BEDMAS" although in the US and other countries they have things like "PEDMAS" and even more than that... let's see ... BEDMAS -- Brackets, Exponents - oh! We have an exponent...
-
Then it continues Division/Multiplication, Addition/Subtraction. Let's see, a negative sign would fall under either multiplication in this case, because we have no proof that it is "-2", but we have proof that it isn't "-2" because there is an exponent in the expression, and as I'm sure we all understand, we should do exponents first.
...
-2˛
= -(4)
= -4

I say that "-" is multiplication because, for example, look at the following statement:

-[83 + (-92) * 5]

We can do one of 2 things: Use order of operations and simplify that way, or we can distribute the "-" among everything, which is basically taking "[83 + (-92) * 5]" and multiplying each number by "-1".

= -83 + -(-92) * -5
= -83 + 92 * -5
= -83 + -460

In the above line, the "-" is of course being used as what ever you want to call it. Negation of 460, as we said earlier, is unlikely to be said verbally, but it is still mathematically correct, isn't it? Regardless, we know that the "-" isn't the negation of 460 in this case because we already have an operator between "460" and "83". In the case of "-83", this isn't the same because there is nothing wrong with starting with an operator, as I just did in the very beginning statement, which means you can't prove that the "-" is strictly for making numbers the negative of that number (if that makes sense), but it can also be used as an operator. Since it could be either, just like in any language, we must look at the context that it is being used in. (Another example isn't needed, I'm sure) The first clue would be brackets, but since we're pretending we aren't necessarily going to be using brackets, we must look for other signs. Are there other operators? Are there exponents? Is it a fraction? Many possibilities, so I'll say it again, let's look at the basic laws of math - order of operations.


OK... that's basically the end of this post, now Ichabod (and anyone else), what logic flaws do I have this time? wink.gif
 
     Top

yoyodyn
Posted: Sep 10 2007, 03:49 PM


Academic Advocate


Group: Registered Owners
Posts: 237 (3 robots)
Member No.: 145
Joined: 19-February 04



The big difference that I see between what you two are saying is that Chess wants the '-' sign to be an operation all the time, no matter the circumstances. And Ichabod is saying that '-2' is a symbol, an atomic unit unto itself that isn't broken down. Otherwise we don't have a single symbol for the number that is 2 whole numbers below zero.
We have a symbol for positive 2. we have a atomic symbol for 22 (which should show that you can have more than one symbol combined into a single atomic unit.)

Look at it this way chess. take 22. What is 22^2? Does that equal 11 * 2^2? No, because 22 is an atomic unit that should not be broken down or factored out before the exponent is taken into account, and that is what you are trying to do with -2^2 by saying that it is (-1) * 2^2. You are trying to do division before the exponent which is against the precious order of operations.

Now, having said all that, I don't really care one way or the other, we have to do it one way for programs to work.


--------------------
"Yea though I walk through the valley of the shadow of Gates, I will fear no Windows."
 
      Top

Ichabod
Posted: Sep 11 2007, 03:48 AM


Grand Vizier


Group: Contest Hosts
Posts: 1238 (16 robots)
Member No.: 700
Joined: 2-May 06



QUOTE (chess123mate @ Sep 10 2007, 05:36 PM)
OK... that's basically the end of this post, now Ichabod (and anyone else), what logic flaws do I have this time? wink.gif

The same ones you've had before. I'm tired of repeating myself, so I won't. This conversation is over.


--------------------
-Ichabod
Nils illegitimo carborundum

QUOTE (Cho Setsu)
By eliminating disturbances, we redouble the disease.


131,628,711 robots killed in the name of simulation
 
     Top

chess123mate
  Posted: Sep 12 2007, 05:13 AM


Logical Programmer


Group: Members
Posts: 587 (24 robots)
Member No.: 936
Joined: 3-February 07



QUOTE
Look at it this way chess. take 22. What is 22^2? Does that equal 11 * 2^2? No, because 22 is an atomic unit that should not be broken down or factored out before the exponent is taken into account, and that is what you are trying to do with -2^2 by saying that it is (-1) * 2^2. You are trying to do division before the exponent which is against the precious order of operations.


22 is unit, and although I was going to have an argument much like this, I came to the same conclusion you just made (so I didn't mention it). 22^2 is indeed NOT 11*2^2, for numerous reasons. I agree, it doesn't work.
11*2^2
=11*4
=44
where as
22^2
= 22 * 22
= 484

On the other hand, -2 could be "negative two" or it could be "the negation of 2..." I put ... because if there is something higher than multiplication (or division), then you must do that operation first. In this case, it is the exponents.

Anyway, I agree, this is getting tiring. "-2" isn't necessarily an "atomic unit" if used elsewhere. Just like in the English language if you have the word "can" and then add an "e" you now have "cane" as in a candy-cane rather than the verb or noun "can". Some of you guys are obviously not going to believe the math, claiming that "-2" is a unit no matter where it is.
-2^2
=-(2)(2)
=-(4)
and
(-2)^2, as my teacher once again explained to me, means to give the exponent to everything in the brackets, and so "-2" is treated as "negative two", as that unit.

If you don't want to believe the facts, that's your guys' loss, and thus what can I do?

I agree, Ichabod, I don't want to argue this anymore either. You won't listen, and you haven't listened to the exponent rules. That's your problem.

As for that part about doing division first, I'm not saying that -2^2 should be converted to -1*2^2, although it is the exact same thing.

Ex.
4^2 = 16
you can factor it or divide it, as long as it is in the brackets, like this:
(2*2)^2=16
They are the same, which is why
-2^2 = -4.
 
     Top

Ichabod
Posted: Sep 12 2007, 05:28 AM


Grand Vizier


Group: Contest Hosts
Posts: 1238 (16 robots)
Member No.: 700
Joined: 2-May 06



QUOTE (chess123mate @ Sep 12 2007, 07:13 AM)
I agree, Ichabod, I don't want to argue this anymore either. You won't listen, and you haven't listened to the exponent rules. That's your problem.

I have done my best throughout this to argue reasonably and rationally without resorting to ad hominem attacks such as the above. I have defended my position logically while you have ignored my logical defenses in favor of repeating the same circular reasoning and other irrelevancies. I do not appreciate you saying I have some sort of "problem" just because I refuse to believe your unsupported assertions.


--------------------
-Ichabod
Nils illegitimo carborundum

QUOTE (Cho Setsu)
By eliminating disturbances, we redouble the disease.


131,628,711 robots killed in the name of simulation
 
     Top

DarkCypher
Posted: Sep 12 2007, 05:36 AM


Player


Group: Members
Posts: 27 (3 robots)
Member No.: 1205
Joined: 10-September 07



Unary +/- is an operator of higher precedence the ^(to the power)

Therefore

-a^x != 0-a^x

Take note, that technically, the - on the LHS and the - on the RHS are different operators.
The LHS is Unary -, the RHS is binary - (ie, needs 2 operands)


Atleast, that is what my Mathematics and Computer Science degrees taught me.

You probably want be able to read this though as all my posts are going to the 'Newly Joined' limbo with no moderators to be seen sad.gif


--------------------
Programmer by profession
 
     Top
Pages: (4) 1 2 [3] 4 
<< Back to Technical Support