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, Sum, e, frac, i, pi, subtract, 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 = Exp(Exp(e, Mult(two, pi, i, subtract(_phase, frac(m, _two_pow_t)))), k), 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} (\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\varphi - \frac{m}{2^{t}}\right)})^{k}
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: 12
body: 5
4ExprTuple12
5Conditionalvalue: 6
condition: 7
6Operationoperator: 41
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple12, 13
11Operationoperator: 41
operands: 14
12Variable
13Operationoperator: 15
operands: 16
14ExprTuple17, 18
15Literal
16ExprTuple19, 20
17Literal
18Operationoperator: 21
operands: 22
19Literal
20Operationoperator: 28
operands: 23
21Literal
22ExprTuple43, 24, 25, 26
23ExprTuple40, 27
24Literal
25Literal
26Operationoperator: 28
operands: 29
27Operationoperator: 34
operand: 33
28Literal
29ExprTuple31, 32
30ExprTuple33
31Literal
32Operationoperator: 34
operand: 36
33Literal
34Literal
35ExprTuple36
36Operationoperator: 37
operands: 38
37Literal
38ExprTuple39, 40
39Variable
40Operationoperator: 41
operands: 42
41Literal
42ExprTuple43, 44
43Literal
44Literal