Why Divide does not give the same answer?Prefix operator with low precedencewhen is f@g not the same as f[g]?How to construct custom operators with precedence?
Applications of pure mathematics in operations research
Can machine learning learn a function like finding maximum from a list?
Why does the Rust compiler not optimize code assuming that two mutable references cannot alias?
"Fewer errors means better products" or fewer errors mean better products."
UX writing: When to use "we"?
"Valet parking " or "parking valet"
How can you tell the version of Ubuntu on a system in a .sh (bash) script?
What is the full text of the song about the failed battle of Kiska?
Can you remove a blindfold using the Telekinesis spell?
Should students have access to past exams or an exam bank?
How do discovery writers hibernate?
A conjectural trigonometric identity
Ambiguous Compound Words
How can flights operated by the same company have such different prices when marketed by another?
What is my clock telling me to do?
How to litter train a cat if both my husband and I work away from home all day?
Coworker mumbles to herself when working, how to ask her to stop?
Why would an invisible personal shield be necessary?
Can living where Rare Earth magnetic ore is abundant provide any protection?
Easy way to get process information from a window
My employer is refusing to give me the pay that was advertised after an internal job move
Introduction to the Sicilian
Why are prop blades not shaped like household fan blades?
Derivative is just speed of change?
Why Divide does not give the same answer?
Prefix operator with low precedencewhen is f@g not the same as f[g]?How to construct custom operators with precedence?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
I saw a question on Facebook $8div2 (2 + 2)=?$
Consider these inputs.
Divide[8, 2 (2 + 2)]
1
$8div2 (2 + 2)$ using esc+div+esc
16
Why the results are different.
I also tried these entries.
8/2 (2 + 2)
16
8/(2 (2 + 2))
1
Precedence /@ Plus, Subtract, Times, Divide
310., 310., 400., 470.
precedence
$endgroup$
add a comment |
$begingroup$
I saw a question on Facebook $8div2 (2 + 2)=?$
Consider these inputs.
Divide[8, 2 (2 + 2)]
1
$8div2 (2 + 2)$ using esc+div+esc
16
Why the results are different.
I also tried these entries.
8/2 (2 + 2)
16
8/(2 (2 + 2))
1
Precedence /@ Plus, Subtract, Times, Divide
310., 310., 400., 470.
precedence
$endgroup$
$begingroup$
Try usingTrace[]to see how the evaluation is performed.
$endgroup$
– Anjan Kumar
8 hours ago
$begingroup$
Is Mathematica just following the usual order of operations: en.m.wikipedia.org/wiki/Order_of_operations ?
$endgroup$
– JimB
8 hours ago
$begingroup$
@OkkesDulgerci The arguments toDivideare treated as if you had parenthesis around each one. There is no spilling from denominator to numerator because of operator precedence like you can have when you are writing/as infix operator.
$endgroup$
– Thies Heidecke
8 hours ago
$begingroup$
Then question is how should enter to find out the question?
$endgroup$
– Okkes Dulgerci
8 hours ago
1
$begingroup$
The answer to the question should be "It is X if I follow these rules, and Y if I follow these rules." It would be nice if that is what the Facebook poster is after. But my bias is that it is not an attempt at enlightenment.
$endgroup$
– JimB
8 hours ago
add a comment |
$begingroup$
I saw a question on Facebook $8div2 (2 + 2)=?$
Consider these inputs.
Divide[8, 2 (2 + 2)]
1
$8div2 (2 + 2)$ using esc+div+esc
16
Why the results are different.
I also tried these entries.
8/2 (2 + 2)
16
8/(2 (2 + 2))
1
Precedence /@ Plus, Subtract, Times, Divide
310., 310., 400., 470.
precedence
$endgroup$
I saw a question on Facebook $8div2 (2 + 2)=?$
Consider these inputs.
Divide[8, 2 (2 + 2)]
1
$8div2 (2 + 2)$ using esc+div+esc
16
Why the results are different.
I also tried these entries.
8/2 (2 + 2)
16
8/(2 (2 + 2))
1
Precedence /@ Plus, Subtract, Times, Divide
310., 310., 400., 470.
precedence
precedence
asked 8 hours ago
Okkes DulgerciOkkes Dulgerci
5,9671 gold badge11 silver badges21 bronze badges
5,9671 gold badge11 silver badges21 bronze badges
$begingroup$
Try usingTrace[]to see how the evaluation is performed.
$endgroup$
– Anjan Kumar
8 hours ago
$begingroup$
Is Mathematica just following the usual order of operations: en.m.wikipedia.org/wiki/Order_of_operations ?
$endgroup$
– JimB
8 hours ago
$begingroup$
@OkkesDulgerci The arguments toDivideare treated as if you had parenthesis around each one. There is no spilling from denominator to numerator because of operator precedence like you can have when you are writing/as infix operator.
$endgroup$
– Thies Heidecke
8 hours ago
$begingroup$
Then question is how should enter to find out the question?
$endgroup$
– Okkes Dulgerci
8 hours ago
1
$begingroup$
The answer to the question should be "It is X if I follow these rules, and Y if I follow these rules." It would be nice if that is what the Facebook poster is after. But my bias is that it is not an attempt at enlightenment.
$endgroup$
– JimB
8 hours ago
add a comment |
$begingroup$
Try usingTrace[]to see how the evaluation is performed.
$endgroup$
– Anjan Kumar
8 hours ago
$begingroup$
Is Mathematica just following the usual order of operations: en.m.wikipedia.org/wiki/Order_of_operations ?
$endgroup$
– JimB
8 hours ago
$begingroup$
@OkkesDulgerci The arguments toDivideare treated as if you had parenthesis around each one. There is no spilling from denominator to numerator because of operator precedence like you can have when you are writing/as infix operator.
$endgroup$
– Thies Heidecke
8 hours ago
$begingroup$
Then question is how should enter to find out the question?
$endgroup$
– Okkes Dulgerci
8 hours ago
1
$begingroup$
The answer to the question should be "It is X if I follow these rules, and Y if I follow these rules." It would be nice if that is what the Facebook poster is after. But my bias is that it is not an attempt at enlightenment.
$endgroup$
– JimB
8 hours ago
$begingroup$
Try using
Trace[] to see how the evaluation is performed.$endgroup$
– Anjan Kumar
8 hours ago
$begingroup$
Try using
Trace[] to see how the evaluation is performed.$endgroup$
– Anjan Kumar
8 hours ago
$begingroup$
Is Mathematica just following the usual order of operations: en.m.wikipedia.org/wiki/Order_of_operations ?
$endgroup$
– JimB
8 hours ago
$begingroup$
Is Mathematica just following the usual order of operations: en.m.wikipedia.org/wiki/Order_of_operations ?
$endgroup$
– JimB
8 hours ago
$begingroup$
@OkkesDulgerci The arguments to
Divide are treated as if you had parenthesis around each one. There is no spilling from denominator to numerator because of operator precedence like you can have when you are writing / as infix operator.$endgroup$
– Thies Heidecke
8 hours ago
$begingroup$
@OkkesDulgerci The arguments to
Divide are treated as if you had parenthesis around each one. There is no spilling from denominator to numerator because of operator precedence like you can have when you are writing / as infix operator.$endgroup$
– Thies Heidecke
8 hours ago
$begingroup$
Then question is how should enter to find out the question?
$endgroup$
– Okkes Dulgerci
8 hours ago
$begingroup$
Then question is how should enter to find out the question?
$endgroup$
– Okkes Dulgerci
8 hours ago
1
1
$begingroup$
The answer to the question should be "It is X if I follow these rules, and Y if I follow these rules." It would be nice if that is what the Facebook poster is after. But my bias is that it is not an attempt at enlightenment.
$endgroup$
– JimB
8 hours ago
$begingroup$
The answer to the question should be "It is X if I follow these rules, and Y if I follow these rules." It would be nice if that is what the Facebook poster is after. But my bias is that it is not an attempt at enlightenment.
$endgroup$
– JimB
8 hours ago
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
First, since the precedence of Divide is higher than Times, you should expect to parse 8 ÷ 2(2+2) as:
Divide[8, 2] (2+2)
You can also verify this by entering the input into a cell and using Cell | Show Expression to see what the boxes look like. The rendered version:
8 ÷ 2 (2 + 2)
and the version after using Cell | Show Expression:
Cell[BoxData[
RowBox[
RowBox["8", "[Divide]", "2"],
RowBox["(",
RowBox["2", "+", "2"], ")"]]], "Input",
CellLabel->"In[353]:="]
The boxes show that 8 ÷ 2 (with the boxes RowBox["8" "[Divide]", "2"]) is being multiplied by 2 + 2 (with the boxes RowBox["2", "+", "2"]).
$endgroup$
1
$begingroup$
AlsoFullForm[Hold[8/2 (2 + 2)]]might be easier to understand than "show expression"
$endgroup$
– Gustavo Delfino
4 hours ago
$begingroup$
Thanks. This clears things a bit. But my main concern was, on help page forDivideit says you can use esc+div+esc for shorthand $div$ and I expected to get the same result as Divide[8, 2 (2 + 2)]=1 but it didn't.
$endgroup$
– Okkes Dulgerci
34 mins ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2fmathematica.stackexchange.com%2fquestions%2f203106%2fwhy-divide-does-not-give-the-same-answer%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
First, since the precedence of Divide is higher than Times, you should expect to parse 8 ÷ 2(2+2) as:
Divide[8, 2] (2+2)
You can also verify this by entering the input into a cell and using Cell | Show Expression to see what the boxes look like. The rendered version:
8 ÷ 2 (2 + 2)
and the version after using Cell | Show Expression:
Cell[BoxData[
RowBox[
RowBox["8", "[Divide]", "2"],
RowBox["(",
RowBox["2", "+", "2"], ")"]]], "Input",
CellLabel->"In[353]:="]
The boxes show that 8 ÷ 2 (with the boxes RowBox["8" "[Divide]", "2"]) is being multiplied by 2 + 2 (with the boxes RowBox["2", "+", "2"]).
$endgroup$
1
$begingroup$
AlsoFullForm[Hold[8/2 (2 + 2)]]might be easier to understand than "show expression"
$endgroup$
– Gustavo Delfino
4 hours ago
$begingroup$
Thanks. This clears things a bit. But my main concern was, on help page forDivideit says you can use esc+div+esc for shorthand $div$ and I expected to get the same result as Divide[8, 2 (2 + 2)]=1 but it didn't.
$endgroup$
– Okkes Dulgerci
34 mins ago
add a comment |
$begingroup$
First, since the precedence of Divide is higher than Times, you should expect to parse 8 ÷ 2(2+2) as:
Divide[8, 2] (2+2)
You can also verify this by entering the input into a cell and using Cell | Show Expression to see what the boxes look like. The rendered version:
8 ÷ 2 (2 + 2)
and the version after using Cell | Show Expression:
Cell[BoxData[
RowBox[
RowBox["8", "[Divide]", "2"],
RowBox["(",
RowBox["2", "+", "2"], ")"]]], "Input",
CellLabel->"In[353]:="]
The boxes show that 8 ÷ 2 (with the boxes RowBox["8" "[Divide]", "2"]) is being multiplied by 2 + 2 (with the boxes RowBox["2", "+", "2"]).
$endgroup$
1
$begingroup$
AlsoFullForm[Hold[8/2 (2 + 2)]]might be easier to understand than "show expression"
$endgroup$
– Gustavo Delfino
4 hours ago
$begingroup$
Thanks. This clears things a bit. But my main concern was, on help page forDivideit says you can use esc+div+esc for shorthand $div$ and I expected to get the same result as Divide[8, 2 (2 + 2)]=1 but it didn't.
$endgroup$
– Okkes Dulgerci
34 mins ago
add a comment |
$begingroup$
First, since the precedence of Divide is higher than Times, you should expect to parse 8 ÷ 2(2+2) as:
Divide[8, 2] (2+2)
You can also verify this by entering the input into a cell and using Cell | Show Expression to see what the boxes look like. The rendered version:
8 ÷ 2 (2 + 2)
and the version after using Cell | Show Expression:
Cell[BoxData[
RowBox[
RowBox["8", "[Divide]", "2"],
RowBox["(",
RowBox["2", "+", "2"], ")"]]], "Input",
CellLabel->"In[353]:="]
The boxes show that 8 ÷ 2 (with the boxes RowBox["8" "[Divide]", "2"]) is being multiplied by 2 + 2 (with the boxes RowBox["2", "+", "2"]).
$endgroup$
First, since the precedence of Divide is higher than Times, you should expect to parse 8 ÷ 2(2+2) as:
Divide[8, 2] (2+2)
You can also verify this by entering the input into a cell and using Cell | Show Expression to see what the boxes look like. The rendered version:
8 ÷ 2 (2 + 2)
and the version after using Cell | Show Expression:
Cell[BoxData[
RowBox[
RowBox["8", "[Divide]", "2"],
RowBox["(",
RowBox["2", "+", "2"], ")"]]], "Input",
CellLabel->"In[353]:="]
The boxes show that 8 ÷ 2 (with the boxes RowBox["8" "[Divide]", "2"]) is being multiplied by 2 + 2 (with the boxes RowBox["2", "+", "2"]).
answered 7 hours ago
Carl WollCarl Woll
88.7k3 gold badges117 silver badges228 bronze badges
88.7k3 gold badges117 silver badges228 bronze badges
1
$begingroup$
AlsoFullForm[Hold[8/2 (2 + 2)]]might be easier to understand than "show expression"
$endgroup$
– Gustavo Delfino
4 hours ago
$begingroup$
Thanks. This clears things a bit. But my main concern was, on help page forDivideit says you can use esc+div+esc for shorthand $div$ and I expected to get the same result as Divide[8, 2 (2 + 2)]=1 but it didn't.
$endgroup$
– Okkes Dulgerci
34 mins ago
add a comment |
1
$begingroup$
AlsoFullForm[Hold[8/2 (2 + 2)]]might be easier to understand than "show expression"
$endgroup$
– Gustavo Delfino
4 hours ago
$begingroup$
Thanks. This clears things a bit. But my main concern was, on help page forDivideit says you can use esc+div+esc for shorthand $div$ and I expected to get the same result as Divide[8, 2 (2 + 2)]=1 but it didn't.
$endgroup$
– Okkes Dulgerci
34 mins ago
1
1
$begingroup$
Also
FullForm[Hold[8/2 (2 + 2)]] might be easier to understand than "show expression"$endgroup$
– Gustavo Delfino
4 hours ago
$begingroup$
Also
FullForm[Hold[8/2 (2 + 2)]] might be easier to understand than "show expression"$endgroup$
– Gustavo Delfino
4 hours ago
$begingroup$
Thanks. This clears things a bit. But my main concern was, on help page for
Divide it says you can use esc+div+esc for shorthand $div$ and I expected to get the same result as Divide[8, 2 (2 + 2)]=1 but it didn't.$endgroup$
– Okkes Dulgerci
34 mins ago
$begingroup$
Thanks. This clears things a bit. But my main concern was, on help page for
Divide it says you can use esc+div+esc for shorthand $div$ and I expected to get the same result as Divide[8, 2 (2 + 2)]=1 but it didn't.$endgroup$
– Okkes Dulgerci
34 mins ago
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- 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.
Use MathJax to format equations. MathJax reference.
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%2fmathematica.stackexchange.com%2fquestions%2f203106%2fwhy-divide-does-not-give-the-same-answer%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
$begingroup$
Try using
Trace[]to see how the evaluation is performed.$endgroup$
– Anjan Kumar
8 hours ago
$begingroup$
Is Mathematica just following the usual order of operations: en.m.wikipedia.org/wiki/Order_of_operations ?
$endgroup$
– JimB
8 hours ago
$begingroup$
@OkkesDulgerci The arguments to
Divideare treated as if you had parenthesis around each one. There is no spilling from denominator to numerator because of operator precedence like you can have when you are writing/as infix operator.$endgroup$
– Thies Heidecke
8 hours ago
$begingroup$
Then question is how should enter to find out the question?
$endgroup$
– Okkes Dulgerci
8 hours ago
1
$begingroup$
The answer to the question should be "It is X if I follow these rules, and Y if I follow these rules." It would be nice if that is what the Facebook poster is after. But my bias is that it is not an attempt at enlightenment.
$endgroup$
– JimB
8 hours ago