Algebra/Variables

From Wikibooks, open books for an open world
Jump to navigation Jump to search
Algebra
 ← Order of Operations Variables Sets → 

In this section, we review the definitions and applications of variables and expressions. In case this is not review, we will attempt to go over the ideas carefully enough so that this section may serve as a first introduction.

Types of Numbers

In mathematics there are names for many different types of numbers and you've encountered lots of these types already and some of these types contain the others. For instance we can start with the whole numbers such as 0, 1, 2, 3, etc. Using subtraction we can build negative numbers by subtracting a bigger number from a smaller giving us an answer in the set {... -3, -2, -1, 0}.

Using division we can identify fractions between 0 and 1 by dividing a smaller number by a bigger e.g. {1/2, 2/3, 3/4, ...} or {-1/-2, -2/-3, -3/-4, ....} We can also identify negative fractions between -1 and 0 by dividing a negative number by a positive or a positive number by a negative {-1/2, -2/3, -3/4, ...} or {1/-2, 2/-3, 3/-4, ...}. Every whole number can be written as a fraction, such as . The rational numbers are exactly those numbers which can be written as fractions.

Rational numbers are a subset of numbers we call real numbers. Some calculators allow you to differentiate between rational numbers and real numbers by representing the rational number as a fraction. If you use decimal notation the decimals in your rational number may go on forever, for example . The real numbers include all of the types of numbers mentioned before (whole numbers, negative numbers, fractions, etc.) and others that require special operations such as roots to represent. These other numbers may not have any recognizable pattern to their digits, such as . But, at the end of the day, the real numbers act just like the rational numbers that you're already familiar with. For those readers that are geometrically inclined, one may think of the real numbers as a line (or ruler), where every point on the line corresponds to exactly one number, as in the picture below.

Variables and Constants

When working with mathematics or science problems it is frequently necessary to talk about numbers whose value you do not know immediately. For example, suppose you are asked how many 1 × 1 squares fit inside a rectangle that measures 9 squares by 10 squares? In this case the number we do not know is "the number of squares." Some people answer correctly right away by saying "The number of squares that fit inside the rectangle is 90." But how did they find this? They could say "The number of squares in the rectangle is equal to the number of squares of its length times the number of squares of its width. The rectangle is 9 squares long and 10 squares wide, so it contains 90 squares." This is a lot of words. We could express ourselves mathematically by writing:

For mathematicians, this is still a lot of writing. Mathematicians usually choose to name each unknown with just a single letter, mostly out of a need for conciseness (that is, shortness), since writing one letter is easier than writing a word. A variable is the letter (or symbol) we are using to represent an unknown number. We could rewrite the calculations above as:

Evaluating expressions

An expression is a collection of symbols you could put into a calculator and get a number. To be precise, an expression is a well-formed formula, but don't worry about the formal details. Expressions are things we can evaluate and I like to call them "numbers in fancy clothing."

Consider the following examples of expressions and non-expressions:

This is an expression, since we can simply add and get

This is also an expression, since it can be evaluated to

This is not an expression. Note that is not being multiplied by anything, and there is no right parenthesis to match left one.

While is not a real number, it is still an expression since it follows the rules of the order of operations.

Now that you're familiar with what expressions look like, let's consider a practical example. A cup of coffee at my favorite café costs $2.00. I drink 4 cups of coffee a day. I want to calculate how much money I spent on coffee this week, and in all of this year.

Let's start with figuring out how much I spend on coffee in a week.

  • Let's call the total number of cups of coffee I drink in a week T. We can give a name to how much money I spend, lets call it C (for cost). C is an expression, but we need a more useful one involving T. Every cup of coffee costs $2.00, so:
  • 0 cups of coffee costs $0, as 0×2 is 0.
  • 1 cup of coffee costs $2, as 1×2 is 2.
  • 2 cups of coffee costs $4, as 2×2 is 4.
  • T cups of coffee costs ... $2T.

So, 2T is an expression representing the cost of T cups of coffee.

This is the first step in figuring out how much I spend on coffee in a week. To get further we need to know the value of T: how many cups of coffee I drink in a week. If I drink 4 cups a day, and there are 7 days in a week, this must mean that

T = 4 × 7 = 28.

By replacing T with the number we calculated we can see that

C is the same as 2.00 × 28 = 56.00.

So I spend $56.00 a week on coffee! Maybe I should cut back!

What about how much I spend in a year? Well, we figure this out in the same way. Let's first think about a year, if we keep our names the same we still have that

C is the same as 2.00 × T.

But now there are 365 days in a year, so the total number of cups of coffee (that is the number T) changes. We can calculate it just as we did before, drinking 4 cups a day leads to:

T = 365 × 4 = 1,460.

Now that we know the value of T we can see that:

C is the same as 2.00 × 1,460 = 2,920.00.

Now I can see that I spend $2,920.00 a year on coffee. Yes, I need to cut back!!

