abstractmath.org 2.0
help with abstract math

Produced by Charles Wells     Revised 2017-01-27
Introduction to this website    website TOC
website index   blog


# VARIABLES AND SUBSTITUTION

### Contents

Variables

Substitution

Free and bound

Variable mathematical objects (separate file)

A variable is a symbol (usually a Roman or Greek letter) that denotes a mathematical object of a certain type. The type (real number, set, group, etc) may be specified explicitly or by the context or by convention.

You already know about substituting values for variables in an expression and evaluating the result. This chapter is intended to make your implicit knowledge more explicit.

## Variables

Variables in high-school algebra and in calculus are usually of some number type. But in abstract math, variables can vary over any type of mathematical object or structure.

The main point about variables is that a variable denotes a math object of a certain type, that a text may given you some facts about the variable, but you do not necessarily know the precise math object that it names.

#### Example

Suppose a math text says, "Let $x$ be a real number, and let $y=x^2$".

• You know that $x$ is a real number, but you don't know whether it is positive, negative or $0$.
• You do know that $x^2$ is nonnegative.
• You know that $y$ is a real number, since the square of a real number is a real number, and that "$y$" and "$x^2$" are two symbols that denote the same real number.
• If you are also told that $x\gt 2$, then you can deduce that $y\gt 4$, but that's all you know about it.

#### Example

A statement in a text that says "Let $S$ be a finite set" establishes that in this part of the text, "$S$" is a variable denoting a finite set.

• You know that $S$ might or might not contain the number $3$, or all the integers between $3$ and $42$, and lots of other possible statements like those.
• You know that $S$ does not contain all the integers bigger than $42$, because there are an infinite number of such integers.
• You know that $S$ is not the number $3$, because $3$ is a number, not a set.

Some mathematicians would not refer to "$S$" as a variable in this context.

### The type of a variable

The type (or data type) of a variable determines what can be legally substituted for it. For example, to say that $x$ is a variable of type real means that $x$ denotes a real number. The fact that it is a variable means that you don't necessarily know what that real number is.

This terminology follows the use of the word "type" in many programming languages. Not all mathematicians use the word in this way.

#### Usage

The name of the type may be used as an adjective before the name of the variable.  Thus a real variable is a variable of type real: in other words, a real variable $x$ may have any real number as its value, subject to any constraints that have been put on it.  Similarly complex variable, integer variable, set variable

#### Examples

All these are different ways of saying the same thing:

1. Let $x$ be of type real.
2. Let $x$ be a real variable.
3. Let $x$ be a real number.
4. Let $x\in\mathbb{R}$.

Note that 1) and 2) refer to the variable "$x$" and 3) and 4) refer to $x$ as a number. If you are really really hung up on accuracy you might write:  Let "$x$" be a real variable. Mathe­maticians rarely use quotes in this way, but logicians usually make the distinction.

#### Conventions for types of variables

Authors may use certain letters of the alphabet to indicate certain types of variable without saying so.

• The letters $i, j, k, m, n$ may be integer variables.
• The letters $r, s, t, u, x, y, z$ are usually real variables, except in texts specifically concerned with complex variables.
• Letters at the beginning of the alphabet may denote constants or parameters.
• If an upper case letter denotes a structure, the same letter in lower case may denote an element of the structure.  For example a text might refer to the element $a$ of the set $A$. Both "$a$" and "$A$" are variables in this context.
• These conventions are not observed universally.

#### Natural kinds

In effect, the word "type", for those mathematicians who use it, is a reference to one of the natural kinds of things used in math.  I might say "Let $x$ be of type real and suppose $x\gt3$". A mathematician would not say "Let $X$ be of type real-greater-than-$3$" because "real-greater-than-$3$" is thought of as a constraint.

This concept of "natural kind" has psychological reality for many of us but does not have a mathematical definition.  There is more about this in the Wikipedia article on natural kind, in the Handbook (jump to type) and in the article Communication of Mathematical Reasoning

## Substitution

### Definition of "substitute"

To substitute an expression $e$ for a variable $x$ that occurs in an expression $t$ is to replace every occurrence of $x$ by $e$ (in a sophisticated way - see below).

The expression resulting from the substitution has a generally different meaning and the meaning can be determined just knowing the old expression and what was substituted.

