- Introduction
- What is a variable?
- Constants, coefficients and terms
- What is an expression?
- Translating words into expressions
- The order of operations
- Evaluating an expression
- Simplifying expressions
- More than one variable
- Common mistakes
- Programming
- AI and machine learning
- Practice problems
- Conclusion
1. Introduction
Every field of mathematics rests on a small number of ideas that everything else is built from. In algebra, those ideas are variables and expressions. A variable is a symbol that stands for a number we do not know yet, or a number that is allowed to change. An expression is a combination of numbers, variables and operations that describes a calculation. Together they give us a compact language for saying things that would otherwise take whole paragraphs of words.
Consider the sentence, "Take a number, multiply it by three, and then add two." Written in words it is clumsy, and it gets worse as the instructions grow longer. In algebra we write 3x + 2 and the whole idea fits in four symbols. The letter x stands for any number you like, and the expression tells you what to do with it.
This article walks through the topic from the ground up. We will define the key terms, practise reading and writing expressions, learn the rules for evaluating and simplifying them, and look at the mistakes that trip up most beginners. Then we will step outside the classroom and see how the same ideas appear in everyday life, in computer programming and in artificial intelligence, where variables and expressions quietly do most of the work. If you can handle the material here, you have the foundation for linear equations, functions, calculus and almost every quantitative subject that follows.
2. What is a variable?
A variable is a letter or symbol that represents a quantity. The word itself explains the idea: the value can vary. When a shopkeeper says "the price depends on how many items you buy," the number of items is a variable, because it can be one, five or fifty. Mathematicians usually choose letters from the end of the alphabet, such as x, y and z, but any symbol will do. Letters are often chosen to remind you of their meaning: t for time, r for radius, n for a count, p for price.
Variables play two slightly different roles. In the first role, a variable is an unknown that we want to find. In the equation x + 4 = 10, the letter x is a placeholder for one specific number, and our job is to discover that it is 6. In the second role, a variable is a quantity that really does change. In the formula for the area of a square, A = s², the side length s can be any positive number, and the area changes along with it. Here the variable is not a mystery to be solved. It is an input we are free to choose.
3. Constants, coefficients and terms
Before we can talk about expressions, we need a few more words. A constant is a value that never changes, such as 7, −3 or one half. A well-known mathematical constant is π, which is approximately 3.14159. A coefficient is the number multiplied by a variable. In 5x, the coefficient is 5. When no number is written, as in x, the coefficient is understood to be 1. In −y the coefficient is −1.
A term is a single piece of an expression, separated from the others by plus or minus signs. A term can be a lone number, a lone variable, or numbers and variables multiplied together. Take the expression 4x² − 7x + 9. It has three terms, listed in the table below.
| Term | Coefficient | Variable part | Type |
|---|---|---|---|
| 4x² | 4 | x² | Variable term |
| −7x | −7 | x | Variable term |
| 9 | 9 | none | Constant term |
Notice that the sign in front of a term belongs to that term. The second term is negative seven times x, not "seven x that is being subtracted." This detail matters when you start rearranging things. Another useful word is exponent, the small raised number that says how many times to multiply a quantity by itself. In x², the exponent is 2, so x² = x · x. The exponent applies only to what it touches. In 4x², only the x is squared, not the 4.
4. What is an expression?
An algebraic expression is a mathematical phrase made from numbers, variables and operations such as addition, subtraction, multiplication, division and exponents. Examples include x + 5, 2(a − 3) and (x² + 1) / 4. An expression describes a calculation, but it does not make a claim. It has no equals sign and cannot be true or false. It simply stands for a value once the variables are given numbers.
The easiest way to understand the difference between an expression and an equation is through grammar. An expression is like a noun phrase, for example "the cost of three notebooks." An equation is like a complete sentence, for example "the cost of three notebooks is twelve dollars." The first names something, and the second makes a statement that can be checked. So 3n is an expression, while 3n = 12 is an equation that happens to be true when n = 4.
Expressions are classified by their structure. A monomial has one term, such as 6x³. A binomial has two terms, such as x + 9. A trinomial has three, such as the 4x² − 7x + 9 we met above. Anything with several terms is called a polynomial. The highest exponent of the variable in a polynomial is its degree, so 4x² − 7x + 9 is a degree-two polynomial. This is the same shape you will meet again when you study quadratic equations.
| Name | Terms | Example | Degree |
|---|---|---|---|
| Monomial | 1 | 6x³ | 3 |
| Binomial | 2 | x + 9 | 1 |
| Trinomial | 3 | 4x² − 7x + 9 | 2 |
| Polynomial | any number | 2x³ + x² − 5x + 1 | 3 |
5. Translating words into expressions
One of the most practical skills in algebra is turning a sentence into an expression. Certain phrases signal certain operations. "Sum," "more than" and "increased by" point to addition. "Difference," "less than" and "decreased by" point to subtraction. "Product" and "times" point to multiplication, and "quotient" or "divided by" to division. "Twice" means multiply by 2, and "square of" means raise to the power 2.
| Operation | Words to look for | Symbol |
|---|---|---|
| Addition | sum, plus, more than, increased by, total | + |
| Subtraction | difference, minus, less than, decreased by | − |
| Multiplication | product, times, twice, of | × |
| Division | quotient, divided by, per, ratio | ÷ |
| Exponent | squared, cubed, to the power of | xⁿ |
Let a number be n. Then "five more than twice a number" becomes 2n + 5. First we build "twice a number," which is 2n, and then we add 5. The phrase "three less than a number" becomes n − 3, and this is the place where people most often slip. The order of the words in English is reversed in the symbols, so writing 3 − n would be wrong. "The sum of a number and 7, doubled" becomes 2(n + 7), with parentheses because the doubling applies to the whole sum.
| Phrase | Expression |
|---|---|
| five more than twice a number | 2n + 5 |
| three less than a number | n − 3 |
| the sum of a number and 7, doubled | 2(n + 7) |
| the square of a number, decreased by 1 | n² − 1 |
| half of a number | n / 2 |
Real situations work the same way. Suppose a taxi charges a fixed fee of 4 dollars plus 1.50 dollars for every kilometre. If k is the distance in kilometres, the cost in dollars is C = 4 + 1.5k. The constant 4 is the starting charge, and the coefficient 1.5 is the rate per kilometre. A ten-kilometre trip costs 4 + 1.5(10) = 19 dollars. Once you have the expression, you never need to reason about the story again. You just substitute numbers.
| Distance k (km) | Calculation | Cost C ($) |
|---|---|---|
| 0 | 4 + 1.5(0) | 4.00 |
| 5 | 4 + 1.5(5) | 11.50 |
| 10 | 4 + 1.5(10) | 19.00 |
| 15 | 4 + 1.5(15) | 26.50 |
| 20 | 4 + 1.5(20) | 34.00 |
6. The order of operations
An expression can only be evaluated if everyone agrees on the order in which to perform the operations. Consider 2 + 3 × 4. If you add first you get 20, and if you multiply first you get 14. To avoid confusion, mathematicians use a fixed convention that is often remembered by the acronym PEMDAS or BODMAS.
- Parentheses (brackets): work inside them first.
- Exponents (orders): powers and roots come next.
- Multiplication and division: from left to right, with equal priority.
- Addition and subtraction: from left to right, with equal priority.
| Priority | Operation | Example | Result |
|---|---|---|---|
| 1 | Parentheses | 2 × (3 + 4) | 14 |
| 2 | Exponents | 2 + 3² | 11 |
| 3 | Multiply / divide | 2 + 3 × 4 | 14 |
| 4 | Add / subtract | 8 − 3 + 2 | 7 |
By this rule, 2 + 3 × 4 = 2 + 12 = 14. If we wanted the addition to happen first, we would have to say so with parentheses: (2 + 3) × 4 = 20. A common trap involves the phrase "left to right." The expression 8 − 3 + 2 equals 7, not 3, because subtraction and addition share the same level and are handled in the order they appear. The same applies to 24 ÷ 4 × 3, which is 18 and not 2.
Negative numbers and exponents deserve special care. The expression −3² means the negative of 3 squared, so it equals −9. The expression (−3)² squares the number negative three, so it equals 9. The parentheses change the answer completely. Computers follow exactly the same rules, which is one reason this convention matters beyond the classroom.
| Expression | Typical wrong answer | Correct answer | Why |
|---|---|---|---|
| 8 − 3 + 2 | 3 | 7 | left to right |
| 24 ÷ 4 × 3 | 2 | 18 | left to right |
| 2 + 3 × 4 | 20 | 14 | multiply before adding |
| −3² | 9 | −9 | square first, then negate |
| (−3)² | −9 | 9 | the bracket squares the negative |
7. Evaluating an expression
To evaluate an expression means to find its numerical value once each variable has been replaced by a number. The method is called substitution, and it has three steps. Replace each variable with its value, using parentheses around any negative number. Follow the order of operations. Write the final answer clearly.
Let us evaluate 3x² − 2x + 5 at x = 4. Substituting gives 3(4)² − 2(4) + 5. The exponent comes first, so 4² = 16. Then we multiply, giving 3 × 16 = 48 and 2 × 4 = 8. The expression becomes 48 − 8 + 5, which equals 45.
Now try the same expression at x = −2. Substituting gives 3(−2)² − 2(−2) + 5. The square of negative two is 4, so the first term is 12. The second term is −2 × (−2) = +4, because a negative times a negative is positive. The total is 12 + 4 + 5 = 21. Using parentheses around the substituted value is what protects you from sign errors, and that habit is worth building early.
| x | 3x² | −2x | + 5 | Result |
|---|---|---|---|---|
| −2 | 12 | +4 | 5 | 21 |
| −1 | 3 | +2 | 5 | 10 |
| 0 | 0 | 0 | 5 | 5 |
| 1 | 3 | −2 | 5 | 6 |
| 2 | 12 | −4 | 5 | 13 |
| 3 | 27 | −6 | 5 | 26 |
| 4 | 48 | −8 | 5 | 45 |
Evaluation is the same as running a machine. The expression is the machine, the variable value is the input, and the result is the output. Feed in 4 and 45 comes out. Feed in −2 and 21 comes out. This simple picture is the seed of the concept of a function, which is the next topic in algebra.
8. Simplifying expressions
Two expressions that look different can still have the same value for every choice of variable. Simplifying means rewriting an expression in a shorter or cleaner equivalent form. There are two main tools: combining like terms and applying the distributive property.
Like terms are terms with exactly the same variable part, such as 4x and −2x, or 5y² and y². You can combine them by adding their coefficients, because they count the same kind of object. Four apples minus two apples is two apples, and in the same way 4x − 2x = 2x. Unlike terms cannot be merged. You cannot combine 3x and 3y any more than you can add apples to oranges and call them apples. As an example, 4x + 3y − 2x + 7y simplifies to 2x + 10y, since we group the x terms and the y terms separately.
| Pair | Like terms? | Reason |
|---|---|---|
| 4x and −2x | Yes | same variable part, x |
| 5y² and y² | Yes | same variable part, y² |
| xy and yx | Yes | same variables, order does not matter |
| 3x and 3y | No | different variables |
| x and x² | No | different exponents |
The distributive property says that multiplying a sum by a number is the same as multiplying each part and adding the results: a(b + c) = ab + ac. For example, 3(2x + 5) = 6x + 15. It also works in reverse, which is called factoring: 6x + 15 = 3(2x + 5). Factoring pulls out a common factor and is one of the most useful moves in all of algebra.
Both tools combine in longer problems. Simplify 2(x + 4) + 3(x − 1). Distribute first to get 2x + 8 + 3x − 3. Then combine like terms: the x terms give 5x and the constants give 5. The result is 5x + 5. To check, try x = 2 in both forms. The original gives 2(6) + 3(1) = 15, and the simplified version gives 5(2) + 5 = 15. Testing a value is a quick way to catch mistakes.
9. More than one variable
Many expressions contain several variables. The expression 2a + 3b − c has three of them, and to evaluate it we need a value for each. If a = 5, b = 2 and c = 4, the result is 10 + 6 − 4 = 12. The same rules apply as before. Like terms must share exactly the same variables with the same exponents, so xy and x²y are not like terms.
Formulas are expressions with several variables that describe relationships in science and everyday life. The area of a rectangle is A = l × w. The distance travelled at constant speed is d = v × t. The conversion from Celsius to Fahrenheit is F = (9/5)C + 32, so water boiling at 100 degrees Celsius gives (9/5)(100) + 32 = 212 degrees Fahrenheit. In each case, the formula is a reusable expression and the variables are the slots that you fill in.
| Formula | Meaning | Example |
|---|---|---|
| A = l × w | area of a rectangle | l = 5, w = 3 gives A = 15 |
| d = v × t | distance at constant speed | v = 60, t = 2 gives d = 120 |
| F = (9/5)C + 32 | Celsius to Fahrenheit | C = 100 gives F = 212 |
| C = 4 + 1.5k | taxi fare | k = 10 gives C = 19 |
10. Common mistakes
Most errors with variables and expressions fall into a small number of patterns, and knowing them in advance saves a lot of frustration.
| Mistake | Wrong | Right |
|---|---|---|
| Adding unlike terms | 3x + 2 = 5x | cannot be combined: 3x + 2 |
| Squaring a sum term by term | (x + 3)² = x² + 9 | x² + 6x + 9 |
| Dropping a sign when distributing | −2(x − 5) = −2x − 10 | −2x + 10 |
| Misreading negatives and powers | −4² = 16 | −4² = −16 and (−4)² = 16 |
| Reversing “less than” | 7 − n for “7 less than n” | n − 7 |
| Treating an expression like an equation | trying to solve 2x + 6 | evaluate or simplify it |
The best defence is the habit of checking. Substitute a simple number, such as 2 or 3, into both the original and your answer. If the results differ, an error has crept in. A second habit is writing every step instead of doing several in your head. Slowing down is faster than redoing the problem.
11. Programming
If you have ever written code, you have already worked with variables and expressions. A programming variable is a named location in memory that holds a value, and an expression is any combination of values, variables and operators that the computer can evaluate. There is one important difference in notation. In most languages, the symbol = means assignment, which stores a value, and not mathematical equality. Many languages use == to compare two values.
x = 3
y = 3 * x**2 - 2 * x + 5 # an expression, evaluated to 26
def f(x):
return 3 * x**2 - 2 * x + 5
print(f(4)) # 45
print(f(-2)) # 21
The code mirrors our earlier work exactly. With x = 3 the expression gives 27 − 6 + 5 = 26, and the function reproduces the values 45 and 21 that we calculated by hand for x = 4 and x = −2. Programming languages also follow the same order of operations, with exponents before multiplication and multiplication before addition, which is why the algebra rules you learn now remain useful for your entire career.
12. AI and machine learning
Modern artificial intelligence is built almost entirely from variables and expressions, assembled at enormous scale. A machine learning model is, at heart, a large expression with some inputs and some adjustable numbers. The inputs are the data, such as the size of a house or the pixels in a photograph. The adjustable numbers are called parameters, and training a model means finding good values for them.
The simplest example is a linear model that predicts a house price from two features. It can be written as ŷ = w₁x₁ + w₂x₂ + b. Here x₁ and x₂ are features such as floor area and number of rooms, w₁ and w₂ are weights that act as coefficients, and b is a constant term called the bias. The hat on ŷ signals that it is a prediction, not a true value. With w₁ = 0.5, x₁ = 4, w₂ = −1, x₂ = 2 and b = 3, the model outputs 2 − 2 + 3 = 3. This is exactly the substitution process from section seven.
| Part | Symbols | How it combines | Contribution |
|---|---|---|---|
| Feature 1 (floor area) | x₁ = 4, w₁ = 0.5 | weight × feature | 2 |
| Feature 2 (rooms) | x₂ = 2, w₂ = −1 | weight × feature | −2 |
| Bias | b = 3 | constant term | 3 |
| Prediction | ŷ | sum of the three | 3 |
Everything else in training is also expressed this way. The error of a prediction can be written as (y − ŷ)², so a true value of 5 against a prediction of 3 gives an error of 4. Adding the errors over all examples gives a loss expression, and the learning algorithm repeatedly adjusts the weights to make that loss smaller. Deep neural networks simply nest thousands of such expressions inside one another. Understanding what a coefficient, a term and an order of operations mean is therefore the first step toward understanding how these systems work.
| Algebra | Programming | Machine learning |
|---|---|---|
| variable | variable name | feature (input) or parameter (learned) |
| coefficient | multiplier | weight |
| constant term | constant | bias |
| expression | expression | model or loss formula |
| evaluating (substituting) | running the code | inference (making a prediction) |
13. Practice problems
Try these on paper before you check the answers below.
- Evaluate 5a − 3b + 2 when a = 3 and b = 4.
- Simplify 7x + 2 − 3x + 9.
- Expand 4(2y − 3).
- Write an expression for "six less than three times a number."
- Evaluate (2x + 1)² when x = 3.
- Simplify 3(x + 2) − 2(x − 4).
- Evaluate 2 + 3 × (8 − 5)².
Answers.
- 5(3) − 3(4) + 2 = 15 − 12 + 2 = 5.
- Combine 7x − 3x = 4x and 2 + 9 = 11, giving 4x + 11.
- 8y − 12.
- 3n − 6.
- (2 × 3 + 1)² = 7² = 49.
- 3x + 6 − 2x + 8 = x + 14.
- Parentheses give 3, the exponent gives 9, multiplication gives 27, and adding 2 gives 29.
14. Conclusion
Variables and expressions are the grammar and vocabulary of algebra. A variable lets us talk about numbers in general, and an expression lets us describe what to do with them. Once you can read an expression, build one from a description, evaluate it by substitution and simplify it with like terms and the distributive property, you can handle the great majority of early algebra with confidence.