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, Sum, e, i, pi, two
from proveit.physics.quantum.QPE import _delta_b_round, _m_domain
In [2]:
# build up the expression from sub-expressions
expr = Sum(index_or_indices = [k], summand = Exp(Exp(e, Mult(two, pi, i, _delta_b_round)), 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 \delta_{b_{\textit{r}}}})^{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: 32
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple12, 13
11Operationoperator: 32
operands: 14
12Variable
13Operationoperator: 15
operands: 16
14ExprTuple17, 18
15Literal
16ExprTuple19, 20
17Literal
18Operationoperator: 21
operands: 22
19Literal
20Operationoperator: 23
operands: 24
21Literal
22ExprTuple37, 25, 26, 27
23Literal
24ExprTuple28, 29
25Literal
26Literal
27Operationoperator: 30
operand: 36
28Operationoperator: 32
operands: 33
29Operationoperator: 34
operand: 39
30Literal
31ExprTuple36
32Literal
33ExprTuple37, 38
34Literal
35ExprTuple39
36Literal
37Literal
38Literal
39Literal