#### Example

Let the expression $E$ be "$3+5x$".

• The result of substituting $4$ for $x$ in $E$ is $3+5\cdot4$, which is $23$.
• The result of substituting $x+y$ for $x$ in $E$ is $3+5(x+y)$.

#### Terminology

Instead of "substitute $4$ for $x$", people may say "replace $x$ by $4$" or "plug $4$ into $E$ for $x$".

There are mathematicians who find the "plug in" terminology offensive. From my early experience, I don't think any sexual connotation was intended. I worked on an IBM "computer" in the 1950’s that you programmed by connecting sockets to each other. There was sockets for inputs and other sockets for multiplication, addition, negative sign, and so on. By hooking the sockets up correctly you could cause a socket to output the value of $3+5x$ whenever a value was literally plugged into the socket representing $x$.

That "computer" did not deserve to be called a computer, since it did not operate on stored programs.

### Syntax of substitution

The act of substituting may require insertion of parentheses and other adjustments to the expression containing the variable.

#### Examples

• Suppose $f(x,y)={{x}^{2}}-{{y}^{2}}$.   Then $f(y,x)={{y}^{2}}-{{x}^{2}}$ and $f(x,x)={{x}^{2}}-{{x}^{2}}=0$.
• Substituting $4$ for $x$ in the expression $3x$ results in $12$, not $34$ (!).
• Let $e$ be $x+y$ and $t$ be $2u$. Then substituting $e$ for $u$ in $t$ yields $2(x+y)$. The rules of algebra require you to put "$x +y$" in parentheses.  The answer "$2x+y$" would be wrong.
• Substituting $2u$ for $x$  in ${{x}^{2}}+2x+y$ gives ${{(2u)}^{2}}+2\,(2u)+y$. Note the changes that have to be made from a straight textual substitution. You could write $2\cdot 2u$ instead of $2(2u)$ but you can’t write it as "$22u$". Of course, the expression ${{(2u)}^{2}}+2\,(2u)+y$ simplifies to $4{{u}^{2}}+4u+y$.

Substituting is not a mechanical act.
It requires understanding
the form and meaning of the expression.

#### Uniform substitution

All uses of a particular identifier must refer to the same object.

#### Example

When I substituted $2u$ for $x$ in ${{x}^{2}}+2x+y$ above, I had to substitute it for both occurrences of $x$.  "Replace the first $x$ by $2u$ and the second $x$ by $w$" gives ${{(2u)}^{2}}+2w+y$, but that action is not an example of substitution in the mathematical sense.

This observation is an implicit rule in pattern recognition The statement "$x+x=2x$" is true whatever real number is substituted for $x$. So $3+3=2\cdot 3$ and $5+5=2\cdot 5$.  But of course the statement does not mean $3+4=2\cdot 5$.

One of the few examples in math that I know of where the uniform substitution rule is not used is in the theory of context free grammars, where you normally replace just one instance in an expression with another expression, leaving other instances alone. And, as I did in the previous sentence, they usually say "replace" rather the "substitute".

### Semantics of substitution

A fundamental fact about the syntax and semantics of all mathematical expressions (as far as I know) is that substitution commutes with evaluation.  This means:

If you replace a subexpression by its value,
the value of the containing expression remains the same.

#### Example

The expression $3x+{{y}^{2}}$ has "$3x$" and "${{y}^{2}}$" as subexpressions.

• (a) If you substitute $4$ for $x$ and $5$ for $y$ in the expression $3x+{{y}^{2}}$, you get the expression $3\cdot 4+{{5}^{2}}$, which equals $37$.
• (b) If you substitute $4$ for $x$ in the expression $3x$, you get $12+y^2$. Then if you substitute $5$ for $y$ in $12+y^2$, you get $12+25$, which is $37$.

The principle that substitution commutes with evaluation is explained with pretty diagrams in my blog post The only axiom of algebra.

This is an obvious but basic property of mathematical expressions.  Teachers and students of math almost never see an explicit statement of it.  I believe I have observed students being confused because they didn’t fully grasp this fact.  Whether that happens often is something the math ed people have not investigated, as far as I know.

The phrase "substitution commutes with evaluation" has nothing to do with commuta­tivity of addition or multiplication. It means you can evaluate first, then substitute, or substitute first, then evaluate, and get the same result, as the example illustrates.

### Expression and process

You can describe how to calculate $3x+{{y}^{2}}$ for $x=4$ and $y=5$ by saying:

"Substitute $4$ for $x$ and $5$ for $y$ in $3x+{{y}^{2}}$."

You can spell it out in a more transparent way by describing it as a process:

• Multiply $x$ by $3$.
• Square $y$.
• Add the preceding two results.

This illustrates the fact that an expression may be associated with a computational process: The expression encapsulates the process.

There are more examples in the article Functions: Images and Metaphors.

## Free and bound

A variable in an expression is either free or bound. It is approximately correct to say:

A variable is free if you can substitute a value for it and the resulting expressions is meaningful.

A variable is bound if the expression is a statement about all the possible values of the variable all at once. You cannot substitute a value for a bound value.

A bound variable is bound by an operator such as the integral sign, a quantifier, or a summation sign.

Those statements are a guide to what "free" and "bound" mean but are not totally precise – they are not mathematical definitions. Precise mathematical definitions of "free" and "bound" involve technicalities (see Wikipedia).

#### Examples

• In the expression "${{x}^{2}}+1$", "$x$" is a free variable. You can substitute $4$ for $x$ in this expression and the result is $17$.
• In "$\int_{3}^{5}{({{x}^{2}}+1)\,\,dx}$", the variable $x$ is bound by the integral sign. The value of the integral, which is $104/3$, depends on all the values of $x$ between $3$ and $5$. If you substitute $4$ for $x$ you get nonsense:$\int_{3}^{5}{({{4}^{2}}+1)\,\,d4}$.
• You can substitute for the variables $a$ and $b$ in the integral $\int_{a}^{b}{({{x}^{2}}+1\,)\,dx}$.  In this expression, $a$ and $b$ are free (and $x$ is bound).  They are parameters. If you substitute $a := 3$ and $b : = 5$, you get the integral we had in the previous example. The integral $\int_{a}^{b}{({{x}^{2}}+1\,)\,dx}$ is actually a function of two variables – $a$ and $b$.
• In the symbolic assertion "$x\gt7$", $x$ is free. You can substitute $42$ for $x$ and get the true assertion "$42\gt7$". You can also substitute $5$ for $x$ and get the assertion "$5\gt7$", which is a false assertion but is nevertheless a correctly formed assertion with a specific meaning.
• In the assertion "For all real $x$, $x\gt7$", $x$ is bound by the universal quantifier.  The statement is a (false) claim about all possible values of $x$ (even though "$x\gt7$" is true of some of them).

#### Subtle example

Suppose we define a function by saying, "Let $f(x)={{x}^{2}}+1$".  Then the $x$ in that expression (it occurs twice) is bound. There is an implicit "for all $x$" in such a definition. The statement "Let $f(4)={{4}^{2}}+1$" is perfectly legitimate, but it defines a different function that has only one element in its domain.

## How to think about variables

Assuming $x$ has been specified as a real variable, you can think of $x$ in several related ways.  All the remarks in this section assume that $x$ is free.

### Role playing

If the author says "$x$ is a real variable" then it plays the role of a real number in whatever expression it occurs in. It is like an actor in a play.

• If the producer says Dwayne will play Polonius you know that Dwayne will hide behind a curtain at a certain point in the play.
• When $x$ occurs in the expression ${{x}^{3}}-1$ you know that if $3$ is substituted for $x$ in the expression ($3$ plays the role of $x$), the expression will then denote the result of cubing the number and subtracting $1$ from it.

If I were going to be cubed, I would hide behind a curtain too.

### Slot or cell

The variable $x$ is a slot into which you can put any real number.

#### Example

If you plug $3$ into $x$ in the expression ${{x}^{3}}-1$ you will get $26$.

This is like a blank cell in a spreadsheet. If you define another cell with the formula "$={{x}^{3}}-1$" and put $3$ in the cell representing $x$, the other cell will show $26$.

In some school workbooks, a variable is denoted by an empty box. That is essentially the same metaphor. The trouble with blank boxes is that they don't allow you to have more than one variable.

## Variable mathematical objects

This section is in a separate file.