Why does =-x^2+x for x=3 in Excel result in 12 instead of -6?
Suppose my cell A1 in an Excel spreadsheet holds the number 3.
If I enter the formula
= - A1^2 + A1
in A2, then A2 shows the number 12, when it should show -6 (or -9+3)
Why is that? How can I prevent this misleading behaviour?
microsoft-excel worksheet-function notation
|
show 6 more comments
Suppose my cell A1 in an Excel spreadsheet holds the number 3.
If I enter the formula
= - A1^2 + A1
in A2, then A2 shows the number 12, when it should show -6 (or -9+3)
Why is that? How can I prevent this misleading behaviour?
microsoft-excel worksheet-function notation
18
A negative number squared is a positive number. Which would make the formula 9+3. -(A1)^2 would give you -6.
– Ramhound
Dec 18 at 19:08
7
@Ramhound = -(A1)^2 gives 9 in Excel
– Rodolfo Oviedo
Dec 18 at 19:29
59
@Ramhound Powers have higher priority than minus signs in any sane environment.
– Nobody
Dec 18 at 20:35
15
It ought to be -(A1^2) to get -6... you need parenthesis around the operation, not just the number. Excel is just fine for math, but you need to respect order of operations, and when in doubt, use parenthesis!
– SnakeDoc
Dec 18 at 21:51
13
This is all about order of operations and nothing to do with Excel.
– YetAnotherRandomUser
Dec 19 at 13:58
|
show 6 more comments
Suppose my cell A1 in an Excel spreadsheet holds the number 3.
If I enter the formula
= - A1^2 + A1
in A2, then A2 shows the number 12, when it should show -6 (or -9+3)
Why is that? How can I prevent this misleading behaviour?
microsoft-excel worksheet-function notation
Suppose my cell A1 in an Excel spreadsheet holds the number 3.
If I enter the formula
= - A1^2 + A1
in A2, then A2 shows the number 12, when it should show -6 (or -9+3)
Why is that? How can I prevent this misleading behaviour?
microsoft-excel worksheet-function notation
microsoft-excel worksheet-function notation
edited Dec 21 at 6:48
asked Dec 18 at 13:52
Rodolfo Oviedo
1,4602315
1,4602315
18
A negative number squared is a positive number. Which would make the formula 9+3. -(A1)^2 would give you -6.
– Ramhound
Dec 18 at 19:08
7
@Ramhound = -(A1)^2 gives 9 in Excel
– Rodolfo Oviedo
Dec 18 at 19:29
59
@Ramhound Powers have higher priority than minus signs in any sane environment.
– Nobody
Dec 18 at 20:35
15
It ought to be -(A1^2) to get -6... you need parenthesis around the operation, not just the number. Excel is just fine for math, but you need to respect order of operations, and when in doubt, use parenthesis!
– SnakeDoc
Dec 18 at 21:51
13
This is all about order of operations and nothing to do with Excel.
– YetAnotherRandomUser
Dec 19 at 13:58
|
show 6 more comments
18
A negative number squared is a positive number. Which would make the formula 9+3. -(A1)^2 would give you -6.
– Ramhound
Dec 18 at 19:08
7
@Ramhound = -(A1)^2 gives 9 in Excel
– Rodolfo Oviedo
Dec 18 at 19:29
59
@Ramhound Powers have higher priority than minus signs in any sane environment.
– Nobody
Dec 18 at 20:35
15
It ought to be -(A1^2) to get -6... you need parenthesis around the operation, not just the number. Excel is just fine for math, but you need to respect order of operations, and when in doubt, use parenthesis!
– SnakeDoc
Dec 18 at 21:51
13
This is all about order of operations and nothing to do with Excel.
– YetAnotherRandomUser
Dec 19 at 13:58
18
18
A negative number squared is a positive number. Which would make the formula 9+3. -(A1)^2 would give you -6.
– Ramhound
Dec 18 at 19:08
A negative number squared is a positive number. Which would make the formula 9+3. -(A1)^2 would give you -6.
– Ramhound
Dec 18 at 19:08
7
7
@Ramhound = -(A1)^2 gives 9 in Excel
– Rodolfo Oviedo
Dec 18 at 19:29
@Ramhound = -(A1)^2 gives 9 in Excel
– Rodolfo Oviedo
Dec 18 at 19:29
59
59
@Ramhound Powers have higher priority than minus signs in any sane environment.
– Nobody
Dec 18 at 20:35
@Ramhound Powers have higher priority than minus signs in any sane environment.
– Nobody
Dec 18 at 20:35
15
15
It ought to be -(A1^2) to get -6... you need parenthesis around the operation, not just the number. Excel is just fine for math, but you need to respect order of operations, and when in doubt, use parenthesis!
– SnakeDoc
Dec 18 at 21:51
It ought to be -(A1^2) to get -6... you need parenthesis around the operation, not just the number. Excel is just fine for math, but you need to respect order of operations, and when in doubt, use parenthesis!
– SnakeDoc
Dec 18 at 21:51
13
13
This is all about order of operations and nothing to do with Excel.
– YetAnotherRandomUser
Dec 19 at 13:58
This is all about order of operations and nothing to do with Excel.
– YetAnotherRandomUser
Dec 19 at 13:58
|
show 6 more comments
11 Answers
11
active
oldest
votes
Short answer
To solve this problem, just add a 0 before the equal sign
= 0 - A1^2 + A1
or add a couple of parenthesis to force the standard order of operations
= - (A1^2) + A1
or replace the minus sign by its common interpretation of multiplication by -1
= -1 * A1^2 + A1
Detailed explanation
Under Excel's conventions,
= - 3^2
equals (-3)^2 = 9, while
= 0-3^2
equals 0-9 = -9.
Why adding just a 0 changes the result?
Not preceded by a minuend, the minus sign in -3^2 is considered a negation operator, which is a unary operator (with only one argument) that changes the sign of the number (or expression) that follows. However, the minus sign in 0-3^2 is a subtraction operator, which is a binary operator that subtracts what follows -
from what precedes -
. According to Excel's conventions, the exponentiation operator ^
is computed after the negation operator and before the subtraction operator. See "Calculation operators and precedence in Excel", section "The order in which Excel performs operations in formulas".
The standard mathematical convention is that the exponentiation is computed before both negation and subtraction or, more simply stated, ^
is computed before -
. Shamefully, Excel chose different conventions from those of algebra rules, school textbooks, academic writing, scientific calculators, Lotus 1-2-3, Mathematica, Maple, computations oriented languages like Fortran or Matlab, MS Works, and... VBA (the language used to write Excel's macros). Unfortunately, Calc from LibreOffice and Google Sheets follow the same convention for compatibility with Excel. However, placing an expression in Google's search box or bar give excellent results. If you press enter, the order of computations will be given by using parentheses. A discussion where a mathematician kills the arguments of a "computer scientist" defending the precedence of negation over exponenciation: http://mathforum.org/library/drmath/view/69058.html
General Workarounds
If you want to compute
- anything ^ 2,
add a 0 before the equal sign
0 - anything ^ 2
or add a couple of parenthesis to force the standard order of operations
- ( anything ^ 2 )
or replace the minus sign by its common interpretation of multiplication by -1
-1 * anything ^ 2
A comment to another answer says that the only case you have to be aware of the the non-standard precedence rule is where a minus sign follows an equal sign (=-). However, there are other examples, like =exp(-x^2) or =(-2^2=2^2), where there isn't a minuend before the equal sign.
Thanks to @BruceWayne for proposing a short answer, which I wrote at the beginning.
You may be interested in Why does 2^1^2 in Excel result in 4 instead of 2?
1
Comments are not for extended discussion; this conversation has been moved to chat.
– DavidPostill♦
Dec 21 at 19:13
Please see above. All comments will be deleted if they are not part of the chat discussion.
– DavidPostill♦
Dec 21 at 19:32
PEDMAS that, Internet!
– Ron Jensen
Dec 23 at 0:31
add a comment |
A bit more succint than Rodolfo's Answer, you can use:
=-(A1^2)+(A1)
(Edit: I totally didn't see it was a self question/answer.)
1
Exactly! Depending on any language or application's precedence rules to be what you think they ought to be is a recipe for trouble.
– jamesqf
Dec 18 at 17:58
2
@jamesqf, but there must be some sense and limits to this. Nobody writes 2+(3*4). If a language has arithmetic operations and any precedence rules at all, it absolutely must support all the standard mathematical conventions. There is no excuse for such blunder in Excel.
– Zeus
Dec 18 at 23:39
4
@Zeus: Nobody? I probably would, especially if it was in a more complicated expression, or an if-condition. Of course I would write 3 *4 + 2 even if I were leaving out the parens.
– jamesqf
Dec 19 at 0:57
3
I long had a suspicion than such a habit of parens overuse comes from the (oh so prevalent) over-exposure to C (and its syntactic descendants). But C is by no means a good example of correct following of the math rules, including precedence (plus it has issues with macros). By contrast, people with initial exposure to more academic systems/languages strongly expect correct design and don't tend to make forward concessions 'just in case'. Hence genuine surprises like in the OP.
– Zeus
Dec 19 at 2:31
add a comment |
A leading -
is considered part of the first term.
=-3^2
is processed as (-3)^2 = 9
With a zero at the start it is instead treated as normal subtraction.
=0-3^2
is processed as 0 - 3^2 = -9
And if you have two operators, then the same thing will happen.
=0--3^2
is processed as 0 - (-3)^2 = -9
and
=0+-3^2
is processed as 0 + (-3)^2 = 9
1
Neatly written and clear, good job.
– Solar Mike
Dec 20 at 13:27
add a comment |
The expression = - A1^2 + A1
is specific to Excel so must follow Excels rules. Contrary to some other answers here, there is no correct order of precedence. There are merely different conventions adopted by different applications. For your reference, the order of precedence used by excel is:
: Range
<space> intersection
, union
- Negation
% Percentage
^ Exponential
* and / Multiplication and Division
+ and - Addition and Subtraction
& Concatenation
= < > <= >= <> Comparison
Which you can override using parentheses.
New contributor
8
Of course, Excel could have chosen + to mean multiplication and * to mean subtraction etc. and anyone needing to use Excel would have to know it. But it would have been wrong. The case in point is not the same level of wrong (or silly), but you definitely can argue that Excel defined got the priorities wrong.
– Mormegil
Dec 20 at 7:37
4
@Mormegil Well said! Once you try =1+2*2 and see that the answer is 5 and not 6. you are led to assume that Excel follows the rules of algebra. What is the point of misleading people?
– Rodolfo Oviedo
Dec 20 at 7:56
There IS a correct order of precedence, but computers have additional operations. The problem here is that computers use '-' for negation AND for subtraction where the person doing written algebra sees discriminates between negation and subtraction. For the computer to tell the difference it needs a set of rules. In '-x', the '-' is a unary operator (acts on one operand). In '1-x', the '-' is a binary operator. So, Excel (and other computer software) converts -x^2 to (-x)^2. The rest of the order of precedence still applies as we all learned it in grade school.
– Xalorous
Dec 21 at 13:10
2
@Xalorous: Yes,-
can be unary or binary. But that doesn't imply an order of operations. Other languages get this right: in Python, Ruby, Octave, Awk, and Haskell (the first five languages with an exponentiation operator that came to mind),-3 ** 2
always evaluates to-9
. Why? Because that is the correct answer.
– wchargin
Dec 22 at 10:27
1
@Xalorous the person doing written algebra uses the conventions of their audience combined with parentheses to reduce ambiguity. There is no correct order of precedence, and the rules of algebra are actually just conventions.
– Paul Smith
2 days ago
|
show 1 more comment
You can have it either way:
=-A1^2+A1
will return a 12, but:
=0-A1^2+A1
will return a -6
If you feel that returning 12 violates common sense; be aware that Google Sheets does the same thing.
1
It seems like the unary minus sign has "too high" precedence.
– Andreas Rejbrand
Dec 18 at 19:04
@AndreasRejbrand It appears to be unitary only if it directly follows the = sign...............=A1-A1^2
also returns -6
– Gary's Student
Dec 18 at 19:09
2
But in the example A1 - A1^2, the minus sign is obviously binary. (A unary operator is one that takes a single operand (like the unary minus sign in -5, or the factorial, the not sign etc.); a binary operator is one that takes two operands (like binary plus, minus, multiplication, union, etc.).) Notice that the minus sign can be unary even if it doesn't follow immediately after the equals sign: 5 + (-4 + 3).
– Andreas Rejbrand
Dec 18 at 19:15
@AndreasRejbrand I agree with you completely!
– Gary's Student
Dec 18 at 19:16
Just to defend Google's reputation, try the search box or bar to input mathematical expressions. You will get very results consistent to good mathematics, even better that from Matlab or Octave, for example, try 2^1^2.
– Rodolfo Oviedo
Dec 21 at 1:29
add a comment |
Because Excel is interpreting your equation as:
(-x)^2 + x
When you wanted:
-(x^2) + x
To prevent this sort of undesired behavior, I find the best practice is to make heavy use of parenthesis to define your own priority system, since negation is not the same as subtraction, and thus not covered by PEMDAS. An example would be like:
(-(x^2))+x
It might be overkill, but this is how I guarantee Excel behaves the way I want.
4
“since PEMDAS is not guaranteed in Excel” — No, it is absolutely guaranteed in Excel. Anything else would be madness. Whether or not unary negation (which is distinct from subtraction!) has precedence over exponentiation isn’t covered by PEMDAS.
– Konrad Rudolph
Dec 19 at 17:02
1
@routhken Heavy use of parentheses makes writing, editing and debugging cumbersome. To ease those tasks, I check the precedence of operators in the software I am working with and use only the necessary parentheses. In addition, I add spaces to improve readability.
– Rodolfo Oviedo
Dec 20 at 11:56
@KonradRudolph I edited my answer, thank you for the clarification.
– routhken
Dec 21 at 3:06
I'd prefer usingx - x^2
. This ensures the - is interpreted as the binary subtraction operator.
– Xalorous
Dec 21 at 13:00
@KonradRudolph I think the way to look at this is that spreadsheets and computer programming languages use PUEMDAS where unary operations are evaluated after parenthetical operations but before binary mathematical operations.
– Xalorous
Dec 21 at 13:02
add a comment |
Alternatively, you could just do
= A1 - A1^2
because -y + x = x-y
New contributor
This doesn't explain why that should work, and duplicates numerous earlier answers.
– fixer1234
2 days ago
@fixer1234 Literally no one else has said that, and I have given the mathematical reason for it?
– lioness99a
2 days ago
1. Many answers describe turning this into an explicit subtraction. 2. That's not the mathematical reason. The question is about why Excel does not behave that way. The answer is that the negative is not treated as subtraction by Excel.
– fixer1234
yesterday
They asked how to prevent the behaviour. I showed them the simplest way. And not a single answer states what I have...
– lioness99a
yesterday
add a comment |
The expression - A1^2
contains two operators, namely the unary negation operator -
and the binary exponentiation operator ^
. With the absence of any parenthesis, there could be two interpretations. Either:
-(A1^2)
or:
(-A1)^2
The first one says first do the exponentiation with operands A1
and 2
, and then do the negation on that.
The second one says first do the negation on operand A1
, and then use exponentiation on the result of that and 2
.
As was said in the comments to the question, Powers have higher priority than minus signs in any sane environment. Which means, it is best if a system assumes the first one.
However, Excel prefers the second one.
The lesson is, if you are unsure whether your environments is sane or not, include the parenthesis to be on the safe side. So write -(A1^2)
.
This duplicates the accepted answer and other earlier answers.
– fixer1234
2 days ago
add a comment |
This is not a problem with excel but with exponents and negatives. When you take a number and raise it to an even power, you cancel the negative sign.
-x^2 + x == (-x * -x) + x
x = 3 => (-3 * -3) + 3
== 9 + 3 => 12
You need to use parenthesis and multiple by -1
-1 * (x^2) + x
New contributor
10
This is not how signs work. It should be: x = 3 => -(3 * 3) + 3 = 6. Excel just doesn't use standard algebraic convention.
– henning
Dec 19 at 15:01
3
@henning As mentioned in another comment, while this isn’t the “standard” convention, it’s a convention, albeit not the most common one. To say that “this is not how signs work” is therefore quite incorrect. Rather, this isn’t how signs work in prevailing usage.
– Konrad Rudolph
Dec 19 at 17:01
2
@KonradRudolph Fair enough. I admit, I'm only aware of the prevailing usage, which, I believe, is what caused OP to be confused.
– henning
Dec 19 at 17:05
6
No, it absolutely is a problem with Excel. Excel uses the wrong rules for operator precedence.
– Dawood ibn Kareem
Dec 19 at 18:40
Please note the difference between-x^2
where x is 3 andx^2
where x is -3.-x^2+x
will never reach 12: wolframalpha.com/input/?i=-x%5E2%2Bx
– Thomas Weller
Dec 20 at 7:49
add a comment |
It is just a really simple maths.
Rule 1. Even multiplications of negative numbers, would output a positive result:
minus * minus = plus
minus * minus * minus = minus
minus * minus * minus * minus = plus
This is due to the fact, that minuses cancel each other in pairs.
Rule 2. The power of every number identifies that this number will be multiplied by itself a number of times.
(2)^n, where n=2 => 2*2 = 4
(-2)^n, where n=2 => (-2)*(-2) = 4
And if you can see Rule number 1..
(-3)^n, where n=3 => (-3) * (-3) * (-3) = 9 * (-3) = -27
Rule 3. Multiplication and Division have higher priority, than addition and subtraction.
3*5+2 = 15+2 = 17
3*(5+2) = 3*7 = 21
And there is the answer of your question:
Combining all 3 rules from before:
-x^2 + x, where x=3 => -3^2+3 = 9+3 = 12
My advice to you is to spend some time every year and keep refreshing the fundamental rules of mathematics.
It is in fact a skill you can maintain and stay on top of a large portion of the world, only by knowing basic maths.
New contributor
8
When you write "Combining all 3 rules from before: -x^2 + x, where x=3 => -3^2+3 = 9+3 = 12" you are assuming that -x^2 = (-x)^2. You have not stated that assumption before. Therefore your conclusion is unwarranted. Actually, if you read mathematics textbook or Wikipedia, you will notice that your implied assumption is not followed. Mathematics textbooks, scientific papers, etc. follow the assumption that -x^2 = -(x^2)
– Rodolfo Oviedo
Dec 20 at 12:31
rule 3 applies to binary operators like+-*/
, but not unary operators like-
or+
. Precedence of the power operator is higher than*
and/
but unary operators have even higher precedence
– phuclv
Dec 23 at 3:45
add a comment |
-x^2+x where x =3 This is an example of a quadratic equation
The equation can be written like this:
-3*-3+3
:Multiplication takes precedence over addition so result will be written as follows:
9 + 3 :Why =9 because a negative number x a negative number gives a positive result.
This can be verified using any calculator, slide rule, or any computer mathematics program
Final result 9 + 3 = 12
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1385570%2fwhy-does-x2x-for-x-3-in-excel-result-in-12-instead-of-6%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
11 Answers
11
active
oldest
votes
11 Answers
11
active
oldest
votes
active
oldest
votes
active
oldest
votes
Short answer
To solve this problem, just add a 0 before the equal sign
= 0 - A1^2 + A1
or add a couple of parenthesis to force the standard order of operations
= - (A1^2) + A1
or replace the minus sign by its common interpretation of multiplication by -1
= -1 * A1^2 + A1
Detailed explanation
Under Excel's conventions,
= - 3^2
equals (-3)^2 = 9, while
= 0-3^2
equals 0-9 = -9.
Why adding just a 0 changes the result?
Not preceded by a minuend, the minus sign in -3^2 is considered a negation operator, which is a unary operator (with only one argument) that changes the sign of the number (or expression) that follows. However, the minus sign in 0-3^2 is a subtraction operator, which is a binary operator that subtracts what follows -
from what precedes -
. According to Excel's conventions, the exponentiation operator ^
is computed after the negation operator and before the subtraction operator. See "Calculation operators and precedence in Excel", section "The order in which Excel performs operations in formulas".
The standard mathematical convention is that the exponentiation is computed before both negation and subtraction or, more simply stated, ^
is computed before -
. Shamefully, Excel chose different conventions from those of algebra rules, school textbooks, academic writing, scientific calculators, Lotus 1-2-3, Mathematica, Maple, computations oriented languages like Fortran or Matlab, MS Works, and... VBA (the language used to write Excel's macros). Unfortunately, Calc from LibreOffice and Google Sheets follow the same convention for compatibility with Excel. However, placing an expression in Google's search box or bar give excellent results. If you press enter, the order of computations will be given by using parentheses. A discussion where a mathematician kills the arguments of a "computer scientist" defending the precedence of negation over exponenciation: http://mathforum.org/library/drmath/view/69058.html
General Workarounds
If you want to compute
- anything ^ 2,
add a 0 before the equal sign
0 - anything ^ 2
or add a couple of parenthesis to force the standard order of operations
- ( anything ^ 2 )
or replace the minus sign by its common interpretation of multiplication by -1
-1 * anything ^ 2
A comment to another answer says that the only case you have to be aware of the the non-standard precedence rule is where a minus sign follows an equal sign (=-). However, there are other examples, like =exp(-x^2) or =(-2^2=2^2), where there isn't a minuend before the equal sign.
Thanks to @BruceWayne for proposing a short answer, which I wrote at the beginning.
You may be interested in Why does 2^1^2 in Excel result in 4 instead of 2?
1
Comments are not for extended discussion; this conversation has been moved to chat.
– DavidPostill♦
Dec 21 at 19:13
Please see above. All comments will be deleted if they are not part of the chat discussion.
– DavidPostill♦
Dec 21 at 19:32
PEDMAS that, Internet!
– Ron Jensen
Dec 23 at 0:31
add a comment |
Short answer
To solve this problem, just add a 0 before the equal sign
= 0 - A1^2 + A1
or add a couple of parenthesis to force the standard order of operations
= - (A1^2) + A1
or replace the minus sign by its common interpretation of multiplication by -1
= -1 * A1^2 + A1
Detailed explanation
Under Excel's conventions,
= - 3^2
equals (-3)^2 = 9, while
= 0-3^2
equals 0-9 = -9.
Why adding just a 0 changes the result?
Not preceded by a minuend, the minus sign in -3^2 is considered a negation operator, which is a unary operator (with only one argument) that changes the sign of the number (or expression) that follows. However, the minus sign in 0-3^2 is a subtraction operator, which is a binary operator that subtracts what follows -
from what precedes -
. According to Excel's conventions, the exponentiation operator ^
is computed after the negation operator and before the subtraction operator. See "Calculation operators and precedence in Excel", section "The order in which Excel performs operations in formulas".
The standard mathematical convention is that the exponentiation is computed before both negation and subtraction or, more simply stated, ^
is computed before -
. Shamefully, Excel chose different conventions from those of algebra rules, school textbooks, academic writing, scientific calculators, Lotus 1-2-3, Mathematica, Maple, computations oriented languages like Fortran or Matlab, MS Works, and... VBA (the language used to write Excel's macros). Unfortunately, Calc from LibreOffice and Google Sheets follow the same convention for compatibility with Excel. However, placing an expression in Google's search box or bar give excellent results. If you press enter, the order of computations will be given by using parentheses. A discussion where a mathematician kills the arguments of a "computer scientist" defending the precedence of negation over exponenciation: http://mathforum.org/library/drmath/view/69058.html
General Workarounds
If you want to compute
- anything ^ 2,
add a 0 before the equal sign
0 - anything ^ 2
or add a couple of parenthesis to force the standard order of operations
- ( anything ^ 2 )
or replace the minus sign by its common interpretation of multiplication by -1
-1 * anything ^ 2
A comment to another answer says that the only case you have to be aware of the the non-standard precedence rule is where a minus sign follows an equal sign (=-). However, there are other examples, like =exp(-x^2) or =(-2^2=2^2), where there isn't a minuend before the equal sign.
Thanks to @BruceWayne for proposing a short answer, which I wrote at the beginning.
You may be interested in Why does 2^1^2 in Excel result in 4 instead of 2?
1
Comments are not for extended discussion; this conversation has been moved to chat.
– DavidPostill♦
Dec 21 at 19:13
Please see above. All comments will be deleted if they are not part of the chat discussion.
– DavidPostill♦
Dec 21 at 19:32
PEDMAS that, Internet!
– Ron Jensen
Dec 23 at 0:31
add a comment |
Short answer
To solve this problem, just add a 0 before the equal sign
= 0 - A1^2 + A1
or add a couple of parenthesis to force the standard order of operations
= - (A1^2) + A1
or replace the minus sign by its common interpretation of multiplication by -1
= -1 * A1^2 + A1
Detailed explanation
Under Excel's conventions,
= - 3^2
equals (-3)^2 = 9, while
= 0-3^2
equals 0-9 = -9.
Why adding just a 0 changes the result?
Not preceded by a minuend, the minus sign in -3^2 is considered a negation operator, which is a unary operator (with only one argument) that changes the sign of the number (or expression) that follows. However, the minus sign in 0-3^2 is a subtraction operator, which is a binary operator that subtracts what follows -
from what precedes -
. According to Excel's conventions, the exponentiation operator ^
is computed after the negation operator and before the subtraction operator. See "Calculation operators and precedence in Excel", section "The order in which Excel performs operations in formulas".
The standard mathematical convention is that the exponentiation is computed before both negation and subtraction or, more simply stated, ^
is computed before -
. Shamefully, Excel chose different conventions from those of algebra rules, school textbooks, academic writing, scientific calculators, Lotus 1-2-3, Mathematica, Maple, computations oriented languages like Fortran or Matlab, MS Works, and... VBA (the language used to write Excel's macros). Unfortunately, Calc from LibreOffice and Google Sheets follow the same convention for compatibility with Excel. However, placing an expression in Google's search box or bar give excellent results. If you press enter, the order of computations will be given by using parentheses. A discussion where a mathematician kills the arguments of a "computer scientist" defending the precedence of negation over exponenciation: http://mathforum.org/library/drmath/view/69058.html
General Workarounds
If you want to compute
- anything ^ 2,
add a 0 before the equal sign
0 - anything ^ 2
or add a couple of parenthesis to force the standard order of operations
- ( anything ^ 2 )
or replace the minus sign by its common interpretation of multiplication by -1
-1 * anything ^ 2
A comment to another answer says that the only case you have to be aware of the the non-standard precedence rule is where a minus sign follows an equal sign (=-). However, there are other examples, like =exp(-x^2) or =(-2^2=2^2), where there isn't a minuend before the equal sign.
Thanks to @BruceWayne for proposing a short answer, which I wrote at the beginning.
You may be interested in Why does 2^1^2 in Excel result in 4 instead of 2?
Short answer
To solve this problem, just add a 0 before the equal sign
= 0 - A1^2 + A1
or add a couple of parenthesis to force the standard order of operations
= - (A1^2) + A1
or replace the minus sign by its common interpretation of multiplication by -1
= -1 * A1^2 + A1
Detailed explanation
Under Excel's conventions,
= - 3^2
equals (-3)^2 = 9, while
= 0-3^2
equals 0-9 = -9.
Why adding just a 0 changes the result?
Not preceded by a minuend, the minus sign in -3^2 is considered a negation operator, which is a unary operator (with only one argument) that changes the sign of the number (or expression) that follows. However, the minus sign in 0-3^2 is a subtraction operator, which is a binary operator that subtracts what follows -
from what precedes -
. According to Excel's conventions, the exponentiation operator ^
is computed after the negation operator and before the subtraction operator. See "Calculation operators and precedence in Excel", section "The order in which Excel performs operations in formulas".
The standard mathematical convention is that the exponentiation is computed before both negation and subtraction or, more simply stated, ^
is computed before -
. Shamefully, Excel chose different conventions from those of algebra rules, school textbooks, academic writing, scientific calculators, Lotus 1-2-3, Mathematica, Maple, computations oriented languages like Fortran or Matlab, MS Works, and... VBA (the language used to write Excel's macros). Unfortunately, Calc from LibreOffice and Google Sheets follow the same convention for compatibility with Excel. However, placing an expression in Google's search box or bar give excellent results. If you press enter, the order of computations will be given by using parentheses. A discussion where a mathematician kills the arguments of a "computer scientist" defending the precedence of negation over exponenciation: http://mathforum.org/library/drmath/view/69058.html
General Workarounds
If you want to compute
- anything ^ 2,
add a 0 before the equal sign
0 - anything ^ 2
or add a couple of parenthesis to force the standard order of operations
- ( anything ^ 2 )
or replace the minus sign by its common interpretation of multiplication by -1
-1 * anything ^ 2
A comment to another answer says that the only case you have to be aware of the the non-standard precedence rule is where a minus sign follows an equal sign (=-). However, there are other examples, like =exp(-x^2) or =(-2^2=2^2), where there isn't a minuend before the equal sign.
Thanks to @BruceWayne for proposing a short answer, which I wrote at the beginning.
You may be interested in Why does 2^1^2 in Excel result in 4 instead of 2?
edited Dec 21 at 19:29
answered Dec 18 at 13:52
Rodolfo Oviedo
1,4602315
1,4602315
1
Comments are not for extended discussion; this conversation has been moved to chat.
– DavidPostill♦
Dec 21 at 19:13
Please see above. All comments will be deleted if they are not part of the chat discussion.
– DavidPostill♦
Dec 21 at 19:32
PEDMAS that, Internet!
– Ron Jensen
Dec 23 at 0:31
add a comment |
1
Comments are not for extended discussion; this conversation has been moved to chat.
– DavidPostill♦
Dec 21 at 19:13
Please see above. All comments will be deleted if they are not part of the chat discussion.
– DavidPostill♦
Dec 21 at 19:32
PEDMAS that, Internet!
– Ron Jensen
Dec 23 at 0:31
1
1
Comments are not for extended discussion; this conversation has been moved to chat.
– DavidPostill♦
Dec 21 at 19:13
Comments are not for extended discussion; this conversation has been moved to chat.
– DavidPostill♦
Dec 21 at 19:13
Please see above. All comments will be deleted if they are not part of the chat discussion.
– DavidPostill♦
Dec 21 at 19:32
Please see above. All comments will be deleted if they are not part of the chat discussion.
– DavidPostill♦
Dec 21 at 19:32
PEDMAS that, Internet!
– Ron Jensen
Dec 23 at 0:31
PEDMAS that, Internet!
– Ron Jensen
Dec 23 at 0:31
add a comment |
A bit more succint than Rodolfo's Answer, you can use:
=-(A1^2)+(A1)
(Edit: I totally didn't see it was a self question/answer.)
1
Exactly! Depending on any language or application's precedence rules to be what you think they ought to be is a recipe for trouble.
– jamesqf
Dec 18 at 17:58
2
@jamesqf, but there must be some sense and limits to this. Nobody writes 2+(3*4). If a language has arithmetic operations and any precedence rules at all, it absolutely must support all the standard mathematical conventions. There is no excuse for such blunder in Excel.
– Zeus
Dec 18 at 23:39
4
@Zeus: Nobody? I probably would, especially if it was in a more complicated expression, or an if-condition. Of course I would write 3 *4 + 2 even if I were leaving out the parens.
– jamesqf
Dec 19 at 0:57
3
I long had a suspicion than such a habit of parens overuse comes from the (oh so prevalent) over-exposure to C (and its syntactic descendants). But C is by no means a good example of correct following of the math rules, including precedence (plus it has issues with macros). By contrast, people with initial exposure to more academic systems/languages strongly expect correct design and don't tend to make forward concessions 'just in case'. Hence genuine surprises like in the OP.
– Zeus
Dec 19 at 2:31
add a comment |
A bit more succint than Rodolfo's Answer, you can use:
=-(A1^2)+(A1)
(Edit: I totally didn't see it was a self question/answer.)
1
Exactly! Depending on any language or application's precedence rules to be what you think they ought to be is a recipe for trouble.
– jamesqf
Dec 18 at 17:58
2
@jamesqf, but there must be some sense and limits to this. Nobody writes 2+(3*4). If a language has arithmetic operations and any precedence rules at all, it absolutely must support all the standard mathematical conventions. There is no excuse for such blunder in Excel.
– Zeus
Dec 18 at 23:39
4
@Zeus: Nobody? I probably would, especially if it was in a more complicated expression, or an if-condition. Of course I would write 3 *4 + 2 even if I were leaving out the parens.
– jamesqf
Dec 19 at 0:57
3
I long had a suspicion than such a habit of parens overuse comes from the (oh so prevalent) over-exposure to C (and its syntactic descendants). But C is by no means a good example of correct following of the math rules, including precedence (plus it has issues with macros). By contrast, people with initial exposure to more academic systems/languages strongly expect correct design and don't tend to make forward concessions 'just in case'. Hence genuine surprises like in the OP.
– Zeus
Dec 19 at 2:31
add a comment |
A bit more succint than Rodolfo's Answer, you can use:
=-(A1^2)+(A1)
(Edit: I totally didn't see it was a self question/answer.)
A bit more succint than Rodolfo's Answer, you can use:
=-(A1^2)+(A1)
(Edit: I totally didn't see it was a self question/answer.)
edited Dec 18 at 17:59
answered Dec 18 at 15:21
BruceWayne
1,7871721
1,7871721
1
Exactly! Depending on any language or application's precedence rules to be what you think they ought to be is a recipe for trouble.
– jamesqf
Dec 18 at 17:58
2
@jamesqf, but there must be some sense and limits to this. Nobody writes 2+(3*4). If a language has arithmetic operations and any precedence rules at all, it absolutely must support all the standard mathematical conventions. There is no excuse for such blunder in Excel.
– Zeus
Dec 18 at 23:39
4
@Zeus: Nobody? I probably would, especially if it was in a more complicated expression, or an if-condition. Of course I would write 3 *4 + 2 even if I were leaving out the parens.
– jamesqf
Dec 19 at 0:57
3
I long had a suspicion than such a habit of parens overuse comes from the (oh so prevalent) over-exposure to C (and its syntactic descendants). But C is by no means a good example of correct following of the math rules, including precedence (plus it has issues with macros). By contrast, people with initial exposure to more academic systems/languages strongly expect correct design and don't tend to make forward concessions 'just in case'. Hence genuine surprises like in the OP.
– Zeus
Dec 19 at 2:31
add a comment |
1
Exactly! Depending on any language or application's precedence rules to be what you think they ought to be is a recipe for trouble.
– jamesqf
Dec 18 at 17:58
2
@jamesqf, but there must be some sense and limits to this. Nobody writes 2+(3*4). If a language has arithmetic operations and any precedence rules at all, it absolutely must support all the standard mathematical conventions. There is no excuse for such blunder in Excel.
– Zeus
Dec 18 at 23:39
4
@Zeus: Nobody? I probably would, especially if it was in a more complicated expression, or an if-condition. Of course I would write 3 *4 + 2 even if I were leaving out the parens.
– jamesqf
Dec 19 at 0:57
3
I long had a suspicion than such a habit of parens overuse comes from the (oh so prevalent) over-exposure to C (and its syntactic descendants). But C is by no means a good example of correct following of the math rules, including precedence (plus it has issues with macros). By contrast, people with initial exposure to more academic systems/languages strongly expect correct design and don't tend to make forward concessions 'just in case'. Hence genuine surprises like in the OP.
– Zeus
Dec 19 at 2:31
1
1
Exactly! Depending on any language or application's precedence rules to be what you think they ought to be is a recipe for trouble.
– jamesqf
Dec 18 at 17:58
Exactly! Depending on any language or application's precedence rules to be what you think they ought to be is a recipe for trouble.
– jamesqf
Dec 18 at 17:58
2
2
@jamesqf, but there must be some sense and limits to this. Nobody writes 2+(3*4). If a language has arithmetic operations and any precedence rules at all, it absolutely must support all the standard mathematical conventions. There is no excuse for such blunder in Excel.
– Zeus
Dec 18 at 23:39
@jamesqf, but there must be some sense and limits to this. Nobody writes 2+(3*4). If a language has arithmetic operations and any precedence rules at all, it absolutely must support all the standard mathematical conventions. There is no excuse for such blunder in Excel.
– Zeus
Dec 18 at 23:39
4
4
@Zeus: Nobody? I probably would, especially if it was in a more complicated expression, or an if-condition. Of course I would write 3 *4 + 2 even if I were leaving out the parens.
– jamesqf
Dec 19 at 0:57
@Zeus: Nobody? I probably would, especially if it was in a more complicated expression, or an if-condition. Of course I would write 3 *4 + 2 even if I were leaving out the parens.
– jamesqf
Dec 19 at 0:57
3
3
I long had a suspicion than such a habit of parens overuse comes from the (oh so prevalent) over-exposure to C (and its syntactic descendants). But C is by no means a good example of correct following of the math rules, including precedence (plus it has issues with macros). By contrast, people with initial exposure to more academic systems/languages strongly expect correct design and don't tend to make forward concessions 'just in case'. Hence genuine surprises like in the OP.
– Zeus
Dec 19 at 2:31
I long had a suspicion than such a habit of parens overuse comes from the (oh so prevalent) over-exposure to C (and its syntactic descendants). But C is by no means a good example of correct following of the math rules, including precedence (plus it has issues with macros). By contrast, people with initial exposure to more academic systems/languages strongly expect correct design and don't tend to make forward concessions 'just in case'. Hence genuine surprises like in the OP.
– Zeus
Dec 19 at 2:31
add a comment |
A leading -
is considered part of the first term.
=-3^2
is processed as (-3)^2 = 9
With a zero at the start it is instead treated as normal subtraction.
=0-3^2
is processed as 0 - 3^2 = -9
And if you have two operators, then the same thing will happen.
=0--3^2
is processed as 0 - (-3)^2 = -9
and
=0+-3^2
is processed as 0 + (-3)^2 = 9
1
Neatly written and clear, good job.
– Solar Mike
Dec 20 at 13:27
add a comment |
A leading -
is considered part of the first term.
=-3^2
is processed as (-3)^2 = 9
With a zero at the start it is instead treated as normal subtraction.
=0-3^2
is processed as 0 - 3^2 = -9
And if you have two operators, then the same thing will happen.
=0--3^2
is processed as 0 - (-3)^2 = -9
and
=0+-3^2
is processed as 0 + (-3)^2 = 9
1
Neatly written and clear, good job.
– Solar Mike
Dec 20 at 13:27
add a comment |
A leading -
is considered part of the first term.
=-3^2
is processed as (-3)^2 = 9
With a zero at the start it is instead treated as normal subtraction.
=0-3^2
is processed as 0 - 3^2 = -9
And if you have two operators, then the same thing will happen.
=0--3^2
is processed as 0 - (-3)^2 = -9
and
=0+-3^2
is processed as 0 + (-3)^2 = 9
A leading -
is considered part of the first term.
=-3^2
is processed as (-3)^2 = 9
With a zero at the start it is instead treated as normal subtraction.
=0-3^2
is processed as 0 - 3^2 = -9
And if you have two operators, then the same thing will happen.
=0--3^2
is processed as 0 - (-3)^2 = -9
and
=0+-3^2
is processed as 0 + (-3)^2 = 9
answered Dec 19 at 3:31
trapper
2492
2492
1
Neatly written and clear, good job.
– Solar Mike
Dec 20 at 13:27
add a comment |
1
Neatly written and clear, good job.
– Solar Mike
Dec 20 at 13:27
1
1
Neatly written and clear, good job.
– Solar Mike
Dec 20 at 13:27
Neatly written and clear, good job.
– Solar Mike
Dec 20 at 13:27
add a comment |
The expression = - A1^2 + A1
is specific to Excel so must follow Excels rules. Contrary to some other answers here, there is no correct order of precedence. There are merely different conventions adopted by different applications. For your reference, the order of precedence used by excel is:
: Range
<space> intersection
, union
- Negation
% Percentage
^ Exponential
* and / Multiplication and Division
+ and - Addition and Subtraction
& Concatenation
= < > <= >= <> Comparison
Which you can override using parentheses.
New contributor
8
Of course, Excel could have chosen + to mean multiplication and * to mean subtraction etc. and anyone needing to use Excel would have to know it. But it would have been wrong. The case in point is not the same level of wrong (or silly), but you definitely can argue that Excel defined got the priorities wrong.
– Mormegil
Dec 20 at 7:37
4
@Mormegil Well said! Once you try =1+2*2 and see that the answer is 5 and not 6. you are led to assume that Excel follows the rules of algebra. What is the point of misleading people?
– Rodolfo Oviedo
Dec 20 at 7:56
There IS a correct order of precedence, but computers have additional operations. The problem here is that computers use '-' for negation AND for subtraction where the person doing written algebra sees discriminates between negation and subtraction. For the computer to tell the difference it needs a set of rules. In '-x', the '-' is a unary operator (acts on one operand). In '1-x', the '-' is a binary operator. So, Excel (and other computer software) converts -x^2 to (-x)^2. The rest of the order of precedence still applies as we all learned it in grade school.
– Xalorous
Dec 21 at 13:10
2
@Xalorous: Yes,-
can be unary or binary. But that doesn't imply an order of operations. Other languages get this right: in Python, Ruby, Octave, Awk, and Haskell (the first five languages with an exponentiation operator that came to mind),-3 ** 2
always evaluates to-9
. Why? Because that is the correct answer.
– wchargin
Dec 22 at 10:27
1
@Xalorous the person doing written algebra uses the conventions of their audience combined with parentheses to reduce ambiguity. There is no correct order of precedence, and the rules of algebra are actually just conventions.
– Paul Smith
2 days ago
|
show 1 more comment
The expression = - A1^2 + A1
is specific to Excel so must follow Excels rules. Contrary to some other answers here, there is no correct order of precedence. There are merely different conventions adopted by different applications. For your reference, the order of precedence used by excel is:
: Range
<space> intersection
, union
- Negation
% Percentage
^ Exponential
* and / Multiplication and Division
+ and - Addition and Subtraction
& Concatenation
= < > <= >= <> Comparison
Which you can override using parentheses.
New contributor
8
Of course, Excel could have chosen + to mean multiplication and * to mean subtraction etc. and anyone needing to use Excel would have to know it. But it would have been wrong. The case in point is not the same level of wrong (or silly), but you definitely can argue that Excel defined got the priorities wrong.
– Mormegil
Dec 20 at 7:37
4
@Mormegil Well said! Once you try =1+2*2 and see that the answer is 5 and not 6. you are led to assume that Excel follows the rules of algebra. What is the point of misleading people?
– Rodolfo Oviedo
Dec 20 at 7:56
There IS a correct order of precedence, but computers have additional operations. The problem here is that computers use '-' for negation AND for subtraction where the person doing written algebra sees discriminates between negation and subtraction. For the computer to tell the difference it needs a set of rules. In '-x', the '-' is a unary operator (acts on one operand). In '1-x', the '-' is a binary operator. So, Excel (and other computer software) converts -x^2 to (-x)^2. The rest of the order of precedence still applies as we all learned it in grade school.
– Xalorous
Dec 21 at 13:10
2
@Xalorous: Yes,-
can be unary or binary. But that doesn't imply an order of operations. Other languages get this right: in Python, Ruby, Octave, Awk, and Haskell (the first five languages with an exponentiation operator that came to mind),-3 ** 2
always evaluates to-9
. Why? Because that is the correct answer.
– wchargin
Dec 22 at 10:27
1
@Xalorous the person doing written algebra uses the conventions of their audience combined with parentheses to reduce ambiguity. There is no correct order of precedence, and the rules of algebra are actually just conventions.
– Paul Smith
2 days ago
|
show 1 more comment
The expression = - A1^2 + A1
is specific to Excel so must follow Excels rules. Contrary to some other answers here, there is no correct order of precedence. There are merely different conventions adopted by different applications. For your reference, the order of precedence used by excel is:
: Range
<space> intersection
, union
- Negation
% Percentage
^ Exponential
* and / Multiplication and Division
+ and - Addition and Subtraction
& Concatenation
= < > <= >= <> Comparison
Which you can override using parentheses.
New contributor
The expression = - A1^2 + A1
is specific to Excel so must follow Excels rules. Contrary to some other answers here, there is no correct order of precedence. There are merely different conventions adopted by different applications. For your reference, the order of precedence used by excel is:
: Range
<space> intersection
, union
- Negation
% Percentage
^ Exponential
* and / Multiplication and Division
+ and - Addition and Subtraction
& Concatenation
= < > <= >= <> Comparison
Which you can override using parentheses.
New contributor
New contributor
answered Dec 19 at 23:04
Paul Smith
1472
1472
New contributor
New contributor
8
Of course, Excel could have chosen + to mean multiplication and * to mean subtraction etc. and anyone needing to use Excel would have to know it. But it would have been wrong. The case in point is not the same level of wrong (or silly), but you definitely can argue that Excel defined got the priorities wrong.
– Mormegil
Dec 20 at 7:37
4
@Mormegil Well said! Once you try =1+2*2 and see that the answer is 5 and not 6. you are led to assume that Excel follows the rules of algebra. What is the point of misleading people?
– Rodolfo Oviedo
Dec 20 at 7:56
There IS a correct order of precedence, but computers have additional operations. The problem here is that computers use '-' for negation AND for subtraction where the person doing written algebra sees discriminates between negation and subtraction. For the computer to tell the difference it needs a set of rules. In '-x', the '-' is a unary operator (acts on one operand). In '1-x', the '-' is a binary operator. So, Excel (and other computer software) converts -x^2 to (-x)^2. The rest of the order of precedence still applies as we all learned it in grade school.
– Xalorous
Dec 21 at 13:10
2
@Xalorous: Yes,-
can be unary or binary. But that doesn't imply an order of operations. Other languages get this right: in Python, Ruby, Octave, Awk, and Haskell (the first five languages with an exponentiation operator that came to mind),-3 ** 2
always evaluates to-9
. Why? Because that is the correct answer.
– wchargin
Dec 22 at 10:27
1
@Xalorous the person doing written algebra uses the conventions of their audience combined with parentheses to reduce ambiguity. There is no correct order of precedence, and the rules of algebra are actually just conventions.
– Paul Smith
2 days ago
|
show 1 more comment
8
Of course, Excel could have chosen + to mean multiplication and * to mean subtraction etc. and anyone needing to use Excel would have to know it. But it would have been wrong. The case in point is not the same level of wrong (or silly), but you definitely can argue that Excel defined got the priorities wrong.
– Mormegil
Dec 20 at 7:37
4
@Mormegil Well said! Once you try =1+2*2 and see that the answer is 5 and not 6. you are led to assume that Excel follows the rules of algebra. What is the point of misleading people?
– Rodolfo Oviedo
Dec 20 at 7:56
There IS a correct order of precedence, but computers have additional operations. The problem here is that computers use '-' for negation AND for subtraction where the person doing written algebra sees discriminates between negation and subtraction. For the computer to tell the difference it needs a set of rules. In '-x', the '-' is a unary operator (acts on one operand). In '1-x', the '-' is a binary operator. So, Excel (and other computer software) converts -x^2 to (-x)^2. The rest of the order of precedence still applies as we all learned it in grade school.
– Xalorous
Dec 21 at 13:10
2
@Xalorous: Yes,-
can be unary or binary. But that doesn't imply an order of operations. Other languages get this right: in Python, Ruby, Octave, Awk, and Haskell (the first five languages with an exponentiation operator that came to mind),-3 ** 2
always evaluates to-9
. Why? Because that is the correct answer.
– wchargin
Dec 22 at 10:27
1
@Xalorous the person doing written algebra uses the conventions of their audience combined with parentheses to reduce ambiguity. There is no correct order of precedence, and the rules of algebra are actually just conventions.
– Paul Smith
2 days ago
8
8
Of course, Excel could have chosen + to mean multiplication and * to mean subtraction etc. and anyone needing to use Excel would have to know it. But it would have been wrong. The case in point is not the same level of wrong (or silly), but you definitely can argue that Excel defined got the priorities wrong.
– Mormegil
Dec 20 at 7:37
Of course, Excel could have chosen + to mean multiplication and * to mean subtraction etc. and anyone needing to use Excel would have to know it. But it would have been wrong. The case in point is not the same level of wrong (or silly), but you definitely can argue that Excel defined got the priorities wrong.
– Mormegil
Dec 20 at 7:37
4
4
@Mormegil Well said! Once you try =1+2*2 and see that the answer is 5 and not 6. you are led to assume that Excel follows the rules of algebra. What is the point of misleading people?
– Rodolfo Oviedo
Dec 20 at 7:56
@Mormegil Well said! Once you try =1+2*2 and see that the answer is 5 and not 6. you are led to assume that Excel follows the rules of algebra. What is the point of misleading people?
– Rodolfo Oviedo
Dec 20 at 7:56
There IS a correct order of precedence, but computers have additional operations. The problem here is that computers use '-' for negation AND for subtraction where the person doing written algebra sees discriminates between negation and subtraction. For the computer to tell the difference it needs a set of rules. In '-x', the '-' is a unary operator (acts on one operand). In '1-x', the '-' is a binary operator. So, Excel (and other computer software) converts -x^2 to (-x)^2. The rest of the order of precedence still applies as we all learned it in grade school.
– Xalorous
Dec 21 at 13:10
There IS a correct order of precedence, but computers have additional operations. The problem here is that computers use '-' for negation AND for subtraction where the person doing written algebra sees discriminates between negation and subtraction. For the computer to tell the difference it needs a set of rules. In '-x', the '-' is a unary operator (acts on one operand). In '1-x', the '-' is a binary operator. So, Excel (and other computer software) converts -x^2 to (-x)^2. The rest of the order of precedence still applies as we all learned it in grade school.
– Xalorous
Dec 21 at 13:10
2
2
@Xalorous: Yes,
-
can be unary or binary. But that doesn't imply an order of operations. Other languages get this right: in Python, Ruby, Octave, Awk, and Haskell (the first five languages with an exponentiation operator that came to mind), -3 ** 2
always evaluates to -9
. Why? Because that is the correct answer.– wchargin
Dec 22 at 10:27
@Xalorous: Yes,
-
can be unary or binary. But that doesn't imply an order of operations. Other languages get this right: in Python, Ruby, Octave, Awk, and Haskell (the first five languages with an exponentiation operator that came to mind), -3 ** 2
always evaluates to -9
. Why? Because that is the correct answer.– wchargin
Dec 22 at 10:27
1
1
@Xalorous the person doing written algebra uses the conventions of their audience combined with parentheses to reduce ambiguity. There is no correct order of precedence, and the rules of algebra are actually just conventions.
– Paul Smith
2 days ago
@Xalorous the person doing written algebra uses the conventions of their audience combined with parentheses to reduce ambiguity. There is no correct order of precedence, and the rules of algebra are actually just conventions.
– Paul Smith
2 days ago
|
show 1 more comment
You can have it either way:
=-A1^2+A1
will return a 12, but:
=0-A1^2+A1
will return a -6
If you feel that returning 12 violates common sense; be aware that Google Sheets does the same thing.
1
It seems like the unary minus sign has "too high" precedence.
– Andreas Rejbrand
Dec 18 at 19:04
@AndreasRejbrand It appears to be unitary only if it directly follows the = sign...............=A1-A1^2
also returns -6
– Gary's Student
Dec 18 at 19:09
2
But in the example A1 - A1^2, the minus sign is obviously binary. (A unary operator is one that takes a single operand (like the unary minus sign in -5, or the factorial, the not sign etc.); a binary operator is one that takes two operands (like binary plus, minus, multiplication, union, etc.).) Notice that the minus sign can be unary even if it doesn't follow immediately after the equals sign: 5 + (-4 + 3).
– Andreas Rejbrand
Dec 18 at 19:15
@AndreasRejbrand I agree with you completely!
– Gary's Student
Dec 18 at 19:16
Just to defend Google's reputation, try the search box or bar to input mathematical expressions. You will get very results consistent to good mathematics, even better that from Matlab or Octave, for example, try 2^1^2.
– Rodolfo Oviedo
Dec 21 at 1:29
add a comment |
You can have it either way:
=-A1^2+A1
will return a 12, but:
=0-A1^2+A1
will return a -6
If you feel that returning 12 violates common sense; be aware that Google Sheets does the same thing.
1
It seems like the unary minus sign has "too high" precedence.
– Andreas Rejbrand
Dec 18 at 19:04
@AndreasRejbrand It appears to be unitary only if it directly follows the = sign...............=A1-A1^2
also returns -6
– Gary's Student
Dec 18 at 19:09
2
But in the example A1 - A1^2, the minus sign is obviously binary. (A unary operator is one that takes a single operand (like the unary minus sign in -5, or the factorial, the not sign etc.); a binary operator is one that takes two operands (like binary plus, minus, multiplication, union, etc.).) Notice that the minus sign can be unary even if it doesn't follow immediately after the equals sign: 5 + (-4 + 3).
– Andreas Rejbrand
Dec 18 at 19:15
@AndreasRejbrand I agree with you completely!
– Gary's Student
Dec 18 at 19:16
Just to defend Google's reputation, try the search box or bar to input mathematical expressions. You will get very results consistent to good mathematics, even better that from Matlab or Octave, for example, try 2^1^2.
– Rodolfo Oviedo
Dec 21 at 1:29
add a comment |
You can have it either way:
=-A1^2+A1
will return a 12, but:
=0-A1^2+A1
will return a -6
If you feel that returning 12 violates common sense; be aware that Google Sheets does the same thing.
You can have it either way:
=-A1^2+A1
will return a 12, but:
=0-A1^2+A1
will return a -6
If you feel that returning 12 violates common sense; be aware that Google Sheets does the same thing.
edited Dec 20 at 13:37
answered Dec 18 at 19:03
Gary's Student
13.3k31729
13.3k31729
1
It seems like the unary minus sign has "too high" precedence.
– Andreas Rejbrand
Dec 18 at 19:04
@AndreasRejbrand It appears to be unitary only if it directly follows the = sign...............=A1-A1^2
also returns -6
– Gary's Student
Dec 18 at 19:09
2
But in the example A1 - A1^2, the minus sign is obviously binary. (A unary operator is one that takes a single operand (like the unary minus sign in -5, or the factorial, the not sign etc.); a binary operator is one that takes two operands (like binary plus, minus, multiplication, union, etc.).) Notice that the minus sign can be unary even if it doesn't follow immediately after the equals sign: 5 + (-4 + 3).
– Andreas Rejbrand
Dec 18 at 19:15
@AndreasRejbrand I agree with you completely!
– Gary's Student
Dec 18 at 19:16
Just to defend Google's reputation, try the search box or bar to input mathematical expressions. You will get very results consistent to good mathematics, even better that from Matlab or Octave, for example, try 2^1^2.
– Rodolfo Oviedo
Dec 21 at 1:29
add a comment |
1
It seems like the unary minus sign has "too high" precedence.
– Andreas Rejbrand
Dec 18 at 19:04
@AndreasRejbrand It appears to be unitary only if it directly follows the = sign...............=A1-A1^2
also returns -6
– Gary's Student
Dec 18 at 19:09
2
But in the example A1 - A1^2, the minus sign is obviously binary. (A unary operator is one that takes a single operand (like the unary minus sign in -5, or the factorial, the not sign etc.); a binary operator is one that takes two operands (like binary plus, minus, multiplication, union, etc.).) Notice that the minus sign can be unary even if it doesn't follow immediately after the equals sign: 5 + (-4 + 3).
– Andreas Rejbrand
Dec 18 at 19:15
@AndreasRejbrand I agree with you completely!
– Gary's Student
Dec 18 at 19:16
Just to defend Google's reputation, try the search box or bar to input mathematical expressions. You will get very results consistent to good mathematics, even better that from Matlab or Octave, for example, try 2^1^2.
– Rodolfo Oviedo
Dec 21 at 1:29
1
1
It seems like the unary minus sign has "too high" precedence.
– Andreas Rejbrand
Dec 18 at 19:04
It seems like the unary minus sign has "too high" precedence.
– Andreas Rejbrand
Dec 18 at 19:04
@AndreasRejbrand It appears to be unitary only if it directly follows the = sign...............
=A1-A1^2
also returns -6– Gary's Student
Dec 18 at 19:09
@AndreasRejbrand It appears to be unitary only if it directly follows the = sign...............
=A1-A1^2
also returns -6– Gary's Student
Dec 18 at 19:09
2
2
But in the example A1 - A1^2, the minus sign is obviously binary. (A unary operator is one that takes a single operand (like the unary minus sign in -5, or the factorial, the not sign etc.); a binary operator is one that takes two operands (like binary plus, minus, multiplication, union, etc.).) Notice that the minus sign can be unary even if it doesn't follow immediately after the equals sign: 5 + (-4 + 3).
– Andreas Rejbrand
Dec 18 at 19:15
But in the example A1 - A1^2, the minus sign is obviously binary. (A unary operator is one that takes a single operand (like the unary minus sign in -5, or the factorial, the not sign etc.); a binary operator is one that takes two operands (like binary plus, minus, multiplication, union, etc.).) Notice that the minus sign can be unary even if it doesn't follow immediately after the equals sign: 5 + (-4 + 3).
– Andreas Rejbrand
Dec 18 at 19:15
@AndreasRejbrand I agree with you completely!
– Gary's Student
Dec 18 at 19:16
@AndreasRejbrand I agree with you completely!
– Gary's Student
Dec 18 at 19:16
Just to defend Google's reputation, try the search box or bar to input mathematical expressions. You will get very results consistent to good mathematics, even better that from Matlab or Octave, for example, try 2^1^2.
– Rodolfo Oviedo
Dec 21 at 1:29
Just to defend Google's reputation, try the search box or bar to input mathematical expressions. You will get very results consistent to good mathematics, even better that from Matlab or Octave, for example, try 2^1^2.
– Rodolfo Oviedo
Dec 21 at 1:29
add a comment |
Because Excel is interpreting your equation as:
(-x)^2 + x
When you wanted:
-(x^2) + x
To prevent this sort of undesired behavior, I find the best practice is to make heavy use of parenthesis to define your own priority system, since negation is not the same as subtraction, and thus not covered by PEMDAS. An example would be like:
(-(x^2))+x
It might be overkill, but this is how I guarantee Excel behaves the way I want.
4
“since PEMDAS is not guaranteed in Excel” — No, it is absolutely guaranteed in Excel. Anything else would be madness. Whether or not unary negation (which is distinct from subtraction!) has precedence over exponentiation isn’t covered by PEMDAS.
– Konrad Rudolph
Dec 19 at 17:02
1
@routhken Heavy use of parentheses makes writing, editing and debugging cumbersome. To ease those tasks, I check the precedence of operators in the software I am working with and use only the necessary parentheses. In addition, I add spaces to improve readability.
– Rodolfo Oviedo
Dec 20 at 11:56
@KonradRudolph I edited my answer, thank you for the clarification.
– routhken
Dec 21 at 3:06
I'd prefer usingx - x^2
. This ensures the - is interpreted as the binary subtraction operator.
– Xalorous
Dec 21 at 13:00
@KonradRudolph I think the way to look at this is that spreadsheets and computer programming languages use PUEMDAS where unary operations are evaluated after parenthetical operations but before binary mathematical operations.
– Xalorous
Dec 21 at 13:02
add a comment |
Because Excel is interpreting your equation as:
(-x)^2 + x
When you wanted:
-(x^2) + x
To prevent this sort of undesired behavior, I find the best practice is to make heavy use of parenthesis to define your own priority system, since negation is not the same as subtraction, and thus not covered by PEMDAS. An example would be like:
(-(x^2))+x
It might be overkill, but this is how I guarantee Excel behaves the way I want.
4
“since PEMDAS is not guaranteed in Excel” — No, it is absolutely guaranteed in Excel. Anything else would be madness. Whether or not unary negation (which is distinct from subtraction!) has precedence over exponentiation isn’t covered by PEMDAS.
– Konrad Rudolph
Dec 19 at 17:02
1
@routhken Heavy use of parentheses makes writing, editing and debugging cumbersome. To ease those tasks, I check the precedence of operators in the software I am working with and use only the necessary parentheses. In addition, I add spaces to improve readability.
– Rodolfo Oviedo
Dec 20 at 11:56
@KonradRudolph I edited my answer, thank you for the clarification.
– routhken
Dec 21 at 3:06
I'd prefer usingx - x^2
. This ensures the - is interpreted as the binary subtraction operator.
– Xalorous
Dec 21 at 13:00
@KonradRudolph I think the way to look at this is that spreadsheets and computer programming languages use PUEMDAS where unary operations are evaluated after parenthetical operations but before binary mathematical operations.
– Xalorous
Dec 21 at 13:02
add a comment |
Because Excel is interpreting your equation as:
(-x)^2 + x
When you wanted:
-(x^2) + x
To prevent this sort of undesired behavior, I find the best practice is to make heavy use of parenthesis to define your own priority system, since negation is not the same as subtraction, and thus not covered by PEMDAS. An example would be like:
(-(x^2))+x
It might be overkill, but this is how I guarantee Excel behaves the way I want.
Because Excel is interpreting your equation as:
(-x)^2 + x
When you wanted:
-(x^2) + x
To prevent this sort of undesired behavior, I find the best practice is to make heavy use of parenthesis to define your own priority system, since negation is not the same as subtraction, and thus not covered by PEMDAS. An example would be like:
(-(x^2))+x
It might be overkill, but this is how I guarantee Excel behaves the way I want.
edited Dec 21 at 3:05
answered Dec 19 at 8:44
routhken
392
392
4
“since PEMDAS is not guaranteed in Excel” — No, it is absolutely guaranteed in Excel. Anything else would be madness. Whether or not unary negation (which is distinct from subtraction!) has precedence over exponentiation isn’t covered by PEMDAS.
– Konrad Rudolph
Dec 19 at 17:02
1
@routhken Heavy use of parentheses makes writing, editing and debugging cumbersome. To ease those tasks, I check the precedence of operators in the software I am working with and use only the necessary parentheses. In addition, I add spaces to improve readability.
– Rodolfo Oviedo
Dec 20 at 11:56
@KonradRudolph I edited my answer, thank you for the clarification.
– routhken
Dec 21 at 3:06
I'd prefer usingx - x^2
. This ensures the - is interpreted as the binary subtraction operator.
– Xalorous
Dec 21 at 13:00
@KonradRudolph I think the way to look at this is that spreadsheets and computer programming languages use PUEMDAS where unary operations are evaluated after parenthetical operations but before binary mathematical operations.
– Xalorous
Dec 21 at 13:02
add a comment |
4
“since PEMDAS is not guaranteed in Excel” — No, it is absolutely guaranteed in Excel. Anything else would be madness. Whether or not unary negation (which is distinct from subtraction!) has precedence over exponentiation isn’t covered by PEMDAS.
– Konrad Rudolph
Dec 19 at 17:02
1
@routhken Heavy use of parentheses makes writing, editing and debugging cumbersome. To ease those tasks, I check the precedence of operators in the software I am working with and use only the necessary parentheses. In addition, I add spaces to improve readability.
– Rodolfo Oviedo
Dec 20 at 11:56
@KonradRudolph I edited my answer, thank you for the clarification.
– routhken
Dec 21 at 3:06
I'd prefer usingx - x^2
. This ensures the - is interpreted as the binary subtraction operator.
– Xalorous
Dec 21 at 13:00
@KonradRudolph I think the way to look at this is that spreadsheets and computer programming languages use PUEMDAS where unary operations are evaluated after parenthetical operations but before binary mathematical operations.
– Xalorous
Dec 21 at 13:02
4
4
“since PEMDAS is not guaranteed in Excel” — No, it is absolutely guaranteed in Excel. Anything else would be madness. Whether or not unary negation (which is distinct from subtraction!) has precedence over exponentiation isn’t covered by PEMDAS.
– Konrad Rudolph
Dec 19 at 17:02
“since PEMDAS is not guaranteed in Excel” — No, it is absolutely guaranteed in Excel. Anything else would be madness. Whether or not unary negation (which is distinct from subtraction!) has precedence over exponentiation isn’t covered by PEMDAS.
– Konrad Rudolph
Dec 19 at 17:02
1
1
@routhken Heavy use of parentheses makes writing, editing and debugging cumbersome. To ease those tasks, I check the precedence of operators in the software I am working with and use only the necessary parentheses. In addition, I add spaces to improve readability.
– Rodolfo Oviedo
Dec 20 at 11:56
@routhken Heavy use of parentheses makes writing, editing and debugging cumbersome. To ease those tasks, I check the precedence of operators in the software I am working with and use only the necessary parentheses. In addition, I add spaces to improve readability.
– Rodolfo Oviedo
Dec 20 at 11:56
@KonradRudolph I edited my answer, thank you for the clarification.
– routhken
Dec 21 at 3:06
@KonradRudolph I edited my answer, thank you for the clarification.
– routhken
Dec 21 at 3:06
I'd prefer using
x - x^2
. This ensures the - is interpreted as the binary subtraction operator.– Xalorous
Dec 21 at 13:00
I'd prefer using
x - x^2
. This ensures the - is interpreted as the binary subtraction operator.– Xalorous
Dec 21 at 13:00
@KonradRudolph I think the way to look at this is that spreadsheets and computer programming languages use PUEMDAS where unary operations are evaluated after parenthetical operations but before binary mathematical operations.
– Xalorous
Dec 21 at 13:02
@KonradRudolph I think the way to look at this is that spreadsheets and computer programming languages use PUEMDAS where unary operations are evaluated after parenthetical operations but before binary mathematical operations.
– Xalorous
Dec 21 at 13:02
add a comment |
Alternatively, you could just do
= A1 - A1^2
because -y + x = x-y
New contributor
This doesn't explain why that should work, and duplicates numerous earlier answers.
– fixer1234
2 days ago
@fixer1234 Literally no one else has said that, and I have given the mathematical reason for it?
– lioness99a
2 days ago
1. Many answers describe turning this into an explicit subtraction. 2. That's not the mathematical reason. The question is about why Excel does not behave that way. The answer is that the negative is not treated as subtraction by Excel.
– fixer1234
yesterday
They asked how to prevent the behaviour. I showed them the simplest way. And not a single answer states what I have...
– lioness99a
yesterday
add a comment |
Alternatively, you could just do
= A1 - A1^2
because -y + x = x-y
New contributor
This doesn't explain why that should work, and duplicates numerous earlier answers.
– fixer1234
2 days ago
@fixer1234 Literally no one else has said that, and I have given the mathematical reason for it?
– lioness99a
2 days ago
1. Many answers describe turning this into an explicit subtraction. 2. That's not the mathematical reason. The question is about why Excel does not behave that way. The answer is that the negative is not treated as subtraction by Excel.
– fixer1234
yesterday
They asked how to prevent the behaviour. I showed them the simplest way. And not a single answer states what I have...
– lioness99a
yesterday
add a comment |
Alternatively, you could just do
= A1 - A1^2
because -y + x = x-y
New contributor
Alternatively, you could just do
= A1 - A1^2
because -y + x = x-y
New contributor
New contributor
answered Dec 21 at 11:01
lioness99a
1212
1212
New contributor
New contributor
This doesn't explain why that should work, and duplicates numerous earlier answers.
– fixer1234
2 days ago
@fixer1234 Literally no one else has said that, and I have given the mathematical reason for it?
– lioness99a
2 days ago
1. Many answers describe turning this into an explicit subtraction. 2. That's not the mathematical reason. The question is about why Excel does not behave that way. The answer is that the negative is not treated as subtraction by Excel.
– fixer1234
yesterday
They asked how to prevent the behaviour. I showed them the simplest way. And not a single answer states what I have...
– lioness99a
yesterday
add a comment |
This doesn't explain why that should work, and duplicates numerous earlier answers.
– fixer1234
2 days ago
@fixer1234 Literally no one else has said that, and I have given the mathematical reason for it?
– lioness99a
2 days ago
1. Many answers describe turning this into an explicit subtraction. 2. That's not the mathematical reason. The question is about why Excel does not behave that way. The answer is that the negative is not treated as subtraction by Excel.
– fixer1234
yesterday
They asked how to prevent the behaviour. I showed them the simplest way. And not a single answer states what I have...
– lioness99a
yesterday
This doesn't explain why that should work, and duplicates numerous earlier answers.
– fixer1234
2 days ago
This doesn't explain why that should work, and duplicates numerous earlier answers.
– fixer1234
2 days ago
@fixer1234 Literally no one else has said that, and I have given the mathematical reason for it?
– lioness99a
2 days ago
@fixer1234 Literally no one else has said that, and I have given the mathematical reason for it?
– lioness99a
2 days ago
1. Many answers describe turning this into an explicit subtraction. 2. That's not the mathematical reason. The question is about why Excel does not behave that way. The answer is that the negative is not treated as subtraction by Excel.
– fixer1234
yesterday
1. Many answers describe turning this into an explicit subtraction. 2. That's not the mathematical reason. The question is about why Excel does not behave that way. The answer is that the negative is not treated as subtraction by Excel.
– fixer1234
yesterday
They asked how to prevent the behaviour. I showed them the simplest way. And not a single answer states what I have...
– lioness99a
yesterday
They asked how to prevent the behaviour. I showed them the simplest way. And not a single answer states what I have...
– lioness99a
yesterday
add a comment |
The expression - A1^2
contains two operators, namely the unary negation operator -
and the binary exponentiation operator ^
. With the absence of any parenthesis, there could be two interpretations. Either:
-(A1^2)
or:
(-A1)^2
The first one says first do the exponentiation with operands A1
and 2
, and then do the negation on that.
The second one says first do the negation on operand A1
, and then use exponentiation on the result of that and 2
.
As was said in the comments to the question, Powers have higher priority than minus signs in any sane environment. Which means, it is best if a system assumes the first one.
However, Excel prefers the second one.
The lesson is, if you are unsure whether your environments is sane or not, include the parenthesis to be on the safe side. So write -(A1^2)
.
This duplicates the accepted answer and other earlier answers.
– fixer1234
2 days ago
add a comment |
The expression - A1^2
contains two operators, namely the unary negation operator -
and the binary exponentiation operator ^
. With the absence of any parenthesis, there could be two interpretations. Either:
-(A1^2)
or:
(-A1)^2
The first one says first do the exponentiation with operands A1
and 2
, and then do the negation on that.
The second one says first do the negation on operand A1
, and then use exponentiation on the result of that and 2
.
As was said in the comments to the question, Powers have higher priority than minus signs in any sane environment. Which means, it is best if a system assumes the first one.
However, Excel prefers the second one.
The lesson is, if you are unsure whether your environments is sane or not, include the parenthesis to be on the safe side. So write -(A1^2)
.
This duplicates the accepted answer and other earlier answers.
– fixer1234
2 days ago
add a comment |
The expression - A1^2
contains two operators, namely the unary negation operator -
and the binary exponentiation operator ^
. With the absence of any parenthesis, there could be two interpretations. Either:
-(A1^2)
or:
(-A1)^2
The first one says first do the exponentiation with operands A1
and 2
, and then do the negation on that.
The second one says first do the negation on operand A1
, and then use exponentiation on the result of that and 2
.
As was said in the comments to the question, Powers have higher priority than minus signs in any sane environment. Which means, it is best if a system assumes the first one.
However, Excel prefers the second one.
The lesson is, if you are unsure whether your environments is sane or not, include the parenthesis to be on the safe side. So write -(A1^2)
.
The expression - A1^2
contains two operators, namely the unary negation operator -
and the binary exponentiation operator ^
. With the absence of any parenthesis, there could be two interpretations. Either:
-(A1^2)
or:
(-A1)^2
The first one says first do the exponentiation with operands A1
and 2
, and then do the negation on that.
The second one says first do the negation on operand A1
, and then use exponentiation on the result of that and 2
.
As was said in the comments to the question, Powers have higher priority than minus signs in any sane environment. Which means, it is best if a system assumes the first one.
However, Excel prefers the second one.
The lesson is, if you are unsure whether your environments is sane or not, include the parenthesis to be on the safe side. So write -(A1^2)
.
answered Dec 22 at 17:41
Jeppe Stig Nielsen
35926
35926
This duplicates the accepted answer and other earlier answers.
– fixer1234
2 days ago
add a comment |
This duplicates the accepted answer and other earlier answers.
– fixer1234
2 days ago
This duplicates the accepted answer and other earlier answers.
– fixer1234
2 days ago
This duplicates the accepted answer and other earlier answers.
– fixer1234
2 days ago
add a comment |
This is not a problem with excel but with exponents and negatives. When you take a number and raise it to an even power, you cancel the negative sign.
-x^2 + x == (-x * -x) + x
x = 3 => (-3 * -3) + 3
== 9 + 3 => 12
You need to use parenthesis and multiple by -1
-1 * (x^2) + x
New contributor
10
This is not how signs work. It should be: x = 3 => -(3 * 3) + 3 = 6. Excel just doesn't use standard algebraic convention.
– henning
Dec 19 at 15:01
3
@henning As mentioned in another comment, while this isn’t the “standard” convention, it’s a convention, albeit not the most common one. To say that “this is not how signs work” is therefore quite incorrect. Rather, this isn’t how signs work in prevailing usage.
– Konrad Rudolph
Dec 19 at 17:01
2
@KonradRudolph Fair enough. I admit, I'm only aware of the prevailing usage, which, I believe, is what caused OP to be confused.
– henning
Dec 19 at 17:05
6
No, it absolutely is a problem with Excel. Excel uses the wrong rules for operator precedence.
– Dawood ibn Kareem
Dec 19 at 18:40
Please note the difference between-x^2
where x is 3 andx^2
where x is -3.-x^2+x
will never reach 12: wolframalpha.com/input/?i=-x%5E2%2Bx
– Thomas Weller
Dec 20 at 7:49
add a comment |
This is not a problem with excel but with exponents and negatives. When you take a number and raise it to an even power, you cancel the negative sign.
-x^2 + x == (-x * -x) + x
x = 3 => (-3 * -3) + 3
== 9 + 3 => 12
You need to use parenthesis and multiple by -1
-1 * (x^2) + x
New contributor
10
This is not how signs work. It should be: x = 3 => -(3 * 3) + 3 = 6. Excel just doesn't use standard algebraic convention.
– henning
Dec 19 at 15:01
3
@henning As mentioned in another comment, while this isn’t the “standard” convention, it’s a convention, albeit not the most common one. To say that “this is not how signs work” is therefore quite incorrect. Rather, this isn’t how signs work in prevailing usage.
– Konrad Rudolph
Dec 19 at 17:01
2
@KonradRudolph Fair enough. I admit, I'm only aware of the prevailing usage, which, I believe, is what caused OP to be confused.
– henning
Dec 19 at 17:05
6
No, it absolutely is a problem with Excel. Excel uses the wrong rules for operator precedence.
– Dawood ibn Kareem
Dec 19 at 18:40
Please note the difference between-x^2
where x is 3 andx^2
where x is -3.-x^2+x
will never reach 12: wolframalpha.com/input/?i=-x%5E2%2Bx
– Thomas Weller
Dec 20 at 7:49
add a comment |
This is not a problem with excel but with exponents and negatives. When you take a number and raise it to an even power, you cancel the negative sign.
-x^2 + x == (-x * -x) + x
x = 3 => (-3 * -3) + 3
== 9 + 3 => 12
You need to use parenthesis and multiple by -1
-1 * (x^2) + x
New contributor
This is not a problem with excel but with exponents and negatives. When you take a number and raise it to an even power, you cancel the negative sign.
-x^2 + x == (-x * -x) + x
x = 3 => (-3 * -3) + 3
== 9 + 3 => 12
You need to use parenthesis and multiple by -1
-1 * (x^2) + x
New contributor
New contributor
answered Dec 19 at 14:58
nitrodmr
11
11
New contributor
New contributor
10
This is not how signs work. It should be: x = 3 => -(3 * 3) + 3 = 6. Excel just doesn't use standard algebraic convention.
– henning
Dec 19 at 15:01
3
@henning As mentioned in another comment, while this isn’t the “standard” convention, it’s a convention, albeit not the most common one. To say that “this is not how signs work” is therefore quite incorrect. Rather, this isn’t how signs work in prevailing usage.
– Konrad Rudolph
Dec 19 at 17:01
2
@KonradRudolph Fair enough. I admit, I'm only aware of the prevailing usage, which, I believe, is what caused OP to be confused.
– henning
Dec 19 at 17:05
6
No, it absolutely is a problem with Excel. Excel uses the wrong rules for operator precedence.
– Dawood ibn Kareem
Dec 19 at 18:40
Please note the difference between-x^2
where x is 3 andx^2
where x is -3.-x^2+x
will never reach 12: wolframalpha.com/input/?i=-x%5E2%2Bx
– Thomas Weller
Dec 20 at 7:49
add a comment |
10
This is not how signs work. It should be: x = 3 => -(3 * 3) + 3 = 6. Excel just doesn't use standard algebraic convention.
– henning
Dec 19 at 15:01
3
@henning As mentioned in another comment, while this isn’t the “standard” convention, it’s a convention, albeit not the most common one. To say that “this is not how signs work” is therefore quite incorrect. Rather, this isn’t how signs work in prevailing usage.
– Konrad Rudolph
Dec 19 at 17:01
2
@KonradRudolph Fair enough. I admit, I'm only aware of the prevailing usage, which, I believe, is what caused OP to be confused.
– henning
Dec 19 at 17:05
6
No, it absolutely is a problem with Excel. Excel uses the wrong rules for operator precedence.
– Dawood ibn Kareem
Dec 19 at 18:40
Please note the difference between-x^2
where x is 3 andx^2
where x is -3.-x^2+x
will never reach 12: wolframalpha.com/input/?i=-x%5E2%2Bx
– Thomas Weller
Dec 20 at 7:49
10
10
This is not how signs work. It should be: x = 3 => -(3 * 3) + 3 = 6. Excel just doesn't use standard algebraic convention.
– henning
Dec 19 at 15:01
This is not how signs work. It should be: x = 3 => -(3 * 3) + 3 = 6. Excel just doesn't use standard algebraic convention.
– henning
Dec 19 at 15:01
3
3
@henning As mentioned in another comment, while this isn’t the “standard” convention, it’s a convention, albeit not the most common one. To say that “this is not how signs work” is therefore quite incorrect. Rather, this isn’t how signs work in prevailing usage.
– Konrad Rudolph
Dec 19 at 17:01
@henning As mentioned in another comment, while this isn’t the “standard” convention, it’s a convention, albeit not the most common one. To say that “this is not how signs work” is therefore quite incorrect. Rather, this isn’t how signs work in prevailing usage.
– Konrad Rudolph
Dec 19 at 17:01
2
2
@KonradRudolph Fair enough. I admit, I'm only aware of the prevailing usage, which, I believe, is what caused OP to be confused.
– henning
Dec 19 at 17:05
@KonradRudolph Fair enough. I admit, I'm only aware of the prevailing usage, which, I believe, is what caused OP to be confused.
– henning
Dec 19 at 17:05
6
6
No, it absolutely is a problem with Excel. Excel uses the wrong rules for operator precedence.
– Dawood ibn Kareem
Dec 19 at 18:40
No, it absolutely is a problem with Excel. Excel uses the wrong rules for operator precedence.
– Dawood ibn Kareem
Dec 19 at 18:40
Please note the difference between
-x^2
where x is 3 and x^2
where x is -3. -x^2+x
will never reach 12: wolframalpha.com/input/?i=-x%5E2%2Bx– Thomas Weller
Dec 20 at 7:49
Please note the difference between
-x^2
where x is 3 and x^2
where x is -3. -x^2+x
will never reach 12: wolframalpha.com/input/?i=-x%5E2%2Bx– Thomas Weller
Dec 20 at 7:49
add a comment |
It is just a really simple maths.
Rule 1. Even multiplications of negative numbers, would output a positive result:
minus * minus = plus
minus * minus * minus = minus
minus * minus * minus * minus = plus
This is due to the fact, that minuses cancel each other in pairs.
Rule 2. The power of every number identifies that this number will be multiplied by itself a number of times.
(2)^n, where n=2 => 2*2 = 4
(-2)^n, where n=2 => (-2)*(-2) = 4
And if you can see Rule number 1..
(-3)^n, where n=3 => (-3) * (-3) * (-3) = 9 * (-3) = -27
Rule 3. Multiplication and Division have higher priority, than addition and subtraction.
3*5+2 = 15+2 = 17
3*(5+2) = 3*7 = 21
And there is the answer of your question:
Combining all 3 rules from before:
-x^2 + x, where x=3 => -3^2+3 = 9+3 = 12
My advice to you is to spend some time every year and keep refreshing the fundamental rules of mathematics.
It is in fact a skill you can maintain and stay on top of a large portion of the world, only by knowing basic maths.
New contributor
8
When you write "Combining all 3 rules from before: -x^2 + x, where x=3 => -3^2+3 = 9+3 = 12" you are assuming that -x^2 = (-x)^2. You have not stated that assumption before. Therefore your conclusion is unwarranted. Actually, if you read mathematics textbook or Wikipedia, you will notice that your implied assumption is not followed. Mathematics textbooks, scientific papers, etc. follow the assumption that -x^2 = -(x^2)
– Rodolfo Oviedo
Dec 20 at 12:31
rule 3 applies to binary operators like+-*/
, but not unary operators like-
or+
. Precedence of the power operator is higher than*
and/
but unary operators have even higher precedence
– phuclv
Dec 23 at 3:45
add a comment |
It is just a really simple maths.
Rule 1. Even multiplications of negative numbers, would output a positive result:
minus * minus = plus
minus * minus * minus = minus
minus * minus * minus * minus = plus
This is due to the fact, that minuses cancel each other in pairs.
Rule 2. The power of every number identifies that this number will be multiplied by itself a number of times.
(2)^n, where n=2 => 2*2 = 4
(-2)^n, where n=2 => (-2)*(-2) = 4
And if you can see Rule number 1..
(-3)^n, where n=3 => (-3) * (-3) * (-3) = 9 * (-3) = -27
Rule 3. Multiplication and Division have higher priority, than addition and subtraction.
3*5+2 = 15+2 = 17
3*(5+2) = 3*7 = 21
And there is the answer of your question:
Combining all 3 rules from before:
-x^2 + x, where x=3 => -3^2+3 = 9+3 = 12
My advice to you is to spend some time every year and keep refreshing the fundamental rules of mathematics.
It is in fact a skill you can maintain and stay on top of a large portion of the world, only by knowing basic maths.
New contributor
8
When you write "Combining all 3 rules from before: -x^2 + x, where x=3 => -3^2+3 = 9+3 = 12" you are assuming that -x^2 = (-x)^2. You have not stated that assumption before. Therefore your conclusion is unwarranted. Actually, if you read mathematics textbook or Wikipedia, you will notice that your implied assumption is not followed. Mathematics textbooks, scientific papers, etc. follow the assumption that -x^2 = -(x^2)
– Rodolfo Oviedo
Dec 20 at 12:31
rule 3 applies to binary operators like+-*/
, but not unary operators like-
or+
. Precedence of the power operator is higher than*
and/
but unary operators have even higher precedence
– phuclv
Dec 23 at 3:45
add a comment |
It is just a really simple maths.
Rule 1. Even multiplications of negative numbers, would output a positive result:
minus * minus = plus
minus * minus * minus = minus
minus * minus * minus * minus = plus
This is due to the fact, that minuses cancel each other in pairs.
Rule 2. The power of every number identifies that this number will be multiplied by itself a number of times.
(2)^n, where n=2 => 2*2 = 4
(-2)^n, where n=2 => (-2)*(-2) = 4
And if you can see Rule number 1..
(-3)^n, where n=3 => (-3) * (-3) * (-3) = 9 * (-3) = -27
Rule 3. Multiplication and Division have higher priority, than addition and subtraction.
3*5+2 = 15+2 = 17
3*(5+2) = 3*7 = 21
And there is the answer of your question:
Combining all 3 rules from before:
-x^2 + x, where x=3 => -3^2+3 = 9+3 = 12
My advice to you is to spend some time every year and keep refreshing the fundamental rules of mathematics.
It is in fact a skill you can maintain and stay on top of a large portion of the world, only by knowing basic maths.
New contributor
It is just a really simple maths.
Rule 1. Even multiplications of negative numbers, would output a positive result:
minus * minus = plus
minus * minus * minus = minus
minus * minus * minus * minus = plus
This is due to the fact, that minuses cancel each other in pairs.
Rule 2. The power of every number identifies that this number will be multiplied by itself a number of times.
(2)^n, where n=2 => 2*2 = 4
(-2)^n, where n=2 => (-2)*(-2) = 4
And if you can see Rule number 1..
(-3)^n, where n=3 => (-3) * (-3) * (-3) = 9 * (-3) = -27
Rule 3. Multiplication and Division have higher priority, than addition and subtraction.
3*5+2 = 15+2 = 17
3*(5+2) = 3*7 = 21
And there is the answer of your question:
Combining all 3 rules from before:
-x^2 + x, where x=3 => -3^2+3 = 9+3 = 12
My advice to you is to spend some time every year and keep refreshing the fundamental rules of mathematics.
It is in fact a skill you can maintain and stay on top of a large portion of the world, only by knowing basic maths.
New contributor
New contributor
answered Dec 20 at 11:36
Michael John
51
51
New contributor
New contributor
8
When you write "Combining all 3 rules from before: -x^2 + x, where x=3 => -3^2+3 = 9+3 = 12" you are assuming that -x^2 = (-x)^2. You have not stated that assumption before. Therefore your conclusion is unwarranted. Actually, if you read mathematics textbook or Wikipedia, you will notice that your implied assumption is not followed. Mathematics textbooks, scientific papers, etc. follow the assumption that -x^2 = -(x^2)
– Rodolfo Oviedo
Dec 20 at 12:31
rule 3 applies to binary operators like+-*/
, but not unary operators like-
or+
. Precedence of the power operator is higher than*
and/
but unary operators have even higher precedence
– phuclv
Dec 23 at 3:45
add a comment |
8
When you write "Combining all 3 rules from before: -x^2 + x, where x=3 => -3^2+3 = 9+3 = 12" you are assuming that -x^2 = (-x)^2. You have not stated that assumption before. Therefore your conclusion is unwarranted. Actually, if you read mathematics textbook or Wikipedia, you will notice that your implied assumption is not followed. Mathematics textbooks, scientific papers, etc. follow the assumption that -x^2 = -(x^2)
– Rodolfo Oviedo
Dec 20 at 12:31
rule 3 applies to binary operators like+-*/
, but not unary operators like-
or+
. Precedence of the power operator is higher than*
and/
but unary operators have even higher precedence
– phuclv
Dec 23 at 3:45
8
8
When you write "Combining all 3 rules from before: -x^2 + x, where x=3 => -3^2+3 = 9+3 = 12" you are assuming that -x^2 = (-x)^2. You have not stated that assumption before. Therefore your conclusion is unwarranted. Actually, if you read mathematics textbook or Wikipedia, you will notice that your implied assumption is not followed. Mathematics textbooks, scientific papers, etc. follow the assumption that -x^2 = -(x^2)
– Rodolfo Oviedo
Dec 20 at 12:31
When you write "Combining all 3 rules from before: -x^2 + x, where x=3 => -3^2+3 = 9+3 = 12" you are assuming that -x^2 = (-x)^2. You have not stated that assumption before. Therefore your conclusion is unwarranted. Actually, if you read mathematics textbook or Wikipedia, you will notice that your implied assumption is not followed. Mathematics textbooks, scientific papers, etc. follow the assumption that -x^2 = -(x^2)
– Rodolfo Oviedo
Dec 20 at 12:31
rule 3 applies to binary operators like
+-*/
, but not unary operators like -
or +
. Precedence of the power operator is higher than *
and /
but unary operators have even higher precedence– phuclv
Dec 23 at 3:45
rule 3 applies to binary operators like
+-*/
, but not unary operators like -
or +
. Precedence of the power operator is higher than *
and /
but unary operators have even higher precedence– phuclv
Dec 23 at 3:45
add a comment |
-x^2+x where x =3 This is an example of a quadratic equation
The equation can be written like this:
-3*-3+3
:Multiplication takes precedence over addition so result will be written as follows:
9 + 3 :Why =9 because a negative number x a negative number gives a positive result.
This can be verified using any calculator, slide rule, or any computer mathematics program
Final result 9 + 3 = 12
New contributor
add a comment |
-x^2+x where x =3 This is an example of a quadratic equation
The equation can be written like this:
-3*-3+3
:Multiplication takes precedence over addition so result will be written as follows:
9 + 3 :Why =9 because a negative number x a negative number gives a positive result.
This can be verified using any calculator, slide rule, or any computer mathematics program
Final result 9 + 3 = 12
New contributor
add a comment |
-x^2+x where x =3 This is an example of a quadratic equation
The equation can be written like this:
-3*-3+3
:Multiplication takes precedence over addition so result will be written as follows:
9 + 3 :Why =9 because a negative number x a negative number gives a positive result.
This can be verified using any calculator, slide rule, or any computer mathematics program
Final result 9 + 3 = 12
New contributor
-x^2+x where x =3 This is an example of a quadratic equation
The equation can be written like this:
-3*-3+3
:Multiplication takes precedence over addition so result will be written as follows:
9 + 3 :Why =9 because a negative number x a negative number gives a positive result.
This can be verified using any calculator, slide rule, or any computer mathematics program
Final result 9 + 3 = 12
New contributor
New contributor
answered Dec 22 at 19:50
Cripple2Cripple
1
1
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1385570%2fwhy-does-x2x-for-x-3-in-excel-result-in-12-instead-of-6%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
18
A negative number squared is a positive number. Which would make the formula 9+3. -(A1)^2 would give you -6.
– Ramhound
Dec 18 at 19:08
7
@Ramhound = -(A1)^2 gives 9 in Excel
– Rodolfo Oviedo
Dec 18 at 19:29
59
@Ramhound Powers have higher priority than minus signs in any sane environment.
– Nobody
Dec 18 at 20:35
15
It ought to be -(A1^2) to get -6... you need parenthesis around the operation, not just the number. Excel is just fine for math, but you need to respect order of operations, and when in doubt, use parenthesis!
– SnakeDoc
Dec 18 at 21:51
13
This is all about order of operations and nothing to do with Excel.
– YetAnotherRandomUser
Dec 19 at 13:58