Commutation 1.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.4
2
+ Name: Commutation
3
+ Version: 1.5.0
4
+ Summary: A small package for doing commutator algebra
5
+ Author-email: Alaric Sanders <thathatatt@gmail.com>
6
+ Project-URL: Homepage, https://github.com/Spuriosity1/Commutation
7
+ Project-URL: Issues, https://github.com/Spuriosity1/Commutation/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: ipython
15
+ Dynamic: license-file
16
+
17
+ # Commutation Station for Operator Elimination
18
+
19
+ A proof assistant tool for the busy physicist, to be used in evaluating large commutator expressions.
20
+ This package does symbolic algebra on noncommutative objects.
21
+
22
+ Example usage:
23
+
24
+ ### Creating Expressions from Operators
25
+ ```python
26
+ from commutation import *
27
+ from fractions import Fraction
28
+
29
+ a = Operator('a','S^x_a')
30
+ b = Operator('b','S^z_b')
31
+ c = Operator('c','S^z_c')
32
+ d = Operator('d','S^z_d')
33
+
34
+ # building everything up from elementary operators
35
+
36
+ x = a-9*b*c + a*b*a
37
+ print(x)
38
+ # +1 a -9 b c +1 a b a
39
+ ```
40
+
41
+ ### Complicated substitutions
42
+ ```python
43
+ x = a*b*b*b*a*c*a*a*c*a*b + 1
44
+
45
+ y = x.substitute(a*b,c+d)
46
+ print(x) # +1 a b b b a c a a c a b +1
47
+ print(y) # +1 c b b a c a a c c +1 c b b a c a a c d +1 d b b a c a a c c +1 d b b a c a a c d +1
48
+ ```
49
+
50
+ ### Factorisations
51
+
52
+ ```python
53
+ xx = 7*a*b*b + Fraction(4,5)*a*c*b*b + a*d*b*b + a*c*a*a*b*b + 3*a*b*b
54
+ fr, ba = xx.factor('right')
55
+ print(str(fr) + ' * [' + str(ba) + ' ] = ' +str(fr*ba)) # +1 a * [ +10 b b +4/5 c b b +1 d b b +1 c a a b b ] = +10 a b b +4/5 a c b b +1 a d b b +1 a c a a b b
56
+
57
+ fr, ba = xx.factor()
58
+ print('['+str(fr) + ' ] * ' + str(ba) + ' = ' +str(fr*ba)) # [ +10 a +4/5 a c +1 a d +1 a c a a ] * +1 b b = +10 a b b +4/5 a c b b +1 a d b b +1 a c a a b b
59
+ ```
60
+
61
+ ### Commutators
62
+
63
+ ```python
64
+ ca = CommutatorAlgebra()
65
+
66
+ az = Operator('az','S^z_a')
67
+ ap = Operator('a⁺','S^+_a')
68
+ am = Operator('a⁻','S^-_a')
69
+
70
+ KA = Operator('KA', 'K_A', scalar=True)
71
+
72
+ # note the funky bracket sequence - set_commutator actually returns a function
73
+ ca.set_commutator(az,ap)(ap)
74
+ ca.set_commutator(az,am)(-1*am)
75
+ ca.set_commutator(ap,am)(2*az)
76
+
77
+ # there are two modes: move_left and move_right
78
+ # Note that pathological commutators will make these fall into recursion loops...
79
+
80
+ xpr = Expression(az*ap*az*az*am)
81
+ ca.move_right(xpr, az)
82
+ xpr.collect()
83
+ print(xpr) # +1 a⁺ a⁻ az az az -2 a⁺ a⁻ az az +1 a⁺ a⁻ az
84
+
85
+ xpr = Expression(az*ap*az*az*am)
86
+ ca.move_left(xpr, am)
87
+ xpr.collect()
88
+ print(xpr) # +1 a⁻ az a⁺ az az -2 a⁻ az a⁺ az +2 az az az az -1 a⁻ a⁺ az az +1 a⁻ az a⁺ -4 az az az +2 a⁻ a⁺ az +2 az az -1 a⁻ a⁺
89
+
90
+ # these will warn you if you add an unknown operator...
91
+ xpr2 = Expression(az*ap*am*c*am)
92
+ ca.move_right(xpr2, az) # UserWarning: Non-scalar operator "c" is not in the commutator database, assuming it commutes...
93
+ xpr2.collect()
94
+ print(xpr2) # +1 a⁺ a⁻ c a⁻ az -1 a⁺ a⁻ c a⁻
95
+
96
+ # # ... but scalars are fine.
97
+ xpr3 = Expression(az*ap*am*KA*am)
98
+ ca.move_right(xpr3, az)
99
+ xpr3.collect()
100
+ print(xpr3) # +1 a⁺ a⁻ KA a⁻ az -1 a⁺ a⁻ KA a⁻
101
+ ```
@@ -0,0 +1,9 @@
1
+ commutation/__init__.py,sha256=BsvFbBhsBo23SnW5PoSbxP2_vo5-zovLVAlTKXDUP3E,235
2
+ commutation/commutatoralgebra.py,sha256=m4jJZ9pUKRrVKmThcrgdNWPlk9qUeS_4U-nq4bYGPRY,7861
3
+ commutation/expression.py,sha256=WSm5zW9lUHtfsgZR4WcwKKQOSCkEDmwNe6mUjDyTGRg,18327
4
+ commutation/style.py,sha256=ZXQZd6xGcRTAW1RO6UYtS_sM9_QU8UNMtuhGYO4-AB4,967
5
+ commutation-1.5.0.dist-info/licenses/LICENSE,sha256=5X8cMguM-HmKfS_4Om-eBqM6A1hfbgZf6pfx2G24QFI,35150
6
+ commutation-1.5.0.dist-info/METADATA,sha256=6OF_R8SHdKyIJytY_bq0tQ7lmA3R6dUEm4PztxgB8D4,3186
7
+ commutation-1.5.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ commutation-1.5.0.dist-info/top_level.txt,sha256=uK6XLltjNiEoxO4fapcExhy7Nl2bL0gvHNJeMvmqUPs,12
9
+ commutation-1.5.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+