# 求解方程（Solve equations，solve）

对一到多个未知量求解方程。

使用这个函数时，求解器只要找到步骤就会展示。

## 怎么写

### solve(equations, variables)

对未知量求解。

**equations**

要求解的内容；方程列表表示方程组。接受一个方程或放在方括号中的方程列表。

**variables**

一个变量，或变量列表，例如 \[x, y\]。接受一个变量或变量列表。

### solve(equations, variables, domain = real|complex)

在实数或复数范围内求解。

**equations**

要求解的内容；方程列表表示方程组。接受一个方程或放在方括号中的方程列表。

**variables**

一个变量，或变量列表，例如 \[x, y\]。接受一个变量或变量列表。

**domain = real|complex**

在哪个范围内计算：实数或复数。接受real或complex。

## 示例

- $\displaystyle x^{2}-4 = 0 \Rightarrow x = -2,\quad x = 2$

  `solve(x^2 - 4 = 0, x)`

  在求解器中，`solve(x^2 - 4 = 0, x)` 的结果是 `[[x -> -2], [x -> 2]]`。

  [在求解器中打开](https://zh.hilberon.com/?q=solve%28x%5E2%20-%204%20%3D%200%2C%20x%29)
- $\displaystyle \begin{cases} x+y = 3 \\ x-y = 1 \end{cases} \Rightarrow (x, y) = (2, 1)$

  `solve([x + y = 3, x - y = 1], [x, y])`

  在求解器中，`solve([x + y = 3, x - y = 1], [x, y])` 的结果是 `[[x -> 2, y -> 1]]`。

  [在求解器中打开](https://zh.hilberon.com/?q=solve%28%5Bx%20%2B%20y%20%3D%203%2C%20x%20-%20y%20%3D%201%5D%2C%20%5Bx%2C%20y%5D%29)
- $\displaystyle x^{2}+1 = 0 \Rightarrow x = -i,\quad x = i$

  `solve(x^2 + 1 = 0, x, domain = complex)`

  在求解器中，`solve(x^2 + 1 = 0, x, domain = complex)` 的结果是 `[[x -> -i], [x -> i]]`。

  [在求解器中打开](https://zh.hilberon.com/?q=solve%28x%5E2%20%2B%201%20%3D%200%2C%20x%2C%20domain%20%3D%20complex%29)

## 相关函数

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

  描述方程和不等式的完整解集。
- [numeric_solve](https://zh.hilberon.com/library/numeric_solve)

  数值求解方程。
- [solve_identity](https://zh.hilberon.com/library/solve_identity)

  找出使方程对变量的每个取值都成立的参数值。
- [linear_solve](https://zh.hilberon.com/library/linear_solve)

  求解由矩阵和右端项给出的线性方程组 A x = b。
- [eliminate](https://zh.hilberon.com/library/eliminate)

  从方程组中消去变量，留下只含其他变量的方程。
- [least_squares](https://zh.hilberon.com/library/least_squares)

  A x = b 的最小二乘解。

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