logo

Expression of type Abs

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, Exp, Mult, e, frac, i, one, pi, subtract, two
from proveit.physics.quantum.QPE import _delta_b_floor, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Abs(Mult(frac(one, _two_pow_t), frac(subtract(one, Exp(e, Mult(two, pi, i, subtract(Mult(_two_pow_t, _delta_b_floor), l)))), subtract(one, Exp(e, Mult(two, pi, i, subtract(_delta_b_floor, frac(l, _two_pow_t))))))))
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}{2^{t}} \cdot \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|
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operand: 3
1Literal
2ExprTuple3
3Operationoperator: 37
operands: 4
4ExprTuple5, 6
5Operationoperator: 46
operands: 7
6Operationoperator: 46
operands: 8
7ExprTuple14, 50
8ExprTuple9, 10
9Operationoperator: 32
operands: 11
10Operationoperator: 32
operands: 12
11ExprTuple14, 13
12ExprTuple14, 15
13Operationoperator: 40
operand: 18
14Literal
15Operationoperator: 40
operand: 19
16ExprTuple18
17ExprTuple19
18Operationoperator: 51
operands: 20
19Operationoperator: 51
operands: 21
20ExprTuple23, 22
21ExprTuple23, 24
22Operationoperator: 37
operands: 25
23Literal
24Operationoperator: 37
operands: 26
25ExprTuple53, 28, 29, 27
26ExprTuple53, 28, 29, 30
27Operationoperator: 32
operands: 31
28Literal
29Literal
30Operationoperator: 32
operands: 33
31ExprTuple34, 35
32Literal
33ExprTuple42, 36
34Operationoperator: 37
operands: 38
35Operationoperator: 40
operand: 49
36Operationoperator: 40
operand: 43
37Literal
38ExprTuple50, 42
39ExprTuple49
40Literal
41ExprTuple43
42Operationoperator: 44
operand: 48
43Operationoperator: 46
operands: 47
44Literal
45ExprTuple48
46Literal
47ExprTuple49, 50
48Literal
49Variable
50Operationoperator: 51
operands: 52
51Literal
52ExprTuple53, 54
53Literal
54Literal