Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

WARNING! Excel order of operations problem... 1

Status
Not open for further replies.
A quick note on calculators:

My HP48 also outputs 25 when I square -5. The reason is that in order to enter the -5 you have effectively put parenthesis around it. The calculator assumes that since you entered it first, you wanted it first. If you typed -5^2 + 5^2 and then hit execute, it should give you 0, which is the correct answer. This means that it would be using the order of operations correctly. Excel incorrectly says this is 50.

Again, by international agreement, as stated in dik's link, for -5^2, the number to be squared is 5, THEN the negative is applied. In Tomfh's first link, Microsoft even admits that Excel does not use the standard order of operations (which is the link I was speaking about in my original post):


Mathematica and MathCAD give the correct output.
 
My old Quattro Pro evaluates -5^2 as -25 and -5^2+5^2 as 0.

Three other calculators evaluate this as 25 and 50 without using().
 
In grade school, we were tqaught that squaring a negative number produces a positive number. Therefore, -5^2 - 25.

However, the equation 5^2-5^2 = 0 because you doi the powers before the subtraction. There is no subtraction in -5^2 = 25.
 
PEinc,

You might want to go back and check your grade school book. Since I tutor grade school through college math on a regular basis, I happen to have a grade school book and they have this exact example in there.

You are exactly correct when you say that squaring a negative number produces a positive number. The problem is that according to the order of operations, you're not squaring a negative number in the example. You're squaring a positive number and then negating the answer.

Why do you think Microsoft actually posted a work-around on their Knowledge Base?

Let me pose it to you this way: Let's assume what you and Excel say is true:

-5^2 + 5^2 = 50

If I want to move the -5^2 to the other side of the equation, how would I go about doing it? If I add 5^2 to both sides, and we stand by your assumption that -5^2 = 5^2, then we'd get:

5^2 + -5^2 + 5^2 = 5^2 + 50

Now if the first two terms cancel, you know it's not right. Now let's try adding -5^2 to both sides:

-5^2 + -5^2 + 5^2 = -5^2 + 50

By your example, the first -5^2 = 25 and the second -5^2 = -25 (negation vs subtraction, as in a previous post) and they cancel and you're left with:

5^2 = -5^2 + 50

Which you'll say can't be true because you contend -5^2 = 25 in your book (in my book, and any math book, it IS true however because -5^2 + 50 = 25).

I don't know what more I can say, but I think we're whipping a dead horse... :p
 
One side is saying -5^2 is actually -1*5^2, which everybody agrees would be -25. The other side is saying that -5^2 is actually (-5)^2, or "(negative five) squared." I've never heard that a negative in front of a number raised to a power is actually -1 times that number raised to a power. I would tend to think -5^2, with the "naked" negative sign as opposed to a subtraction sign, is 25.

Either way, it is always good practice to use parentheses and/or "-1*..." in these cases to be absolutely sure. Who knows what the programmers had in mind when a bunch of engineers can't even agree on what is correct!
 
I believe that -5^2 = 25, which is what is taught in your basic math classes when learning the order of operations. However, I’m saying that the way –most- calculators and computer programs operate on -25^2 as (-1)*5^2.

During my education in using calculators (in high school) and computer software and programs (in college) this point has always been made very clear and we were always warned to use parentheses to be safe. I’m surprised this issue can spark such a long thread…I would think most engineers would be aware of this issue. Maybe this is something that has only been taught in school in more recent times?

 
You've got a good point that a bunch of engineers can't agree, but there's a difference between agreement and fact. The fact is that by international standard, the order of operations is as I've presented it. This is supported by the major mathematics programs, text books, and the Excel programmers themselves. We can disagree on whether the sky is blue or that -5^2 = -25, but they are what they are...
 
For what its worth I entered it into Mathematica:

-5^2=-25

In my opinion this is what it should be.

Regards,
-Mike
 
If you factor out the -1 from the -5 in -5^2, both the -1 and the +5 should still need to be squared. Therefore, the -1^2 = 1 and 5^2 = 25 and their product would be +25. That's how I see it.

swearingen's equation, 5^2 + -5^2 + 5^2 = 5^2 + 50, could use parentheses, I believe, to make sense.

The real question is whether the number being squared is intended to be -5 or 5. Parentheses would clarify that. A negative number squared is positive.
 
PEinc, your question of how can you write the square of -3 without parenthesis is a good one.

If -3^2 = 9, then the issue would be you must use parenthesis to get the other answer: -(3^2) = -9.

It just happens to be the other way around - you don't need parenthesis to get the negative answer and you do need the parenthesis to get the positive answer. This is, I believe, the reason the spreadsheet guys made their change to the standard: most people are looking to get the positive answer, so they were trying to save them the trouble of using parenthesis when, in fact, they actually need them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor