Skip to main content
Logo image

Section 1.3 Variables

Variables are placeholders for mathematical objects. In this chapter variables will be placeholders for integers. We use the characters \(a\text{,}\) \(b\text{,}\) \(c\text{,}\) …, \(z\) and \(A\text{,}\) \(B\text{,}\) \(C\text{,}\) …, \(Z\) as variables. Note that when we use a letter as a variable, it is written in italics.
We use variables in several ways, which we describe below. Sometimes we simply want to give a value a name. If we do not assign a concrete value, for example a number, to a variable, we describe what values the variable can have, for example, a natural number. Sometimes, we use a variable that does not have a concrete value in a mathematical statement, such as an equation or an inequality. Finding a solution to such an equation or inequality means finding values for the variables that make the equation or inequality true.
In the video in Figure 1.3.1 we give an overview of the topics covered below.
Figure 1.3.1. Variables by Matt Farmer and Stephen Steward

Subsection Assigning a Value to a Variable

The most concrete use of variables is to assign a value to a variable. To assign a value to the variable \(a\) we say or write “let \(a\) be ” or “let \(a:=\).”
The symbol \(:=\) is used for assignment, which shows that an action is taking place. The symbol \(=\text{,}\) which shows equality, is used in statements. The assignment “let \(a:=\)” changes the value of the variable \(a\text{.}\)

Example 1.3.2. Assigning values to variables.

We write “let \(a\) be \(65536\)” or “let \(a:=65536\)” to assign the value \(65536\) to \(a\text{.}\) Both notations mean exactly the same thing.
After assigning this value to \(a\text{,}\) the statement \(a=65536\) is true.
However we can change the value of \(a\text{.}\) Let \(a:=32\text{.}\) Now \(a=65536\) is false and \(a=32\) is true.

Subsection Equality and Substitution

When an equality statement is true, such as \(a = 32\) at the end of Example 1.3.2, we can replace \(32\) with \(a\) (or \(a\) with \(32\)) in other statements and expressions. This replacement is called substitution. Substitution is a basic principle that we will often use without explicitly saying that we have substituted one expression for another expression that is equal to the first. For example, we used substitution when evaluating the expressions in Example 1.1.8. We replaced \(2+3\) with \(5\) because \(2+3 = 5\) is a true equality.

Example 1.3.3. Substitution.

We give an example of using substitution. Let \(a := 32\text{.}\) Since \(32 + 7 = 39\) is a true equality statement, \(a + 7 = 39\) is also a true equality statement.

Subsection Variables in Definitions

Definitions introduce new terms for objects, properties, and operations.
First, we state what kind of object we mean. We give the object a variable name so we can refer to it. Then we use that variable to state the definition of the property.

Example 1.3.4. A definition.

We give an example of a definition of a property for a real-world object, a cup, using the language of mathematics.
Let \(c\) be a cup. When we say \(c\) is full, we mean that you cannot put anything else in \(c\) without spilling over.
The variable \(c\) is defined to be a cup (any cup). We are defining the property full, so full is in italics. We define full to mean that you cannot put anything else in the cup. If you had a cup, you could test to see if you could put anything else in it or not.
Now we define the property non-negative for an integer. The first sentence, “Let \(a\) be an integer,” states the kind of object. The second sentence uses \(a\) and gives the condition for calling it non-negative.

Definition 1.3.5.

Let \(a\) be an integer. When we say \(a\) is non-negative, we mean that \(a\ge 0\text{.}\)
Now instead of saying “\(a\) is an integer and \(a\ge 0\text{,}\)” we can say “\(a\) is a non-negative integer.” In this example, using the definition does not make the statement much shorter than the earlier version. As ideas become more complicated, the vocabulary and notation introduced by definitions become more useful. We start with familiar terms.

Definition 1.3.6.

Let \(a\) and \(b\) be integers.
  1. We call \(a+b\) the sum of \(a\) and \(b\text{.}\)
  2. We call \(a-b\) the difference of \(a\) and \(b\text{.}\)
Now we define a new notation in the form of a new operation, namely the square of an integer.

Definition 1.3.7.

Let \(a\) be an integer. We let \(a^2:=a\cdot a\text{.}\) We call \(a^2\) the square of \(a\) and read \(a^2\) as “\(a\) squared.”

Example 1.3.8. Squares.

We give examples for squares.
  1. \(\displaystyle 5^2=5\cdot 5=25\)
  2. \((-11)^2=(-11)\cdot(-11)=121\) (remember a negative integer times a negative integer is a positive integer)
  3. \(-(11^2)=-(11\cdot 11)=-121\) (here the parentheses force us to square first and then negate)
  4. \(\displaystyle (2^2)^2=4^2=16\)
