logo

Expression of type VecSum

from the theory of proveit.physics.quantum.algebra

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 A, i, j, m, n
from proveit.core_expr_types import v_i, w_j
from proveit.linear_algebra import VecSum
from proveit.numbers import Interval, one
from proveit.physics.quantum import Bra, Ket, Qmult
In [2]:
# build up the expression from sub-expressions
expr = VecSum(index_or_indices = [i], summand = VecSum(index_or_indices = [j], summand = Qmult(Bra(w_j), A, Ket(v_i), Ket(w_j), Bra(v_i)), domain = Interval(one, n)), domain = Interval(one, m))
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())
\sum_{i=1}^{m} \left(\sum_{j=1}^{n} \left(\langle w_{j} \rvert \thinspace A \thinspace \lvert v_{i} \rangle \thinspace \lvert w_{j} \rangle \thinspace \langle v_{i} \rvert\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 6
operand: 2
1ExprTuple2
2Lambdaparameter: 41
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 18
operands: 8
6Literal
7ExprTuple9
8ExprTuple41, 10
9Lambdaparameter: 40
body: 11
10Operationoperator: 30
operands: 12
11Conditionalvalue: 13
condition: 14
12ExprTuple34, 15
13Operationoperator: 16
operands: 17
14Operationoperator: 18
operands: 19
15Variable
16Literal
17ExprTuple20, 21, 22, 23, 24
18Literal
19ExprTuple40, 25
20Operationoperator: 28
operand: 32
21Variable
22Operationoperator: 26
operand: 33
23Operationoperator: 26
operand: 32
24Operationoperator: 28
operand: 33
25Operationoperator: 30
operands: 31
26Literal
27ExprTuple32
28Literal
29ExprTuple33
30Literal
31ExprTuple34, 35
32IndexedVarvariable: 36
index: 40
33IndexedVarvariable: 38
index: 41
34Literal
35Variable
36Variable
37ExprTuple40
38Variable
39ExprTuple41
40Variable
41Variable