logo

Expression of type Add

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 l
from proveit.numbers import Abs, Add, Exp, Mult, Sum, four, frac, one, two
from proveit.physics.quantum.QPE import _diff_l_scaled_delta_floor, _neg_domain, _pos_domain, _rel_indexed_alpha
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [l]
expr = Add(Sum(index_or_indices = sub_expr1, summand = frac(one, Mult(four, Exp(_diff_l_scaled_delta_floor, two))), domain = _neg_domain), Sum(index_or_indices = sub_expr1, summand = Exp(Abs(_rel_indexed_alpha), two), domain = _pos_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())
\left(\sum_{l = -2^{t - 1} + 1}^{-\left(e + 1\right)} \frac{1}{4 \cdot \left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\right) + \left(\sum_{l = e + 1}^{2^{t - 1}} \left|\alpha_{b_{\textit{f}} \oplus l}\right|^{2}\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()()('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 61
operands: 1
1ExprTuple2, 3
2Operationoperator: 5
operand: 7
3Operationoperator: 5
operand: 8
4ExprTuple7
5Literal
6ExprTuple8
7Lambdaparameter: 54
body: 9
8Lambdaparameter: 54
body: 11
9Conditionalvalue: 12
condition: 13
10ExprTuple54
11Conditionalvalue: 14
condition: 15
12Operationoperator: 16
operands: 17
13Operationoperator: 20
operands: 18
14Operationoperator: 66
operands: 19
15Operationoperator: 20
operands: 21
16Literal
17ExprTuple75, 22
18ExprTuple54, 23
19ExprTuple24, 72
20Literal
21ExprTuple54, 25
22Operationoperator: 59
operands: 26
23Operationoperator: 30
operands: 27
24Operationoperator: 28
operand: 36
25Operationoperator: 30
operands: 31
26ExprTuple32, 33
27ExprTuple34, 35
28Literal
29ExprTuple36
30Literal
31ExprTuple44, 52
32Literal
33Operationoperator: 66
operands: 37
34Operationoperator: 61
operands: 38
35Operationoperator: 70
operand: 44
36Operationoperator: 40
operand: 45
37ExprTuple42, 72
38ExprTuple43, 75
39ExprTuple44
40Literal
41ExprTuple45
42Operationoperator: 61
operands: 46
43Operationoperator: 70
operand: 52
44Operationoperator: 61
operands: 48
45Operationoperator: 49
operands: 50
46ExprTuple54, 51
47ExprTuple52
48ExprTuple53, 75
49Literal
50ExprTuple74, 54
51Operationoperator: 70
operand: 57
52Operationoperator: 66
operands: 56
53Variable
54Variable
55ExprTuple57
56ExprTuple72, 58
57Operationoperator: 59
operands: 60
58Operationoperator: 61
operands: 62
59Literal
60ExprTuple63, 64
61Literal
62ExprTuple73, 65
63Operationoperator: 66
operands: 67
64Operationoperator: 68
operand: 74
65Operationoperator: 70
operand: 75
66Literal
67ExprTuple72, 73
68Literal
69ExprTuple74
70Literal
71ExprTuple75
72Literal
73Literal
74Literal
75Literal