Variables and Functions

How do we represent and find unknown values?

KEY TERMS

  • Variable: A symbol that represents an unknown value.

  • Equation: A statement that says two mathematical expressions are equal.

Variables

One of the fundamental building blocks of algebra is the concept of variables. Sometimes, we don't know what a value will be -- for example, prices at a grocery store change all the time! Let's say you have the following grocery list every week:

  • Banana (1)

  • Loaf of bread (1)

But food prices often change! One week, a banana may cost $0.50; the next, it might be $1.00. If we know the price of a loaf of bread will always be $3.00, how do we represent the total value of the things we're buying?

(price of banana) + $3.00

If the banana is $1.00, then we can say the total price is $4.00; if it's $0.50, the total price is $3.50.

In this case, bananas are an unknown value. It can be helpful to represent unknown values with variables -- quantities that we know are going to change. We usually represent variables as letters or words; they take the place of numbers in calculations. For example, we can call the price of a banana b.

You can have more than one unknown variable.

Equations

We perform calculations on numbers all the time! A simple one is doubling a value. Take the banana example above: what if we wanted two bananas? How would we represent that?

Since b is the price of the banana, we can multiply the banana price by 2. If the price were $1.00 per banana, for example, two bananas would be $2.00. We represent this as 2b.

What if we wanted another variable that represented these two bananas? We can call it t. Currently its value is $2.00.

We know that t is equal to 2b. This can be represented by something called an equation:

t = 2b

This means that anywhere t exists, it can be represented by 2b. When b's value increases, so does t's!

Functions

Doubling values can be very useful! It would be great if we could extend this logic further.

So, how can we find unknown values? By using something called a function!

Functions transform values according to a set of rules. They have several components:

  • Name: describes the function, like a variable name!

  • Inputs: the values a function transforms.

  • Output: the value the function transforms the input into.

Let's try building a function!

What if we wanted to double any price? We could write a function that takes in an input of price and outputs twice the price!

We can call this function double; we know the input will be price. All that's left is the output! Since we want to double our output, we can multiply price by 2.

In function notation, this is written as:

double(price) = 2 * price

What does this function mean? We write the function name, double, and put the inputs in parenthesis next to it. We say that the function is equal to the output: 2 * price.

Functions can also take in multiple inputs: if we wanted to add together two values, x and y, we could write a function called add:

add(x, y) = x + y

In many ways, functions are a valuable tool to describe the world around us. When your brain tells your arm to move, it is providing your muscles with some signals that output movement. When you turn on a car, you are signaling that the car's engine should run.

Last updated