Notice that solution of these two problems is basically the same, the only things that changes is the values of C and T. This is why they are called variables, because the exact numbers varied. Some of the numbers we used in this calculation do not change. For example, the number of days in a week is always 7. We may still use a letter to represent the number of days in a week if we want, but since the number is not going to change, we simply leave it as 7. Letters or symbols that represent specific unchanging numbers are called constants.

In practical situations what you think of as a constant sometimes depends on how you think about the problem. A careful reader may point out that there are not always 365 days in a year: on leap years there are 366. Since I was working out how much I spent for the year 2010, the number of days in the year is constant and equal to 365. If I wanted to make a table of how much I spent on coffee in the last 10 years, then it might be better to use a variable to represent the number of days in a year.

Another example, which might be familiar from physics, is the amount of acceleration of a falling object due to gravity. For most problems this acceleration is treated as a constant g = 9.8 m/s2. However, for problems involving objects that aren't on Earth this may be a bad approximation. The value we used for g in equations concerning objects on other planets may not be considered constants. The problems here are not going to ask us to worry about when it is OK to treat the acceleration due to gravity as a constant, as that is much more appropriate for a physics course. For us, constants are going to be those numbers fixed in the problem and that do not change like the price of coffee in the example above or in some cases some very well known fixed numbers may come up (such as the number of cards in a deck, the number of days in a week, etc.).

Variables are typically written using letters, such as x, t, or C. For cultural reasons x is an extremely common choice for the name of a variable. But when naming a variable or constant yourself it is best to choose something connected to the problem such as C for cost, T for total, etc. This makes it much easier to make sense of the equations you end up looking at. Constants are typically written as the numbers themselves, such as 2, -5, and 0.75, or in some cases may be represented by letters, such as g (from above) and π.

As you can imagine, equations that come up are often more complicated than the equation in the preceding example. We are going to need some vocabulary for the different parts of the equations we encounter. For example, if I let G be the amount of gas I spend driving to the café each day, then the expression for how much I spend C might look like:

2.00 × T + G × D

Now C is the sum of two things called terms. In this case there are two terms in the expression, namely 2.00 × T and G × D. A term of a sum is just one of the pieces we are adding together. In the expression 2.00 × T + G × D − 7 there are three terms. Two of the terms are 2.00 × T and G × D. There are two possibilities for handling − 7. The first possibility is to consider subtraction the same as addition and consider 7 to be the third term. The second possibility is that we think of subtracting 7 as adding −7. In this case we might say that the terms are 2.00 × T, G × D, and −7. To be honest, it doesn't really matter much how we choose to think of things, but we should try to be consistent. Since we used the word "sum" in the definition of term above, we shall try to consistently use the second possibility to describe terms that are subtracted instead of added.

Implied Multiplication with Expressions

There are many ways to indicate that two numbers should be multiplied. You are probably most familiar with using the symbol ×, in equations such as 2 × 2 = 4. But because mathematics developed in many places, there are other symbols that sometimes get used and this becomes particularly important in algebra. Why have more than one notation? Believe it or not, for convenience! For cultural reasons the most common letter to choose for a variable is x, but now things can look confusing when we try to write out expressions like x × 2. It is just an unfortunate fact of life that our variable and our multiplication symbol look a lot alike. Add poor penmanship to this and you're asking for trouble! There are two common ways to deal with this. The first is to introduce another symbol for multiplication, namely a dot written in the middle of the line. For example instead of writing 2 × 2 = 4 one can write 2 · 2 = 4. Another even more common strategy is to do away with writing anything at all! Suppose I want to multiply x by 2. Since it can lead to confusion I do not want to write 2 × x. I could write, with our new dot notation 2 · x, or I could just be concise and decide you'll know what it means if I write 2x. That's right, I skipped writing any symbol for multiplication at all! This is known as implied multiplication, because I never really said I was multiplying, I just implied it. This is by far the most common way to express multiplying in algebra.

At first this may seem a crazy way to do things, but it works particularly well with our intuition about units. We are taught from elementary school that if I have 1 apple and someone gives me 1 apple then I have 2 apples. In the same way it seems very natural to write 1x + 1x = 2x. If I have 1 x and someone gives me 1 x then I will just have 2 x's. Because variables have such a strong similarity to our units in simple examples like this, it has been culture to never place the variable before the number in implied multiplication. While it may be in some technical sense correct, to write x2 for the product of 2 and x, people may not understand what it means. So always place explicit numbers before the variables when using implied multiplication.

Implied multiplication is also frequently used between two different variables, or even two whole expressions (provided you use parentheses). So we may encounter expressions like xy for the product of x and y, or x(a + b) for the product of x and a + b. Because implied multiplication is so common it gives us even more reason to use single letters for variables. While it might have been nice to use a variable YC for the yearly cost for my coffee, if I were not very careful to explain what I meant some readers may think this represents some variable Y multiplied by another variable C. On the other hand in complicated situations with lots of variables sometimes it is worth risking confusion to choose variable names that make sense.

