Algebraic Expressions: Terms, Simplifying, Expanding and Factoring

Updated 16 min read Beginner to intermediate Baca dalam Bahasa Indonesia

Algebra Fundamentals Computing

Quick answer

An algebraic expression is a combination of numbers, letters (variables) and operations, such as 3x^2-5x+7; it has no equals sign, so it is simplified or evaluated rather than solved. You simplify it by combining like terms, remove brackets with the distributive law (a(b+c)=ab+ac), and reverse that step by factoring (x^2-9=(x-3)(x+3)). Every step can be checked by substituting a number for the letter.

Key takeaways

  • An expression is built from terms joined by + and −; each term has a coefficient and a variable part, and a term with no letter is a constant.
  • Only like terms, those with exactly the same letters and exponents, can be combined: 3x+5x=8x, but 3x+5x^2 stays as it is.
  • To evaluate, put each value in brackets in place of its letter and then follow the order of operations.
  • To expand, multiply every term of one bracket by every term of the other: (a+b)(c+d)=ac+ad+bc+bd, and (a+b)^2=a^2+2ab+b^2, not a^2+b^2.
  • Factoring undoes expanding: take out a common factor first, then look for a difference of squares, a perfect square, or two numbers with the right product and sum.
  • In a fraction you can cancel factors but never terms, and the canceled factor must not be zero: (x^2-9)/(x+3)=x-3 only for x≠-3.

What is an algebraic expression?

An algebraic expression is a mathematical phrase made of numbers, variables (letters standing for numbers) and operations such as +, −, ×, ÷ and powers. Examples are 2x+3, a^2-2ab+b^2 and (x+1)/(x). An expression is a phrase, not a sentence: it has no equals sign and nothing to solve, but it has a value once the letters are given values.

Expressions are built from terms, the parts joined by + or −. Each term has a coefficient (the number multiplying the letters) and a variable part (the letters with their exponents). A term with no letter is a constant.

TermCoefficientVariable partDegree
3x^23x^22
-5x−5x1
77 (a constant)none0
-y−1y1
4xy4xy2

Three habits make this easier. The sign in front of a term belongs to the term, so 3x^2-5x+7 has the terms 3x^2, -5x and 7. A letter on its own has coefficient 1, so x=1x. And the degree of a term is the sum of the exponents of its letters, so 4xy has degree 2; the degree of an expression is the largest degree among its terms.

The usual names are by number of terms: a monomial has one term, a binomial two and a trinomial three. A sum of terms whose letters have whole-number exponents is a polynomial; its degree gives it a name, linear (1), quadratic (2) or cubic (3). Not every expression is a polynomial: \dfrac1x and √x are algebraic expressions but not polynomials. A linear expression such as 4n+1 is also how the n-th term of an arithmetic sequence is written.

Expression or equation? An equation has an equals sign and says two expressions are equal, as in 2x+3=11; you solve it. An expression such as 2x+3 you simplify, evaluate or factor. Type any expression below to see it taken apart.

Interactive: take an expression apart

Type an expression and see each term split into its coefficient, variable part and degree, with like terms shown in the same color.

Try it: read a coefficient

What is the coefficient of x in 4x^2-7x+2?

How do you combine like terms?

Like terms have exactly the same variable part, the same letters with the same exponents, and you combine them by adding their coefficients and keeping the variable part: 3x+5x=8x. Only the coefficients may differ.

PairLike terms?Why
3x and -7xyessame letter, same exponent
4xy and -xyyessame variable part xy
5 and -2yesboth constants
3x^2 and 5xnoexponents differ
2xy and 2xnoletters differ

Why it works. It is the distributive law read backward: 3x+5x=(3+5)x=8x, as three of something plus five of the same thing is eight of it. That is also why unlike terms cannot be merged: 3x+5x^2 is three of one thing and five of another, and there is no common thing to count.

Worked example: simplify 5x^2+3x-2x^2+7x-4.

  1. Group the like terms: (5x^2-2x^2)+(3x+7x)-4.
  2. Combine each group: 3x^2+10x-4.

