Skip to main content

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 specify 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 1.3.1 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 indicates that an action is taking place. The symbol \(=\text{,}\) which indicates equality, is used in statements. The assignment “let \(a:=\)” changes the value of the variable \(a\text{.}\)

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 1.3.2 Equality and Substitution

When we have a true equality statement, 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, and it is a fundamental principle in mathematics that we will use, often without explicitly mentioning that we have substituted one expression by another expression that is equal to the first. For example, we have already used substitution when evaluating the expressions in Example 1.1.9. We replaced \(2+3\) with \(5\) because \(2+3 = 5\) is a true equality.

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.

In the Checkpoint 1.3.4 decide whether the expressions are statements for the given value of the variable..

Let \(i:=1\text{.}\)

Decide which of the following are statements, true statements, or false statements.

  1. \(\displaystyle 8\ne i\)

  2. \(\displaystyle i\cdot 8\)

  3. \(\displaystyle 8\cdot i\)

  4. \(\displaystyle i=1\)

Subsection 1.3.3 Variables in Definitions

In definitions we introduce new terminology for objects, properties, and operations.

First we state what kind of object we are talking about. To be able to refer to the object in the definition, we give it a variable name. Then we state the definition of the property using the variable name.

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.

In the following definition we define the property non-negative for an integer. With the first sentence, “Let \(a\) be an integer,” we indicate for what kind of object we want to define a property. In the second sentence we refer to the integer \(a\) and give the condition under which it is called non-negative.

Definition 1.3.6.

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 the statement that uses the definition is not much shorter than the explicit version that we were able to give before. As concepts become more complicated, it will become more convenient to use new vocabulary and notation that we introduce with definitions. We start with well-known terminology.

Definition 1.3.7.

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.8.

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.”

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\)

With variables we can define the product of a natural number and an integer using repeated addition as in Example 1.1.7. We introduce the objects under consideration, namely a natural number and an integer, and assign variable names. Then we use the variable names in the statement of the definition.

Definition 1.3.10.

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.10 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 illustrate this definition with an example.

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

Subsection 1.3.4 “For All” Statements

Statements are often applied to all possible mathematical objects of a specified type.

When we use a variable without assigning it a concrete value, as in Definition 1.3.10, we specify 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.12, Example 1.3.13, and Example 1.3.12 we present statements that are true for all integers. In each example we give two formulations of the same statement.

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{.}\)

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{.}\)

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{.}\)

We now formulate a property of the natural numbers using “for all”.

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.

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.

We only need to give one counterexample to show the statement is false even though a false “for all” statement may have many possible counterexamples.

We can also use the “for all” formulation for several variables. We formulate the commutative property of addition of integers 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 formulate the distributive property for integers with “for all.” The statement is true for any choice of integer for the three variables.

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 previous examples and other properties of addition and multiplication.

  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 1.3.5 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 specified type.

The following four statements all say the the same things. The first statement is the statement from Problem 1.3.15.

  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 formulation for the property of integer addition and multiplication, compare Example 1.3.17 and Example 1.3.18 respectively. Instead of using the formulation “for all” we introduce the variables and what kind of numbers they represent with “let” and then state the property in terms of these variables.

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.

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.

In Checkpoint 1.3.23 decide whether the statements are true or false. If a statement is false, proof that it is false by giving a counterexample. That is, give a value of the variable for which the statement is false.

Decide whether the following statements are true or false.

If the statement is false give a counterexample, otherwise leave the box empty.

(i) For all integers \(a\) and \(b\) we have \(a\cdot b=b\cdot a\text{.}\)

  • select

  • The statement is true.

  • The statement is false.

If the statement is false, give a counterexample: \(a=3\text{,}\) \(b=\)

(ii) For all integers \(a\text{,}\) \(b\) and \(c\) we have \(a\cdot(b\cdot c)=(a\cdot b)\cdot c\text{.}\)

  • select

  • The statement is true.

  • The statement is false.

If the statement is false, give a counterexample: \(a=3\text{,}\) \(b=12\text{,}\) \(c=\).

(iii) For all integers \(a\text{,}\) \(b\text{,}\) and \(c\) we have \(a\cdot (b+c)=(a\cdot b)+c\text{.}\)

  • select

  • The statement is true.

  • The statement is false.

If the statement is false, give a counterexample: \(a=\), \(b=3\text{,}\) \(c=12\)

Answer 1.

\(\text{The statement is true.}\)

Answer 2.

\(\text{}\)

Answer 3.

\(\text{The statement is true.}\)

Answer 4.

\(\text{}\)

Answer 5.

\(\text{The statement is false.}\)

Answer 6.

\(1\)

Subsection 1.3.6 There Exists

Many statements assert that there is a number with a certain property. In this case we use the formulation 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.

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.26.

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 1.3.7 Combining “For all” and “There Exists”

Combining the formulations “for all” and “there exists” allows us to formulate more complicated statements.

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.

In Checkpoint 1.3.29 decide whether the statements are true or false. If a statement is true, give a value of the value for which it is true.

Decide whether the following statements are true or false.

(i) There exists an integer \(a\) such that \(a \cdot 5=0\text{.}\)

  • select

  • The statement is true

  • The Statement is false

If the statement is true, give an integer for which it is true: \(a=\)

(ii) There exists a natural number \(a\) such that \(18+a=0\text{.}\)

  • select

  • The statement is true

  • The Statement is false

If the statement is true, give a natural number for which it is true: \(a=\)

(iii) There exists a natural number a such that \(a\lt 0\text{.}\)

  • select

  • The statement is true

  • The Statement is false

If the statement is true, give a natural number for which it is true: \(a=\)

(iv) There exists an integer \(a\) such that \(a\lt 6\text{.}\)

  • select

  • The statement is true

  • The Statement is false

If the statement is true, give an integer for which it is true: a=

Answer 1.

\(\text{The statement is true}\)

Answer 2.

\(0\)

Answer 3.

\(\text{The Statement is false}\)

Answer 4.

\(\text{}\)

Answer 5.

\(\text{The Statement is false}\)

Answer 6.

\(\text{}\)

Answer 7.

\(\text{The statement is true}\)

Answer 8.

\(5\)

Subsection 1.3.8 Evaluation

So far our use of variables has been in the formulation of statements. We now 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.

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{.}\)

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{.}\)

In Checkpoint 1.3.32 evaluate the expressions for the given values of the variables.