psiqit.info
Auto-generated documentation for the psiqit.info module.
psiqit.info
PSIQIT - Python Scientific Quantum Information Toolkit Information Theory Module
This module provides quantum information theory tools including entropy measures and entanglement measures.
Submodules:
entropy.py - Entropy measures (Shannon, von Neumann, Rényi, etc.) entanglement.py - Entanglement measures (concurrence, negativity, etc.)
EntanglementResult
dataclass
Result container for entanglement measures
Attributes:
| Name | Type | Description |
|---|---|---|
value |
float
|
Numerical value of the entanglement measure |
measure |
str
|
Name of the measure used |
is_entangled |
bool
|
Whether the state is entangled |
details |
Dict[str, Any]
|
Additional information |
dims |
Optional[List[int]]
|
Subsystem dimensions |
Source code in psiqit\info\entanglement.py
shannon_entropy(probabilities, base='e')
Compute Shannon entropy of a probability distribution
H = -Σ p_i log(p_i)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
probabilities
|
ndarray
|
Probability distribution (must sum to 1) |
required |
base
|
str
|
Logarithm base: 'e' (natural), '2' (bits), or '10' (dits) |
'e'
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Shannon entropy |
Example
probs = [0.5, 0.5] print(shannon_entropy(probs)) # 0.693147... print(shannon_entropy(probs, base='2')) # 1.0
Source code in psiqit\info\entropy.py
von_neumann_entropy(rho, base='e')
Compute von Neumann entropy of a density matrix
S(ρ) = -Tr(ρ log ρ)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho
|
Union[ndarray, Matrix]
|
Density matrix |
required |
base
|
str
|
Logarithm base: 'e' (natural), '2' (bits), or '10' (dits) |
'e'
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
von Neumann entropy |
Source code in psiqit\info\entropy.py
renyi_entropy(rho, alpha=2, base='e')
Compute Rényi entropy of order α
S_α(ρ) = (1/(1-α)) log(Tr(ρ^α))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho
|
Union[ndarray, Matrix]
|
Density matrix |
required |
alpha
|
float
|
Order parameter (α > 0, α ≠ 1) |
2
|
base
|
str
|
Logarithm base: 'e' (natural), '2' (bits), or '10' (dits) |
'e'
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Rényi entropy |
Example
rho = np.array([[0.5, 0], [0, 0.5]]) print(renyi_entropy(rho, alpha=2)) # 0.693147...
Source code in psiqit\info\entropy.py
collision_entropy(rho, base='e')
Compute collision entropy (Rényi entropy of order 2)
S_2(ρ) = -log(Tr(ρ^2))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho
|
Union[ndarray, Matrix]
|
Density matrix |
required |
base
|
str
|
Logarithm base: 'e' (natural), '2' (bits), or '10' (dits) |
'e'
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Collision entropy |
Example
rho = np.array([[0.5, 0], [0, 0.5]]) print(collision_entropy(rho)) # 0.693147...
Source code in psiqit\info\entropy.py
partial_trace(matrix, dims, keep)
Compute partial trace of a bipartite or multipartite system
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
Union[ndarray, Matrix]
|
Full density matrix (or operator) |
required |
dims
|
List[int]
|
List of subsystem dimensions |
required |
keep
|
List[int]
|
List of subsystem indices to keep (trace out the rest) |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Reduced density matrix |
Example
2-qubit system: dims = [2, 2]
rho = np.array([[0.5, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0.5]]) rho_a = partial_trace(rho, [2, 2], [0]) print(rho_a) # Reduced state of first qubit
Source code in psiqit\info\entropy.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
mutual_information(rho_ab, dim_a, dim_b, base='e')
Compute mutual information between two subsystems
I(A:B) = S(ρ_A) + S(ρ_B) - S(ρ_AB)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho_ab
|
Union[ndarray, Matrix]
|
Joint density matrix of system AB |
required |
dim_a
|
int
|
Dimension of subsystem A |
required |
dim_b
|
int
|
Dimension of subsystem B |
required |
base
|
str
|
Logarithm base |
'e'
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Mutual information |
Source code in psiqit\info\entropy.py
relative_entropy(rho, sigma, base='e')
Compute quantum relative entropy
S(ρ||σ) = Tr(ρ log ρ - ρ log σ)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho
|
Union[ndarray, Matrix]
|
First density matrix |
required |
sigma
|
Union[ndarray, Matrix]
|
Second density matrix |
required |
base
|
str
|
Logarithm base |
'e'
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Relative entropy |
Example
rho = np.array([[0.5, 0], [0, 0.5]]) sigma = np.array([[0.8, 0], [0, 0.2]]) print(relative_entropy(rho, sigma))
Source code in psiqit\info\entropy.py
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | |
purity(rho)
Compute purity of a density matrix
P(ρ) = Tr(ρ²)
For pure states, purity = 1. For maximally mixed states, purity = 1/dim.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho
|
Union[ndarray, Matrix]
|
Density matrix |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Purity (0-1) |
Example
rho = np.array([[1, 0], [0, 0]]) # Pure state print(purity(rho)) # 1.0 rho = np.array([[0.5, 0], [0, 0.5]]) # Maximally mixed print(purity(rho)) # 0.5
Source code in psiqit\info\entropy.py
linear_entropy(rho)
Compute linear entropy
S_L(ρ) = 1 - Tr(ρ²)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho
|
Union[ndarray, Matrix]
|
Density matrix |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Linear entropy (0-1) |
min_entropy(rho)
Compute min-entropy (Rényi entropy of order ∞)
S_∞(ρ) = -log(λ_max)
where λ_max is the maximum eigenvalue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho
|
Union[ndarray, Matrix]
|
Density matrix |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Min-entropy |
Source code in psiqit\info\entropy.py
max_entropy(rho)
Compute max-entropy
S_max(ρ) = log(dim) - S_min(ρ)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho
|
Union[ndarray, Matrix]
|
Density matrix |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Max-entropy |
Source code in psiqit\info\entropy.py
concurrence_pure(state, dims=None)
Compute concurrence for a pure state
For a pure state |ψ⟩, concurrence = 2 * sqrt(det(ρ_A)) where ρ_A is the reduced density matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
Union[Ket, ndarray]
|
Pure state (Ket or array) |
required |
dims
|
Optional[List[int]]
|
Subsystem dimensions [dim_A, dim_B] (default: [2, 2]) |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Concurrence (0-1) |
Example
from psiqit.quantum import bell_phi_plus concurrence = concurrence_pure(bell_phi_plus()) print(concurrence) # 1.0
Source code in psiqit\info\entanglement.py
concurrence_mixed(rho, dims=None)
Compute concurrence for a mixed state (Wootters formula)
For two-qubit systems, concurrence = max(0, λ₁ - λ₂ - λ₃ - λ₄) where λ_i are the square roots of eigenvalues of ρ(σ_y⊗σ_y)ρ*(σ_y⊗σ_y)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rho
|
Union[ndarray, Matrix]
|
Density matrix |
required |
dims
|
Optional[List[int]]
|
Subsystem dimensions (default: [2, 2]) |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Concurrence (0-1) |
Example
rho = np.array([[0.5, 0, 0, 0.5], [0, 0, 0, 0], [0, 0, 0, 0], [0.5, 0, 0, 0.5]]) concurrence = concurrence_mixed(rho) print(concurrence) # 1.0
Source code in psiqit\info\entanglement.py
concurrence(state_or_rho, dims=None)
Compute concurrence for a state (pure or mixed)
Automatically detects if the input is pure or mixed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_or_rho
|
Union[Ket, ndarray, Matrix]
|
State vector or density matrix |
required |
dims
|
Optional[List[int]]
|
Subsystem dimensions |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Concurrence (0-1) |
Example
from psiqit.quantum import bell_phi_plus concurrence(bell_phi_plus()) # 1.0
Source code in psiqit\info\entanglement.py
negativity(state_or_rho, dims=None)
Compute negativity of a quantum state
N(ρ) = (||ρ^{T_A}||₁ - 1) / 2
where ρ^{T_A} is the partial transpose with respect to subsystem A.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_or_rho
|
Union[Ket, ndarray, Matrix]
|
State vector or density matrix |
required |
dims
|
Optional[List[int]]
|
Subsystem dimensions |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Negativity (0-1) |
Example
from psiqit.quantum import bell_phi_plus neg = negativity(bell_phi_plus()) print(neg) # 0.5
Source code in psiqit\info\entanglement.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
logarithmic_negativity(state_or_rho, dims=None)
Compute logarithmic negativity
E_N(ρ) = log₂(||ρ^{T_A}||₁)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_or_rho
|
Union[Ket, ndarray, Matrix]
|
State vector or density matrix |
required |
dims
|
Optional[List[int]]
|
Subsystem dimensions |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Logarithmic negativity |
Example
from psiqit.quantum import bell_phi_plus log_neg = logarithmic_negativity(bell_phi_plus()) print(log_neg) # 1.0
Source code in psiqit\info\entanglement.py
entanglement_entropy(state_or_rho, dims, base='e')
Compute entanglement entropy (von Neumann entropy of reduced state)
S_E(ρ) = S(ρ_A) = -Tr(ρ_A log ρ_A)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_or_rho
|
Union[Ket, ndarray, Matrix]
|
State vector or density matrix |
required |
dims
|
List[int]
|
Subsystem dimensions [dim_A, dim_B] |
required |
base
|
str
|
Logarithm base |
'e'
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Entanglement entropy |
Example
from psiqit.quantum import bell_phi_plus S_E = entanglement_entropy(bell_phi_plus(), [2, 2]) print(S_E) # 0.693147...
Source code in psiqit\info\entanglement.py
schmidt_decomposition(state, dims)
Compute Schmidt decomposition of a bipartite pure state
|ψ⟩ = Σ_i λ_i |i⟩_A ⊗ |i⟩_B
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
Union[Ket, ndarray]
|
Pure state |
required |
dims
|
List[int]
|
Subsystem dimensions [dim_A, dim_B] |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
Dict[str, Any]
|
Schmidt coefficients, Schmidt vectors, and rank |
Example
from psiqit.quantum import bell_phi_plus result = schmidt_decomposition(bell_phi_plus(), [2, 2]) print(result['coefficients']) # [0.707, 0.707]
Source code in psiqit\info\entanglement.py
schmidt_rank(state, dims, tol=1e-10)
Compute Schmidt rank of a bipartite pure state
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
Union[Ket, ndarray]
|
Pure state |
required |
dims
|
List[int]
|
Subsystem dimensions |
required |
tol
|
float
|
Tolerance for zero coefficients |
1e-10
|
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Schmidt rank |
Example
from psiqit.quantum import bell_phi_plus rank = schmidt_rank(bell_phi_plus(), [2, 2]) print(rank) # 2
Source code in psiqit\info\entanglement.py
is_entangled(state_or_rho, dims=None, tol=1e-10)
Detect if a quantum state is entangled
Uses multiple criteria: 1. For pure states: Schmidt rank > 1 2. For mixed states: negativity > 0 (for bipartite)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_or_rho
|
Union[Ket, ndarray, Matrix]
|
State vector or density matrix |
required |
dims
|
Optional[List[int]]
|
Subsystem dimensions |
None
|
tol
|
float
|
Tolerance for numerical checks |
1e-10
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if entangled, False if separable |
Example
from psiqit.quantum import bell_phi_plus, zero is_entangled(bell_phi_plus()) # True is_entangled(zero()) # False
Source code in psiqit\info\entanglement.py
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | |
entanglement_of_formation(state_or_rho, dims=None)
Compute entanglement of formation for two-qubit states
E_F(ρ) = h((1 + √(1 - C²))/2) where h(x) = -x log₂(x) - (1-x) log₂(1-x)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_or_rho
|
Union[Ket, ndarray, Matrix]
|
State vector or density matrix |
required |
dims
|
Optional[List[int]]
|
Subsystem dimensions |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Entanglement of formation (0-1) |
Example
from psiqit.quantum import bell_phi_plus EOF = entanglement_of_formation(bell_phi_plus()) print(EOF) # 1.0
Source code in psiqit\info\entanglement.py
distillable_entanglement(state_or_rho, dims=None)
Compute distillable entanglement (upper bound using log negativity)
E_D(ρ) ≤ log₂(||ρ^{T_A}||₁)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_or_rho
|
Union[Ket, ndarray, Matrix]
|
State vector or density matrix |
required |
dims
|
Optional[List[int]]
|
Subsystem dimensions |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Distillable entanglement (upper bound) |
Source code in psiqit\info\entanglement.py
info()
Get information about the information theory module
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Module information |
Source code in psiqit\info\__init__.py
test()
Run basic tests for the information theory module
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Test results |