Variables let us define the product of a natural number and an integer by repeated addition, as in Example 1.1.6. We name the objects: a natural number and an integer. Then we use those names in the definition.

Definition 1.3.9.

Let \(n\) be a natural number, and let \(a\) be an integer. We define the product of \(n\) and \(a\) as the sum of \(n\) copies of \(a\text{.}\)
We can also write the statement of Definition 1.3.9 as a formula. For a natural number \(n\) and an integer \(a\) we define
\begin{equation*} n\cdot a :=\underbrace{a+a+\ldots+a}_{n\text{ copies of }a}\text{.} \end{equation*}
We show this definition with an example.

Example 1.3.10. Multiplication as repeated addition.

We have \(5\cdot 7=7+7+7+7+7=35\text{.}\)

Subsection “For all” Statements

Statements often apply to every mathematical object of a given type.
When we use a variable without assigning it a concrete value, as in Definition 1.3.9, we describe what kind of object we want the variable to be. “Let \(a\) be an integer” means that the variable \(a\) is an integer, and can be any integer.
We also use the more direct “for all” to formulate statements about all objects with given properties.
In Example 1.3.11, Example 1.3.12, and Example 1.3.11 we present statements that are true for all integers. In each example we give two formulations of the same statement.

Example 1.3.11. Adding \(0\) is special.

The statement
Let \(a\) be an integer then \(a+0=a\text{.}\)
can also be formulated as
For all integers \(a\) we have \(a+0=a\text{.}\)

Example 1.3.12. Multiplying by \(0\) yields \(0\).

The statement
Let \(a\) be an integer then \(a\cdot 0=0\text{.}\)
can also be formulated as
For all integers \(a\) we have \(a\cdot 0=0\text{.}\)

Example 1.3.13. Multiplying by \(1\) is special.

The statement
Let \(a\) be an integer then \(a\cdot 1=a\text{.}\)
can also be formulated as
For all integers \(a\) we have \(a\cdot 1=a\text{.}\)
Now we formulate a property of the natural numbers using “for all”.

Problem 1.3.14. Decide whether the statement with “for all” is true or false.

Decide whether the following statement is true or false. Say why.
For all natural numbers \(n\text{,}\) we have \(n\gt 0\text{.}\)
Solution.
The statement is true as the natural numbers are \(1,2,3,4,\ldots\text{,}\) which are all greater than \(0\text{.}\)
It is not always this easy to decide whether a “for all” statement is true or false, as the statement often is claimed to be true for infinitely many numbers. We know that a “for all” statement is false when we have found one value for which the statement is wrong. This makes it easier to prove that a statement is false. Values for which a “for all” statement is false are called a counterexample.

Problem 1.3.15. Decide whether the statement with “for all” is true or false.

Decide whether the following statement is true or false. Say why.
For all integers \(a\text{,}\) we have \(a>0\text{.}\)
Solution.
The statement is false, since \(-2\) is an integer and \(-2>0\) is false.
One counterexample proves that the statement is false. A false “for all” statement may have many counterexamples.
We can also use the “for all” formulation with several variables. We use “for all.” to state the commutative property of addition of integers.

Example 1.3.16. Commutative property of addition formulated with “for all”.

For all integers \(a\) and all integers \(b\) we have \(a+b = b+a\text{.}\) This is called the commutative property of addition.
We use the “for all.” formulation to state the distributive property for integers. The statement is true for every choice of integers for the three variables.

Example 1.3.17. Distributive property formulated with “for all”.

For all integers \(a\text{,}\) \(b\text{,}\) and \(c\) we have \(a\cdot(b+c)=(a\cdot b) + (a\cdot c)\text{.}\) This statement is called the distributive property for the addition and multiplication of integers.
Finally, we combine the two earlier examples with other properties of addition and multiplication.

Example 1.3.18. Properties of addition and multiplication formulated with “for all”.

  1. For all integers \(a\text{,}\) \(b\text{,}\) and \(c\text{,}\) we have
    \begin{equation*} a+(b+c)=(a+b)+c. \end{equation*}
    This is called the associative property of addition.
  2. For all integers \(a\) and \(b\text{,}\) we have
    \begin{equation*} a+b=b+a. \end{equation*}
    This is called the commutative property of addition.
  3. For all integers \(a\text{,}\) \(b\text{,}\) and \(c\text{,}\) we have
    \begin{equation*} a\cdot(b\cdot c)=(a\cdot b)\cdot c. \end{equation*}
    This is called the associative property of multiplication.
  4. For all integers \(a\) and \(b\text{,}\) we have
    \begin{equation*} a\cdot b=b\cdot a. \end{equation*}
    This is called the commutative property of multiplication.
  5. For all integers \(a\text{,}\) \(b\text{,}\) and \(c\text{,}\) we have
    \begin{equation*} a\cdot(b+c)=(a\cdot b) + (a\cdot c) \end{equation*}
    This is called the distributive property.