Nothing else can be combined, so 3x^2+10x-4 is the simplified form. It is conventional to write the terms from the highest degree down. Use the tool below to check any expression you simplify by hand.

Interactive: expand and simplify

Type an expression with brackets and powers and see it multiplied out and its like terms combined, with its number of terms and degree.

Try it: combine like terms

Simplify, then find a and b.

How do you evaluate an algebraic expression?

To evaluate an expression, replace every letter with its value, writing each value in brackets, and then calculate with the usual order of operations: brackets, then powers, then × and ÷, then + and −. The brackets are what keep negative values safe, and the order of operations with negative numbers has traps of its own.

Evaluate 2x^2-3x at x=-3:

  1. Substitute in brackets: 2(-3)^2-3(-3).
  2. Power first: 2·9-3(-3).
  3. Multiply: 18+9.
  4. Add: 27.

The classic slip is skipping the brackets: 2·-3^2 would give -18, because the power would apply to the 3 alone. A second slip is squaring the coefficient too: in 2x^2 only x is squared, so at x=-3 it is 2·9=18, not (2·(-3))^2=36.

A table of values evaluates one expression at many inputs. For 2x^2-3x:

x−2−1012
2x^2-3x1450−12

Substitution is also how you test. Two expressions are equivalent when they have the same value for every input. One input where they differ proves they are not equivalent: (x+3)^2 and x^2+9 both give 9 at x=0, but at x=1 they give 16 and 10. The reverse does not hold. Agreeing at a few inputs proves nothing, since x^2 and 2x agree at both x=0 and x=2 yet are different expressions.

Interactive: evaluate an expression

Give each letter a value and see the expression with the values substituted and its exact result, plus a table of values for one letter.

Try it: substitute a negative number

Evaluate 2x^2-3x at x=-3.

How do you expand brackets?

To expand brackets, multiply every term inside by whatever is outside, using the distributive law a(b+c)=ab+ac; for two brackets, multiply every term of the first by every term of the second.

For a number outside: 3(x+2)=3x+6. A minus sign in front of a bracket multiplies by −1 and flips every sign inside: -(x-4)=-x+4.

For two binomials the rule is (a+b)(c+d)=ac+ad+bc+bd, four products. Many classes call this FOIL (first, outer, inner, last), which is the same four products in a fixed order. Example:

(x+2)(x-3)=x· x+x·(-3)+2· x+2·(-3)=x^2-3x+2x-6=x^2-x-6.

The area model shows why. A rectangle of width a+b and height c+d has area (a+b)(c+d), the rectangle formula from the area of a quadrilateral. Cut it into four pieces and the areas are ac, bc, ad and bd; the pieces make up the whole, so the four products add up to the product of the sums. Move the sliders to see it with numbers.

Three products come up so often that they are worth recognizing:

NamePatternExample
Square of a sum(a+b)^2=a^2+2ab+b^2(2x+3)^2=4x^2+12x+9
Square of a difference(a-b)^2=a^2-2ab+b^2(x-5)^2=x^2-10x+25
Difference of squares(a+b)(a-b)=a^2-b^2(x+5)(x-5)=x^2-25

In the difference of squares the two middle terms -ab and +ab cancel, which is why no x term is left. A square is never just the squares of the parts: (a+b)^2 is a product of two brackets, (a+b)(a+b), and the cross terms ab appear twice.

Interactive: the area model of multiplying

Move four sliders to cut a rectangle into four smaller ones and see that the product of two sums is the sum of four products.

Try it: expand two brackets

Find a and b.

How do you factor an algebraic expression?