Finally, you can use implied multiplication between two numbers. Just try it, if we wanted to write 2 × 2 = 4 using implied multiplication we would end up writing 22 = 4, but twenty-two is not four! Instead, we write one or both constants in parentheses: 2(2) = 4 or (2)(2) = 4. Both forms are correct. Follow what your teacher says when in doubt.

Evaluating expressions

We treat variables just like numbers — numbers that maybe we do not know at the beginning, but numbers nonetheless. When we know what the numbers associated with a variable are we can figure out what some expression we have written before equals. Suppose we are asked to find the value of x − 5 when x = 7. To do this we substitute 7 for x. This means we rewrite the expression, except everywhere we would write x we write 7. So we get 7 − 5, and now we can use simple arithmetic to figure out that the expression equals 2. If you look back to discussion analyzing my coffee drinking habits, you'll see see we substituted a few times already. Let's look at some more examples.

Problem. Find the value of x · y − 9 when x = 2 and y = 3.

Solution. We will do this in two steps. First we will substitute 2 for x to get:

2 · y − 9.

Now we will substitute 3 for y to get:

2 · 3 − 9 = 6 − 9 = -3.

In the last line, since we had gotten to a problem of arithmetic we simply used the rules of arithmetic we are already familiar with. One time to be a little bit careful is when implied multiplication is involved. Consider the following example. We needed to use our precedence rules to work the simple arithmetic in the right order in order to figure out that the expression equals 2.

Problem. Evaluate 2x + 2 when x = 4.

Solution. Substituting 4 for x we get:

2 · 4 + 2 = 8 + 2 = 10.

Notice a very subtle change when I rewrote the expression. Specifically I inserted a multiplication symbol where there was an implied multiplication. Imagine that I hadn't: the last line would have started 24 + 2, which is not what we meant! We wanted to multiply x by 2, since x = 4, that means we wanted multiply 4 by 2. The number 24 shouldn't be part of our calculation.

It is very important when evaluating expressions to follow the correct order of operations (Don't forget "Please excuse my dear aunt Sally"). For example

Problem. Simplify the expression 3x2(2z+k) given that x is 2, z is 1/2 and k is 1.

Solution. Writing first by substituting for x, we have

3 · 22 · (2z+k)

Now substiting for z

3 · 22 · (2 · 1/2 + k)

Finally we substitute for k to get:

3 · 22 · (2 · 1/2 + 1).

First we need to figure out the value inside the parentheses, that is we need to calculate 2 · 1/2 + 1. The correct order to do this in is to first multiply, then add. That is 2 · 1/2 + 1 = 1 + 1 = 2.

Now that we have figured out what is inside the parentheses, the problem is now to calculate:

3 · 22 · (2).

We do the exponentiation first to get

3 · 4 · (2).

Now we simply multiply, and our answer is 24.

Parentheses

Let's look at when it is OK to add or remove parentheses. The purpose of parentheses is to establish precedence. Precedence tells you which operation goes first. The operation rules for precedence say to evaluate the parentheses first (PEMDAS!). But, what can you do with  ?   doesn't have just one value; it has as many values as we choose to assign to . This is where the distributive property shows its power. It allows us to rearrange the operations while maintaining precedence.

So we can change our equation to

Add to both sides

And multiply both sides by the inverse of

Parentheses allow us to ensure that we treat expressions that have variables as if they were a value. For instance, if we want to know for which values the expression is true we need to use the properties of real numbers to place the variable by itself on one side of the equals sign. To do this we need to get out of the denominator of the fraction. We can do this by multiplying both sides of the equation by . We don't know what the value of is, but it will always be the same thing on both sides of the equation so it doesn't change the notion of equality.


We use the inverse property to re-write as multiplication.

And the associative property to re-write the multiplication.

And the identity property to re-write

Since 2 * (1) has no variables we can evaluate it. We use the distributive property to re-write 3 * (x+ 1)

We subtract 3 from both sides of the equation.

And multiply both sides by .

Using parentheses and the properties of real numbers and equality we were able to get x alone to determine the only number for which our initial statement is true.

Exercises

In the problems below letters will be given to represent various numbers. Decide if the following quantities should be referred to as variables or constants. Note: answer the "Explain" questions on paper.

1 Y, the number of years since the last moon landing.

variable
constant

2 Explain your reasoning.

 

3 x, the number of donuts in an unopened box of a dozen.

variable
constant

4 Explain your reasoning.

 

5 C, the price of a cup of coffee at a particular café.

variable
constant

6 Explain your reasoning.

 

7 c, the number of measured cups in a liter of liquid.

variable
constant

8 Explain your reasoning.

 

9 w, the number of windows open on your computer screen.

variable
constant

10 Explain your reasoning.

 

11 p, the number of problems in this book you have attempted.

variable
constant

12 Explain your reasoning.

 
Evaluate the following expressions at the indicated values.

13 when

14 when and

15 when