acalculator

How do I combine like terms?

Type an expression such as 3x + 7 + 4x + 5 or 3(x + 2) - 5x. The page multiplies out brackets and adds the like terms.

Your numbers

Simplified
7x + 12

3x + 7 + 4x + 5 simplifies to 7x + 12.

Simplified: 7x + 12. 3x + 7 + 4x + 5 simplifies to 7x + 12.

How to calculate

Simplifies an expression by multiplying out brackets and combining like terms, with exact fractions.

Example with the default inputs (Expression 3x + 7 + 4x + 5): 3x + 7 + 4x + 5 simplifies to 7x + 12.

Method: Multiply out brackets and whole powers, then add the exact coefficients of terms with the same letters to the same powers.

  • Coefficients are exact fractions: 0.1 is 1/10. Pieces such as sin(x) are combined only when written the same way.

Machine-readable copies: Markdown, JSON.

Worked examples

Each example is checked against the calculator on every build.

  1. Expression 3x + 7 + 4x + 5 gives Simplified 7x + 12.Source: OpenStax Prealgebra 2e, 2.2, Ex. 2.21. https://openstax.org/books/prealgebra-2e/pages/2-2-evaluate-simplify-and-translate-expressions
  2. Expression 7x^2 + 8x - x^2 - 4x gives Simplified 6x^2 + 4x.

How it works

The page reads your expression and writes it as a sum of terms. Each term is an exact fraction (the coefficient) times a product of factors, each factor to a whole-number power. A factor is a letter, or a piece kept whole:

  • a function of something, such as sin(2x) or ln(x + 1) (its inside is simplified the same way first);
  • π or e;
  • a power whose exponent is not a whole number, such as x^(1/2) or e^x;
  • a sum under a fraction bar, such as (x + 1) in 3/(x + 1) (a sum to a negative whole power down to −20 goes under the bar the same way);
  • a sum to any other power, such as (x + 1)^25, kept whole.

The rules:

  • Brackets: products are multiplied out (every term times every term); a sum to a whole-number power from 0 to 20 is multiplied out; a single term to any whole power up to ±100 is kept as one term; any power 0 is 1, so x^0 is the number 1 and adds to the other numbers.
  • Division: dividing by a number or by a single term (such as 4y²) divides the coefficient and subtracts powers; dividing by a sum keeps that sum whole under the bar. A sum on top is not cancelled against a sum underneath: (x + y)²/(x + y) stays as x²/(x + y) + 2x y/(x + y) + y²/(x + y).
  • Like terms: terms with the same factors to the same powers are added; a term whose coefficient becomes 0 is dropped.
  • Numbers are exact: 0.1 is 1/10, 2.5 is 5/2. Dividing by 0 gives a message.

Check. The written answer is read back and evaluated at 15 test points (each letter set to 3 sin(3i + j) for point i = 1 to 15, where j counts the letters a, b, c, d, f, … from 0); at each point both must be real and agree to 10⁻⁹ × max(1, |value|), or neither may be real.

What you can type

  • Letters: any lowercase letter except e (Euler’s number), and θ. pi (or π) is π.
  • Operations: + − * / and ^; brackets group; numbers and letters side by side multiply (3x y means 3 · x · y).
  • Functions: sqrt, cbrt, ln (and log, written ln), log10, exp, abs, sin, cos, tan, sec, csc, cot, asin, acos, atan, sinh, cosh, tanh and their inverses.

How answers are written

  • Terms whose factors are all letters come first: highest total power first, then by the powers of the letters in alphabetical order (x²y before xy² before y²). Terms with other pieces come next; the number with no letter comes last. 0 when everything cancels.
  • In a term: the numerator of the coefficient (left out when it is 1), then the letters in alphabetical order, then the other pieces; powers above 1 as ^ (x^2); a negative power or a coefficient’s denominator goes under a fraction bar: 5x/6, 3/x, 7x/(4y^2).
  • Signs join the terms: −2x + 6. The page shows the answer as MathML; Copy answer gives this text.

Assumptions

  • Like terms are recognised by their written form only; no identities (such as sin² + cos² = 1) are used.

Worked examples by hand

3x + 7 + 4x + 5 (OpenStax Prealgebra 2e, section 2.2, Example 2.21). The x terms: 3x + 4x = 7x. The numbers: 7 + 5 = 12. Answer 7x + 12.

7x² + 8x − x² − 4x (Example 2.22). The x² terms: 7x² − x² = 6x². The x terms: 8x − 4x = 4x. Answer 6x² + 4x.

Other questions people ask

What are like terms?

Like terms have the same letters raised to the same powers; only their number in front (the coefficient) may differ. 3x and −5x are like terms, and so are 2x²y and 7x²y. x and x² are not, and neither are xy and x. Numbers with no letter, such as 7 and 5, are like terms too.

How do I combine like terms?

Add the coefficients of each group of like terms and keep the letter part: 3x + 4x = 7x and 7 + 5 = 12, so 3x + 7 + 4x + 5 = 7x + 12. Terms that are not alike stay separate: 7x² − x² + 8x − 4x = 6x² + 4x.

Does the page multiply out brackets?

Yes. A number or term times a bracket is distributed, and whole-number powers of a bracket up to the 20th are multiplied out, before the like terms are added: 3(x + 2) − 5x = 3x + 6 − 5x = −2x + 6, and (x + 1)³ = x³ + 3x² + 3x + 1.

What about fractions and decimals?

Coefficients stay exact fractions: x/2 + x/3 = 5x/6, and 0.1x + 0.2x = 3x/10 (0.1 is exactly 1/10). Dividing by a single term moves it under the fraction bar: 1/x + 2/x = 3/x.

Are sin(x) or √x combined too?

Yes, when they are written the same way: 2 sin(x) + 3 sin(x) = 5 sin(x), and sqrt(x) + 2 sqrt(x) = 3 sqrt(x). The page does not use identities, so sqrt(x) and x^(1/2) are kept apart, and so are e^(2x) e^x and e^(3x).

How is the answer checked?

The simplified text is read back and must equal your expression at 15 test points, to about 1 part in a billion. If it does not, the page says "No verified answer".