logo

Expression of type Mult

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 Add, Exp, Mult, Sum, four, frac, one, subtract, two
from proveit.physics.quantum.QPE import _neg_domain, _pos_domain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [l]
expr = Mult(frac(one, four), Add(Sum(index_or_indices = sub_expr1, summand = frac(one, Exp(l, two)), domain = _neg_domain), Sum(index_or_indices = sub_expr1, summand = frac(one, Exp(subtract(l, one), two)), domain = _pos_domain)))
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())
\frac{1}{4} \cdot \left(\left(\sum_{l = -2^{t - 1} + 1}^{-\left(e + 1\right)} \frac{1}{l^{2}}\right) + \left(\sum_{l = e + 1}^{2^{t - 1}} \frac{1}{\left(l - 1\right)^{2}}\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()()('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 24
operands: 5
4Operationoperator: 54
operands: 6
5ExprTuple60, 7
6ExprTuple8, 9
7Literal
8Operationoperator: 11
operand: 13
9Operationoperator: 11
operand: 14
10ExprTuple13
11Literal
12ExprTuple14
13Lambdaparameter: 45
body: 15
14Lambdaparameter: 45
body: 17
15Conditionalvalue: 18
condition: 19
16ExprTuple45
17Conditionalvalue: 20
condition: 21
18Operationoperator: 24
operands: 22
19Operationoperator: 26
operands: 23
20Operationoperator: 24
operands: 25
21Operationoperator: 26
operands: 27
22ExprTuple60, 28
23ExprTuple45, 29
24Literal
25ExprTuple60, 30
26Literal
27ExprTuple45, 31
28Operationoperator: 50
operands: 32
29Operationoperator: 35
operands: 33
30Operationoperator: 50
operands: 34
31Operationoperator: 35
operands: 36
32ExprTuple45, 52
33ExprTuple37, 38
34ExprTuple39, 52
35Literal
36ExprTuple44, 48
37Operationoperator: 54
operands: 40
38Operationoperator: 58
operand: 44
39Operationoperator: 54
operands: 42
40ExprTuple43, 60
41ExprTuple44
42ExprTuple45, 57
43Operationoperator: 58
operand: 48
44Operationoperator: 54
operands: 47
45Variable
46ExprTuple48
47ExprTuple49, 60
48Operationoperator: 50
operands: 51
49Variable
50Literal
51ExprTuple52, 53
52Literal
53Operationoperator: 54
operands: 55
54Literal
55ExprTuple56, 57
56Literal
57Operationoperator: 58
operand: 60
58Literal
59ExprTuple60
60Literal