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 Add, Exp, Mult, Sum, four, frac, one, two
from proveit.physics.quantum.QPE import _diff_l_scaled_delta_floor, _neg_domain, _pos_domain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [l]
sub_expr2 = Exp(_diff_l_scaled_delta_floor, two)
expr = Add(Mult(frac(one, four), Sum(index_or_indices = sub_expr1, summand = frac(one, sub_expr2), domain = _neg_domain)), Sum(index_or_indices = sub_expr1, summand = frac(one, Mult(four, sub_expr2)), 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(\frac{1}{4} \cdot \left(\sum_{l = -2^{t - 1} + 1}^{-\left(e + 1\right)} \frac{1}{\left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\right)^{2}}\right)\right) + \left(\sum_{l = e + 1}^{2^{t - 1}} \frac{1}{4 \cdot \left(l - \left(2^{t} \cdot \delta_{b_{\textit{f}}}\right)\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: 58
operands: 1
1ExprTuple2, 3
2Operationoperator: 53
operands: 4
3Operationoperator: 10
operand: 8
4ExprTuple6, 7
5ExprTuple8
6Operationoperator: 24
operands: 9
7Operationoperator: 10
operand: 13
8Lambdaparameter: 44
body: 12
9ExprTuple70, 31
10Literal
11ExprTuple13
12Conditionalvalue: 14
condition: 15
13Lambdaparameter: 44
body: 17
14Operationoperator: 24
operands: 18
15Operationoperator: 26
operands: 19
16ExprTuple44
17Conditionalvalue: 20
condition: 21
18ExprTuple70, 22
19ExprTuple44, 23
20Operationoperator: 24
operands: 25
21Operationoperator: 26
operands: 27
22Operationoperator: 53
operands: 28
23Operationoperator: 33
operands: 29
24Literal
25ExprTuple70, 32
26Literal
27ExprTuple44, 30
28ExprTuple31, 32
29ExprTuple43, 49
30Operationoperator: 33
operands: 34
31Literal
32Operationoperator: 60
operands: 35
33Literal
34ExprTuple36, 37
35ExprTuple38, 65
36Operationoperator: 58
operands: 39
37Operationoperator: 68
operand: 43
38Operationoperator: 58
operands: 41
39ExprTuple42, 70
40ExprTuple43
41ExprTuple44, 45
42Operationoperator: 68
operand: 49
43Operationoperator: 58
operands: 47
44Variable
45Operationoperator: 68
operand: 51
46ExprTuple49
47ExprTuple50, 70
48ExprTuple51
49Operationoperator: 60
operands: 52
50Variable
51Operationoperator: 53
operands: 54
52ExprTuple65, 55
53Literal
54ExprTuple56, 57
55Operationoperator: 58
operands: 59
56Operationoperator: 60
operands: 61
57Operationoperator: 62
operand: 67
58Literal
59ExprTuple66, 64
60Literal
61ExprTuple65, 66
62Literal
63ExprTuple67
64Operationoperator: 68
operand: 70
65Literal
66Literal
67Literal
68Literal
69ExprTuple70
70Literal