What is the correct result?
|
04-22-2024, 03:46 AM
Post: #61
|
|||
|
|||
RE: What is the correct result?
(04-21-2024 09:49 PM)Steve Simpkin Wrote:(04-21-2024 07:43 PM)Matt Agajanian Wrote: Hi all. I see. That TI technote explains that they made a change. But why didn’t the technote make any explanation as to why they did this? So, why the changeover? |
|||
04-22-2024, 10:19 AM
(This post was last modified: 04-22-2024 10:22 AM by klesl.)
Post: #62
|
|||
|
|||
RE: What is the correct result? | |||
04-22-2024, 05:07 PM
(This post was last modified: 04-22-2024 06:07 PM by carey.)
Post: #63
|
|||
|
|||
RE: What is the correct result?
(04-22-2024 10:19 AM)klesl Wrote: According to me there is no PEMDAS or PEJMDAS in Matlab, it is up to user, which method selects.Your examples support the conclusion that there’s no PEJMDAS (operator precedence AND implied multiplication) in Matlab but don’t appear to me to support the conclusion that there’s no PEMDAS (operator precedence WITHOUT implied multiplication). Example 1 displaying Error in Matlab shows there’s no implied multiplication using parentheses so no PEJMDAS but still can be PEMDAS. Note that the “P” for parentheses in PEMDAS only refers to operator precedence (i.e., operate first within parentheses), not implied multiplication via parentheses. Example 2, same as Example 1 that parentheses can’t be used to imply multiplication so again no PEJMDAS but still can be PEMDAS. Note (parenthetically :), that Examples 1 & 2 show it’s not fully “up to the user” in Matlab as implied multiplication via parentheses triggers an error. Example 3 shows parentheses used for grouping but not for implied multiplication so PEMDAS. Example 4, same as Example 3, showing parentheses for grouping and not implied multiplication so again PEMDAS. As mentioned in one of my previous posts, Matlab (and Python’s Numpy) are generally aligned with PEMDAS, but since both have a huge number of operators and their documentation list differences in some operator precedences, things are (unfortunately :) more complicated than just PEMDAS vs PEJMDAS. However one shouldn’t go (too :) wrong applying PEMDAS in Matlab or Numpy, at least for the basic arithmetic operations (but will go wrong applying PEJMDAS in Matlab as examples 1 & 2 show). |
|||
04-22-2024, 07:04 PM
Post: #64
|
|||
|
|||
RE: What is the correct result?
So, is this to say MatLab and Numpy are the final word on this conundrum?
|
|||
04-22-2024, 08:41 PM
(This post was last modified: 04-23-2024 12:06 AM by carey.)
Post: #65
|
|||
|
|||
RE: What is the correct result?
(04-22-2024 07:04 PM)Matt Agajanian Wrote: So, is this to say MatLab and Numpy are the final word on this conundrum?I don’t think there is a “conundrum”, nor a “final word.” Matlab and Numpy are very popular scientific and engineering tools (though there are others). While it might sound convenient to have an international standard for all operator precedences and implied multiplications, analogous to the international standard (S.I) for units, note that even for units, for which the case for standardization is even more compelling, there exist many fields and applications that don’t subscribe to the S.I. system (e.g., mass of diamonds in carets). In my opinion, we must learn to live with (and maybe even value, as in “vive la différence”) variety in matters such as operator precedence and implied multiplication as these conventions are created by people, while in understanding nature (e.g., in physics), simplicity is the desired goal. But when in doubt, use PEMDAS! :) |
|||
04-23-2024, 12:38 AM
Post: #66
|
|||
|
|||
RE: What is the correct result?
(04-22-2024 08:41 PM)carey Wrote:(04-22-2024 07:04 PM)Matt Agajanian Wrote: So, is this to say MatLab and Numpy are the final word on this conundrum?I don’t think there is a “conundrum”, nor a “final word.” Matlab and Numpy are very popular scientific and engineering tools (though there are others). In addition, when in doubt, write the expression in a manner which it’s clearly written so as to prevent ambiguity. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)