# Special Ways to Input Expressions

The Wolfram Language allows you to use special notation for many common operators. For example, although internally the Wolfram System represents a sum of two terms as Plus[x,y], you can enter this expression in the much more convenient form x+y.

The Wolfram Language has a definite grammar that specifies how your input should be converted to internal form. One aspect of the grammar is that it specifies how pieces of your input should be grouped. For example, if you enter an expression such as a+b^c, the Wolfram Language grammar specifies that this should be considered, following standard mathematical notation, as a+(b^c) rather than (a+b)^c. The Wolfram Language chooses this grouping because it treats the operator ^ as having a higher precedence than +. In general, the arguments of operators with higher precedence are grouped before those of operators with lower precedence.

You should realize that absolutely every special input form in the Wolfram Language is assigned a definite precedence. This includes not only the traditional mathematical operators, but also forms such as ->, := or the semicolons used to separate expressions in a Wolfram Language program.

The table in "Operator Input Forms" gives all the operators of the Wolfram Language in order of decreasing precedence. The precedence is arranged, where possible, to follow standard mathematical usage, and to minimize the number of parentheses that are usually needed.

You will find, for example, that relational operators such as < have lower precedence than arithmetic operators such as +. This means that you can write expressions such as x+y>7 without using parentheses.

There are nevertheless many cases where you do have to use parentheses. For example, since ; has a lower precedence than =, you need to use parentheses to write x=(a;b). The Wolfram System interprets the expression x=a;b as (x=a);b. In general, it can never hurt to include extra parentheses, but it can cause a great deal of trouble if you leave parentheses out, and the Wolfram System interprets your input in a way you do not expect.

 f[x,y] standard form for f[x,y] f@x prefix form for f[x] x//f postfix form for f[x] x~f~y infix form for f[x,y]

Four ways to write expressions in the Wolfram Language.

There are several common types of operators in the Wolfram Language. The + in x+y is an "infix" operator. The - in -p is a "prefix" operator. Even when you enter an expression such as f[x,y,] the Wolfram Language allows you to do it in ways that mimic infix, prefix and postfix forms.

This "postfix form" is exactly equivalent to f[x+y]:
 In:= Out= You will often want to add functions like N as "afterthoughts", and give them in postfix form:
 In:= Out= It is sometimes easier to understand what a function is doing when you write it in infix form:
 In:= Out= You should notice that // has very low precedence. If you put //f at the end of any expression containing arithmetic or logical operators, the f is applied to the whole expression. So, for example, x+y//f means f[x+y], not x+f[y].

The prefix form @ has a much higher precedence. f@x+y is equivalent to f[x]+y, not f[x+y]. You can write f[x+y] in prefix form as f@(x+y).