logo

Expression of type ExprTuple

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 ExprTuple, l
from proveit.numbers import Abs, Exp, Mult, e, frac, i, one, pi, subtract, two
from proveit.physics.quantum.QPE import _delta_b_floor, _two_pow_t
from proveit.trigonometry import Sin
In [2]:
# build up the expression from sub-expressions
sub_expr1 = subtract(_delta_b_floor, frac(l, _two_pow_t))
sub_expr2 = subtract(one, Exp(e, Mult(two, pi, i, subtract(Mult(_two_pow_t, _delta_b_floor), l))))
expr = ExprTuple(Abs(frac(sub_expr2, subtract(one, Exp(e, Mult(two, pi, i, sub_expr1))))), frac(Abs(sub_expr2), Mult(two, Sin(Mult(pi, Abs(sub_expr1))))))
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(\left|\frac{1 - \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\left(2^{t} \cdot \delta_{b_{\textit{f}}}\right) - l\right)}}{1 - \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\delta_{b_{\textit{f}}} - \frac{l}{2^{t}}\right)}}\right|, \frac{\left|1 - \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(\left(2^{t} \cdot \delta_{b_{\textit{f}}}\right) - l\right)}\right|}{2 \cdot \sin{\left(\pi \cdot \left|\delta_{b_{\textit{f}}} - \frac{l}{2^{t}}\right|\right)}}\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 30
operand: 5
2Operationoperator: 54
operands: 4
3ExprTuple5
4ExprTuple6, 7
5Operationoperator: 54
operands: 8
6Operationoperator: 30
operand: 12
7Operationoperator: 48
operands: 10
8ExprTuple12, 11
9ExprTuple12
10ExprTuple63, 13
11Operationoperator: 42
operands: 14
12Operationoperator: 42
operands: 15
13Operationoperator: 16
operand: 21
14ExprTuple19, 18
15ExprTuple19, 20
16Literal
17ExprTuple21
18Operationoperator: 50
operand: 25
19Literal
20Operationoperator: 50
operand: 26
21Operationoperator: 48
operands: 24
22ExprTuple25
23ExprTuple26
24ExprTuple38, 27
25Operationoperator: 61
operands: 28
26Operationoperator: 61
operands: 29
27Operationoperator: 30
operand: 37
28ExprTuple33, 32
29ExprTuple33, 34
30Literal
31ExprTuple37
32Operationoperator: 48
operands: 35
33Literal
34Operationoperator: 48
operands: 36
35ExprTuple63, 38, 39, 37
36ExprTuple63, 38, 39, 40
37Operationoperator: 42
operands: 41
38Literal
39Literal
40Operationoperator: 42
operands: 43
41ExprTuple53, 44
42Literal
43ExprTuple45, 46
44Operationoperator: 50
operand: 52
45Operationoperator: 48
operands: 49
46Operationoperator: 50
operand: 58
47ExprTuple52
48Literal
49ExprTuple59, 53
50Literal
51ExprTuple58
52Operationoperator: 54
operands: 55
53Operationoperator: 56
operand: 60
54Literal
55ExprTuple58, 59
56Literal
57ExprTuple60
58Variable
59Operationoperator: 61
operands: 62
60Literal
61Literal
62ExprTuple63, 64
63Literal
64Literal