Documentation

pyqentangle.schmidt.schmidt_decomposition(bipartitepurestate_tensor, approach='tensornetwork')

Calculate the Schmidt decomposition of the given discrete bipartite quantum system

Given a discrete normalized quantum system, given in terms of 2-D numpy array bipartitepurestate_tensor, each element of bipartitepurestate_tensor[i, j] is the coefficient of the ket \(|ij\rangle\), calculate its Schmidt decomposition, returned as a list of tuples, where each tuple contains the Schmidt coefficient, the vector of eigenmode of first subsystem, and the vector of the eigenmode of second subsystem.

Parameters:
  • bipartitepurestate_tensor (numpy.ndarray) – tensor describing the bi-partitite states, with each elements the coefficients for \(|ij\rangle\)

  • approach (str) – using numpy or tensornetwork in computation. (default: tensornetwork)

Returns:

list of tuples containing the Schmidt coefficient, eigenmode for first subsystem, and eigenmode for second subsystem

Return type:

list

Raise:

ValueError

pyqentangle.schmidt.schmidt_decomposition_numpy(bipartitepurestate_tensor)

Calculate the Schmidt decomposition of the given discrete bipartite quantum system

This is called by schmidt_decomposition(). This runs numpy.

Parameters:

bipartitepurestate_tensor (numpy.ndarray) – tensor describing the bi-partitite states, with each elements the coefficients for \(|ij\rangle\)

Returns:

list of tuples containing the Schmidt coefficient, eigenmode for first subsystem, and eigenmode for second subsystem

Return type:

list

pyqentangle.schmidt.schmidt_decomposition_tensornetwork(bipartitepurestate_tensor)

Calculate the Schmidt decomposition of the given discrete bipartite quantum system

This is called by schmidt_decomposition(). This runs tensornetwork.

Parameters:

bipartitepurestate_tensor (numpy.ndarray) – tensor describing the bi-partitite states, with each elements the coefficients for \(|ij\rangle\)

Returns:

list of tuples containing the Schmidt coefficient, eigenmode for first subsystem, and eigenmode for second subsystem

Return type:

list

pyqentangle.continuous.continuous_schmidt_decomposition(fcn, x1_lo, x1_hi, x2_lo, x2_hi, nb_x1=100, nb_x2=100, keep=None, approach='tensornetwork')

Compute the Schmidt decomposition of a continuous bipartite quantum systems

Given a function fcn (a function with two input variables), perform the Schmidt decomposition, returning a list of tuples, where each contains a Schmidt decomposition, the lambda function of the eigenmode in the first subsystem, and the lambda function of the eigenmode of the second subsystem.

Parameters:
  • fcn (function) – function with two input variables

  • x1_lo (float) – lower bound of \(x_1\)

  • x1_hi (float) – upper bound of \(x_1\)

  • x2_lo (float) – lower bound of \(x_2\)

  • x2_hi (float) – upper bound of \(x_2\)

  • nb_x1 (int) – number of \(x_1\) (default: 100)

  • nb_x2 (int) – number of \(x_2\) (default: 100)

  • keep (int) – the number of Schmidt modes with the largest coefficients to return; the smaller of nb_x1 and nb_x2 will be returned if None is given. (default: None)

  • approach (str) – using numpy or tensornetwork in computation. (default: tensornetwork)

Returns:

list of tuples, where each contains a Schmidt coefficient, the lambda function of the eigenmode of the first subsystem, and the lambda function of the eigenmode of the second subsystem

Return type:

list

Raise:

ValueError

pyqentangle.continuous.discretize_continuous_bipartitesys(fcn, x1_lo, x1_hi, x2_lo, x2_hi, nb_x1=100, nb_x2=100)

Find the discretized representation of the continuous bipartite system

Given a function fcn (a function with two input variables), find the discretized representation of the bipartite system, with the first system ranges from x1_lo to x1_hi, and second from x2_lo to x2_hi.

Parameters:
  • fcn (function) – function with two input variables

  • x1_lo (float) – lower bound of \(x_1\)

  • x1_hi (float) – upper bound of \(x_1\)

  • x2_lo (float) – lower bound of \(x_2\)

  • x2_hi (float) – upper bound of \(x_2\)

  • nb_x1 (int) – number of \(x_1\) (default: 100)

  • nb_x2 (int) – number of \(x_2\) (default: 100)

Returns:

discretized tensor representation of the continuous bipartite system

Return type:

numpy.ndarray

pyqentangle.continuous.numerical_continuous_function(xarray, yarray)

Return a function with the given arrays of independent and dependent variables

With a function approximated by given arrays of independent variable (xarray) and of dependent variable (yarray), it returns a lambda function that takes a numpy.ndarray as an input and calculates the values at all these elements using interpolation.

If x is outside the range of xarray, an OutOfRangeException is raised.

Parameters:
  • xarray (numpy.ndarray) – an array of independent variable values

  • yarray (numpy.ndarray) – an array of dependent variable values

Returns:

a lambda function that takes a numpy.ndarray as the input parameter and calculate the values

Return type:

function

Raises:

OutOfRangeException

pyqentangle.continuous.numerical_continuous_interpolation(xarray, yarray, x)

Evaluate the value of a function given a variable x using interpolation

With a function approximated by given arrays of independent variable (xarray) and of dependent variable (yarray), the value of this function given x is calculated by interpolation.

If x is outside the range of xarray, an OutOfRangeException is raised; if the lengths of xarray and yarray are not equal, an UnequalLengthException is raised.

Parameters:
  • xarray (numpy.ndarray) – an array of independent variable values

  • yarray (numpy.ndarray) – an array of dependent variable values

  • x – the input value at where the function is computed at

Returns:

the value of function with the given x

Return type:

float

Raises:

OutOfRangeException, UnequalLengthException

pyqentangle.metrics.concurrence(bipartite_tensor)

Calculate the concurrence of a bipartite system that contains 2-dimensional state qubit only.

Parameters:

bipartite_tensor (numpy.ndarray) – tensor describing the bi-partitite states, with each elements the coefficients for \(|ij\rangle\)

Returns:

concurrence

Return type:

numpy.float

pyqentangle.metrics.entanglement_entropy(schmidt_modes)

Calculate the entanglement entropy

Given the calculated Schmidt modes, compute the entanglement entropy with the formula \(H=-\sum_i p_i \log p_i\).

Parameters:

schmidt_modes (list) – Schmidt modes

Returns:

the entanglement entropy

Return type:

numpy.float

pyqentangle.metrics.negativity(bipartite_tensor)

Calculate the negativity

Given a normalized bipartite discrete state, compute the negativity with the formula \(N = \frac{||\rho^{\Gamma_A}||_1-1}{2}\)

Parameters:

bipartite_tensor (numpy.ndarray) – tensor describing the bi-partitite states, with each elements the coefficients for \(|ij\rangle\)

Returns:

negativity

Return type:

numpy.float

pyqentangle.metrics.participation_ratio(schmidt_modes)

Calculate the participation ratio

Given the calculated Schmidt modes, compute the participation ratio with the formula \(K=\frac{1}{\sum_i p_i^2}\).

Parameters:

schmidt_modes (list) – Schmidt modes

Returns:

participation ratio

Return type:

numpy.float

pyqentangle.metrics.renyi_entanglement_entropy(schmidt_modes, alpha)

Calculate the Renyi’s entanglement entropy

Given the calculated Schmidt modes and an \(\alpha\), compute the Renyi’s entanglement entropy with the formula \(H= - \frac{1}{1-\alpha} \log \sum p_i^{\alpha}\).

Parameters:
  • schmidt_modes

  • alpha

Returns:

pyqentangle.metrics.schmidt_coefficients(schmidt_modes)

Retrieving Schmidt coefficients from Schmidt modes.

Parameters:

schmidt_modes (list) – Schmidt modes

Returns:

Schmidt coefficients

Return type:

numpy.array

exception pyqentangle.utils.InvalidMatrix(msg='Invalid matrix')
exception pyqentangle.utils.InvalidQuantumStateException(msg)
exception pyqentangle.utils.OutOfRangeException(value)
exception pyqentangle.utils.UnequalLengthException(array1, array2)
pyqentangle.quantumstates.harmonics.correlated_bipartite_gaussian_wavefcn(covmatrix)

Return a normalized correlated bivariate Gaussian wavefunction.

Parameters:

covmatrix (numpy.array) – covariance matrix of size (2, 2)

Returns:

a wavefunction of two variables

Return type:

function

pyqentangle.quantumstates.harmonics.coupled_excited_harmonics(n)

Return a bipartitite wavefunction, with ground state of center of mass, but excited state for the interaction.

Parameters:

n (int) – quantum harmonic state number for the interaction

Returns:

wavefunction of two variables

Return type:

function

pyqentangle.quantumstates.harmonics.disentangled_gaussian_wavefcn()

Return the function of normalized disentangled Gaussian systems.

Returns:

function of two variables

Return type:

function

pyqentangle.quantumstates.harmonics.harmonic_wavefcn(n)

Return the normalized wavefunction of a harmonic oscillator, where $n$ denotes that it is an n-th excited state, or ground state for $n=0$.

Parameters:

n (int) – quantum number of the excited state

Returns:

a normalized wavefunction

Return type:

function

pyqentangle.quantumstates.harmonics.tail_factorial(n, accumulator=1)

Returns the factorial of an integer.

The calculation is done by tail recursion.

Parameters:
  • n (int) – the integer of which the factorial is desired to return

  • accumulator (int) – default to be 1, for tail recursion.

Returns:

factorial of n

Return type:

int