# Expand an expression (expand)

Multiply out products and powers into a sum.

With this function, the solver shows the steps whenever it finds them.

## How to write it

### expand(expr)

**expr**

Any expression: a number, a formula, a list or a matrix. Takes an expression.

## Examples

- $\displaystyle (x+1)^{3} = x^{3}+3 x^{2}+3 x+1$

  `expand((x + 1)^3)`

  In the solver, `expand((x + 1)^3)` gives `x^3 + 3x^2 + 3x + 1`.

  [Open in the solver](https://hilberon.com/?q=expand%28%28x%20%2B%201%29%5E3%29)
- $\displaystyle (x-1) (x+2) = x^{2}+x-2$

  `expand((x - 1)(x + 2))`

  In the solver, `expand((x - 1)(x + 2))` gives `x^2 + x - 2`.

  [Open in the solver](https://hilberon.com/?q=expand%28%28x%20-%201%29%28x%20%2B%202%29%29)

## Related functions

- [function_expand](https://hilberon.com/library/function_expand)

  Rewrite special functions of shifted arguments in terms of simpler ones.
- [complex_expand](https://hilberon.com/library/complex_expand)

  Expand an expression assuming its variables are real.
- [power_expand](https://hilberon.com/library/power_expand)

  Expand powers and logarithms of products and powers.
- [factor](https://hilberon.com/library/factor)

  Factor a polynomial into irreducible factors.
- [discriminant](https://hilberon.com/library/discriminant)

  Discriminant of a polynomial in a variable.
- [full_simplify](https://hilberon.com/library/full_simplify)

  Search harder than simplify for a simpler form, under assumptions.

---
Source: https://hilberon.com/library/expand
