Why I always put parentheses around the arguments to any function.

  • MHB
  • Thread starter Ackbach
  • Start date
  • Tags
    Function
In summary, the conversation discusses the importance of using parentheses and other notation to clarify mathematical expressions. It also acknowledges the balance between being precise and muddling sentences with excessive verbiage in mathematical language, and the difficulty in identifying the proper context in mathematics. The importance of striving for clarity is emphasized, with the understanding that sometimes the reader may need to put in effort to understand the ideas being presented.
  • #1
Ackbach
Gold Member
MHB
4,155
92
Once upon a time, yours truly was taking junior-level classical mechanics. The textbook was the standard Classical Dynamics of Particles and Systems, by Marion and Thornton. In one homework problem from the book, there was a trig function that looked something like this:
$$ \sin \; \text{stuff}_{1} \; \text{stuff}_{2} $$
Clearly, $ \text{stuff}_{1}$ was in the argument of the trig function. But what about $ \text{stuff}_{2}$? I can't remember which assumption I went with, but it ended up being the wrong one.

Ever since then, I have ALWAYS put parentheses around the arguments to any function, whether it is sine, cosine, logarithm, etc. Then there can be no misunderstanding.

Don't write so that you can be understood. Write so that you can't be misunderstood. Don't write $ \sin x$, but $ \sin(x)$. Don't write $ \ln x$, but $ \ln(x)$. That way, you can follow the function with anything you please, with no danger of misunderstanding. Does it really take that much longer to type? Think about the time you might save some other poor soul who's reading your stuff. You might save him time.
 
Physics news on Phys.org
  • #2
I agree with the spirit of your advice, but there does come a point where additional parenthesis (and other "clarifying" notation) actually impair clarity. For a (seemingly) silly example, note that multiplication is a binary operation so, in some sense, $a \cdot b \cdot c$ is not a sensible expression and should be written either as $(a \cdot b) \cdot c$ or $a \cdot (b \cdot c)$. But so long as multiplication associates, it really seems best to drop the parenthesis (and the dots!).

In a more serious example, if one were to try to explicitly keep track of all of the notation for trekking through the behavior of different natural transformations between some functors (say to prove Yoneda's lemma) in a completely unambiguous way, one would be drifting in a sea of symbols. In such a situation, you really do want to simplify your notation (even at the risk of being actually ambiguous!) or no one will understand what you are trying to say at all.

As a similar comparison, take the use of the serial comma in English. Some sentences are made additionally clear with its use, some more ambiguous. Only context distinguishes between the cases. As a cop-out, style guides and English classes will stress the use of one convention, but to be unaware of the pitfalls of that choice is a problem, too. One must always strive for clarity in context.

Now, there is a big difference between a trig class and a course in homological algebra. Part of the context is understanding the level of the ideas one is trying to express. Math is a language--and just as in any "normal" language, one always has to balance being precise and muddling one's sentences with excess verbiage.

Unfortunately, unlike other languages, the proper context can be rather difficult to learn or identify in mathematics. It can easily take years (or lifetimes!) to master.
 
  • #3
Turgul said:
I agree with the spirit of your advice, but there does come a point where additional parenthesis (and other "clarifying" notation) actually impair clarity. For a (seemingly) silly example, note that multiplication is a binary operation so, in some sense, $a \cdot b \cdot c$ is not a sensible expression and should be written either as $(a \cdot b) \cdot c$ or $a \cdot (b \cdot c)$. But so long as multiplication associates, it really seems best to drop the parenthesis (and the dots!).

In a more serious example, if one were to try to explicitly keep track of all of the notation for trekking through the behavior of different natural transformations between some functors (say to prove Yoneda's lemma) in a completely unambiguous way, one would be drifting in a sea of symbols. In such a situation, you really do want to simplify your notation (even at the risk of being actually ambiguous!) or no one will understand what you are trying to say at all.

As a similar comparison, take the use of the serial comma in English. Some sentences are made additionally clear with its use, some more ambiguous. Only context distinguishes between the cases. As a cop-out, style guides and English classes will stress the use of one convention, but to be unaware of the pitfalls of that choice is a problem, too. One must always strive for clarity in context.

Now, there is a big difference between a trig class and a course in homological algebra. Part of the context is understanding the level of the ideas one is trying to express. Math is a language--and just as in any "normal" language, one always has to balance being precise and muddling one's sentences with excess verbiage.

Unfortunately, unlike other languages, the proper context can be rather difficult to learn or identify in mathematics. It can easily take years (or lifetimes!) to master.

Thank you for the thoughtful response! Really quite good. I would definitely agree with you. The goal is clarity, and easing the burden of the reader, however that looks in different situations. Although, come to think of it, sometimes you do want the reader to put forth the effort and reach out to grab a hold of your ideas. Sometimes that very effort is what makes the reader remember the things you want him to remember.

Generally, though, making your expression of the ideas straight-forward and clear is preferable, even if the ideas are deep.
 

FAQ: Why I always put parentheses around the arguments to any function.

Why do you always put parentheses around the arguments to any function?

Parentheses are used to pass arguments to a function. It is a way to indicate to the compiler that the values inside the parentheses are to be passed to the function. Without parentheses, the function would not know what values to use for its parameters.

Can I omit the parentheses when calling a function with no arguments?

Yes, you can omit the parentheses when calling a function with no arguments. However, it is considered good practice to always include them, as it makes the code more readable and consistent.

Do parentheses affect the performance of a function?

No, parentheses do not affect the performance of a function. They are only used to pass arguments to the function and do not have any impact on the execution of the function itself.

Are there any exceptions where parentheses are not necessary for a function call?

Yes, there are a few exceptions where parentheses are not necessary for a function call. For example, if the function is being assigned to a variable, or if it is being passed as an argument to another function, parentheses may be omitted.

Can parentheses be used for other purposes besides passing arguments to a function?

Yes, parentheses can be used for other purposes besides passing arguments to a function. They can be used for mathematical operations, grouping expressions, and creating tuples in some programming languages.

Similar threads

Back
Top