expands out products and positive integer powers in expr.


leaves unexpanded any parts of expr that are free of the pattern patt. »

Details and Options

  • Expand works only on positive integer powers.
  • Expand applies only to the top level in expr.
  • Expand[expr,Modulus->p] expands expr reducing the result modulo p. »
  • Expand automatically threads over lists in expr, as well as equations, inequalities and logic functions.


open allclose all

Basic Examples  (3)

Expand a polynomial as a simple sum of terms:

The process of computation is visualized as follows:

Expand a product of polynomials:

Expand a polynomial of several variables:

Scope  (15)

Basic Uses  (9)

Expand a polynomial:

Expand a rational function:

Expand expressions involving arbitrary functions:

Expand does not go into subexpressions; ExpandAll does:

Expand applies to the numerator only:

ExpandAll applies to both the numerator and denominator:

Verify the equality of an expanded polynomial and its factored form:

Expand accepts polynomials with real or complex coefficients as inputs:

Expand threads over lists:

Expand threads over equations and inequalities:

Advanced Uses  (6)

Apply Expand to a polynomial over the integers modulo :

Apply Expand to a trigonometric expression:

Apply Expand to polynomials with high-order powers efficiently:

Leave parts free of x unexpanded:

Leave parts free of 1+x unexpanded:

Leave anything not matching x[_] unexpanded:

Options  (3)

Modulus  (2)

Work in the field GF(2):

The modulus does not have to be a prime:

Trig  (1)

Expand a trigonometric expression:

Applications  (3)

Calculate the characteristic polynomial of a diagonal matrix:

The characteristic polynomial is the determinant of the following matrix:

Expand the product of diagonal elements to get the characteristic polynomial:

This can be directly computed using the CharacteristicPolynomial function:

Cyclotomic polynomials are monic, with integer coefficients, and are irreducible over the rational numbers.

The 16th cyclotomic polynomial is given below:

Use Expand to show that it has integer coefficients:

These polynomials can be directly computed using the Cyclotomic function:

Expand can be used to verify that two expressions are equal:

Properties & Relations  (3)

Many functions give results in unexpanded form:

Factor is essentially the inverse of Expand:

When no powers are involved, Distribute gives the same results as Expand:

Direct application of the distributive law often generates far more terms than are needed:

Neat Examples  (2)

Create a nested pattern corresponding to an additive cellular automaton (rule 60):

Wolfram Research (1988), Expand, Wolfram Language function, https://reference.wolfram.com/language/ref/Expand.html (updated 2007).


Wolfram Research (1988), Expand, Wolfram Language function, https://reference.wolfram.com/language/ref/Expand.html (updated 2007).


@misc{reference.wolfram_2020_expand, author="Wolfram Research", title="{Expand}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/Expand.html}", note=[Accessed: 27-February-2021 ]}


@online{reference.wolfram_2020_expand, organization={Wolfram Research}, title={Expand}, year={2007}, url={https://reference.wolfram.com/language/ref/Expand.html}, note=[Accessed: 27-February-2021 ]}


Wolfram Language. 1988. "Expand." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2007. https://reference.wolfram.com/language/ref/Expand.html.


Wolfram Language. (1988). Expand. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Expand.html