To factor an expression is to write it as a product, the reverse of expanding: x^2-x-6 becomes (x+2)(x-3). Work through the same checklist every time, in this order, and check the answer by expanding it again.

  1. Take out the common factor. 6x^2+9x=3x(2x+3), since 3 and x divide both terms. Do this first, because it makes everything after it smaller.
  2. Two terms: a difference of squares? a^2-b^2=(a-b)(a+b), so x^2-25=(x-5)(x+5) and 4x^2-9=(2x-3)(2x+3). A sum of squares such as x^2+9 does not factor over the real numbers.
  3. Three terms: a perfect square? a^2±2ab+b^2=(a± b)^2, so x^2+6x+9=(x+3)^2. The test is that the middle term is twice the product of the square roots of the outer terms.
  4. Three terms, leading coefficient 1. For x^2+bx+c find two numbers whose product is c and whose sum is b: they are the numbers in (x+p)(x+q). For x^2-5x+6 the numbers are -2 and -3 (product 6, sum −5), so it is (x-2)(x-3).
  5. Three terms, leading coefficient not 1. For ax^2+bx+c find two numbers whose product is ac and whose sum is b, split the middle term with them, and group. For 2x^2+7x+3 the product is 6 and the sum 7, so the numbers are 1 and 6:

2x^2+x+6x+3=x(2x+1)+3(2x+1)=(2x+1)(x+3).

Reading the signs for x^2+bx+c. If c is positive the two numbers have the same sign, the sign of b: x^2+7x+12=(x+3)(x+4) and x^2-7x+12=(x-3)(x-4). If c is negative they have opposite signs, and the larger one takes the sign of b: x^2+2x-15=(x+5)(x-3).

Not everything factors. An expression is fully factored when no factor can be broken further. The trinomial x^2+x+1 has no whole-number factors at all, and x^2-2 has none with whole numbers, although with radicals it is (x-√2)(x+√2). The tool below follows the checklist and says which step it used.

Interactive: factor an expression

Type a polynomial in one letter and see it factored, with the pattern used named and the factors multiplied back to check.

Try it: a difference of squares

Find p.

Try it: a trinomial

Find q.

How do you simplify algebraic fractions?

To simplify an algebraic fraction, factor the top and the bottom, then cancel the factors they share; you may cancel factors, never terms. This is where factoring pays off.

(x^2-9)/(x+3)=((x-3)(x+3))/(x+3)=x-3.

(x^2-1)/(x^2-x)=((x-1)(x+1))/(x(x-1))=(x+1)/(x).

Restrictions. A fraction is undefined where its bottom is zero, and canceling does not remove that. The first fraction above is not defined at x=-3, although x-3 is. So the honest statement is (x^2-9)/(x+3)=x-3 for x≠-3. Try x=-3 in code below: the original gives an error or NaN.

Terms cannot be canceled. In (x+3)/(3) the 3 on top is part of a sum, not a factor, so it does not cancel. Test with x=3: the fraction is \dfrac63=2, while x+1=4. What is true is (x+3)/(3)=\dfrac x3+1.

Multiplying and dividing work as with numbers: multiply tops and bottoms, \dfrac ab·\dfrac cd=(ac)/(bd), and to divide, multiply by the reciprocal, \dfrac ab÷\dfrac cd=\dfrac ab·\dfrac dc. Factor first and cancel before multiplying out.

Adding and subtracting need a common denominator, just as fractions of numbers such as \frac12+\frac13 do:

\dfrac1x+\dfrac1x+1=(x+1)/(x(x+1))+(x)/(x(x+1))=(2x+1)/(x(x+1)).

The common denominator is the product of the different factors, here x(x+1), with each fraction rewritten over it.

Try it: simplify a fraction

Simplify (x^2-9)/(x+3) (for x≠-3).

  • x-3
  • x-9
  • x^2-3
  • It cannot be simplified

How do you turn words into algebra?

To turn words into algebra, name the unknown quantity with a letter and translate each phrase into an operation, taking care over the order of "less than" and "from". Algebra is a short way of writing a sentence.

In wordsIn algebra
a number plus 5, or 5 more than nn+5
7 less than twice n2n-7
7 less than nn-7
n subtracted from 77-n
the sum of n and 3, doubled2(n+3)
a third of n\dfrac n3
the square of the sum of a and b(a+b)^2
the sum of the squares of a and ba^2+b^2

