logo

Expression of type TensorProd

from the theory of proveit.physics.quantum.QPE

In [1]:
import proveit
# Automation is not needed when building an expression:
proveit.defaults.automation = False # This will speed things up.
proveit.defaults.inline_pngs = False # Makes files smaller.
%load_expr # Load the stored expression as 'stored_expr'
# import Expression classes needed to build the expression
from proveit import ExprRange, Variable, t
from proveit.linear_algebra import ScalarMult, TensorProd, VecAdd
from proveit.numbers import Add, Exp, Mult, Neg, e, frac, i, one, pi, sqrt, subtract, two, zero
from proveit.physics.quantum import ket0, ket1
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = TensorProd(ScalarMult(frac(one, Exp(two, subtract(frac(Add(t, one), two), frac(t, two)))), VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, _phase, two_pow_t)), ket1))), TensorProd(ExprRange(sub_expr1, ScalarMult(frac(one, sqrt(two)), VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(sub_expr1)), _phase)), ket1))), Add(Neg(t), one), zero).with_decreasing_order()))
expr:
In [3]:
# check that the built expression is the same as the stored expression
assert expr == stored_expr
assert expr._style_id == stored_expr._style_id
print("Passed sanity check: expr matches stored_expr")
Passed sanity check: expr matches stored_expr
In [4]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\left(\frac{1}{2^{\frac{t + 1}{2} - \frac{t}{2}}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}} \cdot \lvert 1 \rangle\right)\right)\right) {\otimes} \left(\left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{t - 1} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right) {\otimes}  \left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{t - 2} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right) {\otimes}  \ldots {\otimes}  \left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{0} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()()('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 5
operands: 1
1ExprTuple2, 3
2Operationoperator: 43
operands: 4
3Operationoperator: 5
operands: 6
4ExprTuple7, 8
5Literal
6ExprTuple9
7Operationoperator: 56
operands: 10
8Operationoperator: 30
operands: 11
9ExprRangelambda_map: 12
start_index: 13
end_index: 49
10ExprTuple64, 14
11ExprTuple36, 15
12Lambdaparameter: 77
body: 16
13Operationoperator: 52
operands: 17
14Operationoperator: 71
operands: 18
15Operationoperator: 43
operands: 19
16Operationoperator: 43
operands: 20
17ExprTuple21, 64
18ExprTuple73, 22
19ExprTuple23, 51
20ExprTuple24, 25
21Operationoperator: 75
operand: 61
22Operationoperator: 52
operands: 27
23Operationoperator: 71
operands: 28
24Operationoperator: 56
operands: 29
25Operationoperator: 30
operands: 31
26ExprTuple61
27ExprTuple32, 33
28ExprTuple62, 34
29ExprTuple64, 35
30Literal
31ExprTuple36, 37
32Operationoperator: 56
operands: 38
33Operationoperator: 75
operand: 46
34Operationoperator: 65
operands: 40
35Operationoperator: 71
operands: 41
36Operationoperator: 59
operand: 49
37Operationoperator: 43
operands: 44
38ExprTuple45, 73
39ExprTuple46
40ExprTuple73, 67, 68, 70, 47
41ExprTuple73, 48
42ExprTuple49
43Literal
44ExprTuple50, 51
45Operationoperator: 52
operands: 53
46Operationoperator: 56
operands: 54
47Operationoperator: 71
operands: 55
48Operationoperator: 56
operands: 57
49Literal
50Operationoperator: 71
operands: 58
51Operationoperator: 59
operand: 64
52Literal
53ExprTuple61, 64
54ExprTuple61, 73
55ExprTuple73, 61
56Literal
57ExprTuple64, 73
58ExprTuple62, 63
59Literal
60ExprTuple64
61Variable
62Literal
63Operationoperator: 65
operands: 66
64Literal
65Literal
66ExprTuple73, 67, 68, 69, 70
67Literal
68Literal
69Operationoperator: 71
operands: 72
70Literal
71Literal
72ExprTuple73, 74
73Literal
74Operationoperator: 75
operand: 77
75Literal
76ExprTuple77
77Variable