# Expand into real and imaginary parts (complex_expand)

Expand an expression assuming its variables are real.

## How to write it

### complex_expand(expr)

**expr**

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

## Examples

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

  `complex_expand((1 + i)^2)`

  In the solver, `complex_expand((1 + i)^2)` gives `2i`.

  [Open in the solver](https://hilberon.com/?q=complex_expand%28%281%20%2B%20i%29%5E2%29)

## Related functions

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

  Multiply out products and powers into a sum.
- [function_expand](https://hilberon.com/library/function_expand)

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

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

  Cyclotomic polynomial of a given order.
- [collect](https://hilberon.com/library/collect)

  Group the terms of an expression by powers of a variable.
- [degree](https://hilberon.com/library/degree)

  Degree of a polynomial in a variable.

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