"Less than" and "from" reverse the order: "7 less than n" starts from n, so it is n-7, not 7-n.

A worked example. A notebook costs 5 dollars and a pen costs 3 dollars. For x notebooks and y pens the total is 5x+3y dollars. With 3 notebooks and 2 pens, substitute: 5·3+3·2=21 dollars. The expression is a recipe that works for any quantities, and that is the point of using letters.

Try it: from words to an expression

Which expression means "7 less than twice n"?

  • 2n-7
  • 7-2n
  • 2(n-7)
  • n^2-7

How do you work with algebraic expressions in Python and JavaScript?

In code an expression you want to evaluate becomes a function, and an expression you want to manipulate symbolically needs a library such as SymPy in Python. Plain Python and JavaScript only calculate with numbers; they do not know that x^2-9=(x-3)(x+3).

Python with SymPy (a symbolic algebra library)
>>> from sympy import symbols, expand, factor, simplify
>>> x = symbols('x')
>>> expand((x + 2) * (x - 3))
x**2 - x - 6
>>> factor(x**2 - 5*x + 6)
(x - 3)*(x - 2)
>>> factor(x**2 + 1)          # no real factors, so it is returned unchanged
x**2 + 1
>>> simplify((x**2 - 9) / (x + 3))
x - 3
>>> (3*x**2 - 5*x + 1).subs(x, 2)
3
JavaScript: an expression as a function
const f = (x) => 3 * x ** 2 - 5 * x + 1
f(2)     // 3
f(-2)    // 23

const g = (x) => (x ** 2 - 9) / (x + 3)
g(2)     // -1
g(3)     // 0, the same as 3 - 3
g(-3)    // NaN, because the original is 0 / 0 there
C++
#include <iostream>
using namespace std;

double f(double x) { return 3 * x * x - 5 * x + 1; }
double g(double x) { return (x * x - 9) / (x + 3); }

int main() {
  cout << f(2) << " " << f(-2) << endl;          // 3 23
  cout << g(2) << " " << g(3) << endl;           // -1 0
  // A program cannot expand or factor for you, but it can test an identity at many points
  int bad = 0;
  for (int x = -10; x <= 10; x++) {
    if ((x + 2) * (x - 3) != x * x - x - 6) bad++;        // expand
    if (x * x - 5 * x + 6 != (x - 2) * (x - 3)) bad++;    // factor
  }
  cout << "failures: " << bad << endl;
  return 0;
}

/* output:
3 23
-1 0
failures: 0
*/

The pitfalls, in order of how often they bite:

PitfallWhat happensWhat to do
3x for 3 times xSyntaxError in both languageswrite 3 * x; code has no implied multiplication
2(x + 1)TypeError: the 2 is treated as a functionwrite 2 * (x + 1)
^ for a powerit is XOR, not a poweruse **
x ** 2 in plain PythonNameError until x has a valuegive x a number, or use SymPy for a symbol
Symbolic vs numericx**2 - 9 never becomes (x - 3)*(x + 3) by itselfuse factor in SymPy
Comparing results0.1 * 3 is not exactly 0.3compare with a tolerance, as in the article on real numbers

A numeric test such as f(2) can catch a wrong simplification but cannot prove a right one: it checks one input, exactly the limit described in the section on evaluating.

What are the common mistakes in algebraic expressions?

The most common mistakes with algebraic expressions are the nine below, each with the correct statement and a number that shows why.

MistakeCorrect
❌ 2x+3x=5x^22x+3x=5x. Adding like terms changes the coefficient, not the exponent.
❌ (x+3)^2=x^2+9(x+3)^2=x^2+6x+9. Check at x=1: 16, not 10.
❌ 3(x+2)=3x+23(x+2)=3x+6. The 3 multiplies every term.
❌ -(x-4)=-x-4-(x-4)=-x+4. The minus flips every sign inside.
❌ 3x+5x^2=8x^3Unlike terms stay apart: 3x+5x^2 is already simplest.
❌ (x+3)/(3)=x+1Terms do not cancel: (x+3)/(3)=\dfrac x3+1.
❌ (x^2-9)/(x+3)=x-9Factor first: it is x-3 (for x≠-3).
❌ x^2-16=(x-4)^2x^2-16=(x-4)(x+4). A difference of squares has two different signs.
❌ -x^2=9 at x=-3-x^2=-(-3)^2=-9. Only (-x)^2 is positive.

