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, one, pi, two
from proveit.physics.quantum.QPE import _m_domain, _phase, _t, _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)), frac(one, Exp(two, frac(_t, two))), 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 \frac{1}{2^{\frac{t}{2}}} \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: 49
body: 5
4ExprTuple49
5Conditionalvalue: 6
condition: 7
6Operationoperator: 43
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12, 13
9Literal
10ExprTuple49, 14
11Operationoperator: 45
operands: 15
12Operationoperator: 36
operands: 16
13Operationoperator: 45
operands: 17
14Operationoperator: 18
operands: 19
15ExprTuple22, 20
16ExprTuple42, 21
17ExprTuple22, 23
18Literal
19ExprTuple24, 25
20Operationoperator: 43
operands: 26
21Operationoperator: 45
operands: 27
22Literal
23Operationoperator: 38
operand: 33
24Literal
25Operationoperator: 29
operands: 30
26ExprTuple51, 47, 48, 31, 49
27ExprTuple51, 32
28ExprTuple33
29Literal
30ExprTuple41, 34
31Literal
32Operationoperator: 36
operands: 35
33Operationoperator: 36
operands: 37
34Operationoperator: 38
operand: 42
35ExprTuple52, 51
36Literal
37ExprTuple40, 41
38Literal
39ExprTuple42
40Operationoperator: 43
operands: 44
41Operationoperator: 45
operands: 46
42Literal
43Literal
44ExprTuple51, 47, 48, 49, 50
45Literal
46ExprTuple51, 52
47Literal
48Literal
49Variable
50Variable
51Literal
52Literal