ivy.solve(x1, x2, /, *, adjoint=False, out=None)[source]#

Return the solution to the system of linear equations represented by the well- determined (i.e., full rank) linear matrix equation AX = B.

  • x1 (Union[Array, NativeArray]) – coefficient array A having shape (…, M, M) and whose innermost two dimensions form square matrices. Must be of full rank (i.e., all rows or, equivalently, columns must be linearly independent). Should have a floating-point data type.

  • x2 (Union[Array, NativeArray]) – ordinate (or “dependent variable”) array B. If x2 has shape (M,), x2 is equivalent to an array having shape (…, M, 1). If x2 has shape (…, M, K), each column k defines a set of ordinate values for which to compute a solution, and shape(x2)[:-1] must be compatible with shape(x1)[:-1] (see Broadcasting). Should have a floating-point data type.

  • adjoint (bool, default: False) – specifies whether the system should be solved for x1 or adjoint(x1)

  • out (Optional[Array], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:



ret – an array containing the solution to the system AX = B (or adjoint(A)X = B) for each square matrix. The returned array must have the same shape as x2 (i.e., the array corresponding to B) and must have a floating-point data type determined by Type Promotion Rules.

This function conforms to the Array API Standard. This docstring is an extension of the docstring in the standard.

Both the description and the type hints above assumes an array input for simplicity, but this function is nestable, and therefore also accepts ivy.Container instances in place of any of the arguments.


with ivy.Array input:

>>> x1 = ivy.array([[1., 2.],[3., 4.]])
>>> x2 = ivy.array([5., 6.])
>>> out = ivy.solve(x1, x2)
>>> print(out)
ivy.array([-4. ,  4.5])
>>> x1 = ivy.native_array([[1., 2.],[3., 4.]])
>>> x2 = ivy.array([5., 6.])
>>> z = ivy.zeros_like(x2)
>>> ivy.solve(x1, x2, out=z)
ivy.array([-4. ,  4.5])
Array.solve(self, x2, /, *, adjoint=False, out=None)[source]#
Return type:


Container.solve(self, x2, /, *, adjoint=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type: