Purity

From QETLAB
Jump to: navigation, search
Purity
Computes the purity of a quantum state

Other toolboxes required none
Function category Miscellaneous

Purity is a function that computes the purity of a quantum state $\rho$ (i.e., it computes the quantity ${\rm Tr}(\rho^2)$.

Syntax

  • GAMMA = Purity(RHO)

Argument descriptions

  • RHO: A density matrix to have its purity computed.

Examples

Purity of pure states

Pure states have purity equal to 1, as illustrated by the following code:

>> phi = RandomStateVector(3);
>> Purity(phi*phi')
 
ans =
 
    1.0000
 
>> Purity(RandomDensityMatrix(3,0,1))
 
ans =
 
    1.0000

Purity of mixed states

If $\rho \in M_d$ is mixed then its purity is strictly less than 1. Its purity attains its minimum value of $1/d$ if and only if $\rho$ is the maximally-mixed state (i.e., the scaled identity operator).

>> Purity(WernerState(2,1/4)) % the state WernerState(2,1/4) acts on 4-dimensional space
 
ans =
 
    0.2653
 
>> Purity(eye(4)/4)
 
ans =
 
    0.2500

Source code

Click on "expand" to the right to view the MATLAB source code for this function.

  1. %%  PURITY    Computes the purity of a quantum state
  2. %   This function has one required argument:
  3. %     RHO: a density matrix
  4. %
  5. %   GAMMA = Purity(RHO) is the purity of the quantum state RHO (i.e., GAMMA
  6. %   is the quantity trace(RHO^2)).
  7. %
  8. %   URL: http://www.qetlab.com/Purity
  9.  
  10. %   requires: nothing
  11. %   author: Nathaniel Johnston (nathaniel@njohnston.ca)
  12. %   package: QETLAB
  13. %   last updated: October 15, 2014
  14.  
  15. function gamma = Purity(rho)
  16.  
  17. gamma = real(trace(rho^2)); % "real" gets rid of close-to-0 imaginary part