In mathematics, an expression is an arrangement of symbols following the context-dependent, syntactic conventions of mathematical notation. Symbols can denote numbers, variables, operations, and functions.Oxford English Dictionary, s.v. “Expression (n.), sense II.7,” "A group of symbols which together represent a numeric, algebraic, or other mathematical quantity or function." Other symbols include punctuation marks and brackets, used for grouping where there is not a well-defined order of operations.

Expressions are commonly distinguished from formulas: expressions usually denote mathematical objects, whereas formulas are statements about mathematical objects, such as an equality. This is analogous to natural language, where a noun phrase refers to an object, and a whole sentence refers to a fact. For example, and are both expressions, while the inequality is a formula. However, formulas are often considered as expressions that can be evaluated to the Boolean values true or false.

To evaluate an expression means to find a numerical value equivalent to the expression.Oxford English Dictionary, s.v. "Evaluate (v.), sense a", "Mathematics. To work out the ‘value’ of (a quantitative expression); to find a numerical expression for (any quantitative fact or relation)."Oxford English Dictionary, s.v. “Simplify (v.), sense 4.a”, "To express (an equation or other mathematical expression) in a form that is easier to understand, analyse, or work with, e.g. by collecting like terms or substituting variables." Expressions can be evaluated or simplified by replacing operations that appear in them with their result. For example, the expression simplifies to , and evaluates to

An expression is often used to define a function, by taking the variables to be arguments, or inputs, of the function, and assigning the output to be the evaluation of the resulting expression. For example, and define the function that associates to each number its square plus one. An expression with no variables would define a constant function. Usually, two expressions are considered equal or equivalent if they define the same function; such an equality is called a "semantic equality", that is, both expressions "mean the same thing."

Elementary mathematics

Variables and evaluation In elementary algebra, a variable in an expression is a letter that represents a number whose value may change. To evaluate an expression with a variable means to find the value of the expression when the variable is substituted with given number. Expressions can be simplified by replacing operations that appear in them with their result, or by combining like-terms. The evaluation of an expression consists of repeating simplification steps until getting eventually a single number.

For example, take the expression ; it can be evaluated for in the following steps:

, (replace x with 3)

(evaluate the square)

(evaluate the multiplication)

(evaluate the addition)

A term is a constant or the product of a constant and one or more variables. Some examples include The constant of the product is called the coefficient. Terms that are either constants or have the same variables raised to the same powers are called like terms. If there are like terms in an expression, one can simplify the expression by combining the like terms. One adds the coefficients and keeps the same variable.

Any variable can be classified as being either a free variable or a bound variable. For a given combination of values for the free variables, an expression may be evaluated, although for some combinations of values of the free variables, the value of the expression may be undefined. Thus an expression represents an operation over constants and free variables and whose output is the resulting value of the expression.; here: Sect.1.3

For a non-formalized language, that is, in most mathematical texts outside of mathematical logic, for an individual expression it is not always possible to identify which variables are free and bound. For example, in , depending on the context, the variable can be free and bound, or vice-versa, but they cannot both be free. Determining which value is assumed to be free depends on context and semantics.Sobolev, S.K. (originator). Free variable. Encyclopedia of Mathematics. Springer. .

Equivalence

An expression is often used to define a function, or denote compositions of functions, by taking the variables to be arguments, or inputs, of the function, and assigning the output to be the evaluation of the resulting expression. For example, and define the function that associates to each number its square plus one. An expression with no variables would define a constant function. In this way, two expressions are said to be equivalent if, for each combination of values for the free variables, they have the same output, i.e., they represent the same function.Equation. Encyclopedia of Mathematics. URL: http://encyclopediaofmath.org/index.php?title=Equation&oldid=32613Pratt, Vaughan, "Algebra", The Stanford Encyclopedia of Philosophy (Winter 2022 Edition), Edward N. Zalta & Uri Nodelman (eds.), URL: https://plato.stanford.edu/entries/algebra/#Laws The equivalence between two expressions is called an identity and is sometimes denoted with

For example, in the expression the variable is bound, and the variable is free. This expression is equivalent to the simpler expression ; that is The value for is 36, which can be denoted

Well-defined expressions

The language of mathematics exhibits a kind of grammar (called formal grammar) about how expressions may be written. There are two considerations for well-definedness of mathematical expressions, syntax and semantics. Syntax is concerned with the rules used for constructing, or transforming the symbols of an expression without regard to any interpretation or meaning given to them. Expressions that are syntactically correct are called well-formed. Semantics is concerned with the meaning of these well-formed expressions. Expressions that are semantically correct are called well-defined.

