#### Previous topic

scipy.linalg.inv

#### Next topic

scipy.linalg.solve_banded

# scipy.linalg.solve

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

  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, optional Assume a is symmetric and positive definite. lower : bool, optional Use only data contained in the lower triangle of a, if sym_pos is true. Default is to use upper triangle. overwrite_a : bool, optional Allow overwriting data in a (may enhance performance). Default is False. overwrite_b : bool, optional Allow overwriting data in b (may enhance performance). Default is False. check_finite : bool, 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.
  Returns: | x : (M,) or (M, N) ndarray Solution to the system `a x = b`. Shape of the return matches the shape of b.
  Raises: | 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])
      >>> from scipy import linalg
      >>> x = linalg.solve(a, b)
      >>> x
      array([ 2., -2.,  9.])
      >>> np.dot(a, x) == b
      array([ True,  True,  True], dtype=bool)