Did I find the right examples for you? yes no

# sympy.matrices.Inverse

All Samples(26)  |  Call(18)  |  Derive(0)  |  Import(8)

from sympy.core import S, symbols, Add, Mul
from sympy.functions import transpose, sin, cos, sqrt
from sympy.simplify import simplify
from sympy.matrices import (Identity, ImmutableMatrix, Inverse, MatAdd, MatMul,
MatPow, Matrix, MatrixExpr, MatrixSymbol, ShapeError, ZeroMatrix,

    assert A**1 == A
assert A**2 == AA
assert A**-1 == Inverse(A)
assert A**S.Half == sqrt(A)
raises(ShapeError, lambda: MatrixSymbol('B', 3, 2)**2)

    X = MatrixSymbol('X', n, n)
objs = [Identity(n), ZeroMatrix(m, n), A, MatMul(A, B), MatAdd(A, A),
Transpose(A), Adjoint(A), Inverse(X), MatPow(X, 2), MatPow(X, -1),
MatPow(X, 0)]
for obj in objs:


from sympy.core import S, symbols, Add, Mul
from sympy.functions import transpose, sin, cos, sqrt
from sympy.simplify import simplify
from sympy.matrices import (Identity, ImmutableMatrix, Inverse, MatAdd, MatMul,
MatPow, Matrix, MatrixExpr, MatrixSymbol, ShapeError, ZeroMatrix,

    assert A**1 == A
assert A**2 == AA
assert A**-1 == Inverse(A)
assert A**S.Half == sqrt(A)
raises(ShapeError, lambda: MatrixSymbol('B', 3, 2)**2)

    X = MatrixSymbol('X', n, n)
objs = [Identity(n), ZeroMatrix(m, n), A, MatMul(A, B), MatAdd(A, A),
Transpose(A), Adjoint(A), Inverse(X), MatPow(X, 2), MatPow(X, -1),
MatPow(X, 0)]
for obj in objs:


def test_Adjoint():
from sympy.matrices import Adjoint, Inverse, MatrixSymbol, Transpose
X = MatrixSymbol('X', 2, 2)
Y = MatrixSymbol('Y', 2, 2)
assert pretty(Adjoint(X)) == " +\nX "

    assert pretty(Adjoint(X**2)) == "    +\n/ 2\\ \n\\X / "
assert pretty(Adjoint(X)**2) == "    2\n/ +\\ \n\\X / "
assert pretty(Adjoint(Inverse(X))) == "     +\n/ -1\\ \n\\X  / "
assert pretty(Inverse(Adjoint(X))) == "    -1\n/ +\\  \n\\X /  "
assert pretty(Adjoint(Transpose(X))) == "    +\n/ T\\ \n\\X / "

    assert upretty(Adjoint(X)**2) == \
u("    2\n⎛ †⎞ \n⎝X ⎠ ")
assert upretty(Adjoint(Inverse(X))) == \
u("     †\n⎛ -1⎞ \n⎝X  ⎠ ")
assert upretty(Inverse(Adjoint(X))) == \


def test_Adjoint():
from sympy.matrices import Adjoint, Inverse, MatrixSymbol, Transpose
X = MatrixSymbol('X', 2, 2)
Y = MatrixSymbol('Y', 2, 2)
assert pretty(Adjoint(X)) == " +\nX "

    assert pretty(Adjoint(X**2)) == "    +\n/ 2\\ \n\\X / "
assert pretty(Adjoint(X)**2) == "    2\n/ +\\ \n\\X / "
assert pretty(Adjoint(Inverse(X))) == "     +\n/ -1\\ \n\\X  / "
assert pretty(Inverse(Adjoint(X))) == "    -1\n/ +\\  \n\\X /  "
assert pretty(Adjoint(Transpose(X))) == "    +\n/ T\\ \n\\X / "

    assert upretty(Adjoint(X)**2) == \
u("    2\n⎛ †⎞ \n⎝X ⎠ ")
assert upretty(Adjoint(Inverse(X))) == \
u("     †\n⎛ -1⎞ \n⎝X  ⎠ ")
assert upretty(Inverse(Adjoint(X))) == \


def test_Adjoint():
from sympy.matrices import MatrixSymbol, Adjoint, Inverse, Transpose
X = MatrixSymbol('X', 2, 2)
Y = MatrixSymbol('Y', 2, 2)
assert latex(Adjoint(X)) == r'X^\dag'

    assert latex(Adjoint(X**2)) == r'\left(X^{2}\right)^\dag'
assert latex(Adjoint(X)**2) == r'\left(X^\dag\right)^{2}'
assert latex(Adjoint(Inverse(X))) == r'\left(X^{-1}\right)^\dag'
assert latex(Inverse(Adjoint(X))) == r'\left(X^\dag\right)^{-1}'
assert latex(Adjoint(Transpose(X))) == r'\left(X^T\right)^\dag'


def test_Adjoint():
from sympy.matrices import MatrixSymbol, Adjoint, Inverse, Transpose
X = MatrixSymbol('X', 2, 2)
Y = MatrixSymbol('Y', 2, 2)
assert latex(Adjoint(X)) == r'X^\dag'

    assert latex(Adjoint(X**2)) == r'\left(X^{2}\right)^\dag'
assert latex(Adjoint(X)**2) == r'\left(X^\dag\right)^{2}'
assert latex(Adjoint(Inverse(X))) == r'\left(X^{-1}\right)^\dag'
assert latex(Inverse(Adjoint(X))) == r'\left(X^\dag\right)^{-1}'
assert latex(Adjoint(Transpose(X))) == r'\left(X^T\right)^\dag'


from sympy.core import I, symbols
from sympy.functions import adjoint, transpose
from sympy.matrices import Identity, Inverse, Matrix, MatrixSymbol, ZeroMatrix
from sympy.matrices.expressions import Adjoint, Transpose, det
from sympy.matrices.expressions.matmul import (factor_in_front, remove_ids,

def test_xxinv():
assert xxinv(MatMul(D, Inverse(D), D, evaluate=False)) == \
MatMul(Identity(n), D, evaluate=False)

def test_any_zeros():


from sympy.core import I, symbols
from sympy.functions import adjoint, transpose
from sympy.matrices import Identity, Inverse, Matrix, MatrixSymbol, ZeroMatrix
from sympy.matrices.expressions import Adjoint, Transpose, det
from sympy.matrices.expressions.matmul import (factor_in_front, remove_ids,

def test_xxinv():
assert xxinv(MatMul(D, Inverse(D), D, evaluate=False)) == \
MatMul(Identity(n), D, evaluate=False)

def test_any_zeros():