Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
DerStrom8
How does that solve the conundrum that PEMDAS presents? As I currently understand it, applying PEMDAS, -2^2 = -4
However, (a-b)^2 when expanded is a^2 -2ab + b^2. "0-b" is of the same form as (a-b), so (0-b)^2 = b^2, not -b^2.
John
Unary operators are applied first. PEMDAS or BODMAS in UK is a guide for use in school. -2 squared is very different to 0-2 squared.
Edit, another way to think of it is that -2 is an member of the integers, a number in it's own right and not 0-2.
Mike.
Can you show your work for that?Graph says 4. EXCEL on the other hand says -4!! So does Matlab, so as AUS Dave would say 'A trap for young players!'.
Interesting stuff!
The number -2 is not 2 with a unary operator, it is an integer in it's own right and can't be treated as anything else.
Out of curiosity, using PEMDAS, how would 25/5*2 be worked out? As 25/10 or as 12.5*2?
And, as appears on facebook, what is 3-3*6+2?
Edit, I now see what you mean, -x^2 is -(x^2) and if x=2 will equal -4. However, -2 is not the same as -x. It's kinda weird that I never saw the difference before and just automatically did it without further thought. The more I read the more it appears that parentheses are needed or the answer is -4. Looks like this has been adopted since I left school, I guess for clarity. I wonder how 5+-2^2 is calculated these days as the -2 is a negative number?
Can you show your work for that?
Here is my test on Excel 2007:
View attachment 97703
The J column simply has a -2 entered as shown in the fx line.
That version of Excel follows the old rules, -2^2 = 4, regardless of whether the negative number is calculated (presuming Excel might add parentheses) or entered directly.
John
I think we have wondered a smidge off topic!
Only if "minus 2" is defined as "-2" with parentheses. Once again, use the order of operations (PEMDAS).
PEMDAS is an acronym for the order of arithmetic operations with binary operators (binary meaning quantity of 2; not as in base 2). It does not apply to unary operators. There are special rules in that case, as I mentioned in post #6. Google " unary operations" for more information.
Note that the negative sign in -2 is a unary operator, as it has only one operand. In Boolean logic, NOT is also a unary operator.
From time to time I have had some really weird results in Excel which I could not explain. Maybe it was the order of operations thing.For that reason I don't put much trust in what is returned from Excel.
One lesson to take away from this discussion is that it is important to remove all ambiguity when writing mathematical expressions which have to be interpreted by others.
Exactly right!Which, at the end of the journey, it seems to me, simply boils down to use the adequate number of parenthesis in the adequate places. Isn't it? Even a calculator understands that.
Depending on the application, probably not.BTW, note the time penalty for using extra parenthesis with RFOBasic! in my Samsung tablet to run 5000 times the following calculations (time spent in red - microseconds?):
val = byte1 + byte2 * 2 + byte3 *2 (920.0)
and then
val = (byte1) + (byte2 * 2) + (byte3 *2) (1424.0)
Does anyone care about that anyway?