Sympy Example ============= >>> import sympy >>> from qitensor import qubit >>> ha = qubit('a', dtype=sympy) >>> hb = qubit('b', dtype=sympy) >>> sympy.var('x y') (x, y) >>> s = ha.array([1, x]) >>> t = hb.array([1, y]) >>> s*t HilbertArray(|a,b>, array([[1, y], [x, x*y]], dtype=object)) >>> # density operator >>> (s*t).O HilbertArray(|a,b> [[y, y*conjugate(y)], [y*conjugate(x), y*conjugate(x)*conjugate(y)]]], [[[x, x*conjugate(y)], [x*conjugate(x), x*conjugate(x)*conjugate(y)]], [[x*y, x*y*conjugate(y)], [x*y*conjugate(x), x*y*conjugate(x)*conjugate(y)]]]], dtype=object)) >>> # density operator with ``ha`` traced out >>> (s*t).O.trace(ha) HilbertArray(|b>>> U = (ha * hb).eye() >>> # arrays can be indexed using dictionaries >>> U[{ ha: 0, ha.H: 0, hb: 0, hb.H: 0 }] = x >>> U[{ ha: 0, ha.H: 0, hb: 0, hb.H: 1 }] = y >>> U HilbertArray(|a,b> [[0, 1], [0, 0]]], [[[0, 0], [1, 0]], [[0, 0], [0, 1]]]], dtype=object)) >>> U.I HilbertArray(|a,b> [[0, 1], [0, 0]]], [[[0, 0], [1, 0]], [[0, 0], [0, 1]]]], dtype=object)) >>> U * U.I HilbertArray(|a,b> [[0, 1], [0, 0]]], [[[0, 0], [1, 0]], [[0, 0], [0, 1]]]], dtype=object)) >>> ((U ** 3) * (U ** -3)).simplify_full() HilbertArray(|a,b> [[0, 1], [0, 0]]], [[[0, 0], [1, 0]], [[0, 0], [0, 1]]]], dtype=object))