Practice: test your understanding

These questions mix everything above. A wrong answer costs nothing here: read the hint and try again.

True or false?

Decide whether each statement is True or False.

  • 2x+3x=5x^2.
  • 3(x+2)=3x+6.
  • (x+3)^2=x^2+9.
  • x^2-16=(x-4)(x+4).
  • (x+3)/(3)=x+1.

Select all that apply

Choose all the terms that are like terms of 3x^2y.

  • -5x^2y
  • x^2y
  • 3xy^2
  • 3x^2
  • \frac12x^2y

A special product

Find k.

Evaluate

Evaluate 2x^2-3x+1 at x=3.

Factor a trinomial

Which is the factored form of 2x^2+7x+3?

  • (2x+1)(x+3)
  • (2x+3)(x+1)
  • (2x-1)(x-3)
  • 2(x+1)(x+3)

Words to algebra

A phone plan costs 20 a month plus 3 for every extra gigabyte g. Which expression gives the monthly cost?

  • 20+3g
  • 20g+3
  • 23g
  • 60g

Summary: algebraic expressions at a glance

  • Parts: an expression is terms joined by + and −; a term has a coefficient and a variable part, and a term with no letter is a constant.
  • Like terms: same letters, same exponents; add coefficients, keep the variable part.
  • Evaluate: put each value in brackets, then follow the order of operations. A few matching inputs never prove two expressions equal.
  • Expand: a(b+c)=ab+ac and (a+b)(c+d)=ac+ad+bc+bd; (a± b)^2=a^2±2ab+b^2; (a+b)(a-b)=a^2-b^2.
  • Factor: common factor first, then a difference of squares, a perfect square, or two numbers with product c and sum b; check by expanding.
  • Fractions: factor, then cancel factors, never terms; note where the bottom is zero.
  • Words: name the unknown, and watch the order in "less than".
  • Code: write 3 * x, not 3x; use ** for powers; use SymPy for symbolic work.

Glossary: key terms

Algebraic expression
A combination of numbers, variables and operations with no equals sign, such as 3x squared minus 5x plus 7.
Variable
A letter that stands for a number that can change or is not yet known.
Constant
A term with no variable, whose value never changes, such as the 7 in 3x plus 7.
Term
One part of an expression, separated from the others by a plus or minus sign, which carries its own sign.
Coefficient
The number that multiplies the variables in a term, as the minus 5 in minus 5x.
Like terms
Terms with exactly the same variables raised to the same exponents, which differ at most in their coefficients.
Polynomial
A sum of terms in which each variable has a whole-number exponent, such as x squared minus x minus 6.
Degree
The largest sum of exponents of the variables in any single term of a polynomial.
Binomial
A polynomial with exactly two terms, such as x plus 3.
Distributive law
The rule that a times the sum of b and c equals a times b plus a times c.
Expanding
Removing brackets by multiplying out a product, so that (x plus 2)(x minus 3) becomes x squared minus x minus 6.
Factoring
Writing an expression as a product of simpler expressions, the reverse of expanding.
Difference of squares
An expression of the form a squared minus b squared, which factors as a minus b times a plus b.
Algebraic fraction
A fraction whose top and bottom are algebraic expressions, defined only where the bottom is not zero.

Frequently asked questions

What is an algebraic expression?

An algebraic expression is a combination of numbers, variables and operations without an equals sign, such as 3x plus 5 or a squared minus b squared. It has a value once the variables are given values, and it can be simplified, expanded or factored, but not solved.

What is the difference between an expression and an equation?

