logo

Expression of type Sum

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 k, m
from proveit.numbers import Exp, Mult, Neg, Sum, e, frac, i, pi, two
from proveit.physics.quantum.QPE import _m_domain, _phase, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Sum(index_or_indices = [k], summand = Mult(Exp(e, Mult(two, pi, i, _phase, k)), Exp(e, Neg(frac(Mult(two, pi, i, k, m), _two_pow_t)))), domain = _m_domain)
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_{k = 0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}}\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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 43
body: 5
4ExprTuple43
5Conditionalvalue: 6
condition: 7
6Operationoperator: 37
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple43, 13
11Operationoperator: 39
operands: 14
12Operationoperator: 39
operands: 15
13Operationoperator: 16
operands: 17
14ExprTuple19, 18
15ExprTuple19, 20
16Literal
17ExprTuple21, 22
18Operationoperator: 37
operands: 23
19Literal
20Operationoperator: 32
operand: 28
21Literal
22Operationoperator: 25
operands: 26
23ExprTuple45, 41, 42, 27, 43
24ExprTuple28
25Literal
26ExprTuple35, 29
27Literal
28Operationoperator: 30
operands: 31
29Operationoperator: 32
operand: 36
30Literal
31ExprTuple34, 35
32Literal
33ExprTuple36
34Operationoperator: 37
operands: 38
35Operationoperator: 39
operands: 40
36Literal
37Literal
38ExprTuple45, 41, 42, 43, 44
39Literal
40ExprTuple45, 46
41Literal
42Literal
43Variable
44Variable
45Literal
46Literal