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
from proveit.numbers import Add, Exp, Mult, Neg, four, frac, one, subtract, two
from proveit.physics.quantum.QPE import _eps, _n, _t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Add(one, frac(one, Mult(two, _eps)))
sub_expr2 = Neg(frac(one, Mult(two, sub_expr1)))
expr = ExprTuple(Add(one, sub_expr2, Neg(frac(one, Mult(four, Exp(sub_expr1, two))))), Add(one, sub_expr2, Neg(frac(one, Mult(four, Exp(subtract(Exp(two, subtract(_t, _n)), one), two))))))
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(1 - \frac{1}{2 \cdot \left(1 + \frac{1}{2 \cdot \epsilon}\right)} - \frac{1}{4 \cdot \left(1 + \frac{1}{2 \cdot \epsilon}\right)^{2}}, 1 - \frac{1}{2 \cdot \left(1 + \frac{1}{2 \cdot \epsilon}\right)} - \frac{1}{4 \cdot \left(2^{t - n} - 1\right)^{2}}\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: 45
operands: 3
2Operationoperator: 45
operands: 4
3ExprTuple42, 6, 5
4ExprTuple42, 6, 7
5Operationoperator: 51
operand: 11
6Operationoperator: 51
operand: 12
7Operationoperator: 51
operand: 13
8ExprTuple11
9ExprTuple12
10ExprTuple13
11Operationoperator: 35
operands: 14
12Operationoperator: 35
operands: 15
13Operationoperator: 35
operands: 16
14ExprTuple42, 17
15ExprTuple42, 18
16ExprTuple42, 19
17Operationoperator: 43
operands: 20
18Operationoperator: 43
operands: 21
19Operationoperator: 43
operands: 22
20ExprTuple24, 23
21ExprTuple47, 28
22ExprTuple24, 25
23Operationoperator: 37
operands: 26
24Literal
25Operationoperator: 37
operands: 27
26ExprTuple28, 47
27ExprTuple29, 47
28Operationoperator: 45
operands: 30
29Operationoperator: 45
operands: 31
30ExprTuple42, 32
31ExprTuple33, 34
32Operationoperator: 35
operands: 36
33Operationoperator: 37
operands: 38
34Operationoperator: 51
operand: 42
35Literal
36ExprTuple42, 40
37Literal
38ExprTuple47, 41
39ExprTuple42
40Operationoperator: 43
operands: 44
41Operationoperator: 45
operands: 46
42Literal
43Literal
44ExprTuple47, 48
45Literal
46ExprTuple49, 50
47Literal
48Literal
49Literal
50Operationoperator: 51
operand: 53
51Literal
52ExprTuple53
53Literal