If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Variables, expressions, & equations

In algebra, we use variables like x, y, and z to represent unknown values. Expressions are combinations of variables and numbers, while equations equate two expressions. Variables can take on different values depending on the context, and we can evaluate expressions by substituting values for the variables. Created by Sal Khan.

Want to join the conversation?

Video transcript

When we're dealing with basic arithmetic, we see the concrete numbers there. We'll see 23 plus 5. We know what these numbers are right over here, and we can calculate them. It's going to be 28. We can say 2 times 7. We could say 3 divided by 4. In all of these cases, we know exactly what numbers we're dealing with. As we start entering into the algebraic world-- and you probably have seen this a little bit already-- we start dealing with the ideas of variables. And variables, there's a bunch of ways you can think about them, but they're really just values in expressions where they can change. The values in those expressions can change. For example, if I write x plus 5, this is an expression right over here. This can take on some value depending on what the value of x is. If x is equal to 1, then x plus 5, our expression right over here, is going to be equal to 1. Because now x is 1. It'll be 1 plus 5, so x plus 5 will be equal to 6. If x is equal to, I don't know, negative 7, then x plus 5 is going to be equal to-- well, now x is negative 7. It's going to be negative 7 plus 5, which is negative 2. So notice x here is a variable, and its value can change depending on the context. And this is in the context of an expression. You'll also see it in the context of an equation. It's actually important to realize the distinction between an expression and an equation. An expression is really just a statement of value, a statement of some type of quantity. So this is an expression. An expression would be something like what we saw over here, x plus 5. The value of this expression will change depending on what the value of this variable is. And you could just evaluate it for different values of x. Another expression could be something like, I don't know, y plus z. Now everything is a variable. If y is 1 and z is 2, it's going to be 1 plus 2. If y is 0 and z is negative 1, it's going to be 0 plus negative 1. These can all be evaluated, and they'll essentially give you a value depending on the values of each of these variables that make up the expression. An equation, you're essentially setting expressions to be equal to each other. That's why they're called equations. You're equating two things. An equation, you'll see one expression being equal to another expression. For example, you could say something like x plus 3 is equal to 1. And in this situation where you have one equation with only one unknown, you can actually figure out what x needs to be in this scenario. And you might even do it in your head. What plus 3 is equal to 1? Well, you could do that in your head. If I have negative 2, plus 3 is equal to 1. In this context, an equation is starting to constrain what value this variable can take on. But it doesn't have to necessarily constrain it as much. You could have something like x plus y plus z is equal to 5. Now you have this expression is equal to this other expression. 5 is really just an expression right over here. And there are some constraints. If someone tells you what y and z is, then you're going to get an x. If someone tells you what x and y is, then that constrains what z is. But it depends on what the different things are. For example, if we said y is equal to 3 and z is equal to 2, then what would be x in that situation? If y is equal to 3 and z is equal to 2, then you're going to have the left-hand expression is going to be x plus 3 plus 2. It's going to be x plus 5. This part right over here is just going to be 5. x plus 5 is equal to 5. And so what plus 5 is equal to 5? Well, now we're constraining that x would have to be equal to 0. Hopefully you realize the difference between expression and equation. In an equation, essentially you're equating two expressions. The important thing to take away from here is that a variable can take on different values depending on the context of the problem. And to hit the point home, let's just evaluate a bunch of expressions when the variables have different values. For example, if we had the expression x to the y power, if x is equal to 5 and y is equal to 2, then our expression here is going to evaluate to, well, x is now going to be 5. y is going to be 2. It's going to be 5 to the second power, or it's going to evaluate to 25. If we changed the values-- let me do that in that same color-- if we said x is equal to negative 2 and y is equal to 3, then this expression would evaluate to-- let me do it in that-- negative 2. That's what we're going to substitute for x now in this context. And y is now 3, negative 2 to the third power, which is negative 2 times negative 2 times negative 2, which is negative 8. Negative 2 times negative 2 is positive 4, times negative 2 again is equal to negative 8. We could do even more complex things. We could have an expression like the square root of x plus y and then minus x, like that. Let's say that x is equal to 1 and y is equal to 8. Then this expression would evaluate to, well, every time we see an x, we want to put a 1 there. So we would have a 1 there, and you'd have a 1 over there. And every time you see a y, you would put an 8 in its place in this context. We're setting these variables. So you'd see an 8. Under the radical sign, you would have a 1 plus 8. So you'd have the principal root of 9, which is 3. This whole thing would simplify. In this context, when we set these variables to be these things, this whole thing would simplify to be 3. 1 plus 8 is 9. The principal root of that is 3. And then you'd have 3 minus 1, which is equal to 2.