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(frac(one, Exp(two, frac(_t, two))), 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(\frac{1}{2^{\frac{t}{2}}} \cdot \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)\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: 51
body: 5
4ExprTuple51
5Conditionalvalue: 6
condition: 7
6Operationoperator: 45
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple51, 13
11Operationoperator: 41
operands: 14
12Operationoperator: 45
operands: 15
13Operationoperator: 16
operands: 17
14ExprTuple40, 18
15ExprTuple19, 20
16Literal
17ExprTuple21, 22
18Operationoperator: 47
operands: 23
19Operationoperator: 47
operands: 24
20Operationoperator: 47
operands: 25
21Literal
22Operationoperator: 26
operands: 27
23ExprTuple53, 28
24ExprTuple30, 29
25ExprTuple30, 31
26Literal
27ExprTuple44, 32
28Operationoperator: 41
operands: 33
29Operationoperator: 45
operands: 34
30Literal
31Operationoperator: 36
operand: 39
32Operationoperator: 36
operand: 40
33ExprTuple54, 53
34ExprTuple53, 49, 50, 38, 51
35ExprTuple39
36Literal
37ExprTuple40
38Literal
39Operationoperator: 41
operands: 42
40Literal
41Literal
42ExprTuple43, 44
43Operationoperator: 45
operands: 46
44Operationoperator: 47
operands: 48
45Literal
46ExprTuple53, 49, 50, 51, 52
47Literal
48ExprTuple53, 54
49Literal
50Literal
51Variable
52Variable
53Literal
54Literal