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;








3












$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.











share|improve this question









$endgroup$













  • $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 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






  • 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

















3












$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.











share|improve this question









$endgroup$













  • $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 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






  • 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













3












3








3





$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.











share|improve this question









$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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 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 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






  • 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$
    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$
    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










1 Answer
1






active

oldest

votes


















6












$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"]).






share|improve this answer









$endgroup$










  • 1




    $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













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
);



);













draft saved

draft discarded


















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









6












$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"]).






share|improve this answer









$endgroup$










  • 1




    $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















6












$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"]).






share|improve this answer









$endgroup$










  • 1




    $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













6












6








6





$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"]).






share|improve this answer









$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"]).







share|improve this answer












share|improve this answer



share|improve this answer










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$
    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












  • 1




    $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







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

















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

François Viète Contents Biography Work and thought Bibliography See also Notes Further reading External links Navigation menup. 21Google Bookspp. 75–77Google BooksDe thou (from University of Saint Andrews)ArchivedGoogle BooksGoogle BooksGoogle BooksGoogle booksGoogle Bookscc-parthenay.frL'histoire universelle (fr)Universal History (en)ArchivedAdsabs.harvard.eduPagesperso-orange.frArchive.orgChikara Sasaki. Descartes' mathematical thought p.259Google BooksGoogle BooksGoogle Bookspp. 152 and onwardGoogle BooksGoogle BooksScribd.comGoogle Books1257-7979Google BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGallica.bnf.frGoogle BooksGoogle Books"François Viète"Francois Viète: Father of Modern Algebraic NotationThe Lawyer and the GamblerAbout TarporleySite de Jean-Paul GuichardL'algèbre nouvelle"About the Harmonicon"cb120511976(data)1188044800000 0001 0913 5903n82164680ola2013766880073431702w6vt1sb70287374827140948071409480