0
# Quantum Information and Entanglement
1
2
Tools for quantum information processing including entropy measures, entanglement quantification, and quantum correlations.
3
4
## Capabilities
5
6
### Entropy Measures
7
8
Various entropy and information measures for quantum states.
9
10
```python { .api }
11
def entropy_vn(rho: Qobj, base: float = np.e, sparse: bool = False) -> float:
12
"""
13
Calculate von Neumann entropy S(ρ) = -Tr(ρ log ρ).
14
15
Parameters:
16
- rho: Density matrix
17
- base: Logarithm base (e for nats, 2 for bits)
18
- sparse: Use sparse eigenvalue decomposition
19
20
Returns:
21
- float: von Neumann entropy
22
"""
23
24
def entropy_linear(rho: Qobj) -> float:
25
"""
26
Calculate linear entropy S_L(ρ) = 1 - Tr(ρ²).
27
28
Parameters:
29
- rho: Density matrix
30
31
Returns:
32
- float: Linear entropy
33
"""
34
35
def entropy_mutual(rho: Qobj, selA: list, selB: list, base: float = np.e, sparse: bool = False) -> float:
36
"""
37
Calculate mutual information I(A:B) = S(A) + S(B) - S(AB).
38
39
Parameters:
40
- rho: Bipartite density matrix
41
- selA: Subsystem A indices
42
- selB: Subsystem B indices
43
- base: Logarithm base
44
- sparse: Use sparse calculations
45
46
Returns:
47
- float: Mutual information
48
"""
49
50
def entropy_conditional(rho: Qobj, selA: list, selB: list, base: float = np.e, sparse: bool = False) -> float:
51
"""
52
Calculate conditional entropy S(A|B) = S(AB) - S(B).
53
54
Parameters:
55
- rho: Bipartite density matrix
56
- selA: Subsystem A indices
57
- selB: Subsystem B indices
58
- base: Logarithm base
59
- sparse: Use sparse calculations
60
61
Returns:
62
- float: Conditional entropy
63
"""
64
65
def entropy_relative(rho: Qobj, sigma: Qobj, base: float = np.e, sparse: bool = False) -> float:
66
"""
67
Calculate relative entropy (Kullback-Leibler divergence) S(ρ||σ) = Tr(ρ log ρ - ρ log σ).
68
69
Parameters:
70
- rho: First density matrix
71
- sigma: Second density matrix
72
- base: Logarithm base
73
- sparse: Use sparse calculations
74
75
Returns:
76
- float: Relative entropy
77
"""
78
```
79
80
### Entanglement Measures
81
82
Quantification of quantum entanglement in bipartite systems.
83
84
```python { .api }
85
def concurrence(rho: Qobj) -> float:
86
"""
87
Calculate concurrence for two-qubit states.
88
89
Parameters:
90
- rho: Two-qubit density matrix
91
92
Returns:
93
- float: Concurrence (0 = separable, 1 = maximally entangled)
94
"""
95
96
def negativity(rho: Qobj, mask) -> float:
97
"""
98
Calculate negativity as entanglement measure.
99
100
Parameters:
101
- rho: Bipartite density matrix
102
- mask: Subsystem indices for partial transpose
103
104
Returns:
105
- float: Negativity
106
"""
107
108
def logarithmic_negativity(rho: Qobj, mask) -> float:
109
"""
110
Calculate logarithmic negativity E_N = log₂(2N + 1).
111
112
Parameters:
113
- rho: Bipartite density matrix
114
- mask: Subsystem indices for partial transpose
115
116
Returns:
117
- float: Logarithmic negativity
118
"""
119
```
120
121
### Quantum Fidelity and Distance Measures
122
123
Measures of similarity and distance between quantum states.
124
125
```python { .api }
126
def fidelity(rho: Qobj, sigma: Qobj) -> float:
127
"""
128
Calculate quantum fidelity F(ρ,σ) = Tr(√(√ρ σ √ρ))².
129
130
Parameters:
131
- rho: First quantum state (pure or mixed)
132
- sigma: Second quantum state (pure or mixed)
133
134
Returns:
135
- float: Fidelity (0 to 1)
136
"""
137
138
def trace_distance(rho: Qobj, sigma: Qobj) -> float:
139
"""
140
Calculate trace distance D(ρ,σ) = ½Tr|ρ - σ|.
141
142
Parameters:
143
- rho: First density matrix
144
- sigma: Second density matrix
145
146
Returns:
147
- float: Trace distance (0 to 1)
148
"""
149
150
def hilbert_schmidt_distance(rho: Qobj, sigma: Qobj) -> float:
151
"""
152
Calculate Hilbert-Schmidt distance.
153
154
Parameters:
155
- rho: First quantum state
156
- sigma: Second quantum state
157
158
Returns:
159
- float: Hilbert-Schmidt distance
160
"""
161
162
def bures_distance(rho: Qobj, sigma: Qobj) -> float:
163
"""
164
Calculate Bures distance D_B(ρ,σ) = √(2(1 - √F(ρ,σ))).
165
166
Parameters:
167
- rho: First density matrix
168
- sigma: Second density matrix
169
170
Returns:
171
- float: Bures distance
172
"""
173
```
174
175
### Entangling Power and Capacity
176
177
Measures of a quantum operation's ability to create entanglement.
178
179
```python { .api }
180
def entangling_power(U: Qobj, targets: list = None) -> float:
181
"""
182
Calculate entangling power of unitary operation.
183
184
Parameters:
185
- U: Unitary operator
186
- targets: Target qubit indices
187
188
Returns:
189
- float: Entangling power
190
"""
191
192
def entanglement_capacity(kraus_ops: list) -> float:
193
"""
194
Calculate entanglement capacity of quantum channel.
195
196
Parameters:
197
- kraus_ops: List of Kraus operators
198
199
Returns:
200
- float: Entanglement capacity
201
"""
202
```
203
204
### Quantum Channel Measures
205
206
Information-theoretic measures for quantum channels.
207
208
```python { .api }
209
def channel_fidelity(channel1: list, channel2: list) -> float:
210
"""
211
Calculate fidelity between quantum channels.
212
213
Parameters:
214
- channel1: Kraus operators for first channel
215
- channel2: Kraus operators for second channel
216
217
Returns:
218
- float: Channel fidelity
219
"""
220
221
def diamond_norm(kraus_ops: list) -> float:
222
"""
223
Calculate diamond norm of quantum channel.
224
225
Parameters:
226
- kraus_ops: List of Kraus operators
227
228
Returns:
229
- float: Diamond norm
230
"""
231
```
232
233
### Partial Transpose and Separability
234
235
Tools for analyzing quantum state separability.
236
237
```python { .api }
238
def partial_transpose(rho: Qobj, mask) -> Qobj:
239
"""
240
Calculate partial transpose of density matrix.
241
242
Parameters:
243
- rho: Density matrix
244
- mask: Subsystem indices to transpose
245
246
Returns:
247
- Qobj: Partially transposed density matrix
248
"""
249
250
def is_separable(rho: Qobj, tol: float = 1e-15) -> bool:
251
"""
252
Test if bipartite state is separable using PPT criterion.
253
254
Parameters:
255
- rho: Bipartite density matrix
256
- tol: Numerical tolerance
257
258
Returns:
259
- bool: True if separable (PPT), False if entangled
260
"""
261
```
262
263
### Schmidt Decomposition
264
265
Tools for Schmidt decomposition of bipartite pure states.
266
267
```python { .api }
268
def schmidt_decompose(state: Qobj, splitting: list = None) -> tuple:
269
"""
270
Perform Schmidt decomposition of bipartite pure state.
271
272
Parameters:
273
- state: Bipartite pure state vector
274
- splitting: Dimensions of subsystems [dimA, dimB]
275
276
Returns:
277
- tuple: (schmidt_coefficients, states_A, states_B)
278
"""
279
280
def schmidt_rank(state: Qobj, splitting: list = None, tol: float = 1e-12) -> int:
281
"""
282
Calculate Schmidt rank of bipartite pure state.
283
284
Parameters:
285
- state: Bipartite pure state
286
- splitting: Subsystem dimensions
287
- tol: Tolerance for zero coefficients
288
289
Returns:
290
- int: Schmidt rank
291
"""
292
```
293
294
### Usage Examples
295
296
```python
297
import qutip as qt
298
import numpy as np
299
300
# Entropy calculations
301
# Pure state entropy
302
psi_pure = qt.basis(2, 0) # |0⟩ state
303
rho_pure = psi_pure * psi_pure.dag()
304
S_pure = qt.entropy_vn(rho_pure)
305
print(f"Pure state entropy: {S_pure:.6f}") # Should be 0
306
307
# Mixed state entropy
308
rho_mixed = 0.7 * qt.ket2dm(qt.basis(2,0)) + 0.3 * qt.ket2dm(qt.basis(2,1))
309
S_mixed = qt.entropy_vn(rho_mixed)
310
S_linear = qt.entropy_linear(rho_mixed)
311
print(f"Mixed state entropy: {S_mixed:.3f}")
312
print(f"Linear entropy: {S_linear:.3f}")
313
314
# Maximum entropy state
315
rho_max = qt.maximally_mixed_dm(2) # I/2
316
S_max = qt.entropy_vn(rho_max, base=2) # Using base 2 for bits
317
print(f"Maximum entropy (bits): {S_max:.3f}") # Should be 1 bit
318
319
# Bipartite system entropies
320
bell = qt.bell_state('00') # (|00⟩ + |11⟩)/√2
321
rho_bell = bell * bell.dag()
322
323
# Mutual information
324
I_AB = qt.entropy_mutual(rho_bell, [0], [1])
325
print(f"Bell state mutual information: {I_AB:.3f}")
326
327
# Conditional entropy
328
S_A_given_B = qt.entropy_conditional(rho_bell, [0], [1])
329
print(f"Conditional entropy S(A|B): {S_A_given_B:.3f}")
330
331
# Entanglement measures
332
# Concurrence for two-qubit states
333
C_bell = qt.concurrence(rho_bell)
334
print(f"Bell state concurrence: {C_bell:.3f}") # Should be 1
335
336
# Separable state
337
sep_state = qt.tensor(qt.basis(2,0), qt.basis(2,0)) * qt.tensor(qt.basis(2,0), qt.basis(2,0)).dag()
338
C_sep = qt.concurrence(sep_state)
339
print(f"Separable state concurrence: {C_sep:.6f}") # Should be 0
340
341
# Negativity
342
N_bell = qt.negativity(rho_bell, [0])
343
N_sep = qt.negativity(sep_state, [0])
344
print(f"Bell state negativity: {N_bell:.3f}")
345
print(f"Separable state negativity: {N_sep:.6f}")
346
347
# Logarithmic negativity
348
E_N = qt.logarithmic_negativity(rho_bell, [0])
349
print(f"Bell state log negativity: {E_N:.3f}")
350
351
# Fidelity calculations
352
psi1 = qt.basis(2, 0) # |0⟩
353
psi2 = qt.basis(2, 1) # |1⟩
354
psi3 = (psi1 + psi2).unit() # |+⟩
355
356
F_identical = qt.fidelity(psi1, psi1)
357
F_orthogonal = qt.fidelity(psi1, psi2)
358
F_overlap = qt.fidelity(psi1, psi3)
359
360
print(f"Identical states fidelity: {F_identical:.6f}") # Should be 1
361
print(f"Orthogonal states fidelity: {F_orthogonal:.6f}") # Should be 0
362
print(f"Overlapping states fidelity: {F_overlap:.3f}") # Should be 0.5
363
364
# Mixed state fidelity
365
rho1 = 0.8 * qt.ket2dm(psi1) + 0.2 * qt.ket2dm(psi2)
366
rho2 = 0.6 * qt.ket2dm(psi1) + 0.4 * qt.ket2dm(psi2)
367
F_mixed = qt.fidelity(rho1, rho2)
368
print(f"Mixed states fidelity: {F_mixed:.3f}")
369
370
# Trace distance
371
T_dist = qt.trace_distance(rho1, rho2)
372
print(f"Trace distance: {T_dist:.3f}")
373
374
# Bures distance
375
B_dist = qt.bures_distance(rho1, rho2)
376
print(f"Bures distance: {B_dist:.3f}")
377
378
# Entangling power of quantum gates
379
CNOT = qt.cnot()
380
U_local = qt.tensor(qt.rx(np.pi/4), qt.ry(np.pi/3)) # Local unitary
381
382
EP_CNOT = qt.entangling_power(CNOT)
383
EP_local = qt.entangling_power(U_local)
384
print(f"CNOT entangling power: {EP_CNOT:.3f}")
385
print(f"Local unitary entangling power: {EP_local:.6f}") # Should be 0
386
387
# Partial transpose and separability test
388
rho_PT = qt.partial_transpose(rho_bell, [0])
389
eigenvals_PT = rho_PT.eigenenergies()
390
print(f"Partial transpose eigenvalues: {eigenvals_PT}")
391
# Negative eigenvalue indicates entanglement
392
393
separable = qt.is_separable(sep_state)
394
entangled = qt.is_separable(rho_bell)
395
print(f"Separable state test: {separable}") # Should be True
396
print(f"Entangled state test: {entangled}") # Should be False
397
398
# Schmidt decomposition
399
bell_state = qt.bell_state('00')
400
schmidt_coeffs, states_A, states_B = qt.schmidt_decompose(bell_state, [2, 2])
401
schmidt_r = qt.schmidt_rank(bell_state, [2, 2])
402
403
print(f"Schmidt coefficients: {schmidt_coeffs}")
404
print(f"Schmidt rank: {schmidt_r}")
405
406
# Verify Schmidt decomposition
407
reconstructed = sum(c * qt.tensor(sA, sB)
408
for c, sA, sB in zip(schmidt_coeffs, states_A, states_B))
409
fidelity_check = qt.fidelity(bell_state, reconstructed)
410
print(f"Schmidt decomposition fidelity: {fidelity_check:.6f}") # Should be 1
411
412
# Multi-partite entangled state
413
ghz3 = qt.ghz_state(3)
414
rho_ghz3 = ghz3 * ghz3.dag()
415
416
# Tripartite mutual information
417
I_ABC = (qt.entropy_vn(qt.ptrace(rho_ghz3, [0])) +
418
qt.entropy_vn(qt.ptrace(rho_ghz3, [1])) +
419
qt.entropy_vn(qt.ptrace(rho_ghz3, [2])) -
420
qt.entropy_vn(rho_ghz3))
421
print(f"GHZ state tripartite mutual info: {I_ABC:.3f}")
422
423
# Pairwise entanglement in GHZ state
424
rho_AB = qt.ptrace(rho_ghz3, [0, 1])
425
N_AB = qt.negativity(rho_AB, [0])
426
print(f"GHZ pairwise negativity: {N_AB:.6f}") # GHZ has no pairwise entanglement
427
428
# Information processing
429
# Quantum relative entropy (distinguishability)
430
rho_signal = 0.9 * qt.ket2dm(qt.basis(2,0)) + 0.1 * qt.ket2dm(qt.basis(2,1))
431
rho_noise = qt.maximally_mixed_dm(2)
432
S_rel = qt.entropy_relative(rho_signal, rho_noise, base=2)
433
print(f"Relative entropy (signal||noise): {S_rel:.3f} bits")
434
```
435
436
## Types
437
438
```python { .api }
439
# All quantum information functions return numerical values (float or int)
440
# or quantum objects (Qobj) for operations like partial transpose
441
```