Subsection Alternative formulations for “For all”

Instead of using “for all \(a\) ” we sometimes choose a different approach for formulating statements. We write “given any \(a\)” or more commonly “let \(a\) be ” followed by what type of object \(a\) is and some other statement or property. The statement that follows applies to any objects of the given type.

Example 1.3.19. Different formulations of statements.

The following four statements all say the same thing. The first statement is the statement from Problem 1.3.14.
  1. For all natural numbers \(a\) we have \(a>0\text{.}\)
  2. Given any natural number \(a\) we have \(a>0\text{.}\)
  3. Let \(a\) be a natural number, then \(a>0\text{.}\)
  4. If \(a\) is a natural number, then \(a>0\text{.}\)
We give another common way to state the properties of integer addition and multiplication, shown in Example 1.3.16 and Example 1.3.17, respectively. Instead of using “for all”, we use “let” to introduce the variables and state what kind of numbers they represent. Then we state the property using these variables.

Example 1.3.20. Another formulation of the commutative property of addition.

Let \(a\) be an integer and let \(b\) be an integer. Then \(a+b = b+a\text{.}\) We call this the commutative property of addition.

Example 1.3.21. Another formulation of the distributive property.

Let \(a\) be an integer, let \(b\) be an integer, and let \(c\) be an integer. Then \(a\cdot(b+c)=(a\cdot b) + (a\cdot c)\text{.}\) We call this the distributive property.

Subsection There exists

Many statements assert that there exists a number with a certain property. In this case we use the formulation there exists.
The existence of a number with certain properties can be proven by presenting a number that has these properties. Such a number is called a witness to the validity of the statement. of

Example 1.3.22. A true statement with “there exists”.

Consider the statement:
There exists an integer \(b\) such that \(b+2=0\text{.}\)
The statement is true, because if \(b=-2\) we have \((-2)+2=0\text{,}\) and \(-2\) is an integer.
We call \(b=-2\) a witness to the statement “There exists an integer \(b\) such that \(b+2=0\)”.

Example 1.3.23. A false statement with “there exists”.

Consider the statement:
There exists a natural number \(b\) such that \(b+2=0\text{.}\)
The statement is false, because \(-2\) is the only number with this property, and \(-2\) is not a natural number.
We can also use “there exists” in definitions:

Definition 1.3.24.

Let \(a\) be an integer. If there exists an integer \(b\) such that \(a+b=0\) then \(b\) is called the additive inverse of \(a\text{.}\)

Subsection Combining “For all” and “There exists”

We can combine “for all” and “there exists” to state more complicated ideas.
Since for all integers \(a\) we have \(a+(-a)=0\text{,}\) the number \(-a\) is the additive inverse of \(a\text{.}\) We formulate this as a theorem.
In our formulation of this result as a theorem, we combine the formulations “for all” and “there exists.”
Now we formulate a statement where the “there exists” comes before the “for all.”
This theorem is easy to prove. When we set \(a:=-2\) the statement \(a\lt n\) is clearly true for all natural numbers.

Subsection Evaluation

So far our use of variables has been in the formulation of statements. Now we give a more hands-on use of them. When evaluating an expression we replace the variables by the values given for them and then compute.

Problem 1.3.27. Evaluate for a given value of a variable.

Evaluate \(2\cdot (b+3)\) for \(b:=7\text{.}\)
Solution.
Replacing \(b\) by \(7\) we get \(2\cdot (7+3)=2\cdot 10=20\text{.}\) Thus \(2\cdot (b+3)\) for \(b:=7\) is \(20\text{.}\)

Problem 1.3.28. Decide whether a statement is true for a given value of a variable.

Decide whether \(a\cdot(-2)>4\) is true for \(a:=7\)
Solution.
Replacing \(a\) by \(7\) the left hand side of the inequality becomes \(7\cdot(-2)=-14\text{,}\) As \(-14>4\) is false, the statement \(a\cdot(-2)>4\) is false for \(a:=7\text{.}\)