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, t
from proveit.numbers import Exp, Mult, Neg, frac, one, sqrt, two
In [2]:
# build up the expression from sub-expressions
sub_expr1 = frac(one, two)
sub_expr2 = Mult(sub_expr1, t)
expr = ExprTuple(Mult(one, Exp(Mult(sqrt(two), Exp(two, sub_expr2)), Neg(one))), Mult(one, Mult(Exp(two, Neg(sub_expr1)), Exp(two, Neg(sub_expr2)))))
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 \cdot \left(\sqrt{2} \cdot 2^{\frac{1}{2} \cdot t}\right)^{-1}, 1 \cdot \left(2^{-\frac{1}{2}} \cdot 2^{-\left(\frac{1}{2} \cdot 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: 28
operands: 3
2Operationoperator: 28
operands: 4
3ExprTuple34, 5
4ExprTuple34, 6
5Operationoperator: 22
operands: 7
6Operationoperator: 28
operands: 8
7ExprTuple9, 10
8ExprTuple11, 12
9Operationoperator: 28
operands: 13
10Operationoperator: 25
operand: 34
11Operationoperator: 22
operands: 15
12Operationoperator: 22
operands: 16
13ExprTuple17, 18
14ExprTuple34
15ExprTuple35, 19
16ExprTuple35, 20
17Operationoperator: 22
operands: 21
18Operationoperator: 22
operands: 23
19Operationoperator: 25
operand: 30
20Operationoperator: 25
operand: 27
21ExprTuple35, 30
22Literal
23ExprTuple35, 27
24ExprTuple30
25Literal
26ExprTuple27
27Operationoperator: 28
operands: 29
28Literal
29ExprTuple30, 31
30Operationoperator: 32
operands: 33
31Variable
32Literal
33ExprTuple34, 35
34Literal
35Literal