# scipy.linalg.solve¶

scipy.linalg.solve(a, b, sym_pos=False, lower=False, overwrite_a=False, overwrite_b=False, debug=False, check_finite=True)[source]

Solve the equation a x = b for x.

Parameters: a : (M, M) array_like A square matrix. b : (M,) or (M, N) array_like Right-hand side matrix in a x = b. sym_pos : bool Assume a is symmetric and positive definite. lower : boolean Use only data contained in the lower triangle of a, if sym_pos is true. Default is to use upper triangle. overwrite_a : bool Allow overwriting data in a (may enhance performance). Default is False. overwrite_b : bool Allow overwriting data in b (may enhance performance). Default is False. check_finite : boolean, optional Whether to check that the input matrices contain only finite numbers. Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs. x : (M,) or (M, N) ndarray Solution to the system a x = b. Shape of the return matches the shape of b. LinAlgError If a is singular.

Examples

Given a and b, solve for x:

```>>> a = np.array([[3,2,0],[1,-1,0],[0,5,1]])
>>> b = np.array([2,4,-1])
>>> x = linalg.solve(a,b)
>>> x
array([ 2., -2.,  9.])
>>> np.dot(a, x) == b
array([ True,  True,  True], dtype=bool)
```

scipy.linalg.inv

#### Next topic

scipy.linalg.solve_banded