An equation has an equals sign and states that two expressions are equal, for example 2x plus 3 equals 11, and you solve it for the unknown. An expression has no equals sign, like 2x plus 3, and you simplify it, evaluate it or factor it.

What are like terms?

Like terms have exactly the same variables with the same exponents; only their coefficients may differ. So 3x and minus 7x are like terms, as are 4xy and minus xy, but 3x squared and 5x are not, because the exponents differ. Only like terms can be combined.

What is a coefficient?

The coefficient is the number that multiplies the variables in a term, including its sign. In 4x squared minus 7x plus 2, the coefficients are 4 and minus 7. A variable on its own, such as x, has coefficient 1, and the constant 2 is its own coefficient.

How do you simplify an algebraic expression?

Remove brackets with the distributive law, then group the like terms and add their coefficients, and write the result from the highest degree down. For example 3 times x plus 2, minus 2 times x minus 1, becomes 3x plus 6 minus 2x plus 2, which is x plus 8.

How do you expand two brackets?

Multiply every term in the first bracket by every term in the second, then combine like terms. For x plus 2 times x minus 3 the four products are x squared, minus 3x, 2x and minus 6, which add up to x squared minus x minus 6.

Why is x plus 3, squared, not x squared plus 9?

Because squaring means multiplying the bracket by itself, x plus 3 times x plus 3, and that produces two middle terms: 3x and 3x. The correct result is x squared plus 6x plus 9. A quick check at x equals 1 gives 16 on the left and only 10 for x squared plus 9.

How do you factor a quadratic expression?

First take out any common factor. Then, for x squared plus bx plus c, find two numbers whose product is c and whose sum is b, and write them in two brackets. For x squared minus 5x plus 6 the numbers are minus 2 and minus 3, so it factors as x minus 2 times x minus 3.

What is a difference of squares?

It is an expression of the form a squared minus b squared, which always factors as a minus b times a plus b. For example x squared minus 25 is x minus 5 times x plus 5. A sum of squares such as x squared plus 25 does not factor over the real numbers.

Can you cancel terms in a fraction?

No, only factors can be canceled. In x plus 3 over 3 the 3 on top is part of a sum, so it stays: the result is x over 3 plus 1. To cancel, factor first, as in x squared minus 9 over x plus 3, which becomes x minus 3.

How do you evaluate an expression with a negative number?

Put the negative value in brackets in place of the letter, then follow the order of operations. For 2x squared at x equal to minus 3, write 2 times minus 3, squared, which is 2 times 9, or 18. Without the brackets you would wrongly get minus 18.

What is the degree of a polynomial?

The degree is the highest total of exponents in any single term. In 3x squared minus 5x plus 7 it is 2, so the polynomial is quadratic. The term 4xy has degree 2, because the exponents 1 and 1 add up, and a nonzero constant has degree 0.

How do you check a factorization?

Multiply the factors back out and compare the result with the original expression. If x minus 2 times x minus 3 expands to x squared minus 5x plus 6, the factoring is correct. You can also substitute one number, such as x equals 1, into both forms.

How do you expand and factor with Python?

Use the SymPy library. Create a symbol with symbols, then call expand to remove brackets, factor to write a product, and simplify to reduce a fraction. Plain Python cannot do this because it only calculates with numbers, and the caret is XOR, so write powers with a double asterisk.

References

  1. James Stewart, Lothar Redlin and Saleem Watson (2016). Precalculus: Mathematics for Calculus (7th ed.). Cengage Learning.
  2. Muhammad ibn Musa al-Khwarizmi (820). The Compendious Book on Calculation by Completion and Balancing (Al-kitab al-mukhtasar fi hisab al-jabr wa-l-muqabala).
  3. François Viète (1591). In artem analyticem isagoge.
  4. René Descartes (1637). La Géométrie.
  5. Florian Cajori (1928). A History of Mathematical Notations. Open Court Publishing Company.
  6. SymPy Development Team. SymPy tutorial: simplification. docs.sympy.org. https://docs.sympy.org/latest/tutorials/intro-tutorial/simplification.html.