How to expand expressions and collect like terms
1. Apply distribution
Multiply the factor outside parentheses by every term inside: a(b+c)=ab+ac. For two polynomials, multiply every term in the first by every term in the second.
2. Identify variable parts
Terms are alike only when their variable parts match exactly. 4x² and −x² are like terms; 4x² and 4x are not.
3. Add coefficients
Keep the shared variable part and add only its numerical coefficients: 4x²−x²=(4−1)x²=3x².
4. Write standard form
List nonzero terms by descending total degree (the sum of exponents), then by descending exponents of alphabetically ordered variables. Terms whose coefficients sum to zero disappear.
Distributive property calculator: the rule
a(b + c) = ab + ac
For example, 2(x+3)+x−4+2x expands to 2x+6+x−4+2x. Grouping gives (2+1+2)x+(6−4), so the simplified form is 5x+2.
Worked examples: expand, group, and simplify
Each line is an equivalent form. When there are no parentheses, the distributed form already matches the input.
Basic collection
- Original
- 7x+3x-4
- Distributed form
- 7x + 3x − 4
- Grouped form
- (7 + 3)x − 4
- Coefficient calculation
- 7 + 3 = 10; constant = −4
- Answer
- 10x − 4
Negative coefficient
- Original
- -3(x+2)+5x
- Distributed form
- −3x − 6 + 5x
- Grouped form
- (−3 + 5)x − 6
- Coefficient calculation
- −3 + 5 = 2; constant = −6
- Answer
- 2x − 6
Subtraction before parentheses
- Original
- 5x-(2x-4)
- Distributed form
- 5x − 2x + 4
- Grouped form
- (5 − 2)x + 4
- Coefficient calculation
- 5 − 2 = 3; −(−4) = +4
- Answer
- 3x + 4
Two binomials: FOIL
- Original
- (x+2)(x-3)
- Distributed form
- x² − 3x + 2x − 6
- Grouped form
- x² + (−3 + 2)x − 6
- Coefficient calculation
- x²: 1; x: −3 + 2 = −1; constant: −6
- Answer
- x² − x − 6
Nested parentheses
- Original
- 2(x+3(x-1))
- Distributed form
- 2x + 6x − 6
- Grouped form
- (2 + 6)x − 6
- Coefficient calculation
- 2 + 6 = 8; constant = −6
- Answer
- 8x − 6
Perfect square
- Original
- (x+3)^2
- Distributed form
- x² + 3x + 3x + 9
- Grouped form
- x² + (3 + 3)x + 9
- Coefficient calculation
- x²: 1; x: 3 + 3 = 6; constant: 9
- Answer
- x² + 6x + 9
Fractional coefficients
- Original
- (1/2)x+(3/4)x-2
- Distributed form
- (1/2)x + (3/4)x − 2
- Grouped form
- (1/2 + 3/4)x − 2
- Coefficient calculation
- 1/2 + 3/4 = 2/4 + 3/4 = 5/4
- Answer
- 5/4·x − 2
Cancellation to zero
- Original
- 2(x+1)-2x-2
- Distributed form
- 2x + 2 − 2x − 2
- Grouped form
- (2 − 2)x + (2 − 2)
- Coefficient calculation
- 2 − 2 = 0 for both groups
- Answer
- 0
Multiple variables
- Original
- 7x+2y+3x+4y
- Distributed form
- 7x + 2y + 3x + 4y
- Grouped form
- (7 + 3)x + (2 + 4)y
- Coefficient calculation
- x: 7 + 3 = 10; y: 2 + 4 = 6
- Answer
- 10x + 6y
Canonical variable order
- Original
- 2xy+5yx
- Distributed form
- 2xy + 5xy
- Grouped form
- (2 + 5)xy
- Coefficient calculation
- xy: 2 + 5 = 7
- Answer
- 7xy
Different multivariable powers
- Original
- 3a^2b-2ab^2
- Distributed form
- 3a²b − 2ab²
- Grouped form
- 3(a²b) − 2(ab²)
- Coefficient calculation
- a²b: 3; ab²: −2; these groups differ
- Answer
- 3a²b − 2ab²
Both sides of an equation
- Original
- 2(x+3)=x+x+6
- Distributed form
- 2x + 6 = x + x + 6
- Grouped form
- 2x + 6 = (1 + 1)x + 6
- Coefficient calculation
- Left x: 2; right x: 1 + 1 = 2; constants: 6
- Answer
- 2x + 6 = 2x + 6
FOIL and special products
FOIL works for two binomials
Multiply First, Outer, Inner, Last: (a + b)(c + d) = ac + ad + bc + bd. For (x + 2)(x − 3), the four products are x·x, x·(−3), 2·x, and 2·(−3). This gives x² − 3x + 2x − 6 = x² − x − 6.
FOIL is a shortcut for exactly two binomials. For three-term or larger polynomials, use general distribution: every term in one factor multiplies every term in the other.
Square of a sum
(a + b)² = (a + b)(a + b) = a² + ab + ab + b² = a² + 2ab + b²
Square of a difference
(a − b)² = (a − b)(a − b) = a² − ab − ab + b² = a² − 2ab + b²
The last term is positive because (−b)(−b) = b². Do not omit the middle term.
Product of a sum and difference
(a + b)(a − b) = a² − ab + ab − b² = a² − b²
The two middle terms cancel. The calculator shows these products before collecting them.
Accuracy, editorial accountability, and privacy
Editorial owner: Starlight Tools (Starlight Robotics). Implementation and automated checks reviewed: . This identifies the site owner and technical verification date; it is not a claim of review by a named algebra educator.
Coefficients use reduced BigInt fractions. A finite decimal such as 0.125 is stored exactly as 1/8, so coefficient arithmetic introduces no binary floating-point rounding. The optional spot-check evaluates the original expression tree and the selected result separately at two assignments using exact fractions. Algebraic transformations establish equivalence; numeric samples alone are not proof.
Documented verification set
The page-specific regression suite (equation-expander.test.cjs) checks all worked examples above, all three modes, xy/yx matching, unary minus versus powers, nested parentheses, fractional division, zero cancellation, equation sides, malformed input, and expansion limits. Every recorded transformation is also evaluated against its original expression at representative values.
Supported input and limits
Use single Latin letters, exact integers or finite decimals, constant denominators, and integer powers 0–12. Limits are 400 normalized characters, total degree 12, 500 distributed terms, 18 digits per numeric literal, 220 digits per reduced numerator or denominator, and 1,600 expansion transformations per side. All modes use the same resource limits. The zero polynomial has no defined degree. A zeroth power is treated as 1 under the polynomial convention, including 0^0. The tool does not factor, solve equations, handle functions or roots, or cancel variable denominators.
Calculations run locally. Copy and download actions export only when selected. Shareable URLs store the expression and mode in the URL fragment; anyone with the link can read them. The site’s advertising and analytics policies remain separate from this calculator’s local processing.
Report an incorrect result
Describe the issue, then copy or download a report with your entered expression, mode, and last result attached. Nothing is sent automatically.
Opens your email app with the expression and report included, addressed to info@starlighttools.org (the contact published on our About page). Review the message before sending. If no email app is configured, copy the report into your webmail.
Combining like terms and expansion FAQs
What are like terms?
Like terms have identical variable parts, including every exponent. For example, 3a²b and −5a²b are like terms. Constants form their own group.
What is the difference between expanding and simplifying?
Expanding removes products of sums by distribution: 2(x+3)+x becomes 2x+6+x. Simplifying collects matching terms to give 3x+6. Use the mode controls to choose either operation or both.
How do you distribute a negative sign?
Treat the minus sign as multiplication by −1 and flip every sign: −(2x−3y+4) = −2x+3y−4.
Can x and x² be combined?
No. Their exponents differ, so they are different variable parts. The expression 3x+2x² has two groups.
Are xy and yx like terms?
Yes. Multiplication commutes, so xy=yx and 2xy+5yx=7xy. But x²y and xy² are different terms.
What happens when terms cancel to zero?
Their coefficient sum is zero, so the group disappears from the simplified answer. If every group cancels, the answer is 0. Expand only keeps the distributed terms separate.
Does combining like terms change the value?
No. Adding coefficients of identical variable parts preserves the value for every allowed assignment. The numeric spot-check illustrates this with two exact samples.
Does this calculator solve for x?
No. It expands and collects expressions. With one equals sign, it transforms the two sides independently without moving terms or finding a solution.
Can I enter fractions, decimals, and implicit multiplication?
Yes. For example, 0.5x+(3/4)x becomes 5/4·x. A divisor must be a nonzero constant. Write (1/2)x for half of x; x/y is unsupported. Products such as 3x, xy, and (x+1)(x−1) are accepted.
Does the calculator round coefficients?
No. Finite decimals and constant fractions use exact reduced rational arithmetic. Variable letters are case-sensitive, and function notation is unsupported.