logo

Expression of type Norm

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 Variable
from proveit.linear_algebra import Norm, ScalarMult
from proveit.numbers import Exp, Mult, Neg, e, i, pi, two
from proveit.physics.quantum import ket1
from proveit.physics.quantum.QPE import _phase
In [2]:
# build up the expression from sub-expressions
expr = Norm(ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(Variable("_a", latex_format = r"{_{-}a}"))), _phase)), ket1))
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 \|\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{-{_{-}a}} \cdot \varphi} \cdot \lvert 1 \rangle\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: 4
operands: 5
4Literal
5ExprTuple6, 7
6Operationoperator: 20
operands: 8
7Operationoperator: 9
operand: 13
8ExprTuple11, 12
9Literal
10ExprTuple13
11Literal
12Operationoperator: 14
operands: 15
13Literal
14Literal
15ExprTuple22, 16, 17, 18, 19
16Literal
17Literal
18Operationoperator: 20
operands: 21
19Literal
20Literal
21ExprTuple22, 23
22Literal
23Operationoperator: 24
operand: 26
24Literal
25ExprTuple26
26Variable