Well-formed The syntax of mathematical expressions can be described somewhat informally as follows: the allowed operators must have the correct number of inputs in the correct places (usually written with infix notation), the sub-expressions that make up these inputs must be well-formed themselves, have a clear order of operations, etc. Strings of symbols that conform to the rules of syntax are called well-formed, and those that are not well-formed are called, ill-formed, and do not constitute mathematical expressions.

For example, in arithmetic, the expression 1 + 2 × 3 is well-formed, but

is not.

However, being well-formed is not enough to be considered well-defined. For example in arithmetic, the expression is well-formed, but it is not well-defined (see Division by zero). Such expressions are called undefined.

Well-defined Semantics is the study of meaning. Formal semantics is about attaching meaning to expressions. An expression that defines a unique value or meaning is said to be well-defined. Otherwise, the expression is said to be ill defined or ambiguous. In general the meaning of expressions is not limited to designating values; for instance, an expression might designate a condition, or an equation that is to be solved, or it can be viewed as an object in its own right that can be manipulated according to certain rules. Certain expressions that designate a value simultaneously express a condition that is assumed to hold, for instance those involving the operator to designate an internal direct sum.

In algebra, an expression may be used to designate a value, which might depend on values assigned to variables occurring in the expression. The determination of this value depends on the semantics attached to the symbols of the expression. The choice of semantics depends on the context of the expression. The same syntactic expression 1 + 2 × 3 can have different values (mathematically 7, but also 9), depending on the order of operations implied by the context (See also Operations § Calculators).

For real numbers, the product is unambiguous because ; hence the notation is said to be well defined. This property, also known as associativity of multiplication, guarantees the result does not depend on the sequence of multiplications; therefore, a specification of the sequence can be omitted. The subtraction operation is non-associative; despite that, there is a convention that is shorthand for , thus it is considered "well-defined". On the other hand, Division is non-associative, and in the case of , parenthesization conventions are not well established; therefore, this expression is often considered ill-defined.

Unlike with functions, notational ambiguities can be overcome by means of additional definitions (e.g., rules of precedence, associativity of the operator). For example, in the programming language C, the operator - for subtraction is left-to-right-associative, which means that a-b-c is defined as (a-b)-c, and the operator = for assignment is right-to-left-associative, which means that a=b=c is defined as a=(b=c). In the programming language APL there is only one rule: from right to left – but parentheses first.

Formal definition The term 'expression' is part of the language of mathematics, that is to say, it is not defined within mathematics, but taken as a primitive part of the language. To attempt to define the term would not be doing mathematics, but rather, one would be engaging in a kind of metamathematics (the metalanguage of mathematics), usually mathematical logic. Within mathematical logic, mathematics is usually described as a kind of formal language, and a well-formed expression can be defined recursively as follows:

The alphabet consists of:

A set of individual constants: Symbols representing fixed objects in the domain of discourse, such as numerals (1, 2.5, 1/7, ...), sets (, ...), truth values (T or F), etc. A set of individual variables: A countably infinite amount of symbols representing variables used for representing an unspecified object in the domain. (Usually letters like , or ) A set of operations: Function symbols representing operations that can be performed on elements over the domain, like addition (+), multiplication (×), or set operations like union (∪), or intersection (∩). (Functions can be understood as unary operations) Brackets ( )

With this alphabet, the recursive rules for forming a well-formed expression (WFE) are as follows:

Any constant or variable as defined are the atomic expressions, the simplest well-formed expressions (WFE's). For instance, the constant or the variable are syntactically correct expressions. Let be a metavariable for any n-ary operation over the domain, and let be metavariables for any WFE's. Then is also well-formed. Here represented with prefix notation, but other notations may be used such as Infix notation like , or possibly non-linear notations such as with matrices or summation notation if allowed. For instance, if the domain of discourse is the real numbers, can denote the binary operation +, then is well-formed. Or can be the unary operation so is well-formed. Brackets are initially around each non-atomic expression, but they can be deleted in cases where there is a defined order of operations, or where order doesn't matter (i.e. where operations are associative).

A well-formed expression can be thought as a syntax tree.; here: Sect.II.1.3 The leaf nodes are always atomic expressions. Operations and have exactly two child nodes, while operations , and have exactly one. There are countably infinitely many WFE's, however, each WFE has a finite number of nodes.

Computer science