# 展开为实部与虚部（Expand into real and imaginary parts，complex_expand）

在假定变量为实数的前提下展开表达式。

## 怎么写

### complex_expand(expr)

**expr**

任意表达式：一个数、一个公式、一个列表或一个矩阵。接受一个表达式。

## 示例

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

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

  在求解器中，`complex_expand((1 + i)^2)` 的结果是 `2i`。

  [在求解器中打开](https://zh.hilberon.com/?q=complex_expand%28%281%20%2B%20i%29%5E2%29)

## 相关函数

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

  把乘积和乘方展开成和式。
- [function_expand](https://zh.hilberon.com/library/function_expand)

  把带平移自变量的特殊函数改写为更简单的函数。
- [power_expand](https://zh.hilberon.com/library/power_expand)

  展开乘积与幂的幂和对数。
- [cyclotomic](https://zh.hilberon.com/library/cyclotomic)

  给定阶数的分圆多项式。
- [collect](https://zh.hilberon.com/library/collect)

  按某个变量的幂次合并表达式中的项。
- [degree](https://zh.hilberon.com/library/degree)

  多项式关于某个变量的次数。

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