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