<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://qetlab.com/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nathaniel</id>
	<title>QETLAB - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://qetlab.com/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Nathaniel"/>
	<link rel="alternate" type="text/html" href="https://qetlab.com/Special:Contributions/Nathaniel"/>
	<updated>2026-06-13T15:03:39Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36974</id>
		<title>List of functions</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36974"/>
		<updated>2025-11-18T19:38:37Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: /* Miscellaneous */ Added link to CompoundMatrix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a &#039;&#039;&#039;list of functions&#039;&#039;&#039; provided by QETLAB, arranged by category. If you would prefer an alphabetical list of all functions please see [[:Category:Functions|this page]]. Brief descriptions of these functions are provided here, as well as links to their documentation pages, where full details and numerous examples can be found.&lt;br /&gt;
&lt;br /&gt;
==Basic operations==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPSD]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is positive semidefinite&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Tensor]]&amp;lt;/tt&amp;gt;: Kronecker tensor product of two or more matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TensorSum]]&amp;lt;/tt&amp;gt;: Computes a vector or operator from its tensor decomposition&lt;br /&gt;
&lt;br /&gt;
==Coherence and incoherence==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IskIncoherent]]&amp;lt;/tt&amp;gt;: Determines whether or not a quantum state is k-incoherent&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[L1NormCoherence]]&amp;lt;/tt&amp;gt;: Computes the ℓ&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;-norm of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RelEntCoherence]]&amp;lt;/tt&amp;gt;: Computes the relative entropy of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RobustnessCoherence]]&amp;lt;/tt&amp;gt;: Computes the robustness of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceDistanceCoherence]]&amp;lt;/tt&amp;gt;: Computes the trace distance of coherence of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Distinguishing objects==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChannelDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing two quantum channels&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Distinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[LocalDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states by symmetric-extendible and/or PPT measurements&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPBSepDistinguishable]]&amp;lt;/tt&amp;gt;: Determines whether or not an unextendible product basis is distinguishable by separable measurements&lt;br /&gt;
&lt;br /&gt;
==Entanglement and separability==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntangledSubspace]]&amp;lt;/tt&amp;gt;: Creates a basis of an r-entangled subspace of any requested dimension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductVector]]&amp;lt;/tt&amp;gt;: Determines if a pure state is a product vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the Schmidt decomposition of a bipartite vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the Schmidt rank of a bipartite vector&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FilterNormalForm]]&amp;lt;/tt&amp;gt;: Computes the filter normal form of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsBlockPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator is block positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsEntanglingGate]]&amp;lt;/tt&amp;gt;: Determines if a unitary is an entangling gate&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix has positive partial transpose&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductOperator]]&amp;lt;/tt&amp;gt;: Determines if an operator is an elementary tensor&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsSeparable]]&amp;lt;/tt&amp;gt;: Determines whether or not a bipartite operator is separable&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt decomposition of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt rank of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric extension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricInnerExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric inner extension&lt;br /&gt;
&lt;br /&gt;
===Ball of separability===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AbsPPTConstraints]]&amp;lt;/tt&amp;gt;: Builds the eigenvalue matrices that determine whether or not a state is absolutely PPT&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InSeparableBall]]&amp;lt;/tt&amp;gt;: Checks whether or not an operator is in the ball of separability centered at the maximally-mixed state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsAbsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a density matrix is absolutely PPT&lt;br /&gt;
&lt;br /&gt;
===Entanglement measures===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Concurrence]]&amp;lt;/tt&amp;gt;: Computes the concurrence of a 2-qubit state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntFormation]]&amp;lt;/tt&amp;gt;: Computes the entanglement of formation of a bipartite quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Negativity]]&amp;lt;/tt&amp;gt;: Computes the negativity of a bipartite density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomRobustnessEntanglement]]&amp;lt;/tt&amp;gt;: Computes the random robustness of entanglement of a bipartite quantum state&lt;br /&gt;
&lt;br /&gt;
==Graph theory==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CliqueNumber]]&amp;lt;/tt&amp;gt;: Bounds the clique number (i.e., maximum size of a clique) of a graph&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomGraph]]&amp;lt;/tt&amp;gt;: Generates the adjacency matrix of a random graph&lt;br /&gt;
&lt;br /&gt;
==Information theory==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Entropy]]&amp;lt;/tt&amp;gt;: Computes the von Neumann or Rényi entropy of a density matrix&lt;br /&gt;
&lt;br /&gt;
==Nonlocality and Bell inequalities==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a binary contraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameValue]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a binary constraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMax]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a Bell inequality or nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMaxQubits]]&amp;lt;/tt&amp;gt;: Approximates the optimal value of a Bell inequality in qubit (i.e., 2-dimensional quantum) settings&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NonlocalGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a non-local game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NPAHierarchy]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of probabilities satisfy the conditions of the NPA hierarchy&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ParallelRepetition]]&amp;lt;/tt&amp;gt;: Produces the coefficients of parallel repetitions of a nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[XORGameValue]]&amp;lt;/tt&amp;gt;: Computes the classical or quantum value of a non-local binary XOR game&lt;br /&gt;
&lt;br /&gt;
==Norms and distance measures==&lt;br /&gt;
===Vectors and pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkVectorNorm]]&amp;lt;/tt&amp;gt;: Computes the s(k)-norm of a vector&lt;br /&gt;
&lt;br /&gt;
===Operators and mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Fidelity]]&amp;lt;/tt&amp;gt;: Computes the (Uhlmann) fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedMatrixNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced p&amp;amp;rarr;q norm of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNorm]]&amp;lt;/tt&amp;gt;: Computes the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNormDual]]&amp;lt;/tt&amp;gt;: Computes the dual of the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KyFanNorm]]&amp;lt;/tt&amp;gt;: Computes the Ky Fan k-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MatsumotoFidelity]]&amp;lt;/tt&amp;gt;: Computes the Matsumoto fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkOperatorNorm]]&amp;lt;/tt&amp;gt;: Bounds the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchattenNorm]]&amp;lt;/tt&amp;gt;: Computes the Schatten p-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceNorm]]&amp;lt;/tt&amp;gt;: Computes the trace norm of an operator&lt;br /&gt;
&lt;br /&gt;
===Superoperators and channels===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CBNorm]]&amp;lt;/tt&amp;gt;: Computes the completely bounded norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DiamondNorm]]&amp;lt;/tt&amp;gt;: Computes the diamond norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedSchattenNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced Schatten p&amp;amp;rarr;q norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaximumOutputFidelity]]&amp;lt;/tt&amp;gt;: Computes the maximum output fidelity of two quantum channels&lt;br /&gt;
&lt;br /&gt;
==Permutations and symmetry of subsystems==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AntisymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the antisymmetric subspace&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermutationOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that permutes subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermuteSystems]]&amp;lt;/tt&amp;gt;: Permutes subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Swap]]&amp;lt;/tt&amp;gt;: Swaps two subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SwapOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that swaps two subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the symmetric subspace&lt;br /&gt;
&lt;br /&gt;
==Polynomial optimization==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CopositivePolynomial]]&amp;lt;/tt&amp;gt;: Creates a homogenous polynomial whose non-negativity is equivalent to copositivity of a given matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialAsMatrix]]&amp;lt;/tt&amp;gt;: Creates a compact fully symmetric matrix representation of a polynomial&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt;: Bounds the optimal value of a homogeneous polynomial on the unit sphere&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialSOS]]&amp;lt;/tt&amp;gt;: Bounds the optimal value of a homogeneous polynomial on the unit sphere via the Sum-Of-Squares hierarchy&lt;br /&gt;
&lt;br /&gt;
==Random things==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomDensityMatrix]]&amp;lt;/tt&amp;gt;: Generates a random density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPOVM]]&amp;lt;/tt&amp;gt;: Generates a random POVM (positive-operator valued measure)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPPTState]]&amp;lt;/tt&amp;gt;: Generates a random density matrix with positive partial transpose, and optionally low rank&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomProbabilities]]&amp;lt;/tt&amp;gt;: Computes a random probability vector, distributed uniformly on the unit simplex&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomStateVector]]&amp;lt;/tt&amp;gt;: Generates a random pure state vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomSuperoperator]]&amp;lt;/tt&amp;gt;: Generates a random superoperator (completely positive map)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomUnitary]]&amp;lt;/tt&amp;gt;: Generates a random unitary or orthogonal matrix&lt;br /&gt;
&lt;br /&gt;
==Special states, vectors, and operators==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Bell]]&amp;lt;/tt&amp;gt;: Produces a Bell state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BrauerStates]]&amp;lt;/tt&amp;gt;: Produces all Brauer states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DickeState]]&amp;lt;/tt&amp;gt;: Generates a Dicke state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GHZState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) GHZ state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaxEntangled]]&amp;lt;/tt&amp;gt;: Produces a maximally entangled bipartite pure state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) W-state&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BreuerState]]&amp;lt;/tt&amp;gt;: Generates a Breuer state, which is a specific family of bound entangled states on even local dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChessboardState]]&amp;lt;/tt&amp;gt;: Produces a chessboard state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GisinState]]&amp;lt;/tt&amp;gt;: Generates a 2-qubit Gisin state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[HorodeckiState]]&amp;lt;/tt&amp;gt;: Generates a bound entangled &amp;quot;Horodecki&amp;quot; state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsotropicState]]&amp;lt;/tt&amp;gt;: Produces an isotropic state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WernerState]]&amp;lt;/tt&amp;gt;: Produces a Werner state&lt;br /&gt;
&lt;br /&gt;
===Other operators===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FourierMatrix]]&amp;lt;/tt&amp;gt;: Generates the unitary matrix that implements the quantum Fourier transform&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GellMann]]&amp;lt;/tt&amp;gt;: Produces a Gell-Mann operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenGellMann]]&amp;lt;/tt&amp;gt;: Produces a generalized Gell-Mann operator or the identity matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenPauli]]&amp;lt;/tt&amp;gt;: Produces a generalized Pauli operator (sometimes called a Weyl operator)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Pauli]]&amp;lt;/tt&amp;gt;: Produces a Pauli operator&lt;br /&gt;
&lt;br /&gt;
==Superoperators==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ApplyMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMatrix]]&amp;lt;/tt&amp;gt;: Computes the Choi matrix of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMap]]&amp;lt;/tt&amp;gt;: Produces the Choi map or one of its generalizations&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ComplementaryMap]]&amp;lt;/tt&amp;gt;: Computes the complementary map of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DephasingChannel]]&amp;lt;/tt&amp;gt;: Produces a dephasing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DepolarizingChannel]]&amp;lt;/tt&amp;gt;: Produces a depolarizing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DualMap]]&amp;lt;/tt&amp;gt;: Computes the dual of a superoperator in the Hilbert-Schmidt inner product&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsCP]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is completely positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsHermPreserving]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is Hermiticity preserving&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KrausOperators]]&amp;lt;/tt&amp;gt;: Computes a set of Kraus operators for a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to a subsystem of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTrace]]&amp;lt;/tt&amp;gt;: Computes the partial trace of a vector or a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTranspose]]&amp;lt;/tt&amp;gt;: Computes the partial transpose of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PauliChannel]]&amp;lt;/tt&amp;gt;: Generates a Pauli channel (i.e., a quantum channel with Pauli Kraus operators)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Realignment]]&amp;lt;/tt&amp;gt;: Computes the realignment of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ReductionMap]]&amp;lt;/tt&amp;gt;: Produces the reduction map&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Twirl]]&amp;lt;/tt&amp;gt;: Twirls a bipartite or multipartite operator&lt;br /&gt;
&lt;br /&gt;
==Unextendible product bases==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsUPB]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of product vectors form a UPB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MinUPBSize]]&amp;lt;/tt&amp;gt;: Gives the minimum cardinality of an unextendible product basis in given dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPB]]&amp;lt;/tt&amp;gt;: Generates an unextendible product basis&lt;br /&gt;
&lt;br /&gt;
==Miscellaneous==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Commutant]]&amp;lt;/tt&amp;gt;: Computes the commutant of a set of matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CompoundMatrix]]&amp;lt;/tt&amp;gt;: Computes the &amp;lt;tt&amp;gt;r&amp;lt;/tt&amp;gt;th compound matrix of a given matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyNonsingular]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally nonsingular&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Majorizes]]&amp;lt;/tt&amp;gt;: Determines whether or not a vector or matrix majorizes another&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSinkhorn]]&amp;lt;/tt&amp;gt;: Performs the operator Sinkhorn iteration, making all single-party reduced states proportional to the identity&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Purity]]&amp;lt;/tt&amp;gt;: Computes the purity of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Helper functions==&lt;br /&gt;
These are functions that only serve auxiliary roles within other functions of QETLAB. As an end-user of QETLAB, you likely won&#039;t have any use for these functions, but they are listed here anyway just in case.&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[bcs_to_nonlocal]]&amp;lt;/tt&amp;gt;: Converts a constraint description of a binary constraint system (BCS) game to a general non-local game description&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[dec_to_bin]]&amp;lt;/tt&amp;gt;: Converts a decimal number to a binary number in a similar way to `de2bi&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt;: Looks up a monomial&#039;s lexicographical index based on a list of exponents&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[has_band_k_ordering]]&amp;lt;/tt&amp;gt;: Determines whether a matrix has bandwidth ≤ k up to symmetric permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[iden]]&amp;lt;/tt&amp;gt;: Computes a sparse or full identity matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[jacobi_poly]]&amp;lt;/tt&amp;gt;: Computes the coefficients of Jacobi polynomials&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[normalize_cols]]&amp;lt;/tt&amp;gt;: Scales the columns of a matrix to have norm 1&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[one_factorization]]&amp;lt;/tt&amp;gt;: Computes a 1-factorization of a list of objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_args]]&amp;lt;/tt&amp;gt;: Handles optional input arguments for functions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_disp]]&amp;lt;/tt&amp;gt;: Display a message to the user (sometimes)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pad_array]]&amp;lt;/tt&amp;gt;: Pads an array with zeroes in a similar way to `padarray&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perfect_matchings]]&amp;lt;/tt&amp;gt;: Gives all perfect matchings of N objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_inv]]&amp;lt;/tt&amp;gt;: Computes the inverse of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_sign]]&amp;lt;/tt&amp;gt;: Computes the sign of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pure_to_mixed]]&amp;lt;/tt&amp;gt;: Converts a state vector or density matrix representation of a state to a density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sk_iterate]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[spnull]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the null space&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sporth]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the range&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[superoperator_dims]]&amp;lt;/tt&amp;gt;: Computes the input, output, and environment dimensions of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[update_odometer]]&amp;lt;/tt&amp;gt;: Increases the entries of a vector subject to constraints on how large the entries of that vector can be&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[vec_partitions]]&amp;lt;/tt&amp;gt;: Produces all possible partitions of a vector&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=Old_versions&amp;diff=36973</id>
		<title>Old versions</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=Old_versions&amp;diff=36973"/>
		<updated>2025-07-22T17:07:56Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Fix v1.0 release date&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains an archived list of previous releases of QETLAB. However, it is highly recommended that you always use the most up-to-date version of QETLAB whenever possible.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:auto;margin-right:auto;&amp;quot;&lt;br /&gt;
! Version&lt;br /&gt;
! .zip download&lt;br /&gt;
! .tar.gz download&lt;br /&gt;
! release date&lt;br /&gt;
! change log&lt;br /&gt;
|-&lt;br /&gt;
! v1.0 &amp;lt;font style=&amp;quot;color:#008800&amp;quot;&amp;gt;(current version)&amp;lt;/font&amp;gt;&lt;br /&gt;
|[https://github.com/nathanieljohnston/QETLAB/archive/v1.0.zip .zip]&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/archive/v1.0.tar.gz .tar.gz]&lt;br /&gt;
| July 22, 2025&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/blob/master/CHANGELOG.md#10---2025-07-22 view]&lt;br /&gt;
|-&lt;br /&gt;
! v0.9&lt;br /&gt;
|[https://github.com/nathanieljohnston/QETLAB/archive/v0.9.zip .zip]&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/archive/v0.9.tar.gz .tar.gz]&lt;br /&gt;
| January 12, 2016&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/blob/master/CHANGELOG.md#09---2016-01-12 view]&lt;br /&gt;
|-&lt;br /&gt;
! v0.8&lt;br /&gt;
|[https://github.com/nathanieljohnston/QETLAB/archive/v0.8.zip .zip]&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/archive/v0.8.tar.gz .tar.gz]&lt;br /&gt;
| April 13, 2015&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/blob/master/CHANGELOG.md#08---2015-04-13 view]&lt;br /&gt;
|-&lt;br /&gt;
! v0.7&lt;br /&gt;
|[https://github.com/nathanieljohnston/QETLAB/archive/v0.7.zip .zip]&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/archive/v0.7.tar.gz .tar.gz]&lt;br /&gt;
| January 22, 2015&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/blob/master/CHANGELOG.md#07---2015-01-22 view]&lt;br /&gt;
|-&lt;br /&gt;
! v0.6&lt;br /&gt;
|[https://github.com/nathanieljohnston/QETLAB/archive/v0.6.zip .zip]&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/archive/v0.6.tar.gz .tar.gz]&lt;br /&gt;
| November 27, 2014&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/blob/master/CHANGELOG.md#06---2014-11-27 view]&lt;br /&gt;
|-&lt;br /&gt;
! v0.5&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/archive/v0.5.zip .zip]&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/archive/v0.5.tar.gz .tar.gz]&lt;br /&gt;
| November 6, 2014&lt;br /&gt;
| &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=Old_versions&amp;diff=36972</id>
		<title>Old versions</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=Old_versions&amp;diff=36972"/>
		<updated>2025-07-22T17:07:19Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Updating for v1.0&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains an archived list of previous releases of QETLAB. However, it is highly recommended that you always use the most up-to-date version of QETLAB whenever possible.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin-left:auto;margin-right:auto;&amp;quot;&lt;br /&gt;
! Version&lt;br /&gt;
! .zip download&lt;br /&gt;
! .tar.gz download&lt;br /&gt;
! release date&lt;br /&gt;
! change log&lt;br /&gt;
|-&lt;br /&gt;
! v1.0 &amp;lt;font style=&amp;quot;color:#008800&amp;quot;&amp;gt;(current version)&amp;lt;/font&amp;gt;&lt;br /&gt;
|[https://github.com/nathanieljohnston/QETLAB/archive/v1.0.zip .zip]&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/archive/v1.0.tar.gz .tar.gz]&lt;br /&gt;
| January 12, 2016&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/blob/master/CHANGELOG.md#10---2025-07-22 view]&lt;br /&gt;
|-&lt;br /&gt;
! v0.9&lt;br /&gt;
|[https://github.com/nathanieljohnston/QETLAB/archive/v0.9.zip .zip]&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/archive/v0.9.tar.gz .tar.gz]&lt;br /&gt;
| January 12, 2016&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/blob/master/CHANGELOG.md#09---2016-01-12 view]&lt;br /&gt;
|-&lt;br /&gt;
! v0.8&lt;br /&gt;
|[https://github.com/nathanieljohnston/QETLAB/archive/v0.8.zip .zip]&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/archive/v0.8.tar.gz .tar.gz]&lt;br /&gt;
| April 13, 2015&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/blob/master/CHANGELOG.md#08---2015-04-13 view]&lt;br /&gt;
|-&lt;br /&gt;
! v0.7&lt;br /&gt;
|[https://github.com/nathanieljohnston/QETLAB/archive/v0.7.zip .zip]&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/archive/v0.7.tar.gz .tar.gz]&lt;br /&gt;
| January 22, 2015&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/blob/master/CHANGELOG.md#07---2015-01-22 view]&lt;br /&gt;
|-&lt;br /&gt;
! v0.6&lt;br /&gt;
|[https://github.com/nathanieljohnston/QETLAB/archive/v0.6.zip .zip]&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/archive/v0.6.tar.gz .tar.gz]&lt;br /&gt;
| November 27, 2014&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/blob/master/CHANGELOG.md#06---2014-11-27 view]&lt;br /&gt;
|-&lt;br /&gt;
! v0.5&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/archive/v0.5.zip .zip]&lt;br /&gt;
| [https://github.com/nathanieljohnston/QETLAB/archive/v0.5.tar.gz .tar.gz]&lt;br /&gt;
| November 6, 2014&lt;br /&gt;
| &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=Template:LastUpdated&amp;diff=36971</id>
		<title>Template:LastUpdated</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=Template:LastUpdated&amp;diff=36971"/>
		<updated>2025-07-22T17:05:48Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Updating to v1.0&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;includeonly&amp;gt;July 22, 2025&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;This page gives the date that the current public-ready version of QETLAB was released. The value that it currently returns is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;{{LastUpdated}}&amp;lt;/tt&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=Template:CurrentVersion&amp;diff=36970</id>
		<title>Template:CurrentVersion</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=Template:CurrentVersion&amp;diff=36970"/>
		<updated>2025-07-22T17:05:13Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Updating to v1.0&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;includeonly&amp;gt;1.0&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;This page gives the current version (&#039;&#039;without&#039;&#039; the &amp;quot;v&amp;quot; before it) of the current public-ready version of QETLAB. The value that it currently returns is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;{{CurrentVersion}}&amp;lt;/tt&amp;gt;&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36968</id>
		<title>List of functions</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36968"/>
		<updated>2025-07-21T13:31:33Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: /* Helper functions */ Added has_band_k_ordering&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a &#039;&#039;&#039;list of functions&#039;&#039;&#039; provided by QETLAB, arranged by category. If you would prefer an alphabetical list of all functions please see [[:Category:Functions|this page]]. Brief descriptions of these functions are provided here, as well as links to their documentation pages, where full details and numerous examples can be found.&lt;br /&gt;
&lt;br /&gt;
==Basic operations==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPSD]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is positive semidefinite&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Tensor]]&amp;lt;/tt&amp;gt;: Kronecker tensor product of two or more matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TensorSum]]&amp;lt;/tt&amp;gt;: Computes a vector or operator from its tensor decomposition&lt;br /&gt;
&lt;br /&gt;
==Coherence and incoherence==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IskIncoherent]]&amp;lt;/tt&amp;gt;: Determines whether or not a quantum state is k-incoherent&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[L1NormCoherence]]&amp;lt;/tt&amp;gt;: Computes the ℓ&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;-norm of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RelEntCoherence]]&amp;lt;/tt&amp;gt;: Computes the relative entropy of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RobustnessCoherence]]&amp;lt;/tt&amp;gt;: Computes the robustness of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceDistanceCoherence]]&amp;lt;/tt&amp;gt;: Computes the trace distance of coherence of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Distinguishing objects==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChannelDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing two quantum channels&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Distinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[LocalDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states by symmetric-extendible and/or PPT measurements&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPBSepDistinguishable]]&amp;lt;/tt&amp;gt;: Determines whether or not an unextendible product basis is distinguishable by separable measurements&lt;br /&gt;
&lt;br /&gt;
==Entanglement and separability==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntangledSubspace]]&amp;lt;/tt&amp;gt;: Creates a basis of an r-entangled subspace of any requested dimension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductVector]]&amp;lt;/tt&amp;gt;: Determines if a pure state is a product vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the Schmidt decomposition of a bipartite vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the Schmidt rank of a bipartite vector&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FilterNormalForm]]&amp;lt;/tt&amp;gt;: Computes the filter normal form of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsBlockPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator is block positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsEntanglingGate]]&amp;lt;/tt&amp;gt;: Determines if a unitary is an entangling gate&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix has positive partial transpose&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductOperator]]&amp;lt;/tt&amp;gt;: Determines if an operator is an elementary tensor&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsSeparable]]&amp;lt;/tt&amp;gt;: Determines whether or not a bipartite operator is separable&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt decomposition of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt rank of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric extension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricInnerExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric inner extension&lt;br /&gt;
&lt;br /&gt;
===Ball of separability===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AbsPPTConstraints]]&amp;lt;/tt&amp;gt;: Builds the eigenvalue matrices that determine whether or not a state is absolutely PPT&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InSeparableBall]]&amp;lt;/tt&amp;gt;: Checks whether or not an operator is in the ball of separability centered at the maximally-mixed state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsAbsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a density matrix is absolutely PPT&lt;br /&gt;
&lt;br /&gt;
===Entanglement measures===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Concurrence]]&amp;lt;/tt&amp;gt;: Computes the concurrence of a 2-qubit state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntFormation]]&amp;lt;/tt&amp;gt;: Computes the entanglement of formation of a bipartite quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Negativity]]&amp;lt;/tt&amp;gt;: Computes the negativity of a bipartite density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomRobustnessEntanglement]]&amp;lt;/tt&amp;gt;: Computes the random robustness of entanglement of a bipartite quantum state&lt;br /&gt;
&lt;br /&gt;
==Graph theory==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CliqueNumber]]&amp;lt;/tt&amp;gt;: Bounds the clique number (i.e., maximum size of a clique) of a graph&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomGraph]]&amp;lt;/tt&amp;gt;: Generates the adjacency matrix of a random graph&lt;br /&gt;
&lt;br /&gt;
==Information theory==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Entropy]]&amp;lt;/tt&amp;gt;: Computes the von Neumann or Rényi entropy of a density matrix&lt;br /&gt;
&lt;br /&gt;
==Nonlocality and Bell inequalities==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a binary contraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameValue]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a binary constraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMax]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a Bell inequality or nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMaxQubits]]&amp;lt;/tt&amp;gt;: Approximates the optimal value of a Bell inequality in qubit (i.e., 2-dimensional quantum) settings&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NonlocalGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a non-local game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NPAHierarchy]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of probabilities satisfy the conditions of the NPA hierarchy&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ParallelRepetition]]&amp;lt;/tt&amp;gt;: Produces the coefficients of parallel repetitions of a nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[XORGameValue]]&amp;lt;/tt&amp;gt;: Computes the classical or quantum value of a non-local binary XOR game&lt;br /&gt;
&lt;br /&gt;
==Norms and distance measures==&lt;br /&gt;
===Vectors and pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkVectorNorm]]&amp;lt;/tt&amp;gt;: Computes the s(k)-norm of a vector&lt;br /&gt;
&lt;br /&gt;
===Operators and mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Fidelity]]&amp;lt;/tt&amp;gt;: Computes the (Uhlmann) fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedMatrixNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced p&amp;amp;rarr;q norm of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNorm]]&amp;lt;/tt&amp;gt;: Computes the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNormDual]]&amp;lt;/tt&amp;gt;: Computes the dual of the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KyFanNorm]]&amp;lt;/tt&amp;gt;: Computes the Ky Fan k-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MatsumotoFidelity]]&amp;lt;/tt&amp;gt;: Computes the Matsumoto fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkOperatorNorm]]&amp;lt;/tt&amp;gt;: Bounds the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchattenNorm]]&amp;lt;/tt&amp;gt;: Computes the Schatten p-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceNorm]]&amp;lt;/tt&amp;gt;: Computes the trace norm of an operator&lt;br /&gt;
&lt;br /&gt;
===Superoperators and channels===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CBNorm]]&amp;lt;/tt&amp;gt;: Computes the completely bounded norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DiamondNorm]]&amp;lt;/tt&amp;gt;: Computes the diamond norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedSchattenNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced Schatten p&amp;amp;rarr;q norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaximumOutputFidelity]]&amp;lt;/tt&amp;gt;: Computes the maximum output fidelity of two quantum channels&lt;br /&gt;
&lt;br /&gt;
==Permutations and symmetry of subsystems==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AntisymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the antisymmetric subspace&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermutationOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that permutes subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermuteSystems]]&amp;lt;/tt&amp;gt;: Permutes subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Swap]]&amp;lt;/tt&amp;gt;: Swaps two subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SwapOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that swaps two subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the symmetric subspace&lt;br /&gt;
&lt;br /&gt;
==Polynomial optimization==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CopositivePolynomial]]&amp;lt;/tt&amp;gt;: Creates a homogenous polynomial whose non-negativity is equivalent to copositivity of a given matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialAsMatrix]]&amp;lt;/tt&amp;gt;: Creates a compact fully symmetric matrix representation of a polynomial&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt;: Bounds the optimal value of a homogeneous polynomial on the unit sphere&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialSOS]]&amp;lt;/tt&amp;gt;: Bounds the optimal value of a homogeneous polynomial on the unit sphere via the Sum-Of-Squares hierarchy&lt;br /&gt;
&lt;br /&gt;
==Random things==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomDensityMatrix]]&amp;lt;/tt&amp;gt;: Generates a random density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPOVM]]&amp;lt;/tt&amp;gt;: Generates a random POVM (positive-operator valued measure)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPPTState]]&amp;lt;/tt&amp;gt;: Generates a random density matrix with positive partial transpose, and optionally low rank&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomProbabilities]]&amp;lt;/tt&amp;gt;: Computes a random probability vector, distributed uniformly on the unit simplex&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomStateVector]]&amp;lt;/tt&amp;gt;: Generates a random pure state vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomSuperoperator]]&amp;lt;/tt&amp;gt;: Generates a random superoperator (completely positive map)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomUnitary]]&amp;lt;/tt&amp;gt;: Generates a random unitary or orthogonal matrix&lt;br /&gt;
&lt;br /&gt;
==Special states, vectors, and operators==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Bell]]&amp;lt;/tt&amp;gt;: Produces a Bell state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BrauerStates]]&amp;lt;/tt&amp;gt;: Produces all Brauer states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DickeState]]&amp;lt;/tt&amp;gt;: Generates a Dicke state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GHZState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) GHZ state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaxEntangled]]&amp;lt;/tt&amp;gt;: Produces a maximally entangled bipartite pure state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) W-state&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BreuerState]]&amp;lt;/tt&amp;gt;: Generates a Breuer state, which is a specific family of bound entangled states on even local dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChessboardState]]&amp;lt;/tt&amp;gt;: Produces a chessboard state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GisinState]]&amp;lt;/tt&amp;gt;: Generates a 2-qubit Gisin state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[HorodeckiState]]&amp;lt;/tt&amp;gt;: Generates a bound entangled &amp;quot;Horodecki&amp;quot; state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsotropicState]]&amp;lt;/tt&amp;gt;: Produces an isotropic state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WernerState]]&amp;lt;/tt&amp;gt;: Produces a Werner state&lt;br /&gt;
&lt;br /&gt;
===Other operators===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FourierMatrix]]&amp;lt;/tt&amp;gt;: Generates the unitary matrix that implements the quantum Fourier transform&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GellMann]]&amp;lt;/tt&amp;gt;: Produces a Gell-Mann operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenGellMann]]&amp;lt;/tt&amp;gt;: Produces a generalized Gell-Mann operator or the identity matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenPauli]]&amp;lt;/tt&amp;gt;: Produces a generalized Pauli operator (sometimes called a Weyl operator)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Pauli]]&amp;lt;/tt&amp;gt;: Produces a Pauli operator&lt;br /&gt;
&lt;br /&gt;
==Superoperators==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ApplyMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMatrix]]&amp;lt;/tt&amp;gt;: Computes the Choi matrix of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMap]]&amp;lt;/tt&amp;gt;: Produces the Choi map or one of its generalizations&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ComplementaryMap]]&amp;lt;/tt&amp;gt;: Computes the complementary map of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DephasingChannel]]&amp;lt;/tt&amp;gt;: Produces a dephasing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DepolarizingChannel]]&amp;lt;/tt&amp;gt;: Produces a depolarizing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DualMap]]&amp;lt;/tt&amp;gt;: Computes the dual of a superoperator in the Hilbert-Schmidt inner product&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsCP]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is completely positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsHermPreserving]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is Hermiticity preserving&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KrausOperators]]&amp;lt;/tt&amp;gt;: Computes a set of Kraus operators for a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to a subsystem of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTrace]]&amp;lt;/tt&amp;gt;: Computes the partial trace of a vector or a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTranspose]]&amp;lt;/tt&amp;gt;: Computes the partial transpose of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PauliChannel]]&amp;lt;/tt&amp;gt;: Generates a Pauli channel (i.e., a quantum channel with Pauli Kraus operators)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Realignment]]&amp;lt;/tt&amp;gt;: Computes the realignment of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ReductionMap]]&amp;lt;/tt&amp;gt;: Produces the reduction map&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Twirl]]&amp;lt;/tt&amp;gt;: Twirls a bipartite or multipartite operator&lt;br /&gt;
&lt;br /&gt;
==Unextendible product bases==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsUPB]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of product vectors form a UPB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MinUPBSize]]&amp;lt;/tt&amp;gt;: Gives the minimum cardinality of an unextendible product basis in given dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPB]]&amp;lt;/tt&amp;gt;: Generates an unextendible product basis&lt;br /&gt;
&lt;br /&gt;
==Miscellaneous==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Commutant]]&amp;lt;/tt&amp;gt;: Computes the commutant of a set of matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyNonsingular]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally nonsingular&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Majorizes]]&amp;lt;/tt&amp;gt;: Determines whether or not a vector or matrix majorizes another&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSinkhorn]]&amp;lt;/tt&amp;gt;: Performs the operator Sinkhorn iteration, making all single-party reduced states proportional to the identity&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Purity]]&amp;lt;/tt&amp;gt;: Computes the purity of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Helper functions==&lt;br /&gt;
These are functions that only serve auxiliary roles within other functions of QETLAB. As an end-user of QETLAB, you likely won&#039;t have any use for these functions, but they are listed here anyway just in case.&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[bcs_to_nonlocal]]&amp;lt;/tt&amp;gt;: Converts a constraint description of a binary constraint system (BCS) game to a general non-local game description&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[dec_to_bin]]&amp;lt;/tt&amp;gt;: Converts a decimal number to a binary number in a similar way to `de2bi&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt;: Looks up a monomial&#039;s lexicographical index based on a list of exponents&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[has_band_k_ordering]]&amp;lt;/tt&amp;gt;: Determines whether a matrix has bandwidth ≤ k up to symmetric permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[iden]]&amp;lt;/tt&amp;gt;: Computes a sparse or full identity matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[jacobi_poly]]&amp;lt;/tt&amp;gt;: Computes the coefficients of Jacobi polynomials&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[normalize_cols]]&amp;lt;/tt&amp;gt;: Scales the columns of a matrix to have norm 1&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[one_factorization]]&amp;lt;/tt&amp;gt;: Computes a 1-factorization of a list of objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_args]]&amp;lt;/tt&amp;gt;: Handles optional input arguments for functions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_disp]]&amp;lt;/tt&amp;gt;: Display a message to the user (sometimes)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pad_array]]&amp;lt;/tt&amp;gt;: Pads an array with zeroes in a similar way to `padarray&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perfect_matchings]]&amp;lt;/tt&amp;gt;: Gives all perfect matchings of N objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_inv]]&amp;lt;/tt&amp;gt;: Computes the inverse of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_sign]]&amp;lt;/tt&amp;gt;: Computes the sign of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pure_to_mixed]]&amp;lt;/tt&amp;gt;: Converts a state vector or density matrix representation of a state to a density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sk_iterate]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[spnull]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the null space&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sporth]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the range&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[superoperator_dims]]&amp;lt;/tt&amp;gt;: Computes the input, output, and environment dimensions of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[update_odometer]]&amp;lt;/tt&amp;gt;: Increases the entries of a vector subject to constraints on how large the entries of that vector can be&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[vec_partitions]]&amp;lt;/tt&amp;gt;: Produces all possible partitions of a vector&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36967</id>
		<title>List of functions</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36967"/>
		<updated>2025-07-21T13:30:14Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Added IskIncoherent&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a &#039;&#039;&#039;list of functions&#039;&#039;&#039; provided by QETLAB, arranged by category. If you would prefer an alphabetical list of all functions please see [[:Category:Functions|this page]]. Brief descriptions of these functions are provided here, as well as links to their documentation pages, where full details and numerous examples can be found.&lt;br /&gt;
&lt;br /&gt;
==Basic operations==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPSD]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is positive semidefinite&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Tensor]]&amp;lt;/tt&amp;gt;: Kronecker tensor product of two or more matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TensorSum]]&amp;lt;/tt&amp;gt;: Computes a vector or operator from its tensor decomposition&lt;br /&gt;
&lt;br /&gt;
==Coherence and incoherence==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IskIncoherent]]&amp;lt;/tt&amp;gt;: Determines whether or not a quantum state is k-incoherent&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[L1NormCoherence]]&amp;lt;/tt&amp;gt;: Computes the ℓ&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;-norm of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RelEntCoherence]]&amp;lt;/tt&amp;gt;: Computes the relative entropy of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RobustnessCoherence]]&amp;lt;/tt&amp;gt;: Computes the robustness of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceDistanceCoherence]]&amp;lt;/tt&amp;gt;: Computes the trace distance of coherence of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Distinguishing objects==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChannelDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing two quantum channels&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Distinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[LocalDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states by symmetric-extendible and/or PPT measurements&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPBSepDistinguishable]]&amp;lt;/tt&amp;gt;: Determines whether or not an unextendible product basis is distinguishable by separable measurements&lt;br /&gt;
&lt;br /&gt;
==Entanglement and separability==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntangledSubspace]]&amp;lt;/tt&amp;gt;: Creates a basis of an r-entangled subspace of any requested dimension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductVector]]&amp;lt;/tt&amp;gt;: Determines if a pure state is a product vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the Schmidt decomposition of a bipartite vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the Schmidt rank of a bipartite vector&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FilterNormalForm]]&amp;lt;/tt&amp;gt;: Computes the filter normal form of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsBlockPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator is block positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsEntanglingGate]]&amp;lt;/tt&amp;gt;: Determines if a unitary is an entangling gate&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix has positive partial transpose&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductOperator]]&amp;lt;/tt&amp;gt;: Determines if an operator is an elementary tensor&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsSeparable]]&amp;lt;/tt&amp;gt;: Determines whether or not a bipartite operator is separable&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt decomposition of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt rank of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric extension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricInnerExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric inner extension&lt;br /&gt;
&lt;br /&gt;
===Ball of separability===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AbsPPTConstraints]]&amp;lt;/tt&amp;gt;: Builds the eigenvalue matrices that determine whether or not a state is absolutely PPT&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InSeparableBall]]&amp;lt;/tt&amp;gt;: Checks whether or not an operator is in the ball of separability centered at the maximally-mixed state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsAbsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a density matrix is absolutely PPT&lt;br /&gt;
&lt;br /&gt;
===Entanglement measures===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Concurrence]]&amp;lt;/tt&amp;gt;: Computes the concurrence of a 2-qubit state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntFormation]]&amp;lt;/tt&amp;gt;: Computes the entanglement of formation of a bipartite quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Negativity]]&amp;lt;/tt&amp;gt;: Computes the negativity of a bipartite density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomRobustnessEntanglement]]&amp;lt;/tt&amp;gt;: Computes the random robustness of entanglement of a bipartite quantum state&lt;br /&gt;
&lt;br /&gt;
==Graph theory==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CliqueNumber]]&amp;lt;/tt&amp;gt;: Bounds the clique number (i.e., maximum size of a clique) of a graph&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomGraph]]&amp;lt;/tt&amp;gt;: Generates the adjacency matrix of a random graph&lt;br /&gt;
&lt;br /&gt;
==Information theory==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Entropy]]&amp;lt;/tt&amp;gt;: Computes the von Neumann or Rényi entropy of a density matrix&lt;br /&gt;
&lt;br /&gt;
==Nonlocality and Bell inequalities==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a binary contraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameValue]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a binary constraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMax]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a Bell inequality or nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMaxQubits]]&amp;lt;/tt&amp;gt;: Approximates the optimal value of a Bell inequality in qubit (i.e., 2-dimensional quantum) settings&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NonlocalGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a non-local game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NPAHierarchy]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of probabilities satisfy the conditions of the NPA hierarchy&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ParallelRepetition]]&amp;lt;/tt&amp;gt;: Produces the coefficients of parallel repetitions of a nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[XORGameValue]]&amp;lt;/tt&amp;gt;: Computes the classical or quantum value of a non-local binary XOR game&lt;br /&gt;
&lt;br /&gt;
==Norms and distance measures==&lt;br /&gt;
===Vectors and pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkVectorNorm]]&amp;lt;/tt&amp;gt;: Computes the s(k)-norm of a vector&lt;br /&gt;
&lt;br /&gt;
===Operators and mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Fidelity]]&amp;lt;/tt&amp;gt;: Computes the (Uhlmann) fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedMatrixNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced p&amp;amp;rarr;q norm of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNorm]]&amp;lt;/tt&amp;gt;: Computes the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNormDual]]&amp;lt;/tt&amp;gt;: Computes the dual of the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KyFanNorm]]&amp;lt;/tt&amp;gt;: Computes the Ky Fan k-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MatsumotoFidelity]]&amp;lt;/tt&amp;gt;: Computes the Matsumoto fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkOperatorNorm]]&amp;lt;/tt&amp;gt;: Bounds the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchattenNorm]]&amp;lt;/tt&amp;gt;: Computes the Schatten p-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceNorm]]&amp;lt;/tt&amp;gt;: Computes the trace norm of an operator&lt;br /&gt;
&lt;br /&gt;
===Superoperators and channels===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CBNorm]]&amp;lt;/tt&amp;gt;: Computes the completely bounded norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DiamondNorm]]&amp;lt;/tt&amp;gt;: Computes the diamond norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedSchattenNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced Schatten p&amp;amp;rarr;q norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaximumOutputFidelity]]&amp;lt;/tt&amp;gt;: Computes the maximum output fidelity of two quantum channels&lt;br /&gt;
&lt;br /&gt;
==Permutations and symmetry of subsystems==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AntisymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the antisymmetric subspace&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermutationOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that permutes subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermuteSystems]]&amp;lt;/tt&amp;gt;: Permutes subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Swap]]&amp;lt;/tt&amp;gt;: Swaps two subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SwapOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that swaps two subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the symmetric subspace&lt;br /&gt;
&lt;br /&gt;
==Polynomial optimization==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CopositivePolynomial]]&amp;lt;/tt&amp;gt;: Creates a homogenous polynomial whose non-negativity is equivalent to copositivity of a given matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialAsMatrix]]&amp;lt;/tt&amp;gt;: Creates a compact fully symmetric matrix representation of a polynomial&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt;: Bounds the optimal value of a homogeneous polynomial on the unit sphere&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialSOS]]&amp;lt;/tt&amp;gt;: Bounds the optimal value of a homogeneous polynomial on the unit sphere via the Sum-Of-Squares hierarchy&lt;br /&gt;
&lt;br /&gt;
==Random things==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomDensityMatrix]]&amp;lt;/tt&amp;gt;: Generates a random density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPOVM]]&amp;lt;/tt&amp;gt;: Generates a random POVM (positive-operator valued measure)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPPTState]]&amp;lt;/tt&amp;gt;: Generates a random density matrix with positive partial transpose, and optionally low rank&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomProbabilities]]&amp;lt;/tt&amp;gt;: Computes a random probability vector, distributed uniformly on the unit simplex&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomStateVector]]&amp;lt;/tt&amp;gt;: Generates a random pure state vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomSuperoperator]]&amp;lt;/tt&amp;gt;: Generates a random superoperator (completely positive map)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomUnitary]]&amp;lt;/tt&amp;gt;: Generates a random unitary or orthogonal matrix&lt;br /&gt;
&lt;br /&gt;
==Special states, vectors, and operators==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Bell]]&amp;lt;/tt&amp;gt;: Produces a Bell state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BrauerStates]]&amp;lt;/tt&amp;gt;: Produces all Brauer states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DickeState]]&amp;lt;/tt&amp;gt;: Generates a Dicke state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GHZState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) GHZ state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaxEntangled]]&amp;lt;/tt&amp;gt;: Produces a maximally entangled bipartite pure state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) W-state&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BreuerState]]&amp;lt;/tt&amp;gt;: Generates a Breuer state, which is a specific family of bound entangled states on even local dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChessboardState]]&amp;lt;/tt&amp;gt;: Produces a chessboard state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GisinState]]&amp;lt;/tt&amp;gt;: Generates a 2-qubit Gisin state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[HorodeckiState]]&amp;lt;/tt&amp;gt;: Generates a bound entangled &amp;quot;Horodecki&amp;quot; state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsotropicState]]&amp;lt;/tt&amp;gt;: Produces an isotropic state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WernerState]]&amp;lt;/tt&amp;gt;: Produces a Werner state&lt;br /&gt;
&lt;br /&gt;
===Other operators===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FourierMatrix]]&amp;lt;/tt&amp;gt;: Generates the unitary matrix that implements the quantum Fourier transform&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GellMann]]&amp;lt;/tt&amp;gt;: Produces a Gell-Mann operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenGellMann]]&amp;lt;/tt&amp;gt;: Produces a generalized Gell-Mann operator or the identity matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenPauli]]&amp;lt;/tt&amp;gt;: Produces a generalized Pauli operator (sometimes called a Weyl operator)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Pauli]]&amp;lt;/tt&amp;gt;: Produces a Pauli operator&lt;br /&gt;
&lt;br /&gt;
==Superoperators==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ApplyMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMatrix]]&amp;lt;/tt&amp;gt;: Computes the Choi matrix of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMap]]&amp;lt;/tt&amp;gt;: Produces the Choi map or one of its generalizations&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ComplementaryMap]]&amp;lt;/tt&amp;gt;: Computes the complementary map of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DephasingChannel]]&amp;lt;/tt&amp;gt;: Produces a dephasing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DepolarizingChannel]]&amp;lt;/tt&amp;gt;: Produces a depolarizing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DualMap]]&amp;lt;/tt&amp;gt;: Computes the dual of a superoperator in the Hilbert-Schmidt inner product&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsCP]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is completely positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsHermPreserving]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is Hermiticity preserving&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KrausOperators]]&amp;lt;/tt&amp;gt;: Computes a set of Kraus operators for a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to a subsystem of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTrace]]&amp;lt;/tt&amp;gt;: Computes the partial trace of a vector or a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTranspose]]&amp;lt;/tt&amp;gt;: Computes the partial transpose of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PauliChannel]]&amp;lt;/tt&amp;gt;: Generates a Pauli channel (i.e., a quantum channel with Pauli Kraus operators)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Realignment]]&amp;lt;/tt&amp;gt;: Computes the realignment of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ReductionMap]]&amp;lt;/tt&amp;gt;: Produces the reduction map&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Twirl]]&amp;lt;/tt&amp;gt;: Twirls a bipartite or multipartite operator&lt;br /&gt;
&lt;br /&gt;
==Unextendible product bases==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsUPB]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of product vectors form a UPB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MinUPBSize]]&amp;lt;/tt&amp;gt;: Gives the minimum cardinality of an unextendible product basis in given dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPB]]&amp;lt;/tt&amp;gt;: Generates an unextendible product basis&lt;br /&gt;
&lt;br /&gt;
==Miscellaneous==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Commutant]]&amp;lt;/tt&amp;gt;: Computes the commutant of a set of matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyNonsingular]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally nonsingular&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Majorizes]]&amp;lt;/tt&amp;gt;: Determines whether or not a vector or matrix majorizes another&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSinkhorn]]&amp;lt;/tt&amp;gt;: Performs the operator Sinkhorn iteration, making all single-party reduced states proportional to the identity&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Purity]]&amp;lt;/tt&amp;gt;: Computes the purity of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Helper functions==&lt;br /&gt;
These are functions that only serve auxiliary roles within other functions of QETLAB. As an end-user of QETLAB, you likely won&#039;t have any use for these functions, but they are listed here anyway just in case.&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[bcs_to_nonlocal]]&amp;lt;/tt&amp;gt;: Converts a constraint description of a binary constraint system (BCS) game to a general non-local game description&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[dec_to_bin]]&amp;lt;/tt&amp;gt;: Converts a decimal number to a binary number in a similar way to `de2bi&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt;: Looks up a monomial&#039;s lexicographical index based on a list of exponents&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[iden]]&amp;lt;/tt&amp;gt;: Computes a sparse or full identity matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[jacobi_poly]]&amp;lt;/tt&amp;gt;: Computes the coefficients of Jacobi polynomials&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[normalize_cols]]&amp;lt;/tt&amp;gt;: Scales the columns of a matrix to have norm 1&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[one_factorization]]&amp;lt;/tt&amp;gt;: Computes a 1-factorization of a list of objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_args]]&amp;lt;/tt&amp;gt;: Handles optional input arguments for functions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_disp]]&amp;lt;/tt&amp;gt;: Display a message to the user (sometimes)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pad_array]]&amp;lt;/tt&amp;gt;: Pads an array with zeroes in a similar way to `padarray&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perfect_matchings]]&amp;lt;/tt&amp;gt;: Gives all perfect matchings of N objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_inv]]&amp;lt;/tt&amp;gt;: Computes the inverse of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_sign]]&amp;lt;/tt&amp;gt;: Computes the sign of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pure_to_mixed]]&amp;lt;/tt&amp;gt;: Converts a state vector or density matrix representation of a state to a density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sk_iterate]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[spnull]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the null space&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sporth]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the range&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[superoperator_dims]]&amp;lt;/tt&amp;gt;: Computes the input, output, and environment dimensions of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[update_odometer]]&amp;lt;/tt&amp;gt;: Increases the entries of a vector subject to constraints on how large the entries of that vector can be&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[vec_partitions]]&amp;lt;/tt&amp;gt;: Produces all possible partitions of a vector&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36966</id>
		<title>List of functions</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36966"/>
		<updated>2025-04-08T15:53:10Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: GenGellMann description update&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a &#039;&#039;&#039;list of functions&#039;&#039;&#039; provided by QETLAB, arranged by category. If you would prefer an alphabetical list of all functions please see [[:Category:Functions|this page]]. Brief descriptions of these functions are provided here, as well as links to their documentation pages, where full details and numerous examples can be found.&lt;br /&gt;
&lt;br /&gt;
==Basic operations==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPSD]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is positive semidefinite&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Tensor]]&amp;lt;/tt&amp;gt;: Kronecker tensor product of two or more matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TensorSum]]&amp;lt;/tt&amp;gt;: Computes a vector or operator from its tensor decomposition&lt;br /&gt;
&lt;br /&gt;
==Coherence and incoherence==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[L1NormCoherence]]&amp;lt;/tt&amp;gt;: Computes the ℓ&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;-norm of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RelEntCoherence]]&amp;lt;/tt&amp;gt;: Computes the relative entropy of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RobustnessCoherence]]&amp;lt;/tt&amp;gt;: Computes the robustness of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceDistanceCoherence]]&amp;lt;/tt&amp;gt;: Computes the trace distance of coherence of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Distinguishing objects==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChannelDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing two quantum channels&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Distinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[LocalDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states by symmetric-extendible and/or PPT measurements&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPBSepDistinguishable]]&amp;lt;/tt&amp;gt;: Determines whether or not an unextendible product basis is distinguishable by separable measurements&lt;br /&gt;
&lt;br /&gt;
==Entanglement and separability==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntangledSubspace]]&amp;lt;/tt&amp;gt;: Creates a basis of an r-entangled subspace of any requested dimension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductVector]]&amp;lt;/tt&amp;gt;: Determines if a pure state is a product vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the Schmidt decomposition of a bipartite vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the Schmidt rank of a bipartite vector&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FilterNormalForm]]&amp;lt;/tt&amp;gt;: Computes the filter normal form of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsBlockPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator is block positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsEntanglingGate]]&amp;lt;/tt&amp;gt;: Determines if a unitary is an entangling gate&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix has positive partial transpose&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductOperator]]&amp;lt;/tt&amp;gt;: Determines if an operator is an elementary tensor&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsSeparable]]&amp;lt;/tt&amp;gt;: Determines whether or not a bipartite operator is separable&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt decomposition of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt rank of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric extension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricInnerExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric inner extension&lt;br /&gt;
&lt;br /&gt;
===Ball of separability===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AbsPPTConstraints]]&amp;lt;/tt&amp;gt;: Builds the eigenvalue matrices that determine whether or not a state is absolutely PPT&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InSeparableBall]]&amp;lt;/tt&amp;gt;: Checks whether or not an operator is in the ball of separability centered at the maximally-mixed state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsAbsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a density matrix is absolutely PPT&lt;br /&gt;
&lt;br /&gt;
===Entanglement measures===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Concurrence]]&amp;lt;/tt&amp;gt;: Computes the concurrence of a 2-qubit state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntFormation]]&amp;lt;/tt&amp;gt;: Computes the entanglement of formation of a bipartite quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Negativity]]&amp;lt;/tt&amp;gt;: Computes the negativity of a bipartite density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomRobustnessEntanglement]]&amp;lt;/tt&amp;gt;: Computes the random robustness of entanglement of a bipartite quantum state&lt;br /&gt;
&lt;br /&gt;
==Graph theory==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CliqueNumber]]&amp;lt;/tt&amp;gt;: Bounds the clique number (i.e., maximum size of a clique) of a graph&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomGraph]]&amp;lt;/tt&amp;gt;: Generates the adjacency matrix of a random graph&lt;br /&gt;
&lt;br /&gt;
==Information theory==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Entropy]]&amp;lt;/tt&amp;gt;: Computes the von Neumann or Rényi entropy of a density matrix&lt;br /&gt;
&lt;br /&gt;
==Nonlocality and Bell inequalities==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a binary contraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameValue]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a binary constraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMax]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a Bell inequality or nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMaxQubits]]&amp;lt;/tt&amp;gt;: Approximates the optimal value of a Bell inequality in qubit (i.e., 2-dimensional quantum) settings&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NonlocalGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a non-local game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NPAHierarchy]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of probabilities satisfy the conditions of the NPA hierarchy&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ParallelRepetition]]&amp;lt;/tt&amp;gt;: Produces the coefficients of parallel repetitions of a nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[XORGameValue]]&amp;lt;/tt&amp;gt;: Computes the classical or quantum value of a non-local binary XOR game&lt;br /&gt;
&lt;br /&gt;
==Norms and distance measures==&lt;br /&gt;
===Vectors and pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkVectorNorm]]&amp;lt;/tt&amp;gt;: Computes the s(k)-norm of a vector&lt;br /&gt;
&lt;br /&gt;
===Operators and mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Fidelity]]&amp;lt;/tt&amp;gt;: Computes the (Uhlmann) fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedMatrixNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced p&amp;amp;rarr;q norm of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNorm]]&amp;lt;/tt&amp;gt;: Computes the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNormDual]]&amp;lt;/tt&amp;gt;: Computes the dual of the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KyFanNorm]]&amp;lt;/tt&amp;gt;: Computes the Ky Fan k-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MatsumotoFidelity]]&amp;lt;/tt&amp;gt;: Computes the Matsumoto fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkOperatorNorm]]&amp;lt;/tt&amp;gt;: Bounds the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchattenNorm]]&amp;lt;/tt&amp;gt;: Computes the Schatten p-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceNorm]]&amp;lt;/tt&amp;gt;: Computes the trace norm of an operator&lt;br /&gt;
&lt;br /&gt;
===Superoperators and channels===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CBNorm]]&amp;lt;/tt&amp;gt;: Computes the completely bounded norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DiamondNorm]]&amp;lt;/tt&amp;gt;: Computes the diamond norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedSchattenNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced Schatten p&amp;amp;rarr;q norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaximumOutputFidelity]]&amp;lt;/tt&amp;gt;: Computes the maximum output fidelity of two quantum channels&lt;br /&gt;
&lt;br /&gt;
==Permutations and symmetry of subsystems==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AntisymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the antisymmetric subspace&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermutationOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that permutes subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermuteSystems]]&amp;lt;/tt&amp;gt;: Permutes subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Swap]]&amp;lt;/tt&amp;gt;: Swaps two subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SwapOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that swaps two subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the symmetric subspace&lt;br /&gt;
&lt;br /&gt;
==Polynomial optimization==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CopositivePolynomial]]&amp;lt;/tt&amp;gt;: Creates a homogenous polynomial whose non-negativity is equivalent to copositivity of a given matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialAsMatrix]]&amp;lt;/tt&amp;gt;: Creates a compact fully symmetric matrix representation of a polynomial&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt;: Bounds the optimal value of a homogeneous polynomial on the unit sphere&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialSOS]]&amp;lt;/tt&amp;gt;: Bounds the optimal value of a homogeneous polynomial on the unit sphere via the Sum-Of-Squares hierarchy&lt;br /&gt;
&lt;br /&gt;
==Random things==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomDensityMatrix]]&amp;lt;/tt&amp;gt;: Generates a random density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPOVM]]&amp;lt;/tt&amp;gt;: Generates a random POVM (positive-operator valued measure)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPPTState]]&amp;lt;/tt&amp;gt;: Generates a random density matrix with positive partial transpose, and optionally low rank&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomProbabilities]]&amp;lt;/tt&amp;gt;: Computes a random probability vector, distributed uniformly on the unit simplex&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomStateVector]]&amp;lt;/tt&amp;gt;: Generates a random pure state vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomSuperoperator]]&amp;lt;/tt&amp;gt;: Generates a random superoperator (completely positive map)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomUnitary]]&amp;lt;/tt&amp;gt;: Generates a random unitary or orthogonal matrix&lt;br /&gt;
&lt;br /&gt;
==Special states, vectors, and operators==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Bell]]&amp;lt;/tt&amp;gt;: Produces a Bell state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BrauerStates]]&amp;lt;/tt&amp;gt;: Produces all Brauer states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DickeState]]&amp;lt;/tt&amp;gt;: Generates a Dicke state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GHZState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) GHZ state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaxEntangled]]&amp;lt;/tt&amp;gt;: Produces a maximally entangled bipartite pure state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) W-state&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BreuerState]]&amp;lt;/tt&amp;gt;: Generates a Breuer state, which is a specific family of bound entangled states on even local dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChessboardState]]&amp;lt;/tt&amp;gt;: Produces a chessboard state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GisinState]]&amp;lt;/tt&amp;gt;: Generates a 2-qubit Gisin state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[HorodeckiState]]&amp;lt;/tt&amp;gt;: Generates a bound entangled &amp;quot;Horodecki&amp;quot; state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsotropicState]]&amp;lt;/tt&amp;gt;: Produces an isotropic state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WernerState]]&amp;lt;/tt&amp;gt;: Produces a Werner state&lt;br /&gt;
&lt;br /&gt;
===Other operators===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FourierMatrix]]&amp;lt;/tt&amp;gt;: Generates the unitary matrix that implements the quantum Fourier transform&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GellMann]]&amp;lt;/tt&amp;gt;: Produces a Gell-Mann operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenGellMann]]&amp;lt;/tt&amp;gt;: Produces a generalized Gell-Mann operator or the identity matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenPauli]]&amp;lt;/tt&amp;gt;: Produces a generalized Pauli operator (sometimes called a Weyl operator)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Pauli]]&amp;lt;/tt&amp;gt;: Produces a Pauli operator&lt;br /&gt;
&lt;br /&gt;
==Superoperators==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ApplyMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMatrix]]&amp;lt;/tt&amp;gt;: Computes the Choi matrix of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMap]]&amp;lt;/tt&amp;gt;: Produces the Choi map or one of its generalizations&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ComplementaryMap]]&amp;lt;/tt&amp;gt;: Computes the complementary map of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DephasingChannel]]&amp;lt;/tt&amp;gt;: Produces a dephasing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DepolarizingChannel]]&amp;lt;/tt&amp;gt;: Produces a depolarizing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DualMap]]&amp;lt;/tt&amp;gt;: Computes the dual of a superoperator in the Hilbert-Schmidt inner product&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsCP]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is completely positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsHermPreserving]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is Hermiticity preserving&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KrausOperators]]&amp;lt;/tt&amp;gt;: Computes a set of Kraus operators for a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to a subsystem of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTrace]]&amp;lt;/tt&amp;gt;: Computes the partial trace of a vector or a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTranspose]]&amp;lt;/tt&amp;gt;: Computes the partial transpose of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PauliChannel]]&amp;lt;/tt&amp;gt;: Generates a Pauli channel (i.e., a quantum channel with Pauli Kraus operators)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Realignment]]&amp;lt;/tt&amp;gt;: Computes the realignment of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ReductionMap]]&amp;lt;/tt&amp;gt;: Produces the reduction map&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Twirl]]&amp;lt;/tt&amp;gt;: Twirls a bipartite or multipartite operator&lt;br /&gt;
&lt;br /&gt;
==Unextendible product bases==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsUPB]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of product vectors form a UPB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MinUPBSize]]&amp;lt;/tt&amp;gt;: Gives the minimum cardinality of an unextendible product basis in given dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPB]]&amp;lt;/tt&amp;gt;: Generates an unextendible product basis&lt;br /&gt;
&lt;br /&gt;
==Miscellaneous==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Commutant]]&amp;lt;/tt&amp;gt;: Computes the commutant of a set of matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyNonsingular]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally nonsingular&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Majorizes]]&amp;lt;/tt&amp;gt;: Determines whether or not a vector or matrix majorizes another&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSinkhorn]]&amp;lt;/tt&amp;gt;: Performs the operator Sinkhorn iteration, making all single-party reduced states proportional to the identity&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Purity]]&amp;lt;/tt&amp;gt;: Computes the purity of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Helper functions==&lt;br /&gt;
These are functions that only serve auxiliary roles within other functions of QETLAB. As an end-user of QETLAB, you likely won&#039;t have any use for these functions, but they are listed here anyway just in case.&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[bcs_to_nonlocal]]&amp;lt;/tt&amp;gt;: Converts a constraint description of a binary constraint system (BCS) game to a general non-local game description&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[dec_to_bin]]&amp;lt;/tt&amp;gt;: Converts a decimal number to a binary number in a similar way to `de2bi&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt;: Looks up a monomial&#039;s lexicographical index based on a list of exponents&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[iden]]&amp;lt;/tt&amp;gt;: Computes a sparse or full identity matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[jacobi_poly]]&amp;lt;/tt&amp;gt;: Computes the coefficients of Jacobi polynomials&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[normalize_cols]]&amp;lt;/tt&amp;gt;: Scales the columns of a matrix to have norm 1&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[one_factorization]]&amp;lt;/tt&amp;gt;: Computes a 1-factorization of a list of objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_args]]&amp;lt;/tt&amp;gt;: Handles optional input arguments for functions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_disp]]&amp;lt;/tt&amp;gt;: Display a message to the user (sometimes)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pad_array]]&amp;lt;/tt&amp;gt;: Pads an array with zeroes in a similar way to `padarray&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perfect_matchings]]&amp;lt;/tt&amp;gt;: Gives all perfect matchings of N objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_inv]]&amp;lt;/tt&amp;gt;: Computes the inverse of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_sign]]&amp;lt;/tt&amp;gt;: Computes the sign of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pure_to_mixed]]&amp;lt;/tt&amp;gt;: Converts a state vector or density matrix representation of a state to a density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sk_iterate]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[spnull]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the null space&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sporth]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the range&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[superoperator_dims]]&amp;lt;/tt&amp;gt;: Computes the input, output, and environment dimensions of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[update_odometer]]&amp;lt;/tt&amp;gt;: Increases the entries of a vector subject to constraints on how large the entries of that vector can be&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[vec_partitions]]&amp;lt;/tt&amp;gt;: Produces all possible partitions of a vector&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=GenGellMann&amp;diff=36965</id>
		<title>GenGellMann</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=GenGellMann&amp;diff=36965"/>
		<updated>2025-04-08T15:50:18Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Clarified identity matrix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=GenGellMann&lt;br /&gt;
|desc=Produces a generalized Gell-Mann operator&lt;br /&gt;
|rel=[[GellMann]]&amp;lt;br /&amp;gt;[[GenPauli]]&amp;lt;br /&amp;gt;[[Pauli]]&lt;br /&gt;
|cat=[[List of functions#Special_states,_vectors,_and_operators|Special states, vectors, and operators]]&lt;br /&gt;
|upd=December 18, 2013&lt;br /&gt;
|v=0.50}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;GenGellMann&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that produces generalized Gell-Mann matrices. That is, it produces Hermitian matrices that form a traceless orthogonal basis for the space of $d \times d$ complex matrices, together with the identity matrix.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;G = GenGellMann(IND1,IND2,DIM)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;G = GenGellMann(IND1,IND2,DIM,SP)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
* &amp;lt;tt&amp;gt;IND1&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;IND2&amp;lt;/tt&amp;gt;: Integers between &amp;lt;tt&amp;gt;0&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;DIM-1&amp;lt;/tt&amp;gt;, inclusive. If &amp;lt;tt&amp;gt;IND1 == IND2&amp;lt;/tt&amp;gt; then &amp;lt;tt&amp;gt;G&amp;lt;/tt&amp;gt; will be diagonal (if both indices equal 0 then &amp;lt;tt&amp;gt;G&amp;lt;/tt&amp;gt; will be the identity matrix, otherwise &amp;lt;tt&amp;gt;G&amp;lt;/tt&amp;gt; will be traceless). If &amp;lt;tt&amp;gt;IND1 &amp;lt; IND2&amp;lt;/tt&amp;gt; then &amp;lt;tt&amp;gt;G&amp;lt;/tt&amp;gt; will be real and have exactly 2 nonzero entries. If &amp;lt;tt&amp;gt;IND1 &amp;gt; IND2&amp;lt;/tt&amp;gt; then &amp;lt;tt&amp;gt;G&amp;lt;/tt&amp;gt; will be imaginary and have exactly 2 nonzero entries.&lt;br /&gt;
* &amp;lt;tt&amp;gt;DIM&amp;lt;/tt&amp;gt;: The size of the output matrix.&lt;br /&gt;
* &amp;lt;tt&amp;gt;SP&amp;lt;/tt&amp;gt; (optional, default 0): A flag (either 1 or 0) indicating that the generalized Gell-Mann matrix produced should or should not be sparse.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===Gives the Pauli operators when &amp;lt;tt&amp;gt;DIM = 2&amp;lt;/tt&amp;gt;===&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; GenGellMann(0,0,2) % identity&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
     1     0&lt;br /&gt;
     0     1&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; GenGellMann(0,1,2) % Pauli X&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
     0     1&lt;br /&gt;
     1     0&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; GenGellMann(1,0,2) % Pauli Y&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   0.0000 + 0.0000i   0.0000 - 1.0000i&lt;br /&gt;
   0.0000 + 1.0000i   0.0000 + 0.0000i&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; GenGellMann(1,1,2) % Pauli Z&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
     1     0&lt;br /&gt;
     0    -1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Gives the Gell-Mann operators when &amp;lt;tt&amp;gt;DIM = 3&amp;lt;/tt&amp;gt;===&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; GenGellMann(0,1,3)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
     0     1     0&lt;br /&gt;
     1     0     0&lt;br /&gt;
     0     0     0&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; GenGellMann(0,2,3)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
     0     0     1&lt;br /&gt;
     0     0     0&lt;br /&gt;
     1     0     0&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; GenGellMann(2,2,3)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
    0.5774         0         0&lt;br /&gt;
         0    0.5774         0&lt;br /&gt;
         0         0   -1.1547&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===In Higher Dimensions===&lt;br /&gt;
Generalized Gell-Mann matrices can be generated in arbitrary dimensions. It is recommended that you set &amp;lt;tt&amp;gt;SP = 1&amp;lt;/tt&amp;gt; if &amp;lt;tt&amp;gt;DIM&amp;lt;/tt&amp;gt; is large in order to save memory.&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; GenGellMann(2,3,4)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
     0     0     0     0&lt;br /&gt;
     0     0     0     0&lt;br /&gt;
     0     0     0     1&lt;br /&gt;
     0     0     1     0&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; GenGellMann(205,34,500,1) % a 500-by-500 sparse generalized Gell-Mann matrix&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
 (206,35)     0.0000 + 1.0000i&lt;br /&gt;
  (35,206)    0.0000 - 1.0000i&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=GenGellMann}}&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Generalizations_of_the_Pauli_matrices Generalizations of the Pauli matrices] at Wikipedia&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=PauliChannel&amp;diff=36964</id>
		<title>PauliChannel</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=PauliChannel&amp;diff=36964"/>
		<updated>2025-03-28T12:53:41Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Fixed scaling of probability vector&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=PauliChannel&lt;br /&gt;
|desc=Generates a Pauli channel&lt;br /&gt;
|rel=[[Pauli]]&lt;br /&gt;
|cat=[[List of functions#Superoperators|Superoperators]]&lt;br /&gt;
|upd=December 16, 2014}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;PauliChannel&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that generates the Choi matrix of a Pauli channel (either a random Pauli channel on a specified number of qubits, or a specific Pauli channel requested by the user). The output of this function is sparse.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;PHI = PauliChannel(P)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
* &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt;: Either a positive integer, indicating that the user wants a randomly-generated &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt;-qubit Pauli channel. Otherwise, &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt; should be a probability vector of length $4^q$ for some integer $q \geq 1$, whose entries specify the weights of the Pauli operators in the channel&#039;s Kraus decomposition. More specifically, the weight of the $j$-th Pauli operator (in lexicographical order) in the Kraus operator representation of this channel will be $\sqrt{P(j)}$.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===A random 1-qubit Pauli channel===&lt;br /&gt;
The following code returns the Choi matrix a randomly-generated 1-qubit Pauli channel:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; Phi = full(PauliChannel(1)) % generate the random Pauli channel&lt;br /&gt;
&lt;br /&gt;
Phi =&lt;br /&gt;
&lt;br /&gt;
    0.5737         0         0    0.1346&lt;br /&gt;
         0    0.4263    0.3196         0&lt;br /&gt;
         0    0.3196    0.4263         0&lt;br /&gt;
    0.1346         0         0    0.5737&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; celldisp(KrausOperators(Phi)) % look at its Kraus operators&lt;br /&gt;
 &lt;br /&gt;
ans{1} =&lt;br /&gt;
 &lt;br /&gt;
         0    0.6107&lt;br /&gt;
    0.6107         0&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
ans{2} =&lt;br /&gt;
 &lt;br /&gt;
    0.5951         0&lt;br /&gt;
         0    0.5951&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
ans{3} =&lt;br /&gt;
 &lt;br /&gt;
    0.4686         0&lt;br /&gt;
         0   -0.4686&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
ans{4} =&lt;br /&gt;
 &lt;br /&gt;
         0    0.2310&lt;br /&gt;
   -0.2310         0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===A specific Pauli channel===&lt;br /&gt;
The following code generates a Pauli channel with Kraus operators $\left\{\tfrac{1}{\sqrt{15}}I,\tfrac{2}{\sqrt{15}}X,\tfrac{3}{\sqrt{15}}Y,\tfrac{4}{\sqrt{15}}Z\right\}$, where $I,X,Y,Z$ are the usual [[Pauli|Pauli operators]]:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; Phi = full(PauliChannel([1,2,3,4]/10))&lt;br /&gt;
&lt;br /&gt;
Phi =&lt;br /&gt;
&lt;br /&gt;
    0.5000         0         0   -0.3000&lt;br /&gt;
         0    0.5000   -0.1000         0&lt;br /&gt;
         0   -0.1000    0.5000         0&lt;br /&gt;
   -0.3000         0         0    0.5000&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; celldisp(KrausOperators(Phi)) % look at its Kraus operators&lt;br /&gt;
 &lt;br /&gt;
ans{1} =&lt;br /&gt;
 &lt;br /&gt;
   -0.6325         0&lt;br /&gt;
         0    0.6325&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
ans{2} =&lt;br /&gt;
 &lt;br /&gt;
         0   -0.5477&lt;br /&gt;
    0.5477         0&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
ans{3} =&lt;br /&gt;
 &lt;br /&gt;
         0   -0.4472&lt;br /&gt;
   -0.4472         0&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
ans{4} =&lt;br /&gt;
 &lt;br /&gt;
   -0.3162         0&lt;br /&gt;
         0   -0.3162&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=PauliChannel}}&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=UPB&amp;diff=36963</id>
		<title>UPB</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=UPB&amp;diff=36963"/>
		<updated>2024-12-09T13:51:46Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Fixed scaling so that bound entangled state has trace 1&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=UPB&lt;br /&gt;
|desc=Generates an unextendible product basis&lt;br /&gt;
|rel=[[IsUPB]]&amp;lt;br /&amp;gt;[[MinUPBSize]]&amp;lt;br /&amp;gt;[[UPBSepDistinguishable]]&lt;br /&gt;
|cat=[[List of functions#Unextendible_product_bases|Unextendible product bases]]&lt;br /&gt;
|upd=November 12, 2014&lt;br /&gt;
|v=0.50}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;UPB&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that generates an unextendible product basis (UPB). The user may either request a specific UPB from the literature such as &amp;lt;tt&amp;gt;&#039;Tiles&#039;&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&#039;Pyramid&#039;&amp;lt;/tt&amp;gt;&amp;lt;ref name=&amp;quot;BDM99&amp;quot;&amp;gt;C.H. Bennett, D.P. DiVincenzo, T. Mor, P.W. Shor, J.A. Smolin, and B.M. Terhal. Unextendible product bases and bound entanglement. &#039;&#039;Phys. Rev. Lett.&#039;&#039; 82, 5385&amp;amp;ndash;5388, 1999. E-print: [http://arxiv.org/abs/quant-ph/9808030 arXiv:quant-ph/9808030]&amp;lt;/ref&amp;gt;, or they may request a minimal UPB of specified dimensions.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;U = UPB(NAME)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;U = UPB(NAME,OPT_PAR)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[U,V,W,...] = UPB(NAME,OPT_PAR)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;U = UPB(DIM)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;U = UPB(DIM,VERBOSE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[U,V,W,...] = UPB(DIM,VERBOSE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
===Input arguments===&lt;br /&gt;
&#039;&#039;&#039;Important&#039;&#039;&#039;: Do not specify both &amp;lt;tt&amp;gt;NAME&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;DIM&amp;lt;/tt&amp;gt;: just one or the other!&lt;br /&gt;
* &amp;lt;tt&amp;gt;NAME&amp;lt;/tt&amp;gt;: The name of a UPB that is found in the literature. Accepted values include:&lt;br /&gt;
** &amp;lt;tt&amp;gt;&#039;GenShifts&#039;&amp;lt;/tt&amp;gt;: A minimal UPB in &amp;lt;math&amp;gt;(\mathbb{C}^2)^{\otimes p}&amp;lt;/math&amp;gt; (only valid when p &amp;amp;ge; 3 is odd) constructed in &amp;lt;ref name=&amp;quot;DMS03&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;. Note that &amp;lt;tt&amp;gt;OPT_PAR&amp;lt;/tt&amp;gt; must be the number of parties (i.e., the integer p) in this case.&lt;br /&gt;
** &amp;lt;tt&amp;gt;&#039;Min4x4&#039;&amp;lt;/tt&amp;gt;: A minimal UPB in &amp;lt;math&amp;gt;\mathbb{C}^4 \otimes \mathbb{C}^4&amp;lt;/math&amp;gt; constructed in &amp;lt;ref&amp;gt;T.B. Pedersen. &#039;&#039;Characteristics of unextendible product bases&#039;&#039;. Master&#039;s Thesis, Aarhus Universitet, Datalogisk Institut, 2002.&amp;lt;/ref&amp;gt;.&lt;br /&gt;
** &amp;lt;tt&amp;gt;&#039;Pyramid&#039;&amp;lt;/tt&amp;gt;: A minimal UPB in &amp;lt;math&amp;gt;\mathbb{C}^3 \otimes \mathbb{C}^3&amp;lt;/math&amp;gt; constructed in &amp;lt;ref name=&amp;quot;BDM99&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
** &amp;lt;tt&amp;gt;&#039;QuadRes&#039;&amp;lt;/tt&amp;gt;: A minimal UPB in &amp;lt;math&amp;gt;\mathbb{C}^d \otimes \mathbb{C}^d&amp;lt;/math&amp;gt; (only valid when 2d-1 is prime and d is odd) constructed in &amp;lt;ref name=&amp;quot;DMS03&amp;quot;&amp;gt;D.P. DiVincenzo, T. Mor, P.W. Shor, J.A. Smolin, and B.M. Terhal. Unextendible product bases, uncompletable product bases and bound entanglement. &#039;&#039;Commun. Math. Phys.&#039;&#039; 238, 379&amp;amp;ndash;410, 2003. E-print: [http://arxiv.org/abs/quant-ph/9908070 arXiv:quant-ph/9908070]&amp;lt;/ref&amp;gt;. Note that you must set &amp;lt;tt&amp;gt;OPT_PAR&amp;lt;/tt&amp;gt; equal to d (the local dimension) in this case.&lt;br /&gt;
** &amp;lt;tt&amp;gt;&#039;Shifts&#039;&amp;lt;/tt&amp;gt;: A minimal UPB in &amp;lt;math&amp;gt;\mathbb{C}^2 \otimes \mathbb{C}^2 \otimes \mathbb{C}^2&amp;lt;/math&amp;gt; introduced in &amp;lt;ref name=&amp;quot;BDM99&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
** &amp;lt;tt&amp;gt;&#039;SixParam&#039;&amp;lt;/tt&amp;gt;: The six-parameter UPB in &amp;lt;math&amp;gt;\mathbb{C}^3 \otimes \mathbb{C}^3&amp;lt;/math&amp;gt; introduced in Section IV.A of &amp;lt;ref name=&amp;quot;DMS03&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;. Note that &amp;lt;tt&amp;gt;OPT_PAR&amp;lt;/tt&amp;gt; must be a vector containing the six parameters in this case.&lt;br /&gt;
** &amp;lt;tt&amp;gt;&#039;Tiles&#039;&amp;lt;/tt&amp;gt;: A minimal UPB in &amp;lt;math&amp;gt;\mathbb{C}^3 \otimes \mathbb{C}^3&amp;lt;/math&amp;gt; constructed in &amp;lt;ref name=&amp;quot;BDM99&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
** &amp;lt;tt&amp;gt;&#039;GenTiles1&#039;&amp;lt;/tt&amp;gt;: A non-minimal UPB in &amp;lt;math&amp;gt;\mathbb{C}^n \otimes \mathbb{C}^n&amp;lt;/math&amp;gt; when n is even from &amp;lt;ref name=&amp;quot;BDM99&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;. Note that &amp;lt;tt&amp;gt;OPT_PAR&amp;lt;/tt&amp;gt; must be n in this case.&lt;br /&gt;
** &amp;lt;tt&amp;gt;&#039;GenTiles2&#039;&amp;lt;/tt&amp;gt;: A non-minimal UPB in &amp;lt;math&amp;gt;\mathbb{C}^m \otimes \mathbb{C}^n&amp;lt;/math&amp;gt; from &amp;lt;ref name=&amp;quot;BDM99&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;. Note that &amp;lt;tt&amp;gt;OPT_PAR&amp;lt;/tt&amp;gt; must be a 2-entry vector containing m and n in this case.&lt;br /&gt;
* &amp;lt;tt&amp;gt;DIM&amp;lt;/tt&amp;gt;: A vector containing the local dimensions of the desired UPB. In all cases, the smallest known UPB of the desired dimensionality is returned. If no unextendible product basis is known for the specified dimensions, an error is produced.&lt;br /&gt;
* &amp;lt;tt&amp;gt;VERBOSE&amp;lt;/tt&amp;gt; (optional, default &amp;lt;tt&amp;gt;1&amp;lt;/tt&amp;gt;): A flag (either 1 or 0) indicating whether or not a reference to a journal article that contains the UPB (or a description of how to construct the UPB) returned by this script will be displayed.&lt;br /&gt;
&lt;br /&gt;
===Output arguments===&lt;br /&gt;
If only one output argument is specified (e.g., &amp;lt;tt&amp;gt;U = UPB(DIM)&amp;lt;/tt&amp;gt;) then &amp;lt;tt&amp;gt;U&amp;lt;/tt&amp;gt; is a matrix whose columns are the product states in the desired UPB.&lt;br /&gt;
&lt;br /&gt;
If multiple output arguments are specified (e.g., &amp;lt;tt&amp;gt;[U,V,W,...] = UPB(DIM)&amp;lt;/tt&amp;gt;) then the unextendible product basis is obtained by tensoring the columns of &amp;lt;tt&amp;gt;U, V, W, ...&amp;lt;/tt&amp;gt; together. That is, &amp;lt;tt&amp;gt;U, V, W, ...&amp;lt;/tt&amp;gt; are the local vectors in the unextendible product basis.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===Generating the &amp;quot;Shifts&amp;quot; UPB===&lt;br /&gt;
The following code returns the &amp;quot;Shifts&amp;quot; UPB &amp;lt;ref name=&amp;quot;BDM99&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;, which is a UPB of 4 states on $\mathbb{C}^2 \otimes \mathbb{C}^2 \otimes \mathbb{C}^2$:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; v = UPB(&#039;Shifts&#039;)&lt;br /&gt;
&lt;br /&gt;
v =&lt;br /&gt;
&lt;br /&gt;
    1.0000   -0.0000   -0.0000   -0.0000&lt;br /&gt;
         0   -0.0000    0.0000   -0.5000&lt;br /&gt;
         0    0.0000   -0.5000   -0.0000&lt;br /&gt;
         0    0.0000    0.5000   -0.5000&lt;br /&gt;
         0   -0.5000   -0.0000    0.0000&lt;br /&gt;
         0   -0.5000    0.0000    0.5000&lt;br /&gt;
         0    0.5000   -0.5000    0.0000&lt;br /&gt;
         0    0.5000    0.5000    0.5000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively, we can request that the local vectors on each copy of $\mathbb{C}^2$ are returned, rather than the total product vectors on $\mathbb{C}^2 \otimes \mathbb{C}^2 \otimes \mathbb{C}^2$:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; [u,v,w] = UPB(&#039;Shifts&#039;)&lt;br /&gt;
&lt;br /&gt;
u =&lt;br /&gt;
&lt;br /&gt;
    1.0000    0.0000    0.7071   -0.7071&lt;br /&gt;
         0    1.0000    0.7071    0.7071&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
v =&lt;br /&gt;
&lt;br /&gt;
    1.0000   -0.7071    0.0000    0.7071&lt;br /&gt;
         0    0.7071    1.0000    0.7071&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
w =&lt;br /&gt;
&lt;br /&gt;
    1.0000    0.7071   -0.7071    0.0000&lt;br /&gt;
         0    0.7071    0.7071    1.0000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Generating [[bound entangled]] states===&lt;br /&gt;
As noted in &amp;lt;ref name=&amp;quot;BDM99&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;, if &amp;lt;math&amp;gt;\big\{|v_i\rangle\big\}&amp;lt;/math&amp;gt; is an unextendible product basis, then $I - \sum_i |v_i\rangle\langle v_i|$ is (up to scaling) a [[bound entangled]] state. The following code illustrates this fact in $\mathbb{C}^3 \otimes \mathbb{C}^5$ by first constructing a UPB in this space, then constructing the corresponding state, and then verifying that this state is bound entangled.&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; v = UPB([3,5]);&lt;br /&gt;
Generated a minimal 7-state UPB from:&lt;br /&gt;
N. Alon and L. Lovasz. Unextendible product bases. J. Combinatorial Theory, Ser. A, 95:169-179, 2001.&lt;br /&gt;
See also: http://www.njohnston.ca/2013/03/how-to-construct-minimal-upbs/&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; rho = eye(3*5);&lt;br /&gt;
&amp;gt;&amp;gt; for j = 1:7&lt;br /&gt;
       rho = rho - v(:,j)*v(:,j)&#039;;&lt;br /&gt;
   end&lt;br /&gt;
   rho = rho/8; % we are now done constructing the bound entangled state&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; IsSeparable(rho,[3,5]) % show that the state is indeed entangled&lt;br /&gt;
Determined to be entangled by not having a 2-copy symmetric extension. Reference:&lt;br /&gt;
A. C. Doherty, P. A. Parrilo, and F. M. Spedalieri. A complete family of separability criteria.&lt;br /&gt;
Phys. Rev. A, 69:022308, 2004.&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
     0&lt;br /&gt;
&amp;gt;&amp;gt; IsPPT(rho,2,[3,5]) % verify that this state has positive partial transpose and is thus bound entangled&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
     1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Generating multipartite UPBs===&lt;br /&gt;
Many multipartite minimal UPBs can be constructed via this script. For example, the following code generates a minimal UPB (of 6 states) in &amp;lt;math&amp;gt;\mathbb{C}^2 \otimes \mathbb{C}^2 \otimes \mathbb{C}^3&amp;lt;/math&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; [u,v,w] = UPB([2,2,3])&lt;br /&gt;
Generated a minimal 6-state UPB from:&lt;br /&gt;
K. Feng. Unextendible product bases and 1-factorization of complete graphs.&lt;br /&gt;
Discrete Applied Mathematics, 154:942–949, 2006.&lt;br /&gt;
&lt;br /&gt;
u =&lt;br /&gt;
&lt;br /&gt;
    1.0000         0    1.0000    0.7071    0.7071    0.7071&lt;br /&gt;
         0    1.0000         0    0.7071   -0.7071    0.7071&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
v =&lt;br /&gt;
&lt;br /&gt;
    1.0000    0.7071         0         0    0.7071    1.0000&lt;br /&gt;
         0    0.7071    1.0000    1.0000   -0.7071         0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
w =&lt;br /&gt;
&lt;br /&gt;
    1.0000    0.7071    0.5345    0.5774         0         0&lt;br /&gt;
         0         0   -0.8018    0.5774    0.3162    1.0000&lt;br /&gt;
         0    0.7071   -0.2673   -0.5774   -0.9487         0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, the minimum size of UPBs is still unknown in many multipartite cases &amp;amp;ndash; an error is returned in these cases:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; [u,v,w,x] = UPB([2,2,3,7])&lt;br /&gt;
??? Error using ==&amp;gt; UPB at 132&lt;br /&gt;
No minimal UPB is currently known in the specified dimensions.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=UPB}}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=Fidelity&amp;diff=36962</id>
		<title>Fidelity</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=Fidelity&amp;diff=36962"/>
		<updated>2024-09-27T16:46:35Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Undo revision 967 by Etanjk (talk) The QETLAB function doesn&amp;#039;t use squaring; this is addressed in the page&amp;#039;s &amp;quot;notes&amp;quot; section.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=Fidelity&lt;br /&gt;
|desc=Computes the (Uhlmann) fidelity of two density matrices&lt;br /&gt;
|rel=[[MatsumotoFidelity]]&amp;lt;br /&amp;gt;[[MaximumOutputFidelity]]&amp;lt;br /&amp;gt;[[TraceNorm]]&lt;br /&gt;
|cat=[[List of functions#Norms_and_distance_measures|Norms and distance measures]]&lt;br /&gt;
|upd=November 21, 2014&lt;br /&gt;
|cvx=yes (concave)}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;Fidelity&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes the Uhlmann fidelity between two quantum states $\rho$ and $\sigma$, defined as follows:&lt;br /&gt;
: &amp;lt;math&amp;gt;F(\rho,\sigma) := \mathrm{Tr}\Big( \sqrt{ \sqrt{\rho}\sigma\sqrt{\rho}}\Big).&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that, in some sources, &amp;quot;fidelity&amp;quot; refers to the square of this quantity.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;FID = Fidelity(RHO,SIGMA)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
* &amp;lt;tt&amp;gt;RHO&amp;lt;/tt&amp;gt;: A density matrix.&lt;br /&gt;
* &amp;lt;tt&amp;gt;SIGMA&amp;lt;/tt&amp;gt;: A density matrix.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===Pure states===&lt;br /&gt;
If $\rho = |v\rangle\langle v|$ and $\sigma = |w\rangle\langle w|$ are both pure states then their fidelity simply equals $\big|\langle v|w \rangle\big|$:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; v = RandomStateVector(4);&lt;br /&gt;
&amp;gt;&amp;gt; w = RandomStateVector(4);&lt;br /&gt;
&amp;gt;&amp;gt; Fidelity(v*v&#039;,w*w&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   0.6486&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; abs(v&#039;*w)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
    0.6486&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Can be used with CVX===&lt;br /&gt;
The fidelity function is a jointly concave function, and it can be used in the objective function or constraints of a CVX optimization problem. For example, the following code computes the [[MaximumOutputFidelity|maximum output fidelity]] of two quantum channels:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; Phi = RandomSuperoperator(3); % generate a random channel&lt;br /&gt;
&amp;gt;&amp;gt; Psi = RandomSuperoperator(3); % generate another one&lt;br /&gt;
&amp;gt;&amp;gt; cvx_begin sdp quiet&lt;br /&gt;
   variable rho(3,3) hermitian;&lt;br /&gt;
   variable sigma(3,3) hermitian;&lt;br /&gt;
&lt;br /&gt;
   maximize Fidelity(ApplyMap(rho,Phi),ApplyMap(sigma,Psi))&lt;br /&gt;
&lt;br /&gt;
   subject to % the constraints here just force rho and sigma to be density matrices&lt;br /&gt;
       trace(rho) == 1;&lt;br /&gt;
       trace(sigma) == 1;&lt;br /&gt;
       rho &amp;gt;= 0;&lt;br /&gt;
       sigma &amp;gt;= 0;&lt;br /&gt;
   cvx_end&lt;br /&gt;
&amp;gt;&amp;gt; cvx_optval&lt;br /&gt;
&lt;br /&gt;
cvx_optval =&lt;br /&gt;
&lt;br /&gt;
    0.9829&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Of course, in this case it is more convenient to just use the &amp;lt;tt&amp;gt;[[MaximumOutputFidelity]]&amp;lt;/tt&amp;gt; function directly:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; MaximumOutputFidelity(Phi,Psi)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
    0.9829&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=Fidelity}}&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=Contributors&amp;diff=36842</id>
		<title>Contributors</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=Contributors&amp;diff=36842"/>
		<updated>2024-08-29T12:57:57Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Added Benjamin Talbot&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;QETLAB started as a project by &#039;&#039;&#039;[https://njohnston.ca Nathaniel Johnston]&#039;&#039;&#039; and is still primarily maintained by him. Several other people have also contributed to its development (see the [https://github.com/nathanieljohnston/QETLAB/graphs/contributors contributors page on github] for more detailed information):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[https://mateusaraujo.info/about/ Mateus Araújo]&#039;&#039;&#039;: Wrote faster code for computing the classical value of a non-local game in the &amp;lt;tt&amp;gt;[[NonlocalGameValue]]&amp;lt;/tt&amp;gt; function. Also refactored &amp;lt;tt&amp;gt;[[BellInequalityMax]]&amp;lt;/tt&amp;gt; and some other miscellaneous improvements.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[https://cosenal.github.io/ Alessandro Cosentino]&#039;&#039;&#039;: Bug reports, testing, and general guidance for best practices with QETLAB. Also created the &amp;lt;tt&amp;gt;[[LocalDistinguishability]]&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;John D&#039;Errico&#039;&#039;&#039;: Created the &amp;lt;tt&amp;gt;[[unique_perms]]&amp;lt;/tt&amp;gt; function, which was used until QETLAB v0.9 (it has since been removed).&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Bruno Luong&#039;&#039;&#039;: Created the &amp;lt;tt&amp;gt;[[sporth]]&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;[[spnull]]&amp;lt;/tt&amp;gt; functions.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Robert Materi&#039;&#039;&#039;: Improved Octave compatibility, including creation of the &amp;lt;tt&amp;gt;[[dec_to_bin]]&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;[[pad_array]]&amp;lt;/tt&amp;gt; functions.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[http://bartoszregula.github.io/ Bartosz Regula]&#039;&#039;&#039;: Fixed a bug in &amp;lt;tt&amp;gt;[[PartialMap]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[https://vprusso.github.io/ Vincent Russo]&#039;&#039;&#039;: Bug reports, testing, and contributions to several functions such as &amp;lt;tt&amp;gt;[[Fidelity]]&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;[[DickeState]]&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;[[HorodeckiState]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[https://www.linkedin.com/in/benjamin-talbot4/ Benjamin Talbot]&#039;&#039;&#039;: Updated &amp;lt;tt&amp;gt;[[OperatorSchmidtDecomposition]]&amp;lt;/tt&amp;gt; to work properly on Hermitian inputs. Also wrote &amp;lt;tt&amp;gt;[[CompoundMatrix]]&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;[[ElemSymPoly]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
N.J. also thanks the [https://uwaterloo.ca/institute-for-quantum-computing/ Institute for Quantum Computing] for hosting him during QETLAB&#039;s initial development, and the Natural Sciences and Engineering Research Council of Canada for providing funding during QETLAB&#039;s development.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=OperatorSchmidtDecomposition&amp;diff=36841</id>
		<title>OperatorSchmidtDecomposition</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=OperatorSchmidtDecomposition&amp;diff=36841"/>
		<updated>2024-08-29T12:54:40Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Updated note now that the Hermitian issue is fixed&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=OperatorSchmidtDecomposition&lt;br /&gt;
|desc=Computes the operator Schmidt decomposition of a bipartite operator&lt;br /&gt;
|rel=[[FilterNormalForm]]&amp;lt;br /&amp;gt;[[IsProductOperator]]&amp;lt;br /&amp;gt;[[OperatorSchmidtRank]]&amp;lt;br /&amp;gt;[[SchmidtDecomposition]]&amp;lt;br /&amp;gt;[[TensorSum]]&lt;br /&gt;
|cat=[[List of functions#Entanglement_and_separability|Entanglement&amp;amp;nbsp;and&amp;amp;nbsp;separability]]&lt;br /&gt;
|upd=November 12, 2014&lt;br /&gt;
|v=0.50}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;OperatorSchmidtDecomposition&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes the operator Schmidt decomposition of a bipartite operator. The user may specify how many terms in the operator Schmidt decomposition they wish to be returned.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;S = OperatorSchmidtDecomposition(X)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;S = OperatorSchmidtDecomposition(X,DIM)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;S = OperatorSchmidtDecomposition(X,DIM,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[S,U,V] = OperatorSchmidtDecomposition(X,DIM,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
===Input arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;X&amp;lt;/tt&amp;gt;: A [[bipartite]] operator to have its [[operator Schmidt decomposition]] computed.&lt;br /&gt;
* &amp;lt;tt&amp;gt;DIM&amp;lt;/tt&amp;gt; (optional, by default has both subsystems of equal dimension): A specification of the dimensions of the subsystems that &amp;lt;tt&amp;gt;X&amp;lt;/tt&amp;gt; lives on. &amp;lt;tt&amp;gt;DIM&amp;lt;/tt&amp;gt; can be provided in one of three ways:&lt;br /&gt;
** If &amp;lt;tt&amp;gt;DIM&amp;lt;/tt&amp;gt; is a scalar, it is assumed that the first subsystem has dimension &amp;lt;tt&amp;gt;DIM&amp;lt;/tt&amp;gt; and the second subsystem has dimension &amp;lt;tt&amp;gt;length(X)/DIM&amp;lt;/tt&amp;gt;.&lt;br /&gt;
** If $X \in M_{n_1} \otimes M_{n_2}$ then &amp;lt;tt&amp;gt;DIM&amp;lt;/tt&amp;gt; should be a row vector containing the dimensions (i.e., &amp;lt;tt&amp;gt;DIM = [n_1, n_2]&amp;lt;/tt&amp;gt;).&lt;br /&gt;
** If the subsystems aren&#039;t square (i.e., $X \in M_{m_1, n_1} \otimes M_{m_2, n_2}$) then &amp;lt;tt&amp;gt;DIM&amp;lt;/tt&amp;gt; should be a matrix with two rows. The first row of &amp;lt;tt&amp;gt;DIM&amp;lt;/tt&amp;gt; should contain the row dimensions of the subsystems (i.e., the m&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;&#039;s) and its second row should contain the column dimensions (i.e., the n&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;&#039;s). In other words, you should set &amp;lt;tt&amp;gt;DIM = [m_1, m_2; n_1, n_2]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; (optional, default 0): A flag that determines how many terms in the operator Schmidt decomposition should be computed. If &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;&amp;amp;nbsp;=&amp;amp;nbsp;0 then all terms with non-zero operator Schmidt coefficients are computed. If &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;&amp;amp;nbsp;=&amp;amp;nbsp;-1 then all terms (including zero terms) are computed. If &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;&amp;amp;nbsp;&amp;amp;gt;&amp;amp;nbsp;0 then the &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; terms with largest operator Schmidt coefficients are computed.&lt;br /&gt;
&lt;br /&gt;
===Output arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;S&amp;lt;/tt&amp;gt;: A vector containing the operator Schmidt coefficients of &amp;lt;tt&amp;gt;X&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* &amp;lt;tt&amp;gt;U&amp;lt;/tt&amp;gt; (optional): A cell containing the left Schmidt operators of &amp;lt;tt&amp;gt;X&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* &amp;lt;tt&amp;gt;V&amp;lt;/tt&amp;gt; (optional): A cell containing the right Schmidt operators of &amp;lt;tt&amp;gt;X&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===A random example===&lt;br /&gt;
The following code computes the operator Schmidt decomposition of a random [[density matrix]] in $M_2 \otimes M_4$ and verifies that it is indeed a valid tensor decomposition of that density matrix:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; rho = RandomDensityMatrix(8);&lt;br /&gt;
&amp;gt;&amp;gt; [s,U,V] = OperatorSchmidtDecomposition(rho,[2,4])&lt;br /&gt;
&lt;br /&gt;
s =&lt;br /&gt;
&lt;br /&gt;
    0.3986&lt;br /&gt;
    0.2310&lt;br /&gt;
    0.1637&lt;br /&gt;
    0.1118&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
U = &lt;br /&gt;
&lt;br /&gt;
    [2x2 double]    [2x2 double]    [2x2 double]    [2x2 double]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
V = &lt;br /&gt;
&lt;br /&gt;
    [4x4 double]    [4x4 double]    [4x4 double]    [4x4 double]&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; norm(s(1)*kron(U{1},V{1}) + s(2)*kron(U{2},V{2}) + s(3)*kron(U{3},V{3}) + s(4)*kron(U{4},V{4}) - rho)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
  1.8449e-016&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As an alternative (and easier) way to verify that we have a valid tensor decomposition of &amp;lt;tt&amp;gt;rho&amp;lt;/tt&amp;gt;, we can use the &amp;lt;tt&amp;gt;[[TensorSum]]&amp;lt;/tt&amp;gt; function:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; norm(TensorSum(s,U,V) - rho)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
  1.8449e-016&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
The input matrix &amp;lt;tt&amp;gt;X&amp;lt;/tt&amp;gt; does not need to be Hermitian. However, if it &amp;lt;em&amp;gt;is&amp;lt;/em&amp;gt; Hermitian then all of the matrices in its operator-Schmidt decomposition can be chosen to be Hermitian, and this function enforces such a choice (i.e., the matrices in &amp;lt;tt&amp;gt;U&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;V&amp;lt;/tt&amp;gt; are guaranteed to be Hermitian in this case).&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=OperatorSchmidtDecomposition}}&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=CopositivePolynomial&amp;diff=36081</id>
		<title>CopositivePolynomial</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=CopositivePolynomial&amp;diff=36081"/>
		<updated>2023-10-18T13:52:27Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: typo fixes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=CopositivePolynomial&lt;br /&gt;
|desc=Creates a homogenous polynomial whose non-negativity is equivalent to copositivity of a given matrix&lt;br /&gt;
|rel=[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialOptimize]]&amp;lt;br /&amp;gt;[[PolynomialSOS]]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 1, 2023&lt;br /&gt;
|cvx=no}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;CopositivePolynomial&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes the standard quartic homogeneous polynomial that is associated with a copositive matrix (or any symmetric matrix, in the hope of determining whether or not the matrix is copositive). For example, the Horn matrix&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;C = \begin{bmatrix}1 &amp;amp; -1 &amp;amp; 1 &amp;amp; 1 &amp;amp; -1 \\ -1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; 1 \\ 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 \\ 1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; -1 \\ -1 &amp;amp; 1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1\end{bmatrix}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
is associated with the quartic polynomial&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\displaystyle p(x) = \begin{bmatrix}x_1^2 &amp;amp; x_2^2 &amp;amp; x_3^2 &amp;amp; x_4^2 &amp;amp; x_5^2\end{bmatrix}C\begin{bmatrix}x_1^2 \\ x_2^2 \\ x_3^2 \\ x_4^2 \\ x_5^2\end{bmatrix} = \sum_{i=1}^5 x_i^4 - 2\sum_{i=1}^5x_i^2x_{i+1}^2 + 2\sum_{i=1}^5x_i^2x_{i+2}^2,&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the sums in the subscripts are understood to be modulo 5. Copositivity of &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; is equivalent to non-negativity of the polynomial &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;P = CopositivePolynomial(C)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
* &amp;lt;tt&amp;gt;C&amp;lt;/tt&amp;gt;: A matrix.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Horn matrix===&lt;br /&gt;
Let&#039;s compute the polynomial (as a vector) representation of the Horn matrix.&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; C = [1,-1,1,1,-1;-1,1,-1,1,1;1,-1,1,-1,1;1,1,-1,1,-1;-1,1,1,-1,1];% the Horn matrix&lt;br /&gt;
&amp;gt;&amp;gt; p = CopositivePolynomial(C);&lt;br /&gt;
&amp;gt;&amp;gt; sparse(p)% displays the non-zero coefficients of this polynomial&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   (1,1)        1&lt;br /&gt;
   (6,1)       -2&lt;br /&gt;
  (10,1)        2&lt;br /&gt;
  (13,1)        2&lt;br /&gt;
  (15,1)       -2&lt;br /&gt;
  (36,1)        1&lt;br /&gt;
  (40,1)       -2&lt;br /&gt;
  (43,1)        2&lt;br /&gt;
  (45,1)        2&lt;br /&gt;
  (56,1)        1&lt;br /&gt;
  (59,1)       -2&lt;br /&gt;
  (61,1)        2&lt;br /&gt;
  (66,1)        1&lt;br /&gt;
  (68,1)       -2&lt;br /&gt;
  (70,1)        1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To verify that the above vector of coefficients really does represent the polynomial associated with the Horn matrix, we can perform the follow computation (which requires MATLAB&#039;s symbolic computation package):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; syms x1 x2 x3 x4 x5&lt;br /&gt;
&amp;gt;&amp;gt; x = [x1;x2;x3;x4;x5];&lt;br /&gt;
&amp;gt;&amp;gt; n = 5;% number of variables = size of Horn matrix&lt;br /&gt;
&amp;gt;&amp;gt; d = 2;% half of the degree of the (quartic) polynomial&lt;br /&gt;
&amp;gt;&amp;gt; M = PolynomialAsMatrix(p,n,d);% compute a compact fully symmetric matrix representation of this polynomial&lt;br /&gt;
&amp;gt;&amp;gt; P = SymmetricProjection(n,d,1,0);% used to expand M to non-symmetric coordinates&lt;br /&gt;
&amp;gt;&amp;gt; MF = P*M*P&#039;;% MF is a matrix representation in non-symmetric coordinates&lt;br /&gt;
&amp;gt;&amp;gt; expand(kron(x,x).&#039;*MF*kron(x,x))% expand to a polynomial&lt;br /&gt;
 &lt;br /&gt;
ans =&lt;br /&gt;
 &lt;br /&gt;
x1^4 - 2*x1^2*x2^2 + 2*x1^2*x3^2 + 2*x1^2*x4^2 - 2*x1^2*x5^2 + x2^4 - 2*x2^2*x3^2 + 2*x2^2*x4^2 + 2*x2^2*x5^2 + x3^4 - 2*x3^2*x4^2 + 2*x3^2*x5^2 + x4^4 - 2*x4^2*x5^2 + x5^4&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Regardless of whether or not the above verification is performed, the vector p can now be used in polynomial optimization functions like &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;[[PolynomialSOS]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Clique polynomial===&lt;br /&gt;
To be filled in: an example of using this function to create a polynomial whose maximum value bounds the maximum clique size in a graph.&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=CopositivePolynomial}}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=Template:Bibtex&amp;diff=36080</id>
		<title>Template:Bibtex</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=Template:Bibtex&amp;diff=36080"/>
		<updated>2023-10-18T13:36:56Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;includeonly&amp;gt;&lt;br /&gt;
  @misc{qetlab,&lt;br /&gt;
    author       = {Nathaniel Johnston},&lt;br /&gt;
    title        = {{QETLAB}: A {MATLAB} toolbox for quantum entanglement, version {{CurrentVersion}}},&lt;br /&gt;
    howpublished = {\url{&amp;lt;nowiki&amp;gt;https://qetlab.com&amp;lt;/nowiki&amp;gt;}},&lt;br /&gt;
    month        = {Jan},&lt;br /&gt;
    year         = {2016},&lt;br /&gt;
    doi          = {10.5281/zenodo.{{DOI}}}&lt;br /&gt;
  }&amp;lt;/includeonly&amp;gt;&amp;lt;noinclude&amp;gt;This template creates BibTeX code for citing QETLAB. Its output is shown below:&lt;br /&gt;
{{Bibtex}}&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=How_to_cite&amp;diff=36079</id>
		<title>How to cite</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=How_to_cite&amp;diff=36079"/>
		<updated>2023-10-18T13:36:32Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We appreciate it when QETLAB is cited within your work. You can cite it using the following DOI: [http://dx.doi.org/10.5281/zenodo.{{DOI}} 10.5281/zenodo.{{DOI}}]&lt;br /&gt;
&lt;br /&gt;
More explicitly, you can use a bibliography entry that looks something like this:&lt;br /&gt;
&amp;lt;pre&amp;lt;noinclude&amp;gt;&amp;lt;/noinclude&amp;gt;&amp;gt;Nathaniel Johnston. QETLAB: A MATLAB toolbox for quantum entanglement, version {{CurrentVersion}}. &amp;lt;nowiki&amp;gt;https://qetlab.com&amp;lt;/nowiki&amp;gt;, {{LastUpdated}}. doi:10.5281/zenodo.{{DOI}}&amp;lt;/pre&amp;lt;noinclude&amp;gt;&amp;lt;/noinclude&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A BibTeX entry that you can use to cite QETLAB is provided here:&lt;br /&gt;
{{Bibtex}}&lt;br /&gt;
&lt;br /&gt;
==Papers that use QETLAB==&lt;br /&gt;
If you have made use of QETLAB in your work, please add examples of your work to the [[List of functions|documentation pages]]. We love hearing that QETLAB has been useful!&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;[https://scholar.google.ca/scholar?oi=bibs&amp;amp;hl=en&amp;amp;cites=16442313706896235348,16994735883828134979 Click here]&#039;&#039;&#039; for a (mostly) up-to-date list of papers that cite QETLAB.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=How_to_cite&amp;diff=36078</id>
		<title>How to cite</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=How_to_cite&amp;diff=36078"/>
		<updated>2023-10-18T13:34:10Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Protected &amp;quot;How to cite&amp;quot;: spam protection ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We appreciate it when QETLAB is cited within your work. You can cite it using the following DOI: [http://dx.doi.org/10.5281/zenodo.{{DOI}} 10.5281/zenodo.{{DOI}}]&lt;br /&gt;
&lt;br /&gt;
More explicitly, you can use a bibliography entry that looks something like this:&lt;br /&gt;
&amp;lt;pre&amp;lt;noinclude&amp;gt;&amp;lt;/noinclude&amp;gt;&amp;gt;Nathaniel Johnston. QETLAB: A MATLAB toolbox for quantum entanglement, version {{CurrentVersion}}. &amp;lt;nowiki&amp;gt;http://www.qetlab.com&amp;lt;/nowiki&amp;gt;, {{LastUpdated}}. doi:10.5281/zenodo.{{DOI}}&amp;lt;/pre&amp;lt;noinclude&amp;gt;&amp;lt;/noinclude&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A BibTeX entry that you can use to cite QETLAB is provided here:&lt;br /&gt;
{{Bibtex}}&lt;br /&gt;
&lt;br /&gt;
==Papers that use QETLAB==&lt;br /&gt;
If you have made use of QETLAB in your work, please add examples of your work to the [[List of functions|documentation pages]]. We love hearing that QETLAB has been useful!&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;[https://scholar.google.ca/scholar?oi=bibs&amp;amp;hl=en&amp;amp;cites=16442313706896235348,16994735883828134979 Click here]&#039;&#039;&#039; for a (mostly) up-to-date list of papers that cite QETLAB.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=How_to_cite&amp;diff=36077</id>
		<title>How to cite</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=How_to_cite&amp;diff=36077"/>
		<updated>2023-10-18T13:33:38Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Reverted edits by Lonalditchel (talk) to last revision by Nathaniel&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We appreciate it when QETLAB is cited within your work. You can cite it using the following DOI: [http://dx.doi.org/10.5281/zenodo.{{DOI}} 10.5281/zenodo.{{DOI}}]&lt;br /&gt;
&lt;br /&gt;
More explicitly, you can use a bibliography entry that looks something like this:&lt;br /&gt;
&amp;lt;pre&amp;lt;noinclude&amp;gt;&amp;lt;/noinclude&amp;gt;&amp;gt;Nathaniel Johnston. QETLAB: A MATLAB toolbox for quantum entanglement, version {{CurrentVersion}}. &amp;lt;nowiki&amp;gt;http://www.qetlab.com&amp;lt;/nowiki&amp;gt;, {{LastUpdated}}. doi:10.5281/zenodo.{{DOI}}&amp;lt;/pre&amp;lt;noinclude&amp;gt;&amp;lt;/noinclude&amp;gt;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A BibTeX entry that you can use to cite QETLAB is provided here:&lt;br /&gt;
{{Bibtex}}&lt;br /&gt;
&lt;br /&gt;
==Papers that use QETLAB==&lt;br /&gt;
If you have made use of QETLAB in your work, please add examples of your work to the [[List of functions|documentation pages]]. We love hearing that QETLAB has been useful!&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;[https://scholar.google.ca/scholar?oi=bibs&amp;amp;hl=en&amp;amp;cites=16442313706896235348,16994735883828134979 Click here]&#039;&#039;&#039; for a (mostly) up-to-date list of papers that cite QETLAB.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=PolynomialOptimize&amp;diff=36075</id>
		<title>PolynomialOptimize</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=PolynomialOptimize&amp;diff=36075"/>
		<updated>2023-10-17T18:34:42Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Fixing numerical example now that this function is working properly&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=PolynomialOptimize&lt;br /&gt;
|desc=Bounds the optimal value of a homogeneous polynomial on the unit sphere&lt;br /&gt;
|rel=[[CopositivePolynomial]]&amp;lt;br /&amp;gt;[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialSOS]]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 5, 2023&lt;br /&gt;
|cvx=yes}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;PolynomialOptimize&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes upper and lower bounds on the optimum (i.e., maximum or minimum) value of an even-degree homogeneous polynomial on the unit sphere. That is, given an even-degree n-variable homogeneous polynomial p, this function bounds the (very difficult to compute in general) quantity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\max\big\{ p(x_1,x_2,\ldots,x_n) : x_1^2 + x_2^2 + \cdots + x_n^2 = 1 \big\},&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or the corresponding minimization problem.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialOptimize(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialOptimize(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialOptimize(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialOptimize(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
===Input arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt;: The polynomial, represented as a vector of coefficients of its monomials in lexicographic order.&lt;br /&gt;
* &amp;lt;tt&amp;gt;N&amp;lt;/tt&amp;gt;: The number of variables in the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;D&amp;lt;/tt&amp;gt;: Half the degree of the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;: A non-negative integer that specifies the level of the hierarchy that is used to compute the bound(s) on the optimal value. Larger values of K result in better bounds at the expense of increases memory usage and longer computation times.&lt;br /&gt;
* &amp;lt;tt&amp;gt;OPTTYPE&amp;lt;/tt&amp;gt; (optional, default &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt;): Either &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&#039;min&#039;&amp;lt;/tt&amp;gt;, indicating whether the polynomial should be maximized or minimized.&lt;br /&gt;
&lt;br /&gt;
===Output arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB&amp;lt;/tt&amp;gt;: An &amp;quot;outer&amp;quot; bound on the optimal value. If maximizing, this is an upper bound on the maximum; if minimizing, this is a lower bound on the minimum.&lt;br /&gt;
* &amp;lt;tt&amp;gt;IB&amp;lt;/tt&amp;gt;: An &amp;quot;inner&amp;quot; bound on the optimal value. If maximizing, this is a lower bound on the maximum; if minimizing, this is an upper bound on the minimum.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Motzkin polynomial===&lt;br /&gt;
The Motzkin polynomial is the following degree-6 homogeneous polynomial: &amp;lt;math&amp;gt;p(x,y,z) = x^4y^2 + x^2y^4 - 3x^2y^2z^2 + z^6&amp;lt;/math&amp;gt;. We can load this polynomial into a list-of-coefficients form that &amp;lt;tt&amp;gt;PolynomialOptimize&amp;lt;/tt&amp;gt; understands via the &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt; helper function:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 3;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; p = zeros(nchoosek(n+2*d-1,2*d),1);% initialize p to have the correct size&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([4 2 0])) = 1;% the &amp;quot;4 2 0&amp;quot; here are the exponents in the term x^4y^2z^0, while the &amp;quot;1&amp;quot; is the coefficient of this term&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 4 0])) = 1;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 2 2])) = -3;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([0 0 6])) = 1;% now p represents the Motzkin polynomial&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Motzkin polynomial, despite the fact that it cannot be written as a sum of squares, is non-negative. In fact, the minimum value of this polynomial over the unit sphere is exactly 0. We can get lower bounds for the optimal value as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialOptimize(p,n,d,0,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.5000&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialOptimize(p,n,d,1,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.2006&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialOptimize(p,n,d,2,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.1270&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see above that increasing the value of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; (i.e., the level of the hierarchy) results in a better lower bound (i.e., a bound that is closer to the true minimum value of 0). This function is fast enough that we can go to a much higher level of the hierarchy, and we can also get upper bounds on this minimum value:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialOptimize(p,n,d,10,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   -0.0189&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    1.0333e-06&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialOptimize(p,n,d,100,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   -0.0017&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    1.5581e-09&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialOptimize(p,n,d,250,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
  -6.8094e-04&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    7.7534e-13&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, by the 250-th level of the hierarchy we have learned that the minimum value of the Motzkin polynomial is between &amp;lt;tt&amp;gt;-6.8094e-04&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;7.7534e-13&amp;lt;/tt&amp;gt;. Note that the inner bounds are computed by a randomized algorithm, so when you run the code above you might get different inner bounds.&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=PolynomialOptimize}}&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
The inner bounds, even though they are somewhat random, do (deterministically) converge to the true optimal value of the polynomial as &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; approaches infinity. &lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=Contributors&amp;diff=36041</id>
		<title>Contributors</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=Contributors&amp;diff=36041"/>
		<updated>2023-08-09T12:21:10Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: updated unique_perms note&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;QETLAB started as a project by &#039;&#039;&#039;[http://www.njohnston.ca Nathaniel Johnston]&#039;&#039;&#039; and is still primarily maintained by him. Several other people have also contributed to its development (see the [https://github.com/nathanieljohnston/QETLAB/graphs/contributors contributors page on github] for more detailed information):&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[https://mateusaraujo.info/about/ Mateus Araújo]&#039;&#039;&#039;: Wrote faster code for computing the classical value of a non-local game in the &amp;lt;tt&amp;gt;[[NonlocalGameValue]]&amp;lt;/tt&amp;gt; function. Also refactored &amp;lt;tt&amp;gt;[[BellInequalityMax]]&amp;lt;/tt&amp;gt; and some other miscellaneous improvements.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[https://cosenal.github.io/ Alessandro Cosentino]&#039;&#039;&#039;: Bug reports, testing, and general guidance for best practices with QETLAB. Also created the &amp;lt;tt&amp;gt;[[LocalDistinguishability]]&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;John D&#039;Errico&#039;&#039;&#039;: Created the &amp;lt;tt&amp;gt;[[unique_perms]]&amp;lt;/tt&amp;gt; function, which was used until QETLAB v0.9 (it has since been removed).&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Bruno Luong&#039;&#039;&#039;: Created the &amp;lt;tt&amp;gt;[[sporth]]&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;[[spnull]]&amp;lt;/tt&amp;gt; functions.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Robert Materi&#039;&#039;&#039;: Improved Octave compatibility, including creation of the &amp;lt;tt&amp;gt;[[dec_to_bin]]&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;[[pad_array]]&amp;lt;/tt&amp;gt; functions.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[http://bartoszregula.github.io/ Bartosz Regula]&#039;&#039;&#039;: Fixed a bug in &amp;lt;tt&amp;gt;[[PartialMap]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;[https://vprusso.github.io/ Vincent Russo]&#039;&#039;&#039;: Bug reports, testing, and contributions to several functions such as &amp;lt;tt&amp;gt;[[Fidelity]]&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;[[DickeState]]&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;[[HorodeckiState]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
N.J. also thanks the [https://uwaterloo.ca/institute-for-quantum-computing/ Institute for Quantum Computing] for hosting him during QETLAB&#039;s development, and the Natural Sciences and Engineering Research Council of Canada for providing funding during QETLAB&#039;s development.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=PolynomialSOS&amp;diff=36040</id>
		<title>PolynomialSOS</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=PolynomialSOS&amp;diff=36040"/>
		<updated>2023-08-09T12:14:51Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: /* Examples */ adjusting example values now that function has been updated&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=PolynomialSOS&lt;br /&gt;
|desc=Bounds the optimal value of a homogeneous polynomial on the unit sphere via the Sum-Of-Squares hierarchy&lt;br /&gt;
|rel=[[CopositivePolynomial]]&amp;lt;br /&amp;gt;[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialOptimize]]&lt;br /&gt;
|req=[http://cvxr.com/cvx/ CVX]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 5, 2023&lt;br /&gt;
|cvx=yes}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;PolynomialSOS&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes upper and lower bounds on the optimum (i.e., maximum or minimum) value of an even-degree homogeneous polynomial on the unit sphere. That is, given an even-degree n-variable homogeneous polynomial p, this function bounds the (very difficult to compute in general) quantity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\max\big\{ p(x_1,x_2,\ldots,x_n) : x_1^2 + x_2^2 + \cdots + x_n^2 = 1 \big\},&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or the corresponding minimization problem. This function makes use of the sum-of-squares hierarchy, which requires semidefinite programming and thus, for a given level of the hierarchy, is slower but more accurate than the &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialSOS(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialSOS(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialSOS(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialSOS(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
===Input arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt;: The polynomial, represented as a vector of coefficients of its monomials in lexicographic order.&lt;br /&gt;
* &amp;lt;tt&amp;gt;N&amp;lt;/tt&amp;gt;: The number of variables in the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;D&amp;lt;/tt&amp;gt;: Half the degree of the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;: A non-negative integer that specifies the level of the hierarchy that is used to compute the bound(s) on the optimal value. Larger values of K result in better bounds at the expense of increases memory usage and longer computation times.&lt;br /&gt;
* &amp;lt;tt&amp;gt;OPTTYPE&amp;lt;/tt&amp;gt; (optional, default &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt;): Either &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&#039;min&#039;&amp;lt;/tt&amp;gt;, indicating whether the polynomial should be maximized or minimized.&lt;br /&gt;
&lt;br /&gt;
===Output arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB&amp;lt;/tt&amp;gt;: An &amp;quot;outer&amp;quot; bound on the optimal value. If maximizing, this is an upper bound on the maximum; if minimizing, this is a lower bound on the minimum.&lt;br /&gt;
* &amp;lt;tt&amp;gt;IB&amp;lt;/tt&amp;gt;: An &amp;quot;inner&amp;quot; bound on the optimal value. If maximizing, this is a lower bound on the maximum; if minimizing, this is an upper bound on the minimum.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Motzkin polynomial===&lt;br /&gt;
The Motzkin polynomial is the following degree-6 homogeneous polynomial: &amp;lt;math&amp;gt;p(x,y,z) = x^4y^2 + x^2y^4 - 3x^2y^2z^2 + z^6&amp;lt;/math&amp;gt;. We can load this polynomial into a list-of-coefficients form that &amp;lt;tt&amp;gt;PolynomialOptimize&amp;lt;/tt&amp;gt; understands via the &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt; helper function:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 3;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; p = zeros(nchoosek(n+2*d-1,2*d),1);% initialize p to have the correct size&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([4 2 0])) = 1;% the &amp;quot;4 2 0&amp;quot; here are the exponents in the term x^4y^2z^0, while the &amp;quot;1&amp;quot; is the coefficient of this term&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 4 0])) = 1;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 2 2])) = -3;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([0 0 6])) = 1;% now p represents the Motzkin polynomial&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Motzkin polynomial, despite the fact that it cannot be written as a sum of squares, is non-negative. The &amp;lt;tt&amp;gt;K = 0&amp;lt;/tt&amp;gt; level of this function verifies that p cannot be written as a sum of squares (if it could, the following code would return a non-negative answer):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialSOS(p,n,d,0,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.0046&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can verify that the Motzkin polynomial is non-negative by increasing the value of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; (i.e., the level of the hierarchy):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialSOS(p,n,d,1,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -3.2425e-10&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the true minimum value of this polynomial on the unit sphere is 0, for this polynomial higher levels of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; will not improve the lower bound (we already got the exact answer, within numerical precision). However, we can get better and better upper bounds by increasing &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialSOS(p,n,d,2,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   9.8781e-12&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    2.4182e-07&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialSOS(p,n,d,3,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   1.6065e-11&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    3.8579e-09&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the inner bounds are computed by an algorithm that includes some randomness, so when you run the code above you might get different inner bounds.&lt;br /&gt;
&lt;br /&gt;
===Usable within CVX===&lt;br /&gt;
This function is CVX-friendly, meaning that when running in &amp;lt;tt&amp;gt;&#039;min&#039;&amp;lt;/tt&amp;gt; mode you can use it in CVX as you would any other concave function, and when running in &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt; mode you can use it in CVX as you would any other convex function. For example, the following semidefinite program in CVX shows that, for 3-variable degree-6 homogeneous polynomials p that can be written as a sum of squares and have their &amp;lt;math&amp;gt;x^6&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;y^6&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;z^6&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;x^4y^2&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;x^2y^4&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;x^4z^2&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;x^2z^4&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;y^4z^2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;y^2z^4&amp;lt;/math&amp;gt; coefficients equal to 1, the minimal coefficient of the &amp;lt;math&amp;gt;x^2y^2z^2&amp;lt;/math&amp;gt; term is -9:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 3;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; cvx_begin sdp quiet&lt;br /&gt;
&amp;gt;&amp;gt;     cvx_precision best;&lt;br /&gt;
&amp;gt;&amp;gt;     variable p(nchoosek(n+2*d-1,2*d),1)&lt;br /&gt;
&amp;gt;&amp;gt;     minimize p(exp2ind([2 2 2]))&lt;br /&gt;
&amp;gt;&amp;gt;     subject to&lt;br /&gt;
&amp;gt;&amp;gt;         PolynomialSOS(p,n,d,0,&#039;min&#039;) &amp;gt;= 0;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([6 0 0])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([0 6 0])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([0 0 6])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([4 2 0])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([2 4 0])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([4 0 2])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([2 0 4])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([0 4 2])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([0 2 4])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt; cvx_end&lt;br /&gt;
&amp;gt;&amp;gt; cvx_optval&lt;br /&gt;
&lt;br /&gt;
cvx_optval =&lt;br /&gt;
&lt;br /&gt;
   -9.0000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=PolynomialSOS}}&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
* The inner bounds, even though they are somewhat random, do (deterministically) converge to the true optimal value of the polynomial as K approaches infinity.&lt;br /&gt;
* If &amp;lt;tt&amp;gt;K = 0&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;OPTTYPE = &#039;min&#039;&amp;lt;/tt&amp;gt; then the output of this function is non-negative if and only if &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt; can be written as a sum of squares of polynomials.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=PolynomialOptimize&amp;diff=36036</id>
		<title>PolynomialOptimize</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=PolynomialOptimize&amp;diff=36036"/>
		<updated>2023-08-06T01:44:17Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Is now usable inside of CVX&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=PolynomialOptimize&lt;br /&gt;
|desc=Bounds the optimal value of a homogeneous polynomial on the unit sphere&lt;br /&gt;
|rel=[[CopositivePolynomial]]&amp;lt;br /&amp;gt;[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialSOS]]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 5, 2023&lt;br /&gt;
|cvx=yes}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;PolynomialOptimize&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes upper and lower bounds on the optimum (i.e., maximum or minimum) value of an even-degree homogeneous polynomial on the unit sphere. That is, given an even-degree n-variable homogeneous polynomial p, this function bounds the (very difficult to compute in general) quantity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\max\big\{ p(x_1,x_2,\ldots,x_n) : x_1^2 + x_2^2 + \cdots + x_n^2 = 1 \big\},&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or the corresponding minimization problem.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialOptimize(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialOptimize(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialOptimize(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialOptimize(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
===Input arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt;: The polynomial, represented as a vector of coefficients of its monomials in lexicographic order.&lt;br /&gt;
* &amp;lt;tt&amp;gt;N&amp;lt;/tt&amp;gt;: The number of variables in the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;D&amp;lt;/tt&amp;gt;: Half the degree of the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;: A non-negative integer that specifies the level of the hierarchy that is used to compute the bound(s) on the optimal value. Larger values of K result in better bounds at the expense of increases memory usage and longer computation times.&lt;br /&gt;
* &amp;lt;tt&amp;gt;OPTTYPE&amp;lt;/tt&amp;gt; (optional, default &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt;): Either &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&#039;min&#039;&amp;lt;/tt&amp;gt;, indicating whether the polynomial should be maximized or minimized.&lt;br /&gt;
&lt;br /&gt;
===Output arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB&amp;lt;/tt&amp;gt;: An &amp;quot;outer&amp;quot; bound on the optimal value. If maximizing, this is an upper bound on the maximum; if minimizing, this is a lower bound on the minimum.&lt;br /&gt;
* &amp;lt;tt&amp;gt;IB&amp;lt;/tt&amp;gt;: An &amp;quot;inner&amp;quot; bound on the optimal value. If maximizing, this is a lower bound on the maximum; if minimizing, this is an upper bound on the minimum.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Motzkin polynomial===&lt;br /&gt;
The Motzkin polynomial is the following degree-6 homogeneous polynomial: &amp;lt;math&amp;gt;p(x,y,z) = x^4y^2 + x^2y^4 - 3x^2y^2z^2 + z^6&amp;lt;/math&amp;gt;. We can load this polynomial into a list-of-coefficients form that &amp;lt;tt&amp;gt;PolynomialOptimize&amp;lt;/tt&amp;gt; understands via the &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt; helper function:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 3;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; p = zeros(nchoosek(n+2*d-1,2*d),1);% initialize p to have the correct size&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([4 2 0])) = 1;% the &amp;quot;4 2 0&amp;quot; here are the exponents in the term x^4y^2z^0, while the &amp;quot;1&amp;quot; is the coefficient of this term&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 4 0])) = 1;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 2 2])) = -3;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([0 0 6])) = 1;% now p represents the Motzkin polynomial&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Motzkin polynomial, despite the fact that it cannot be written as a sum of squares, is non-negative. In fact, the minimum value of this polynomial over the unit sphere is exactly 0. We can get lower bounds for the optimal value as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialOptimize(p,n,d,0,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.2000&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialOptimize(p,n,d,1,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.1104&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialOptimize(p,n,d,2,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.0780&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see above that increasing the value of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; (i.e., the level of the hierarchy) results in a better lower bound (i.e., a bound that is closer to the true minimum value of 0). This function is fast enough that we can go to a much higher level of the hierarchy, and we can also get upper bounds on this minimum value:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialOptimize(p,n,d,10,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   -0.0158&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    1.0333e-06&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialOptimize(p,n,d,100,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   -0.0017&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    1.5581e-09&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialOptimize(p,n,d,500,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
  -3.3898e-04&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    4.6048e-13&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, by the 500-th level of the hierarchy we have learned that the minimum value of the Motzkin polynomial is between &amp;lt;tt&amp;gt;-3.3898e-04&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;4.6048e-13&amp;lt;/tt&amp;gt;. Note that the inner bounds are computed by an algorithm that includes some randomness, so when you run the code above you might get different inner bounds.&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=PolynomialOptimize}}&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
The inner bounds, even though they are somewhat random, do (deterministically) converge to the true optimal value of the polynomial as &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; approaches infinity. &lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=PolynomialSOS&amp;diff=36035</id>
		<title>PolynomialSOS</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=PolynomialSOS&amp;diff=36035"/>
		<updated>2023-08-06T00:13:32Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: /* Usable within CVX */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=PolynomialSOS&lt;br /&gt;
|desc=Bounds the optimal value of a homogeneous polynomial on the unit sphere via the Sum-Of-Squares hierarchy&lt;br /&gt;
|rel=[[CopositivePolynomial]]&amp;lt;br /&amp;gt;[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialOptimize]]&lt;br /&gt;
|req=[http://cvxr.com/cvx/ CVX]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 5, 2023&lt;br /&gt;
|cvx=yes}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;PolynomialSOS&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes upper and lower bounds on the optimum (i.e., maximum or minimum) value of an even-degree homogeneous polynomial on the unit sphere. That is, given an even-degree n-variable homogeneous polynomial p, this function bounds the (very difficult to compute in general) quantity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\max\big\{ p(x_1,x_2,\ldots,x_n) : x_1^2 + x_2^2 + \cdots + x_n^2 = 1 \big\},&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or the corresponding minimization problem. This function makes use of the sum-of-squares hierarchy, which requires semidefinite programming and thus, for a given level of the hierarchy, is slower but more accurate than the &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialSOS(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialSOS(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialSOS(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialSOS(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
===Input arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt;: The polynomial, represented as a vector of coefficients of its monomials in lexicographic order.&lt;br /&gt;
* &amp;lt;tt&amp;gt;N&amp;lt;/tt&amp;gt;: The number of variables in the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;D&amp;lt;/tt&amp;gt;: Half the degree of the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;: A non-negative integer that specifies the level of the hierarchy that is used to compute the bound(s) on the optimal value. Larger values of K result in better bounds at the expense of increases memory usage and longer computation times.&lt;br /&gt;
* &amp;lt;tt&amp;gt;OPTTYPE&amp;lt;/tt&amp;gt; (optional, default &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt;): Either &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&#039;min&#039;&amp;lt;/tt&amp;gt;, indicating whether the polynomial should be maximized or minimized.&lt;br /&gt;
&lt;br /&gt;
===Output arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB&amp;lt;/tt&amp;gt;: An &amp;quot;outer&amp;quot; bound on the optimal value. If maximizing, this is an upper bound on the maximum; if minimizing, this is a lower bound on the minimum.&lt;br /&gt;
* &amp;lt;tt&amp;gt;IB&amp;lt;/tt&amp;gt;: An &amp;quot;inner&amp;quot; bound on the optimal value. If maximizing, this is a lower bound on the maximum; if minimizing, this is an upper bound on the minimum.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Motzkin polynomial===&lt;br /&gt;
The Motzkin polynomial is the following degree-6 homogeneous polynomial: &amp;lt;math&amp;gt;p(x,y,z) = x^4y^2 + x^2y^4 - 3x^2y^2z^2 + z^6&amp;lt;/math&amp;gt;. We can load this polynomial into a list-of-coefficients form that &amp;lt;tt&amp;gt;PolynomialOptimize&amp;lt;/tt&amp;gt; understands via the &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt; helper function:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 3;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; p = zeros(nchoosek(n+2*d-1,2*d),1);% initialize p to have the correct size&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([4 2 0])) = 1;% the &amp;quot;4 2 0&amp;quot; here are the exponents in the term x^4y^2z^0, while the &amp;quot;1&amp;quot; is the coefficient of this term&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 4 0])) = 1;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 2 2])) = -3;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([0 0 6])) = 1;% now p represents the Motzkin polynomial&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Motzkin polynomial, despite the fact that it cannot be written as a sum of squares, is non-negative. The &amp;lt;tt&amp;gt;K = 0&amp;lt;/tt&amp;gt; level of this function verifies that p cannot be written as a sum of squares (if it could, the following code would return a non-negative answer):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialSOS(p,n,d,0,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.0046&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can verify that the Motzkin polynomial is non-negative by increasing the value of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; (i.e., the level of the hierarchy):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialSOS(p,n,d,1,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   6.1270e-12&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the true minimum value of this polynomial on the unit sphere is 0, for this polynomial higher levels of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; will not improve the lower bound (we already got the exact answer, within numerical precision). However, we can get better and better upper bounds by increasing &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialSOS(p,n,d,2,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   5.9776e-12&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    7.0050e-09&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialSOS(p,n,d,3,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   1.2217e-11&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    3.8579e-09&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the inner bounds are computed by an algorithm that includes some randomness, so when you run the code above you might get different inner bounds.&lt;br /&gt;
&lt;br /&gt;
===Usable within CVX===&lt;br /&gt;
This function is CVX-friendly, meaning that when running in &amp;lt;tt&amp;gt;&#039;min&#039;&amp;lt;/tt&amp;gt; mode you can use it in CVX as you would any other concave function, and when running in &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt; mode you can use it in CVX as you would any other convex function. For example, the following semidefinite program in CVX shows that, for 3-variable degree-6 homogeneous polynomials p that can be written as a sum of squares and have their &amp;lt;math&amp;gt;x^6&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;y^6&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;z^6&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;x^4y^2&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;x^2y^4&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;x^4z^2&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;x^2z^4&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;y^4z^2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;y^2z^4&amp;lt;/math&amp;gt; coefficients equal to 1, the minimal coefficient of the &amp;lt;math&amp;gt;x^2y^2z^2&amp;lt;/math&amp;gt; term is -9:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 3;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; cvx_begin sdp quiet&lt;br /&gt;
&amp;gt;&amp;gt;     cvx_precision best;&lt;br /&gt;
&amp;gt;&amp;gt;     variable p(nchoosek(n+2*d-1,2*d),1)&lt;br /&gt;
&amp;gt;&amp;gt;     minimize p(exp2ind([2 2 2]))&lt;br /&gt;
&amp;gt;&amp;gt;     subject to&lt;br /&gt;
&amp;gt;&amp;gt;         PolynomialSOS(p,n,d,0,&#039;min&#039;) &amp;gt;= 0;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([6 0 0])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([0 6 0])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([0 0 6])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([4 2 0])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([2 4 0])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([4 0 2])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([2 0 4])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([0 4 2])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([0 2 4])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt; cvx_end&lt;br /&gt;
&amp;gt;&amp;gt; cvx_optval&lt;br /&gt;
&lt;br /&gt;
cvx_optval =&lt;br /&gt;
&lt;br /&gt;
   -9.0000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=PolynomialSOS}}&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
* The inner bounds, even though they are somewhat random, do (deterministically) converge to the true optimal value of the polynomial as K approaches infinity.&lt;br /&gt;
* If &amp;lt;tt&amp;gt;K = 0&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;OPTTYPE = &#039;min&#039;&amp;lt;/tt&amp;gt; then the output of this function is non-negative if and only if &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt; can be written as a sum of squares of polynomials.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=PolynomialSOS&amp;diff=36034</id>
		<title>PolynomialSOS</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=PolynomialSOS&amp;diff=36034"/>
		<updated>2023-08-06T00:12:33Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Finished in-CVX example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=PolynomialSOS&lt;br /&gt;
|desc=Bounds the optimal value of a homogeneous polynomial on the unit sphere via the Sum-Of-Squares hierarchy&lt;br /&gt;
|rel=[[CopositivePolynomial]]&amp;lt;br /&amp;gt;[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialOptimize]]&lt;br /&gt;
|req=[http://cvxr.com/cvx/ CVX]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 5, 2023&lt;br /&gt;
|cvx=yes}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;PolynomialSOS&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes upper and lower bounds on the optimum (i.e., maximum or minimum) value of an even-degree homogeneous polynomial on the unit sphere. That is, given an even-degree n-variable homogeneous polynomial p, this function bounds the (very difficult to compute in general) quantity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\max\big\{ p(x_1,x_2,\ldots,x_n) : x_1^2 + x_2^2 + \cdots + x_n^2 = 1 \big\},&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or the corresponding minimization problem. This function makes use of the sum-of-squares hierarchy, which requires semidefinite programming and thus, for a given level of the hierarchy, is slower but more accurate than the &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialSOS(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialSOS(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialSOS(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialSOS(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
===Input arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt;: The polynomial, represented as a vector of coefficients of its monomials in lexicographic order.&lt;br /&gt;
* &amp;lt;tt&amp;gt;N&amp;lt;/tt&amp;gt;: The number of variables in the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;D&amp;lt;/tt&amp;gt;: Half the degree of the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;: A non-negative integer that specifies the level of the hierarchy that is used to compute the bound(s) on the optimal value. Larger values of K result in better bounds at the expense of increases memory usage and longer computation times.&lt;br /&gt;
* &amp;lt;tt&amp;gt;OPTTYPE&amp;lt;/tt&amp;gt; (optional, default &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt;): Either &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&#039;min&#039;&amp;lt;/tt&amp;gt;, indicating whether the polynomial should be maximized or minimized.&lt;br /&gt;
&lt;br /&gt;
===Output arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB&amp;lt;/tt&amp;gt;: An &amp;quot;outer&amp;quot; bound on the optimal value. If maximizing, this is an upper bound on the maximum; if minimizing, this is a lower bound on the minimum.&lt;br /&gt;
* &amp;lt;tt&amp;gt;IB&amp;lt;/tt&amp;gt;: An &amp;quot;inner&amp;quot; bound on the optimal value. If maximizing, this is a lower bound on the maximum; if minimizing, this is an upper bound on the minimum.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Motzkin polynomial===&lt;br /&gt;
The Motzkin polynomial is the following degree-6 homogeneous polynomial: &amp;lt;math&amp;gt;p(x,y,z) = x^4y^2 + x^2y^4 - 3x^2y^2z^2 + z^6&amp;lt;/math&amp;gt;. We can load this polynomial into a list-of-coefficients form that &amp;lt;tt&amp;gt;PolynomialOptimize&amp;lt;/tt&amp;gt; understands via the &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt; helper function:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 3;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; p = zeros(nchoosek(n+2*d-1,2*d),1);% initialize p to have the correct size&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([4 2 0])) = 1;% the &amp;quot;4 2 0&amp;quot; here are the exponents in the term x^4y^2z^0, while the &amp;quot;1&amp;quot; is the coefficient of this term&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 4 0])) = 1;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 2 2])) = -3;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([0 0 6])) = 1;% now p represents the Motzkin polynomial&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Motzkin polynomial, despite the fact that it cannot be written as a sum of squares, is non-negative. The &amp;lt;tt&amp;gt;K = 0&amp;lt;/tt&amp;gt; level of this function verifies that p cannot be written as a sum of squares (if it could, the following code would return a non-negative answer):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialSOS(p,n,d,0,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.0046&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can verify that the Motzkin polynomial is non-negative by increasing the value of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; (i.e., the level of the hierarchy):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialSOS(p,n,d,1,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   6.1270e-12&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the true minimum value of this polynomial on the unit sphere is 0, for this polynomial higher levels of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; will not improve the lower bound (we already got the exact answer, within numerical precision). However, we can get better and better upper bounds by increasing &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialSOS(p,n,d,2,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   5.9776e-12&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    7.0050e-09&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialSOS(p,n,d,3,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   1.2217e-11&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    3.8579e-09&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the inner bounds are computed by an algorithm that includes some randomness, so when you run the code above you might get different inner bounds.&lt;br /&gt;
&lt;br /&gt;
===Usable within CVX===&lt;br /&gt;
This function is CVX-friendly, meaning that when running in &amp;lt;tt&amp;gt;&#039;min&#039;&amp;lt;/tt&amp;gt; mode you can use it in CVX as you would any other concave function, and when running in &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt; mode you can use it in CVX as you would any other convex function. For example, the following semidefinite program in CVX shows that, for 3-variable degree-6 homogeneous polynomials p that can be written as a sum of squares and have their &amp;lt;math&amp;gt;x^6&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;y^6&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;z^6&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;x^4y^2&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;x^2y^4&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;x^4z^2&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;x^2z^4&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;y^4z^2&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;y^2z^4&amp;lt;/math&amp;gt; coefficients equal to 1, the minimal coefficient of the &amp;lt;math&amp;gt;x^2y^2z^2&amp;lt;/math&amp;gt; term is -9:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 3;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; cvx_begin sdp quiet&lt;br /&gt;
&amp;gt;&amp;gt;     cvx_precision best;&lt;br /&gt;
&amp;gt;&amp;gt;     variable p(nchoosek(n+2*d-1,2*d),1)&lt;br /&gt;
&amp;gt;&amp;gt;     minimize p(exp2ind([2 2 2]))&lt;br /&gt;
&amp;gt;&amp;gt;     subject to&lt;br /&gt;
&amp;gt;&amp;gt;         PolynomialSOS(p,3,3,0,&#039;min&#039;) &amp;gt;= 0;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([6 0 0])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([0 6 0])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([0 0 6])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([4 2 0])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([2 4 0])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([4 0 2])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([2 0 4])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([0 4 2])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         p(exp2ind([0 2 4])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt; cvx_end&lt;br /&gt;
&amp;gt;&amp;gt; cvx_optval&lt;br /&gt;
&lt;br /&gt;
cvx_optval =&lt;br /&gt;
&lt;br /&gt;
   -9.0000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=PolynomialSOS}}&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
* The inner bounds, even though they are somewhat random, do (deterministically) converge to the true optimal value of the polynomial as K approaches infinity.&lt;br /&gt;
* If &amp;lt;tt&amp;gt;K = 0&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;OPTTYPE = &#039;min&#039;&amp;lt;/tt&amp;gt; then the output of this function is non-negative if and only if &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt; can be written as a sum of squares of polynomials.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=PolynomialSOS&amp;diff=36033</id>
		<title>PolynomialSOS</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=PolynomialSOS&amp;diff=36033"/>
		<updated>2023-08-06T00:03:46Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Added in-CVX example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=PolynomialSOS&lt;br /&gt;
|desc=Bounds the optimal value of a homogeneous polynomial on the unit sphere via the Sum-Of-Squares hierarchy&lt;br /&gt;
|rel=[[CopositivePolynomial]]&amp;lt;br /&amp;gt;[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialOptimize]]&lt;br /&gt;
|req=[http://cvxr.com/cvx/ CVX]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 5, 2023&lt;br /&gt;
|cvx=yes}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;PolynomialSOS&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes upper and lower bounds on the optimum (i.e., maximum or minimum) value of an even-degree homogeneous polynomial on the unit sphere. That is, given an even-degree n-variable homogeneous polynomial p, this function bounds the (very difficult to compute in general) quantity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\max\big\{ p(x_1,x_2,\ldots,x_n) : x_1^2 + x_2^2 + \cdots + x_n^2 = 1 \big\},&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or the corresponding minimization problem. This function makes use of the sum-of-squares hierarchy, which requires semidefinite programming and thus, for a given level of the hierarchy, is slower but more accurate than the &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialSOS(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialSOS(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialSOS(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialSOS(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
===Input arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt;: The polynomial, represented as a vector of coefficients of its monomials in lexicographic order.&lt;br /&gt;
* &amp;lt;tt&amp;gt;N&amp;lt;/tt&amp;gt;: The number of variables in the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;D&amp;lt;/tt&amp;gt;: Half the degree of the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;: A non-negative integer that specifies the level of the hierarchy that is used to compute the bound(s) on the optimal value. Larger values of K result in better bounds at the expense of increases memory usage and longer computation times.&lt;br /&gt;
* &amp;lt;tt&amp;gt;OPTTYPE&amp;lt;/tt&amp;gt; (optional, default &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt;): Either &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&#039;min&#039;&amp;lt;/tt&amp;gt;, indicating whether the polynomial should be maximized or minimized.&lt;br /&gt;
&lt;br /&gt;
===Output arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB&amp;lt;/tt&amp;gt;: An &amp;quot;outer&amp;quot; bound on the optimal value. If maximizing, this is an upper bound on the maximum; if minimizing, this is a lower bound on the minimum.&lt;br /&gt;
* &amp;lt;tt&amp;gt;IB&amp;lt;/tt&amp;gt;: An &amp;quot;inner&amp;quot; bound on the optimal value. If maximizing, this is a lower bound on the maximum; if minimizing, this is an upper bound on the minimum.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Motzkin polynomial===&lt;br /&gt;
The Motzkin polynomial is the following degree-6 homogeneous polynomial: &amp;lt;math&amp;gt;p(x,y,z) = x^4y^2 + x^2y^4 - 3x^2y^2z^2 + z^6&amp;lt;/math&amp;gt;. We can load this polynomial into a list-of-coefficients form that &amp;lt;tt&amp;gt;PolynomialOptimize&amp;lt;/tt&amp;gt; understands via the &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt; helper function:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 3;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; p = zeros(nchoosek(n+2*d-1,2*d),1);% initialize p to have the correct size&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([4 2 0])) = 1;% the &amp;quot;4 2 0&amp;quot; here are the exponents in the term x^4y^2z^0, while the &amp;quot;1&amp;quot; is the coefficient of this term&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 4 0])) = 1;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 2 2])) = -3;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([0 0 6])) = 1;% now p represents the Motzkin polynomial&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Motzkin polynomial, despite the fact that it cannot be written as a sum of squares, is non-negative. The &amp;lt;tt&amp;gt;K = 0&amp;lt;/tt&amp;gt; level of this function verifies that p cannot be written as a sum of squares (if it could, the following code would return a non-negative answer):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialSOS(p,n,d,0,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.0046&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can verify that the Motzkin polynomial is non-negative by increasing the value of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; (i.e., the level of the hierarchy):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialSOS(p,n,d,1,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   6.1270e-12&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the true minimum value of this polynomial on the unit sphere is 0, for this polynomial higher levels of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; will not improve the lower bound (we already got the exact answer, within numerical precision). However, we can get better and better upper bounds by increasing &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialSOS(p,n,d,2,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   5.9776e-12&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    7.0050e-09&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialSOS(p,n,d,3,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   1.2217e-11&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    3.8579e-09&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the inner bounds are computed by an algorithm that includes some randomness, so when you run the code above you might get different inner bounds.&lt;br /&gt;
&lt;br /&gt;
===Usable within CVX===&lt;br /&gt;
This function is CVX-friendly, meaning that when running in &amp;lt;tt&amp;gt;&#039;min&#039;&amp;lt;/tt&amp;gt; mode you can use it in CVX as you would any other concave function, and when running in &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt; mode you can use it in CVX as you would any other convex function. For example, the following semidefinite program in CVX shows that, for 3-variable degree-6 homogeneous polynomials p that can be written as a sum of squares and have their ?? coefficients equal to 1, the minimal coefficient of the &amp;lt;math&amp;gt;x^2y^2z^2&amp;lt;/math&amp;gt; term is -9:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; cvx_begin sdp quiet&lt;br /&gt;
&amp;gt;&amp;gt;     cvx_precision best;&lt;br /&gt;
&amp;gt;&amp;gt;     variable x(28,1)&lt;br /&gt;
&amp;gt;&amp;gt;     minimize x(exp2ind([2 2 2]))&lt;br /&gt;
&amp;gt;&amp;gt;     subject to&lt;br /&gt;
&amp;gt;&amp;gt;         PolynomialSOS(x,3,3,0,&#039;min&#039;) &amp;gt;= 0;&lt;br /&gt;
&amp;gt;&amp;gt;         x(exp2ind([6 0 0])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         x(exp2ind([0 6 0])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         x(exp2ind([0 0 6])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         x(exp2ind([4 2 0])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         x(exp2ind([2 4 0])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         x(exp2ind([4 0 2])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         x(exp2ind([2 0 4])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         x(exp2ind([0 2 4])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt;         x(exp2ind([0 4 2])) == 1;&lt;br /&gt;
&amp;gt;&amp;gt; cvx_end&lt;br /&gt;
&amp;gt;&amp;gt; cvx_optval&lt;br /&gt;
&lt;br /&gt;
cvx_optval =&lt;br /&gt;
&lt;br /&gt;
   -9.0000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=PolynomialSOS}}&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
* The inner bounds, even though they are somewhat random, do (deterministically) converge to the true optimal value of the polynomial as K approaches infinity.&lt;br /&gt;
* If &amp;lt;tt&amp;gt;K = 0&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;OPTTYPE = &#039;min&#039;&amp;lt;/tt&amp;gt; then the output of this function is non-negative if and only if &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt; can be written as a sum of squares of polynomials.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=PolynomialSOS&amp;diff=36032</id>
		<title>PolynomialSOS</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=PolynomialSOS&amp;diff=36032"/>
		<updated>2023-08-05T23:24:12Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Can now be used within CVX&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=PolynomialSOS&lt;br /&gt;
|desc=Bounds the optimal value of a homogeneous polynomial on the unit sphere via the Sum-Of-Squares hierarchy&lt;br /&gt;
|rel=[[CopositivePolynomial]]&amp;lt;br /&amp;gt;[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialOptimize]]&lt;br /&gt;
|req=[http://cvxr.com/cvx/ CVX]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 5, 2023&lt;br /&gt;
|cvx=yes}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;PolynomialSOS&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes upper and lower bounds on the optimum (i.e., maximum or minimum) value of an even-degree homogeneous polynomial on the unit sphere. That is, given an even-degree n-variable homogeneous polynomial p, this function bounds the (very difficult to compute in general) quantity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\max\big\{ p(x_1,x_2,\ldots,x_n) : x_1^2 + x_2^2 + \cdots + x_n^2 = 1 \big\},&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or the corresponding minimization problem. This function makes use of the sum-of-squares hierarchy, which requires semidefinite programming and thus, for a given level of the hierarchy, is slower but more accurate than the &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialSOS(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialSOS(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialSOS(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialSOS(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
===Input arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt;: The polynomial, represented as a vector of coefficients of its monomials in lexicographic order.&lt;br /&gt;
* &amp;lt;tt&amp;gt;N&amp;lt;/tt&amp;gt;: The number of variables in the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;D&amp;lt;/tt&amp;gt;: Half the degree of the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;: A non-negative integer that specifies the level of the hierarchy that is used to compute the bound(s) on the optimal value. Larger values of K result in better bounds at the expense of increases memory usage and longer computation times.&lt;br /&gt;
* &amp;lt;tt&amp;gt;OPTTYPE&amp;lt;/tt&amp;gt; (optional, default &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt;): Either &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&#039;min&#039;&amp;lt;/tt&amp;gt;, indicating whether the polynomial should be maximized or minimized.&lt;br /&gt;
&lt;br /&gt;
===Output arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB&amp;lt;/tt&amp;gt;: An &amp;quot;outer&amp;quot; bound on the optimal value. If maximizing, this is an upper bound on the maximum; if minimizing, this is a lower bound on the minimum.&lt;br /&gt;
* &amp;lt;tt&amp;gt;IB&amp;lt;/tt&amp;gt;: An &amp;quot;inner&amp;quot; bound on the optimal value. If maximizing, this is a lower bound on the maximum; if minimizing, this is an upper bound on the minimum.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Motzkin polynomial===&lt;br /&gt;
The Motzkin polynomial is the following degree-6 homogeneous polynomial: &amp;lt;math&amp;gt;p(x,y,z) = x^4y^2 + x^2y^4 - 3x^2y^2z^2 + z^6&amp;lt;/math&amp;gt;. We can load this polynomial into a list-of-coefficients form that &amp;lt;tt&amp;gt;PolynomialOptimize&amp;lt;/tt&amp;gt; understands via the &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt; helper function:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 3;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; p = zeros(nchoosek(n+2*d-1,2*d),1);% initialize p to have the correct size&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([4 2 0])) = 1;% the &amp;quot;4 2 0&amp;quot; here are the exponents in the term x^4y^2z^0, while the &amp;quot;1&amp;quot; is the coefficient of this term&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 4 0])) = 1;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 2 2])) = -3;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([0 0 6])) = 1;% now p represents the Motzkin polynomial&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Motzkin polynomial, despite the fact that it cannot be written as a sum of squares, is non-negative. The &amp;lt;tt&amp;gt;K = 0&amp;lt;/tt&amp;gt; level of this function verifies that p cannot be written as a sum of squares (if it could, the following code would return a non-negative answer):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialSOS(p,n,d,0,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.0046&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can verify that the Motzkin polynomial is non-negative by increasing the value of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; (i.e., the level of the hierarchy):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialSOS(p,n,d,1,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   6.1270e-12&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the true minimum value of this polynomial on the unit sphere is 0, for this polynomial higher levels of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; will not improve the lower bound (we already got the exact answer, within numerical precision). However, we can get better and better upper bounds by increasing &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialSOS(p,n,d,2,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   5.9776e-12&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    7.0050e-09&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialSOS(p,n,d,3,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   1.2217e-11&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    3.8579e-09&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the inner bounds are computed by an algorithm that includes some randomness, so when you run the code above you might get different inner bounds.&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=PolynomialSOS}}&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
The inner bounds, even though they are somewhat random, do (deterministically) converge to the true optimal value of the polynomial as K approaches infinity.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=PolynomialAsMatrix&amp;diff=36031</id>
		<title>PolynomialAsMatrix</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=PolynomialAsMatrix&amp;diff=36031"/>
		<updated>2023-08-05T17:52:31Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: now CVX-friendly&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=PolynomialAsMatrix&lt;br /&gt;
|desc=Creates a compact fully symmetric matrix representation of a polynomial&lt;br /&gt;
|rel=[[CopositivePolynomial]]&amp;lt;br /&amp;gt;[[PolynomialOptimize]]&amp;lt;br /&amp;gt;[[PolynomialSOS]]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 5, 2023&lt;br /&gt;
|cvx=yes}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;PolynomialAsMatrix&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes a compact form of a fully symmetric matrix representation of an even-degree homogeneous polynomial. More specifically, if p is a homogeneous polynomial of degree 2d then there is a unique fully symmetric matrix &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; with the property that &amp;lt;math&amp;gt;p(x_1,x_2,\ldots,x_n) = (\mathbf{x}^{\otimes d})^T M(\mathbf{x}^{\otimes d})&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;\mathbf{x} = (x_1,x_2,\ldots,x_n)&amp;lt;/math&amp;gt; as a column vector. Here, &amp;quot;fully symmetric&amp;quot; means that &amp;lt;math&amp;gt;M^T = M&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; is supported on the [[symmetric subspace]] (i.e., &amp;lt;math&amp;gt;PMP = M&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt; is the [[SymmetricProjection|symmetric projection]]), and &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; equals its own [[PartialTranspose|partial transpose]] (across any bipartition).&lt;br /&gt;
&lt;br /&gt;
This function returns this fully symmetric matrix &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt;, in symmetric coordinates. That is, there is an isometry &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; from the symmetric subspace of &amp;lt;math&amp;gt;(\mathbb{C}^n)^{\otimes d}&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;(\mathbb{C}^n)^{\otimes d}&amp;lt;/math&amp;gt; itself with the property that the output of this function equals &amp;lt;math&amp;gt;V^*MV&amp;lt;/math&amp;gt;. This isometry &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; is computed by &amp;lt;tt&amp;gt;[[SymmetricProjection]](N,D,1,0)&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;M = PolynomialAsMatrix(P,N,D)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;M = PolynomialAsMatrix(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
* &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt;: The polynomial, represented as a vector of coefficients of its monomials in lexicographic order.&lt;br /&gt;
* &amp;lt;tt&amp;gt;N&amp;lt;/tt&amp;gt;: The number of variables in the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;D&amp;lt;/tt&amp;gt;: Half the degree of the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; (optional, default 0): A non-negative integer that indicates the level of the SOS or SOS-type hierarchy. More specifically, this input argument causes the output matrix to represent the polynomial (S(x))^K * P(x) instead of P(x) itself, where S(x) = x1^2 + x2^2 + ... + xN^2.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===A simple low-degree polynomial===&lt;br /&gt;
Let&#039;s turn the homogeneous polynomial &amp;lt;math&amp;gt;p(x,y,z) = x^2 + 2xy + 3xz + 4y^2 + 5yz + 6z^2&amp;lt;/math&amp;gt; into its fully symmetric matrix representation.&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 1;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; p = [1;2;3;4;5;6];% coefficients of the polynomial, in lexicographical order of the monomials&lt;br /&gt;
&amp;gt;&amp;gt; M = full(PolynomialAsMatrix(p,n,d))&lt;br /&gt;
&lt;br /&gt;
M =&lt;br /&gt;
&lt;br /&gt;
    1.0000    1.0000    1.5000&lt;br /&gt;
    1.0000    4.0000    2.5000&lt;br /&gt;
    1.5000    2.5000    6.0000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The output of this function is always sparse, so we used the &amp;lt;tt&amp;gt;full&amp;lt;/tt&amp;gt; function around the output above just to make the output easier to see. Since &amp;lt;math&amp;gt;d = 1&amp;lt;/math&amp;gt;, the above matrix is the usual symmetric matrix representation of the quadratric form &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. The following verification of this fact requires MATLAB&#039;s symbolic toolbox:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; syms x y z&lt;br /&gt;
&amp;gt;&amp;gt; expand([x y z]*M*[x;y;z])&lt;br /&gt;
 &lt;br /&gt;
ans =&lt;br /&gt;
 &lt;br /&gt;
x^2 + 2*x*y + 3*x*z + 4*y^2 + 5*y*z + 6*z^2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===The Motzkin polynomial===&lt;br /&gt;
The Motzkin polynomial is the following degree-6 homogeneous polynomial: &amp;lt;math&amp;gt;p(x,y,z) = x^4y^2 + x^2y^4 - 3x^2y^2z^2 + z^6&amp;lt;/math&amp;gt;. To use this &amp;lt;tt&amp;gt;PolynomialAsMatrix&amp;lt;/tt&amp;gt; function, we have to first arrange the monomials of p (even the ones with coefficient 0) in lexicographical order and list them in a vector. To make this task (much!) easier, we use the &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt; helper function:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 3;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; p = zeros(nchoosek(n+2*d-1,2*d),1);% initialize p to have the correct size&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([4 2 0])) = 1;% the &amp;quot;4 2 0&amp;quot; here are the exponents in the term x^4y^2z^0, while the &amp;quot;1&amp;quot; is the coefficient of this term&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 4 0])) = 1;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 2 2])) = -3;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([0 0 6])) = 1;% now p represents the Motzkin polynomial&lt;br /&gt;
&amp;gt;&amp;gt; M = full(PolynomialAsMatrix(p,n,d))&lt;br /&gt;
&lt;br /&gt;
M =&lt;br /&gt;
&lt;br /&gt;
         0         0         0    0.1155         0         0         0         0         0         0&lt;br /&gt;
         0    0.2000         0         0         0         0    0.1155         0   -0.1000         0&lt;br /&gt;
         0         0         0         0         0         0         0   -0.1000         0         0&lt;br /&gt;
    0.1155         0         0    0.2000         0   -0.1000         0         0         0         0&lt;br /&gt;
         0         0         0         0   -0.2000         0         0         0         0         0&lt;br /&gt;
         0         0         0   -0.1000         0         0         0         0         0         0&lt;br /&gt;
         0    0.1155         0         0         0         0         0         0         0         0&lt;br /&gt;
         0         0   -0.1000         0         0         0         0         0         0         0&lt;br /&gt;
         0   -0.1000         0         0         0         0         0         0         0         0&lt;br /&gt;
         0         0         0         0         0         0         0         0         0    1.0000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output of this function is always sparse, so we used the &amp;lt;tt&amp;gt;full&amp;lt;/tt&amp;gt; function around the output above just to make the output easier to see. When &amp;lt;math&amp;gt;d &amp;gt; 1&amp;lt;/math&amp;gt; (like in this example), we can verify that the above matrix represents the given polynomial via the isometry created by the [[SymmetricProjection]] function. The following verification of this fact requires MATLAB&#039;s symbolic toolbox:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; P = SymmetricProjection(n,d,1,0);&lt;br /&gt;
&amp;gt;&amp;gt; MF = P*M*P&#039;;&lt;br /&gt;
&amp;gt;&amp;gt; syms x y z&lt;br /&gt;
&amp;gt;&amp;gt; v = [x;y;z];&lt;br /&gt;
&amp;gt;&amp;gt; expand(Tensor(v,3).&#039;*MF*Tensor(v,3))&lt;br /&gt;
 &lt;br /&gt;
ans =&lt;br /&gt;
 &lt;br /&gt;
x^4*y^2 + x^2*y^4 - 3*x^2*y^2*z^2 + z^6&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=PolynomialAsMatrix}}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=Entropy&amp;diff=36030</id>
		<title>Entropy</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=Entropy&amp;diff=36030"/>
		<updated>2023-08-04T16:59:44Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Fix latex-isms&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=Entropy&lt;br /&gt;
|desc=Computes the von Neumann or Rényi entropy of a density matrix&lt;br /&gt;
|cat=[[List of functions#Information_theory|Information theory]]&lt;br /&gt;
|upd=November 27, 2014}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;Entropy&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes the von Neumann entropy or Rényi entropy of a density matrix. That is, given a density matrix $\rho$, it computes the following quantity:&lt;br /&gt;
&lt;br /&gt;
: &amp;lt;math&amp;gt;S(\rho) := -\mathrm{Tr}\big(\rho\log_2(\rho)\big)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(i.e., the von Neumann entropy) or the following quantity:&lt;br /&gt;
&lt;br /&gt;
: &amp;lt;math&amp;gt;S_\alpha(\rho) := \frac{1}{1-\alpha}\log_2\big(\mathrm{Tr}(\rho^\alpha)\big)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(i.e., the Rényi-&amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; entropy).&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;ENT = Entropy(RHO)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;ENT = Entropy(RHO,BASE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;ENT = Entropy(RHO,BASE,ALPHA)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
* &amp;lt;tt&amp;gt;RHO&amp;lt;/tt&amp;gt;: A density matrix to have its entropy computed.&lt;br /&gt;
* &amp;lt;tt&amp;gt;BASE&amp;lt;/tt&amp;gt; (optional, default 2): The base of the logarithm used in the entropy calculation.&lt;br /&gt;
* &amp;lt;tt&amp;gt;ALPHA&amp;lt;/tt&amp;gt; (optional, default 1): A non-negative real parameter that determines which entropy is computed (&amp;lt;tt&amp;gt;ALPHA = 1&amp;lt;/tt&amp;gt; corresponds to the von Neumann entropy, otherwise the Rényi-&amp;lt;tt&amp;gt;ALPHA&amp;lt;/tt&amp;gt; entropy is computed).&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The extreme cases: pure states and maximally-mixed states===&lt;br /&gt;
A pure state has entropy zero:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; Entropy(RandomDensityMatrix(4,0,1)) % entropy of a random 4-by-4 rank-1 density matrix&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   7.3396e-15 % silly numerical errors: this is effectively zero&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A d-by-d maximally-mixed state has entropy &amp;lt;math&amp;gt;\log_2(d)&amp;lt;/math&amp;gt;:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; Entropy(eye(4)/4)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
     2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All other states have entropy somewhere between these two extremes:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; Entropy(RandomDensityMatrix(4))&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
    1.6157&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
The Rényi-&amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; entropy approaches the von Neumann entropy as &amp;lt;math&amp;gt;\alpha \rightarrow 1&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=Entropy}}&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36029</id>
		<title>List of functions</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36029"/>
		<updated>2023-08-04T16:52:06Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Added Graph theory section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a &#039;&#039;&#039;list of functions&#039;&#039;&#039; provided by QETLAB, arranged by category. If you would prefer an alphabetical list of all functions please see [[:Category:Functions|this page]]. Brief descriptions of these functions are provided here, as well as links to their documentation pages, where full details and numerous examples can be found.&lt;br /&gt;
&lt;br /&gt;
==Basic operations==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPSD]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is positive semidefinite&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Tensor]]&amp;lt;/tt&amp;gt;: Kronecker tensor product of two or more matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TensorSum]]&amp;lt;/tt&amp;gt;: Computes a vector or operator from its tensor decomposition&lt;br /&gt;
&lt;br /&gt;
==Coherence and incoherence==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[L1NormCoherence]]&amp;lt;/tt&amp;gt;: Computes the ℓ&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;-norm of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RelEntCoherence]]&amp;lt;/tt&amp;gt;: Computes the relative entropy of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RobustnessCoherence]]&amp;lt;/tt&amp;gt;: Computes the robustness of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceDistanceCoherence]]&amp;lt;/tt&amp;gt;: Computes the trace distance of coherence of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Distinguishing objects==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChannelDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing two quantum channels&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Distinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[LocalDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states by symmetric-extendible and/or PPT measurements&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPBSepDistinguishable]]&amp;lt;/tt&amp;gt;: Determines whether or not an unextendible product basis is distinguishable by separable measurements&lt;br /&gt;
&lt;br /&gt;
==Entanglement and separability==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntangledSubspace]]&amp;lt;/tt&amp;gt;: Creates a basis of an r-entangled subspace of any requested dimension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductVector]]&amp;lt;/tt&amp;gt;: Determines if a pure state is a product vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the Schmidt decomposition of a bipartite vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the Schmidt rank of a bipartite vector&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FilterNormalForm]]&amp;lt;/tt&amp;gt;: Computes the filter normal form of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsBlockPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator is block positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsEntanglingGate]]&amp;lt;/tt&amp;gt;: Determines if a unitary is an entangling gate&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix has positive partial transpose&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductOperator]]&amp;lt;/tt&amp;gt;: Determines if an operator is an elementary tensor&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsSeparable]]&amp;lt;/tt&amp;gt;: Determines whether or not a bipartite operator is separable&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt decomposition of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt rank of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric extension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricInnerExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric inner extension&lt;br /&gt;
&lt;br /&gt;
===Ball of separability===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AbsPPTConstraints]]&amp;lt;/tt&amp;gt;: Builds the eigenvalue matrices that determine whether or not a state is absolutely PPT&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InSeparableBall]]&amp;lt;/tt&amp;gt;: Checks whether or not an operator is in the ball of separability centered at the maximally-mixed state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsAbsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a density matrix is absolutely PPT&lt;br /&gt;
&lt;br /&gt;
===Entanglement measures===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Concurrence]]&amp;lt;/tt&amp;gt;: Computes the concurrence of a 2-qubit state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntFormation]]&amp;lt;/tt&amp;gt;: Computes the entanglement of formation of a bipartite quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Negativity]]&amp;lt;/tt&amp;gt;: Computes the negativity of a bipartite density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomRobustnessEntanglement]]&amp;lt;/tt&amp;gt;: Computes the random robustness of entanglement of a bipartite quantum state&lt;br /&gt;
&lt;br /&gt;
==Graph theory==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CliqueNumber]]&amp;lt;/tt&amp;gt;: Bounds the clique number (i.e., maximum size of a clique) of a graph&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomGraph]]&amp;lt;/tt&amp;gt;: Generates the adjacency matrix of a random graph&lt;br /&gt;
&lt;br /&gt;
==Information theory==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Entropy]]&amp;lt;/tt&amp;gt;: Computes the von Neumann or Rényi entropy of a density matrix&lt;br /&gt;
&lt;br /&gt;
==Nonlocality and Bell inequalities==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a binary contraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameValue]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a binary constraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMax]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a Bell inequality or nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMaxQubits]]&amp;lt;/tt&amp;gt;: Approximates the optimal value of a Bell inequality in qubit (i.e., 2-dimensional quantum) settings&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NonlocalGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a non-local game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NPAHierarchy]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of probabilities satisfy the conditions of the NPA hierarchy&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ParallelRepetition]]&amp;lt;/tt&amp;gt;: Produces the coefficients of parallel repetitions of a nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[XORGameValue]]&amp;lt;/tt&amp;gt;: Computes the classical or quantum value of a non-local binary XOR game&lt;br /&gt;
&lt;br /&gt;
==Norms and distance measures==&lt;br /&gt;
===Vectors and pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkVectorNorm]]&amp;lt;/tt&amp;gt;: Computes the s(k)-norm of a vector&lt;br /&gt;
&lt;br /&gt;
===Operators and mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Fidelity]]&amp;lt;/tt&amp;gt;: Computes the (Uhlmann) fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedMatrixNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced p&amp;amp;rarr;q norm of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNorm]]&amp;lt;/tt&amp;gt;: Computes the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNormDual]]&amp;lt;/tt&amp;gt;: Computes the dual of the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KyFanNorm]]&amp;lt;/tt&amp;gt;: Computes the Ky Fan k-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MatsumotoFidelity]]&amp;lt;/tt&amp;gt;: Computes the Matsumoto fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkOperatorNorm]]&amp;lt;/tt&amp;gt;: Bounds the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchattenNorm]]&amp;lt;/tt&amp;gt;: Computes the Schatten p-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceNorm]]&amp;lt;/tt&amp;gt;: Computes the trace norm of an operator&lt;br /&gt;
&lt;br /&gt;
===Superoperators and channels===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CBNorm]]&amp;lt;/tt&amp;gt;: Computes the completely bounded norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DiamondNorm]]&amp;lt;/tt&amp;gt;: Computes the diamond norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedSchattenNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced Schatten p&amp;amp;rarr;q norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaximumOutputFidelity]]&amp;lt;/tt&amp;gt;: Computes the maximum output fidelity of two quantum channels&lt;br /&gt;
&lt;br /&gt;
==Permutations and symmetry of subsystems==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AntisymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the antisymmetric subspace&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermutationOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that permutes subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermuteSystems]]&amp;lt;/tt&amp;gt;: Permutes subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Swap]]&amp;lt;/tt&amp;gt;: Swaps two subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SwapOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that swaps two subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the symmetric subspace&lt;br /&gt;
&lt;br /&gt;
==Polynomial optimization==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CopositivePolynomial]]&amp;lt;/tt&amp;gt;: Creates a homogenous polynomial whose non-negativity is equivalent to copositivity of a given matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialAsMatrix]]&amp;lt;/tt&amp;gt;: Creates a compact fully symmetric matrix representation of a polynomial&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt;: Bounds the optimal value of a homogeneous polynomial on the unit sphere&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialSOS]]&amp;lt;/tt&amp;gt;: Bounds the optimal value of a homogeneous polynomial on the unit sphere via the Sum-Of-Squares hierarchy&lt;br /&gt;
&lt;br /&gt;
==Random things==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomDensityMatrix]]&amp;lt;/tt&amp;gt;: Generates a random density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPOVM]]&amp;lt;/tt&amp;gt;: Generates a random POVM (positive-operator valued measure)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPPTState]]&amp;lt;/tt&amp;gt;: Generates a random density matrix with positive partial transpose, and optionally low rank&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomProbabilities]]&amp;lt;/tt&amp;gt;: Computes a random probability vector, distributed uniformly on the unit simplex&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomStateVector]]&amp;lt;/tt&amp;gt;: Generates a random pure state vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomSuperoperator]]&amp;lt;/tt&amp;gt;: Generates a random superoperator (completely positive map)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomUnitary]]&amp;lt;/tt&amp;gt;: Generates a random unitary or orthogonal matrix&lt;br /&gt;
&lt;br /&gt;
==Special states, vectors, and operators==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Bell]]&amp;lt;/tt&amp;gt;: Produces a Bell state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BrauerStates]]&amp;lt;/tt&amp;gt;: Produces all Brauer states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DickeState]]&amp;lt;/tt&amp;gt;: Generates a Dicke state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GHZState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) GHZ state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaxEntangled]]&amp;lt;/tt&amp;gt;: Produces a maximally entangled bipartite pure state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) W-state&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BreuerState]]&amp;lt;/tt&amp;gt;: Generates a Breuer state, which is a specific family of bound entangled states on even local dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChessboardState]]&amp;lt;/tt&amp;gt;: Produces a chessboard state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GisinState]]&amp;lt;/tt&amp;gt;: Generates a 2-qubit Gisin state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[HorodeckiState]]&amp;lt;/tt&amp;gt;: Generates a bound entangled &amp;quot;Horodecki&amp;quot; state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsotropicState]]&amp;lt;/tt&amp;gt;: Produces an isotropic state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WernerState]]&amp;lt;/tt&amp;gt;: Produces a Werner state&lt;br /&gt;
&lt;br /&gt;
===Other operators===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FourierMatrix]]&amp;lt;/tt&amp;gt;: Generates the unitary matrix that implements the quantum Fourier transform&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GellMann]]&amp;lt;/tt&amp;gt;: Produces a Gell-Mann operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenGellMann]]&amp;lt;/tt&amp;gt;: Produces a generalized Gell-Mann operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenPauli]]&amp;lt;/tt&amp;gt;: Produces a generalized Pauli operator (sometimes called a Weyl operator)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Pauli]]&amp;lt;/tt&amp;gt;: Produces a Pauli operator&lt;br /&gt;
&lt;br /&gt;
==Superoperators==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ApplyMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMatrix]]&amp;lt;/tt&amp;gt;: Computes the Choi matrix of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMap]]&amp;lt;/tt&amp;gt;: Produces the Choi map or one of its generalizations&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ComplementaryMap]]&amp;lt;/tt&amp;gt;: Computes the complementary map of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DephasingChannel]]&amp;lt;/tt&amp;gt;: Produces a dephasing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DepolarizingChannel]]&amp;lt;/tt&amp;gt;: Produces a depolarizing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DualMap]]&amp;lt;/tt&amp;gt;: Computes the dual of a superoperator in the Hilbert-Schmidt inner product&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsCP]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is completely positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsHermPreserving]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is Hermiticity preserving&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KrausOperators]]&amp;lt;/tt&amp;gt;: Computes a set of Kraus operators for a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to a subsystem of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTrace]]&amp;lt;/tt&amp;gt;: Computes the partial trace of a vector or a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTranspose]]&amp;lt;/tt&amp;gt;: Computes the partial transpose of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PauliChannel]]&amp;lt;/tt&amp;gt;: Generates a Pauli channel (i.e., a quantum channel with Pauli Kraus operators)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Realignment]]&amp;lt;/tt&amp;gt;: Computes the realignment of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ReductionMap]]&amp;lt;/tt&amp;gt;: Produces the reduction map&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Twirl]]&amp;lt;/tt&amp;gt;: Twirls a bipartite or multipartite operator&lt;br /&gt;
&lt;br /&gt;
==Unextendible product bases==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsUPB]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of product vectors form a UPB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MinUPBSize]]&amp;lt;/tt&amp;gt;: Gives the minimum cardinality of an unextendible product basis in given dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPB]]&amp;lt;/tt&amp;gt;: Generates an unextendible product basis&lt;br /&gt;
&lt;br /&gt;
==Miscellaneous==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Commutant]]&amp;lt;/tt&amp;gt;: Computes the commutant of a set of matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyNonsingular]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally nonsingular&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Majorizes]]&amp;lt;/tt&amp;gt;: Determines whether or not a vector or matrix majorizes another&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSinkhorn]]&amp;lt;/tt&amp;gt;: Performs the operator Sinkhorn iteration, making all single-party reduced states proportional to the identity&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Purity]]&amp;lt;/tt&amp;gt;: Computes the purity of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Helper functions==&lt;br /&gt;
These are functions that only serve auxiliary roles within other functions of QETLAB. As an end-user of QETLAB, you likely won&#039;t have any use for these functions, but they are listed here anyway just in case.&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[bcs_to_nonlocal]]&amp;lt;/tt&amp;gt;: Converts a constraint description of a binary constraint system (BCS) game to a general non-local game description&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[dec_to_bin]]&amp;lt;/tt&amp;gt;: Converts a decimal number to a binary number in a similar way to `de2bi&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt;: Looks up a monomial&#039;s lexicographical index based on a list of exponents&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[iden]]&amp;lt;/tt&amp;gt;: Computes a sparse or full identity matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[jacobi_poly]]&amp;lt;/tt&amp;gt;: Computes the coefficients of Jacobi polynomials&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[normalize_cols]]&amp;lt;/tt&amp;gt;: Scales the columns of a matrix to have norm 1&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[one_factorization]]&amp;lt;/tt&amp;gt;: Computes a 1-factorization of a list of objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_args]]&amp;lt;/tt&amp;gt;: Handles optional input arguments for functions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_disp]]&amp;lt;/tt&amp;gt;: Display a message to the user (sometimes)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pad_array]]&amp;lt;/tt&amp;gt;: Pads an array with zeroes in a similar way to `padarray&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perfect_matchings]]&amp;lt;/tt&amp;gt;: Gives all perfect matchings of N objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_inv]]&amp;lt;/tt&amp;gt;: Computes the inverse of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_sign]]&amp;lt;/tt&amp;gt;: Computes the sign of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pure_to_mixed]]&amp;lt;/tt&amp;gt;: Converts a state vector or density matrix representation of a state to a density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sk_iterate]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[spnull]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the null space&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sporth]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the range&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[superoperator_dims]]&amp;lt;/tt&amp;gt;: Computes the input, output, and environment dimensions of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[update_odometer]]&amp;lt;/tt&amp;gt;: Increases the entries of a vector subject to constraints on how large the entries of that vector can be&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[vec_partitions]]&amp;lt;/tt&amp;gt;: Produces all possible partitions of a vector&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=PolynomialSOS&amp;diff=36028</id>
		<title>PolynomialSOS</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=PolynomialSOS&amp;diff=36028"/>
		<updated>2023-08-03T16:08:12Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Updated in light of random inner bounds modification to the code&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=PolynomialSOS&lt;br /&gt;
|desc=Bounds the optimal value of a homogeneous polynomial on the unit sphere via the Sum-Of-Squares hierarchy&lt;br /&gt;
|rel=[[CopositivePolynomial]]&amp;lt;br /&amp;gt;[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialOptimize]]&lt;br /&gt;
|req=[http://cvxr.com/cvx/ CVX]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 1, 2023&lt;br /&gt;
|cvx=no}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;PolynomialSOS&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes upper and lower bounds on the optimum (i.e., maximum or minimum) value of an even-degree homogeneous polynomial on the unit sphere. That is, given an even-degree n-variable homogeneous polynomial p, this function bounds the (very difficult to compute in general) quantity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\max\big\{ p(x_1,x_2,\ldots,x_n) : x_1^2 + x_2^2 + \cdots + x_n^2 = 1 \big\},&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or the corresponding minimization problem. This function makes use of the sum-of-squares hierarchy, which requires semidefinite programming and thus, for a given level of the hierarchy, is slower but more accurate than the &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialSOS(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialSOS(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialSOS(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialSOS(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
===Input arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt;: The polynomial, represented as a vector of coefficients of its monomials in lexicographic order.&lt;br /&gt;
* &amp;lt;tt&amp;gt;N&amp;lt;/tt&amp;gt;: The number of variables in the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;D&amp;lt;/tt&amp;gt;: Half the degree of the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;: A non-negative integer that specifies the level of the hierarchy that is used to compute the bound(s) on the optimal value. Larger values of K result in better bounds at the expense of increases memory usage and longer computation times.&lt;br /&gt;
* &amp;lt;tt&amp;gt;OPTTYPE&amp;lt;/tt&amp;gt; (optional, default &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt;): Either &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&#039;min&#039;&amp;lt;/tt&amp;gt;, indicating whether the polynomial should be maximized or minimized.&lt;br /&gt;
&lt;br /&gt;
===Output arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB&amp;lt;/tt&amp;gt;: An &amp;quot;outer&amp;quot; bound on the optimal value. If maximizing, this is an upper bound on the maximum; if minimizing, this is a lower bound on the minimum.&lt;br /&gt;
* &amp;lt;tt&amp;gt;IB&amp;lt;/tt&amp;gt;: An &amp;quot;inner&amp;quot; bound on the optimal value. If maximizing, this is a lower bound on the maximum; if minimizing, this is an upper bound on the minimum.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Motzkin polynomial===&lt;br /&gt;
The Motzkin polynomial is the following degree-6 homogeneous polynomial: &amp;lt;math&amp;gt;p(x,y,z) = x^4y^2 + x^2y^4 - 3x^2y^2z^2 + z^6&amp;lt;/math&amp;gt;. We can load this polynomial into a list-of-coefficients form that &amp;lt;tt&amp;gt;PolynomialOptimize&amp;lt;/tt&amp;gt; understands via the &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt; helper function:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 3;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; p = zeros(nchoosek(n+2*d-1,2*d),1);% initialize p to have the correct size&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([4 2 0])) = 1;% the &amp;quot;4 2 0&amp;quot; here are the exponents in the term x^4y^2z^0, while the &amp;quot;1&amp;quot; is the coefficient of this term&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 4 0])) = 1;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 2 2])) = -3;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([0 0 6])) = 1;% now p represents the Motzkin polynomial&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Motzkin polynomial, despite the fact that it cannot be written as a sum of squares, is non-negative. The &amp;lt;tt&amp;gt;K = 0&amp;lt;/tt&amp;gt; level of this function verifies that p cannot be written as a sum of squares (if it could, the following code would return a non-negative answer):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialSOS(p,n,d,0,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.0046&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can verify that the Motzkin polynomial is non-negative by increasing the value of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; (i.e., the level of the hierarchy):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialSOS(p,n,d,1,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   6.1270e-12&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the true minimum value of this polynomial on the unit sphere is 0, for this polynomial higher levels of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; will not improve the lower bound (we already got the exact answer, within numerical precision). However, we can get better and better upper bounds by increasing &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialSOS(p,n,d,2,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   5.9776e-12&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    7.0050e-09&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialSOS(p,n,d,3,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   1.2217e-11&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    3.8579e-09&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the inner bounds are computed by an algorithm that includes some randomness, so when you run the code above you might get different inner bounds.&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=PolynomialSOS}}&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
The inner bounds, even though they are somewhat random, do (deterministically) converge to the true optimal value of the polynomial as K approaches infinity.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=PolynomialOptimize&amp;diff=36027</id>
		<title>PolynomialOptimize</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=PolynomialOptimize&amp;diff=36027"/>
		<updated>2023-08-03T16:05:07Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Updated examples and notes in light of randomized improvement to inner bound&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=PolynomialOptimize&lt;br /&gt;
|desc=Bounds the optimal value of a homogeneous polynomial on the unit sphere&lt;br /&gt;
|rel=[[CopositivePolynomial]]&amp;lt;br /&amp;gt;[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialSOS]]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 1, 2023&lt;br /&gt;
|cvx=no}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;PolynomialOptimize&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes upper and lower bounds on the optimum (i.e., maximum or minimum) value of an even-degree homogeneous polynomial on the unit sphere. That is, given an even-degree n-variable homogeneous polynomial p, this function bounds the (very difficult to compute in general) quantity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\max\big\{ p(x_1,x_2,\ldots,x_n) : x_1^2 + x_2^2 + \cdots + x_n^2 = 1 \big\},&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or the corresponding minimization problem.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialOptimize(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialOptimize(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialOptimize(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialOptimize(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
===Input arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt;: The polynomial, represented as a vector of coefficients of its monomials in lexicographic order.&lt;br /&gt;
* &amp;lt;tt&amp;gt;N&amp;lt;/tt&amp;gt;: The number of variables in the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;D&amp;lt;/tt&amp;gt;: Half the degree of the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;: A non-negative integer that specifies the level of the hierarchy that is used to compute the bound(s) on the optimal value. Larger values of K result in better bounds at the expense of increases memory usage and longer computation times.&lt;br /&gt;
* &amp;lt;tt&amp;gt;OPTTYPE&amp;lt;/tt&amp;gt; (optional, default &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt;): Either &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&#039;min&#039;&amp;lt;/tt&amp;gt;, indicating whether the polynomial should be maximized or minimized.&lt;br /&gt;
&lt;br /&gt;
===Output arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB&amp;lt;/tt&amp;gt;: An &amp;quot;outer&amp;quot; bound on the optimal value. If maximizing, this is an upper bound on the maximum; if minimizing, this is a lower bound on the minimum.&lt;br /&gt;
* &amp;lt;tt&amp;gt;IB&amp;lt;/tt&amp;gt;: An &amp;quot;inner&amp;quot; bound on the optimal value. If maximizing, this is a lower bound on the maximum; if minimizing, this is an upper bound on the minimum.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Motzkin polynomial===&lt;br /&gt;
The Motzkin polynomial is the following degree-6 homogeneous polynomial: &amp;lt;math&amp;gt;p(x,y,z) = x^4y^2 + x^2y^4 - 3x^2y^2z^2 + z^6&amp;lt;/math&amp;gt;. We can load this polynomial into a list-of-coefficients form that &amp;lt;tt&amp;gt;PolynomialOptimize&amp;lt;/tt&amp;gt; understands via the &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt; helper function:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 3;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; p = zeros(nchoosek(n+2*d-1,2*d),1);% initialize p to have the correct size&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([4 2 0])) = 1;% the &amp;quot;4 2 0&amp;quot; here are the exponents in the term x^4y^2z^0, while the &amp;quot;1&amp;quot; is the coefficient of this term&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 4 0])) = 1;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 2 2])) = -3;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([0 0 6])) = 1;% now p represents the Motzkin polynomial&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Motzkin polynomial, despite the fact that it cannot be written as a sum of squares, is non-negative. In fact, the minimum value of this polynomial over the unit sphere is exactly 0. We can get lower bounds for the optimal value as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialOptimize(p,n,d,0,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.2000&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialOptimize(p,n,d,1,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.1104&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialOptimize(p,n,d,2,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.0780&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see above that increasing the value of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; (i.e., the level of the hierarchy) results in a better lower bound (i.e., a bound that is closer to the true minimum value of 0). This function is fast enough that we can go to a much higher level of the hierarchy, and we can also get upper bounds on this minimum value:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialOptimize(p,n,d,10,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   -0.0158&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    1.0333e-06&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialOptimize(p,n,d,100,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   -0.0017&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    1.5581e-09&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialOptimize(p,n,d,500,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
  -3.3898e-04&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    4.6048e-13&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, by the 500-th level of the hierarchy we have learned that the minimum value of the Motzkin polynomial is between &amp;lt;tt&amp;gt;-3.3898e-04&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;4.6048e-13&amp;lt;/tt&amp;gt;. Note that the inner bounds are computed by an algorithm that includes some randomness, so when you run the code above you might get different inner bounds.&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=PolynomialOptimize}}&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
The inner bounds, even though they are somewhat random, do (deterministically) converge to the true optimal value of the polynomial as &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; approaches infinity. &lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36026</id>
		<title>List of functions</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36026"/>
		<updated>2023-08-01T18:54:47Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: /* Polynomial optimization */ added PolynomialSOS&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a &#039;&#039;&#039;list of functions&#039;&#039;&#039; provided by QETLAB, arranged by category. If you would prefer an alphabetical list of all functions please see [[:Category:Functions|this page]]. Brief descriptions of these functions are provided here, as well as links to their documentation pages, where full details and numerous examples can be found.&lt;br /&gt;
&lt;br /&gt;
==Basic operations==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPSD]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is positive semidefinite&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Tensor]]&amp;lt;/tt&amp;gt;: Kronecker tensor product of two or more matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TensorSum]]&amp;lt;/tt&amp;gt;: Computes a vector or operator from its tensor decomposition&lt;br /&gt;
&lt;br /&gt;
==Coherence and incoherence==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[L1NormCoherence]]&amp;lt;/tt&amp;gt;: Computes the ℓ&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;-norm of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RelEntCoherence]]&amp;lt;/tt&amp;gt;: Computes the relative entropy of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RobustnessCoherence]]&amp;lt;/tt&amp;gt;: Computes the robustness of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceDistanceCoherence]]&amp;lt;/tt&amp;gt;: Computes the trace distance of coherence of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Distinguishing objects==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChannelDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing two quantum channels&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Distinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[LocalDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states by symmetric-extendible and/or PPT measurements&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPBSepDistinguishable]]&amp;lt;/tt&amp;gt;: Determines whether or not an unextendible product basis is distinguishable by separable measurements&lt;br /&gt;
&lt;br /&gt;
==Entanglement and separability==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntangledSubspace]]&amp;lt;/tt&amp;gt;: Creates a basis of an r-entangled subspace of any requested dimension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductVector]]&amp;lt;/tt&amp;gt;: Determines if a pure state is a product vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the Schmidt decomposition of a bipartite vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the Schmidt rank of a bipartite vector&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FilterNormalForm]]&amp;lt;/tt&amp;gt;: Computes the filter normal form of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsBlockPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator is block positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsEntanglingGate]]&amp;lt;/tt&amp;gt;: Determines if a unitary is an entangling gate&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix has positive partial transpose&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductOperator]]&amp;lt;/tt&amp;gt;: Determines if an operator is an elementary tensor&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsSeparable]]&amp;lt;/tt&amp;gt;: Determines whether or not a bipartite operator is separable&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt decomposition of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt rank of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric extension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricInnerExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric inner extension&lt;br /&gt;
&lt;br /&gt;
===Ball of separability===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AbsPPTConstraints]]&amp;lt;/tt&amp;gt;: Builds the eigenvalue matrices that determine whether or not a state is absolutely PPT&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InSeparableBall]]&amp;lt;/tt&amp;gt;: Checks whether or not an operator is in the ball of separability centered at the maximally-mixed state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsAbsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a density matrix is absolutely PPT&lt;br /&gt;
&lt;br /&gt;
===Entanglement measures===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Concurrence]]&amp;lt;/tt&amp;gt;: Computes the concurrence of a 2-qubit state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntFormation]]&amp;lt;/tt&amp;gt;: Computes the entanglement of formation of a bipartite quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Negativity]]&amp;lt;/tt&amp;gt;: Computes the negativity of a bipartite density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomRobustnessEntanglement]]&amp;lt;/tt&amp;gt;: Computes the random robustness of entanglement of a bipartite quantum state&lt;br /&gt;
&lt;br /&gt;
==Information theory==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Entropy]]&amp;lt;/tt&amp;gt;: Computes the von Neumann or Rényi entropy of a density matrix&lt;br /&gt;
&lt;br /&gt;
==Nonlocality and Bell inequalities==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a binary contraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameValue]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a binary constraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMax]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a Bell inequality or nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMaxQubits]]&amp;lt;/tt&amp;gt;: Approximates the optimal value of a Bell inequality in qubit (i.e., 2-dimensional quantum) settings&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NonlocalGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a non-local game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NPAHierarchy]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of probabilities satisfy the conditions of the NPA hierarchy&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ParallelRepetition]]&amp;lt;/tt&amp;gt;: Produces the coefficients of parallel repetitions of a nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[XORGameValue]]&amp;lt;/tt&amp;gt;: Computes the classical or quantum value of a non-local binary XOR game&lt;br /&gt;
&lt;br /&gt;
==Norms and distance measures==&lt;br /&gt;
===Vectors and pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkVectorNorm]]&amp;lt;/tt&amp;gt;: Computes the s(k)-norm of a vector&lt;br /&gt;
&lt;br /&gt;
===Operators and mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Fidelity]]&amp;lt;/tt&amp;gt;: Computes the (Uhlmann) fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedMatrixNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced p&amp;amp;rarr;q norm of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNorm]]&amp;lt;/tt&amp;gt;: Computes the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNormDual]]&amp;lt;/tt&amp;gt;: Computes the dual of the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KyFanNorm]]&amp;lt;/tt&amp;gt;: Computes the Ky Fan k-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MatsumotoFidelity]]&amp;lt;/tt&amp;gt;: Computes the Matsumoto fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkOperatorNorm]]&amp;lt;/tt&amp;gt;: Bounds the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchattenNorm]]&amp;lt;/tt&amp;gt;: Computes the Schatten p-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceNorm]]&amp;lt;/tt&amp;gt;: Computes the trace norm of an operator&lt;br /&gt;
&lt;br /&gt;
===Superoperators and channels===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CBNorm]]&amp;lt;/tt&amp;gt;: Computes the completely bounded norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DiamondNorm]]&amp;lt;/tt&amp;gt;: Computes the diamond norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedSchattenNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced Schatten p&amp;amp;rarr;q norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaximumOutputFidelity]]&amp;lt;/tt&amp;gt;: Computes the maximum output fidelity of two quantum channels&lt;br /&gt;
&lt;br /&gt;
==Permutations and symmetry of subsystems==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AntisymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the antisymmetric subspace&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermutationOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that permutes subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermuteSystems]]&amp;lt;/tt&amp;gt;: Permutes subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Swap]]&amp;lt;/tt&amp;gt;: Swaps two subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SwapOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that swaps two subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the symmetric subspace&lt;br /&gt;
&lt;br /&gt;
==Polynomial optimization==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CopositivePolynomial]]&amp;lt;/tt&amp;gt;: Creates a homogenous polynomial whose non-negativity is equivalent to copositivity of a given matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialAsMatrix]]&amp;lt;/tt&amp;gt;: Creates a compact fully symmetric matrix representation of a polynomial&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt;: Bounds the optimal value of a homogeneous polynomial on the unit sphere&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialSOS]]&amp;lt;/tt&amp;gt;: Bounds the optimal value of a homogeneous polynomial on the unit sphere via the Sum-Of-Squares hierarchy&lt;br /&gt;
&lt;br /&gt;
==Random things==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomDensityMatrix]]&amp;lt;/tt&amp;gt;: Generates a random density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPOVM]]&amp;lt;/tt&amp;gt;: Generates a random POVM (positive-operator valued measure)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPPTState]]&amp;lt;/tt&amp;gt;: Generates a random density matrix with positive partial transpose, and optionally low rank&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomProbabilities]]&amp;lt;/tt&amp;gt;: Computes a random probability vector, distributed uniformly on the unit simplex&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomStateVector]]&amp;lt;/tt&amp;gt;: Generates a random pure state vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomSuperoperator]]&amp;lt;/tt&amp;gt;: Generates a random superoperator (completely positive map)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomUnitary]]&amp;lt;/tt&amp;gt;: Generates a random unitary or orthogonal matrix&lt;br /&gt;
&lt;br /&gt;
==Special states, vectors, and operators==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Bell]]&amp;lt;/tt&amp;gt;: Produces a Bell state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BrauerStates]]&amp;lt;/tt&amp;gt;: Produces all Brauer states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DickeState]]&amp;lt;/tt&amp;gt;: Generates a Dicke state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GHZState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) GHZ state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaxEntangled]]&amp;lt;/tt&amp;gt;: Produces a maximally entangled bipartite pure state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) W-state&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BreuerState]]&amp;lt;/tt&amp;gt;: Generates a Breuer state, which is a specific family of bound entangled states on even local dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChessboardState]]&amp;lt;/tt&amp;gt;: Produces a chessboard state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GisinState]]&amp;lt;/tt&amp;gt;: Generates a 2-qubit Gisin state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[HorodeckiState]]&amp;lt;/tt&amp;gt;: Generates a bound entangled &amp;quot;Horodecki&amp;quot; state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsotropicState]]&amp;lt;/tt&amp;gt;: Produces an isotropic state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WernerState]]&amp;lt;/tt&amp;gt;: Produces a Werner state&lt;br /&gt;
&lt;br /&gt;
===Other operators===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FourierMatrix]]&amp;lt;/tt&amp;gt;: Generates the unitary matrix that implements the quantum Fourier transform&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GellMann]]&amp;lt;/tt&amp;gt;: Produces a Gell-Mann operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenGellMann]]&amp;lt;/tt&amp;gt;: Produces a generalized Gell-Mann operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenPauli]]&amp;lt;/tt&amp;gt;: Produces a generalized Pauli operator (sometimes called a Weyl operator)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Pauli]]&amp;lt;/tt&amp;gt;: Produces a Pauli operator&lt;br /&gt;
&lt;br /&gt;
==Superoperators==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ApplyMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMatrix]]&amp;lt;/tt&amp;gt;: Computes the Choi matrix of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMap]]&amp;lt;/tt&amp;gt;: Produces the Choi map or one of its generalizations&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ComplementaryMap]]&amp;lt;/tt&amp;gt;: Computes the complementary map of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DephasingChannel]]&amp;lt;/tt&amp;gt;: Produces a dephasing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DepolarizingChannel]]&amp;lt;/tt&amp;gt;: Produces a depolarizing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DualMap]]&amp;lt;/tt&amp;gt;: Computes the dual of a superoperator in the Hilbert-Schmidt inner product&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsCP]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is completely positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsHermPreserving]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is Hermiticity preserving&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KrausOperators]]&amp;lt;/tt&amp;gt;: Computes a set of Kraus operators for a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to a subsystem of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTrace]]&amp;lt;/tt&amp;gt;: Computes the partial trace of a vector or a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTranspose]]&amp;lt;/tt&amp;gt;: Computes the partial transpose of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PauliChannel]]&amp;lt;/tt&amp;gt;: Generates a Pauli channel (i.e., a quantum channel with Pauli Kraus operators)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Realignment]]&amp;lt;/tt&amp;gt;: Computes the realignment of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ReductionMap]]&amp;lt;/tt&amp;gt;: Produces the reduction map&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Twirl]]&amp;lt;/tt&amp;gt;: Twirls a bipartite or multipartite operator&lt;br /&gt;
&lt;br /&gt;
==Unextendible product bases==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsUPB]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of product vectors form a UPB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MinUPBSize]]&amp;lt;/tt&amp;gt;: Gives the minimum cardinality of an unextendible product basis in given dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPB]]&amp;lt;/tt&amp;gt;: Generates an unextendible product basis&lt;br /&gt;
&lt;br /&gt;
==Miscellaneous==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Commutant]]&amp;lt;/tt&amp;gt;: Computes the commutant of a set of matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyNonsingular]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally nonsingular&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Majorizes]]&amp;lt;/tt&amp;gt;: Determines whether or not a vector or matrix majorizes another&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSinkhorn]]&amp;lt;/tt&amp;gt;: Performs the operator Sinkhorn iteration, making all single-party reduced states proportional to the identity&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Purity]]&amp;lt;/tt&amp;gt;: Computes the purity of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Helper functions==&lt;br /&gt;
These are functions that only serve auxiliary roles within other functions of QETLAB. As an end-user of QETLAB, you likely won&#039;t have any use for these functions, but they are listed here anyway just in case.&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[bcs_to_nonlocal]]&amp;lt;/tt&amp;gt;: Converts a constraint description of a binary constraint system (BCS) game to a general non-local game description&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[dec_to_bin]]&amp;lt;/tt&amp;gt;: Converts a decimal number to a binary number in a similar way to `de2bi&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt;: Looks up a monomial&#039;s lexicographical index based on a list of exponents&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[iden]]&amp;lt;/tt&amp;gt;: Computes a sparse or full identity matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[jacobi_poly]]&amp;lt;/tt&amp;gt;: Computes the coefficients of Jacobi polynomials&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[normalize_cols]]&amp;lt;/tt&amp;gt;: Scales the columns of a matrix to have norm 1&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[one_factorization]]&amp;lt;/tt&amp;gt;: Computes a 1-factorization of a list of objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_args]]&amp;lt;/tt&amp;gt;: Handles optional input arguments for functions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_disp]]&amp;lt;/tt&amp;gt;: Display a message to the user (sometimes)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pad_array]]&amp;lt;/tt&amp;gt;: Pads an array with zeroes in a similar way to `padarray&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perfect_matchings]]&amp;lt;/tt&amp;gt;: Gives all perfect matchings of N objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_inv]]&amp;lt;/tt&amp;gt;: Computes the inverse of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_sign]]&amp;lt;/tt&amp;gt;: Computes the sign of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pure_to_mixed]]&amp;lt;/tt&amp;gt;: Converts a state vector or density matrix representation of a state to a density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sk_iterate]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[spnull]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the null space&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sporth]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the range&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[superoperator_dims]]&amp;lt;/tt&amp;gt;: Computes the input, output, and environment dimensions of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[update_odometer]]&amp;lt;/tt&amp;gt;: Increases the entries of a vector subject to constraints on how large the entries of that vector can be&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[vec_partitions]]&amp;lt;/tt&amp;gt;: Produces all possible partitions of a vector&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=PolynomialSOS&amp;diff=36025</id>
		<title>PolynomialSOS</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=PolynomialSOS&amp;diff=36025"/>
		<updated>2023-08-01T18:54:22Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Requires CVX&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=PolynomialSOS&lt;br /&gt;
|desc=Bounds the optimal value of a homogeneous polynomial on the unit sphere via the Sum-Of-Squares hierarchy&lt;br /&gt;
|rel=[[CopositivePolynomial]]&amp;lt;br /&amp;gt;[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialOptimize]]&lt;br /&gt;
|req=[http://cvxr.com/cvx/ CVX]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 1, 2023&lt;br /&gt;
|cvx=no}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;PolynomialSOS&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes upper and lower bounds on the optimum (i.e., maximum or minimum) value of an even-degree homogeneous polynomial on the unit sphere. That is, given an even-degree n-variable homogeneous polynomial p, this function bounds the (very difficult to compute in general) quantity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\max\big\{ p(x_1,x_2,\ldots,x_n) : x_1^2 + x_2^2 + \cdots + x_n^2 = 1 \big\},&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or the corresponding minimization problem. This function makes use of the sum-of-squares hierarchy, which requires semidefinite programming and thus, for a given level of the hierarchy, is slower but more accurate than the &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialSOS(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialSOS(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialSOS(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialSOS(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
===Input arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt;: The polynomial, represented as a vector of coefficients of its monomials in lexicographic order.&lt;br /&gt;
* &amp;lt;tt&amp;gt;N&amp;lt;/tt&amp;gt;: The number of variables in the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;D&amp;lt;/tt&amp;gt;: Half the degree of the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;: A non-negative integer that specifies the level of the hierarchy that is used to compute the bound(s) on the optimal value. Larger values of K result in better bounds at the expense of increases memory usage and longer computation times.&lt;br /&gt;
* &amp;lt;tt&amp;gt;OPTTYPE&amp;lt;/tt&amp;gt; (optional, default &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt;): Either &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&#039;min&#039;&amp;lt;/tt&amp;gt;, indicating whether the polynomial should be maximized or minimized.&lt;br /&gt;
&lt;br /&gt;
===Output arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB&amp;lt;/tt&amp;gt;: An &amp;quot;outer&amp;quot; bound on the optimal value. If maximizing, this is an upper bound on the maximum; if minimizing, this is a lower bound on the minimum.&lt;br /&gt;
* &amp;lt;tt&amp;gt;IB&amp;lt;/tt&amp;gt;: An &amp;quot;inner&amp;quot; bound on the optimal value. If maximizing, this is a lower bound on the maximum; if minimizing, this is an upper bound on the minimum.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Motzkin polynomial===&lt;br /&gt;
The Motzkin polynomial is the following degree-6 homogeneous polynomial: &amp;lt;math&amp;gt;p(x,y,z) = x^4y^2 + x^2y^4 - 3x^2y^2z^2 + z^6&amp;lt;/math&amp;gt;. We can load this polynomial into a list-of-coefficients form that &amp;lt;tt&amp;gt;PolynomialOptimize&amp;lt;/tt&amp;gt; understands via the &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt; helper function:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 3;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; p = zeros(nchoosek(n+2*d-1,2*d),1);% initialize p to have the correct size&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([4 2 0])) = 1;% the &amp;quot;4 2 0&amp;quot; here are the exponents in the term x^4y^2z^0, while the &amp;quot;1&amp;quot; is the coefficient of this term&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 4 0])) = 1;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 2 2])) = -3;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([0 0 6])) = 1;% now p represents the Motzkin polynomial&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Motzkin polynomial, despite the fact that it cannot be written as a sum of squares, is non-negative. The &amp;lt;tt&amp;gt;K = 0&amp;lt;/tt&amp;gt; level of this function verifies that p cannot be written as a sum of squares (if it could, the following code would return a non-negative answer):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialSOS(p,n,d,0,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.0046&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can verify that the Motzkin polynomial is non-negative by increasing the value of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; (i.e., the level of the hierarchy):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialSOS(p,n,d,1,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   6.1270e-12&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the true minimum value of this polynomial on the unit sphere is 0, for this polynomial higher levels of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; will not improve the lower bound (we already got the exact answer, within numerical precision). However, we can get better and better upper bounds by increasing &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialSOS(p,n,d,2,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   5.9776e-12&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    4.0000&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialSOS(p,n,d,3,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   1.2217e-11&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    3.4286&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get even better upper bounds, we would be better off using higher levels of the &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt; hierarchy.&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=PolynomialSOS}}&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
The outer bounds produced by this function are typically much better than the inner bounds.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=PolynomialSOS&amp;diff=36024</id>
		<title>PolynomialSOS</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=PolynomialSOS&amp;diff=36024"/>
		<updated>2023-08-01T18:53:54Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=PolynomialSOS&lt;br /&gt;
|desc=Bounds the optimal value of a homogeneous polynomial on the unit sphere via the Sum-Of-Squares hierarchy&lt;br /&gt;
|rel=[[CopositivePolynomial]]&amp;lt;br /&amp;gt;[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialOptimize]]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 1, 2023&lt;br /&gt;
|cvx=no}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;PolynomialSOS&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes upper and lower bounds on the optimum (i.e., maximum or minimum) value of an even-degree homogeneous polynomial on the unit sphere. That is, given an even-degree n-variable homogeneous polynomial p, this function bounds the (very difficult to compute in general) quantity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\max\big\{ p(x_1,x_2,\ldots,x_n) : x_1^2 + x_2^2 + \cdots + x_n^2 = 1 \big\},&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or the corresponding minimization problem. This function makes use of the sum-of-squares hierarchy, which requires semidefinite programming and thus, for a given level of the hierarchy, is slower but more accurate than the &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialSOS(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialSOS(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialSOS(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialSOS(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
===Input arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt;: The polynomial, represented as a vector of coefficients of its monomials in lexicographic order.&lt;br /&gt;
* &amp;lt;tt&amp;gt;N&amp;lt;/tt&amp;gt;: The number of variables in the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;D&amp;lt;/tt&amp;gt;: Half the degree of the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;: A non-negative integer that specifies the level of the hierarchy that is used to compute the bound(s) on the optimal value. Larger values of K result in better bounds at the expense of increases memory usage and longer computation times.&lt;br /&gt;
* &amp;lt;tt&amp;gt;OPTTYPE&amp;lt;/tt&amp;gt; (optional, default &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt;): Either &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&#039;min&#039;&amp;lt;/tt&amp;gt;, indicating whether the polynomial should be maximized or minimized.&lt;br /&gt;
&lt;br /&gt;
===Output arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB&amp;lt;/tt&amp;gt;: An &amp;quot;outer&amp;quot; bound on the optimal value. If maximizing, this is an upper bound on the maximum; if minimizing, this is a lower bound on the minimum.&lt;br /&gt;
* &amp;lt;tt&amp;gt;IB&amp;lt;/tt&amp;gt;: An &amp;quot;inner&amp;quot; bound on the optimal value. If maximizing, this is a lower bound on the maximum; if minimizing, this is an upper bound on the minimum.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Motzkin polynomial===&lt;br /&gt;
The Motzkin polynomial is the following degree-6 homogeneous polynomial: &amp;lt;math&amp;gt;p(x,y,z) = x^4y^2 + x^2y^4 - 3x^2y^2z^2 + z^6&amp;lt;/math&amp;gt;. We can load this polynomial into a list-of-coefficients form that &amp;lt;tt&amp;gt;PolynomialOptimize&amp;lt;/tt&amp;gt; understands via the &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt; helper function:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 3;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; p = zeros(nchoosek(n+2*d-1,2*d),1);% initialize p to have the correct size&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([4 2 0])) = 1;% the &amp;quot;4 2 0&amp;quot; here are the exponents in the term x^4y^2z^0, while the &amp;quot;1&amp;quot; is the coefficient of this term&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 4 0])) = 1;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 2 2])) = -3;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([0 0 6])) = 1;% now p represents the Motzkin polynomial&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Motzkin polynomial, despite the fact that it cannot be written as a sum of squares, is non-negative. The &amp;lt;tt&amp;gt;K = 0&amp;lt;/tt&amp;gt; level of this function verifies that p cannot be written as a sum of squares (if it could, the following code would return a non-negative answer):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialSOS(p,n,d,0,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.0046&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can verify that the Motzkin polynomial is non-negative by increasing the value of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; (i.e., the level of the hierarchy):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialSOS(p,n,d,1,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   6.1270e-12&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the true minimum value of this polynomial on the unit sphere is 0, for this polynomial higher levels of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; will not improve the lower bound (we already got the exact answer, within numerical precision). However, we can get better and better upper bounds by increasing &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialSOS(p,n,d,2,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   5.9776e-12&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    4.0000&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialSOS(p,n,d,3,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   1.2217e-11&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    3.4286&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get even better upper bounds, we would be better off using higher levels of the &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt; hierarchy.&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=PolynomialSOS}}&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
The outer bounds produced by this function are typically much better than the inner bounds.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=PolynomialSOS&amp;diff=36023</id>
		<title>PolynomialSOS</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=PolynomialSOS&amp;diff=36023"/>
		<updated>2023-08-01T18:53:17Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Started&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=PolynomialSOS&lt;br /&gt;
|desc=Bounds the optimal value of a homogeneous polynomial on the unit sphere via the Sum-Of-Squares hierarchy&lt;br /&gt;
|rel=[[CopositivePolynomial]]&amp;lt;br /&amp;gt;[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialOptimize]]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 1, 2023&lt;br /&gt;
|cvx=yes}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;PolynomialSOS&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes upper and lower bounds on the optimum (i.e., maximum or minimum) value of an even-degree homogeneous polynomial on the unit sphere. That is, given an even-degree n-variable homogeneous polynomial p, this function bounds the (very difficult to compute in general) quantity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\max\big\{ p(x_1,x_2,\ldots,x_n) : x_1^2 + x_2^2 + \cdots + x_n^2 = 1 \big\},&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or the corresponding minimization problem. This function makes use of the sum-of-squares hierarchy, which requires semidefinite programming and thus, for a given level of the hierarchy, is slower but more accurate than the &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt; function.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialSOS(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialSOS(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialSOS(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialSOS(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
===Input arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt;: The polynomial, represented as a vector of coefficients of its monomials in lexicographic order.&lt;br /&gt;
* &amp;lt;tt&amp;gt;N&amp;lt;/tt&amp;gt;: The number of variables in the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;D&amp;lt;/tt&amp;gt;: Half the degree of the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;: A non-negative integer that specifies the level of the hierarchy that is used to compute the bound(s) on the optimal value. Larger values of K result in better bounds at the expense of increases memory usage and longer computation times.&lt;br /&gt;
* &amp;lt;tt&amp;gt;OPTTYPE&amp;lt;/tt&amp;gt; (optional, default &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt;): Either &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&#039;min&#039;&amp;lt;/tt&amp;gt;, indicating whether the polynomial should be maximized or minimized.&lt;br /&gt;
&lt;br /&gt;
===Output arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB&amp;lt;/tt&amp;gt;: An &amp;quot;outer&amp;quot; bound on the optimal value. If maximizing, this is an upper bound on the maximum; if minimizing, this is a lower bound on the minimum.&lt;br /&gt;
* &amp;lt;tt&amp;gt;IB&amp;lt;/tt&amp;gt;: An &amp;quot;inner&amp;quot; bound on the optimal value. If maximizing, this is a lower bound on the maximum; if minimizing, this is an upper bound on the minimum.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Motzkin polynomial===&lt;br /&gt;
The Motzkin polynomial is the following degree-6 homogeneous polynomial: &amp;lt;math&amp;gt;p(x,y,z) = x^4y^2 + x^2y^4 - 3x^2y^2z^2 + z^6&amp;lt;/math&amp;gt;. We can load this polynomial into a list-of-coefficients form that &amp;lt;tt&amp;gt;PolynomialOptimize&amp;lt;/tt&amp;gt; understands via the &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt; helper function:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 3;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; p = zeros(nchoosek(n+2*d-1,2*d),1);% initialize p to have the correct size&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([4 2 0])) = 1;% the &amp;quot;4 2 0&amp;quot; here are the exponents in the term x^4y^2z^0, while the &amp;quot;1&amp;quot; is the coefficient of this term&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 4 0])) = 1;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 2 2])) = -3;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([0 0 6])) = 1;% now p represents the Motzkin polynomial&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Motzkin polynomial, despite the fact that it cannot be written as a sum of squares, is non-negative. The &amp;lt;tt&amp;gt;K = 0&amp;lt;/tt&amp;gt; level of this function verifies that p cannot be written as a sum of squares (if it could, the following code would return a non-negative answer):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialSOS(p,n,d,0,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.0046&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can verify that the Motzkin polynomial is non-negative by increasing the value of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; (i.e., the level of the hierarchy):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialSOS(p,n,d,1,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   6.1270e-12&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since the true minimum value of this polynomial on the unit sphere is 0, for this polynomial higher levels of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; will not improve the lower bound (we already got the exact answer, within numerical precision). However, we can get better and better upper bounds by increasing &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialSOS(p,n,d,2,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   5.9776e-12&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    4.0000&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialSOS(p,n,d,3,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   1.2217e-11&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    3.4286&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To get even better upper bounds, we would be better off using higher levels of the &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt; hierarchy.&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=PolynomialSOS}}&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
The outer bounds produced by this function are typically much better than the inner bounds.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36022</id>
		<title>List of functions</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36022"/>
		<updated>2023-08-01T18:28:02Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: /* Polynomial optimization */ fix link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a &#039;&#039;&#039;list of functions&#039;&#039;&#039; provided by QETLAB, arranged by category. If you would prefer an alphabetical list of all functions please see [[:Category:Functions|this page]]. Brief descriptions of these functions are provided here, as well as links to their documentation pages, where full details and numerous examples can be found.&lt;br /&gt;
&lt;br /&gt;
==Basic operations==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPSD]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is positive semidefinite&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Tensor]]&amp;lt;/tt&amp;gt;: Kronecker tensor product of two or more matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TensorSum]]&amp;lt;/tt&amp;gt;: Computes a vector or operator from its tensor decomposition&lt;br /&gt;
&lt;br /&gt;
==Coherence and incoherence==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[L1NormCoherence]]&amp;lt;/tt&amp;gt;: Computes the ℓ&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;-norm of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RelEntCoherence]]&amp;lt;/tt&amp;gt;: Computes the relative entropy of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RobustnessCoherence]]&amp;lt;/tt&amp;gt;: Computes the robustness of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceDistanceCoherence]]&amp;lt;/tt&amp;gt;: Computes the trace distance of coherence of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Distinguishing objects==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChannelDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing two quantum channels&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Distinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[LocalDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states by symmetric-extendible and/or PPT measurements&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPBSepDistinguishable]]&amp;lt;/tt&amp;gt;: Determines whether or not an unextendible product basis is distinguishable by separable measurements&lt;br /&gt;
&lt;br /&gt;
==Entanglement and separability==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntangledSubspace]]&amp;lt;/tt&amp;gt;: Creates a basis of an r-entangled subspace of any requested dimension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductVector]]&amp;lt;/tt&amp;gt;: Determines if a pure state is a product vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the Schmidt decomposition of a bipartite vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the Schmidt rank of a bipartite vector&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FilterNormalForm]]&amp;lt;/tt&amp;gt;: Computes the filter normal form of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsBlockPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator is block positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsEntanglingGate]]&amp;lt;/tt&amp;gt;: Determines if a unitary is an entangling gate&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix has positive partial transpose&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductOperator]]&amp;lt;/tt&amp;gt;: Determines if an operator is an elementary tensor&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsSeparable]]&amp;lt;/tt&amp;gt;: Determines whether or not a bipartite operator is separable&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt decomposition of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt rank of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric extension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricInnerExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric inner extension&lt;br /&gt;
&lt;br /&gt;
===Ball of separability===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AbsPPTConstraints]]&amp;lt;/tt&amp;gt;: Builds the eigenvalue matrices that determine whether or not a state is absolutely PPT&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InSeparableBall]]&amp;lt;/tt&amp;gt;: Checks whether or not an operator is in the ball of separability centered at the maximally-mixed state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsAbsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a density matrix is absolutely PPT&lt;br /&gt;
&lt;br /&gt;
===Entanglement measures===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Concurrence]]&amp;lt;/tt&amp;gt;: Computes the concurrence of a 2-qubit state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntFormation]]&amp;lt;/tt&amp;gt;: Computes the entanglement of formation of a bipartite quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Negativity]]&amp;lt;/tt&amp;gt;: Computes the negativity of a bipartite density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomRobustnessEntanglement]]&amp;lt;/tt&amp;gt;: Computes the random robustness of entanglement of a bipartite quantum state&lt;br /&gt;
&lt;br /&gt;
==Information theory==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Entropy]]&amp;lt;/tt&amp;gt;: Computes the von Neumann or Rényi entropy of a density matrix&lt;br /&gt;
&lt;br /&gt;
==Nonlocality and Bell inequalities==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a binary contraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameValue]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a binary constraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMax]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a Bell inequality or nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMaxQubits]]&amp;lt;/tt&amp;gt;: Approximates the optimal value of a Bell inequality in qubit (i.e., 2-dimensional quantum) settings&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NonlocalGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a non-local game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NPAHierarchy]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of probabilities satisfy the conditions of the NPA hierarchy&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ParallelRepetition]]&amp;lt;/tt&amp;gt;: Produces the coefficients of parallel repetitions of a nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[XORGameValue]]&amp;lt;/tt&amp;gt;: Computes the classical or quantum value of a non-local binary XOR game&lt;br /&gt;
&lt;br /&gt;
==Norms and distance measures==&lt;br /&gt;
===Vectors and pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkVectorNorm]]&amp;lt;/tt&amp;gt;: Computes the s(k)-norm of a vector&lt;br /&gt;
&lt;br /&gt;
===Operators and mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Fidelity]]&amp;lt;/tt&amp;gt;: Computes the (Uhlmann) fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedMatrixNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced p&amp;amp;rarr;q norm of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNorm]]&amp;lt;/tt&amp;gt;: Computes the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNormDual]]&amp;lt;/tt&amp;gt;: Computes the dual of the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KyFanNorm]]&amp;lt;/tt&amp;gt;: Computes the Ky Fan k-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MatsumotoFidelity]]&amp;lt;/tt&amp;gt;: Computes the Matsumoto fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkOperatorNorm]]&amp;lt;/tt&amp;gt;: Bounds the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchattenNorm]]&amp;lt;/tt&amp;gt;: Computes the Schatten p-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceNorm]]&amp;lt;/tt&amp;gt;: Computes the trace norm of an operator&lt;br /&gt;
&lt;br /&gt;
===Superoperators and channels===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CBNorm]]&amp;lt;/tt&amp;gt;: Computes the completely bounded norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DiamondNorm]]&amp;lt;/tt&amp;gt;: Computes the diamond norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedSchattenNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced Schatten p&amp;amp;rarr;q norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaximumOutputFidelity]]&amp;lt;/tt&amp;gt;: Computes the maximum output fidelity of two quantum channels&lt;br /&gt;
&lt;br /&gt;
==Permutations and symmetry of subsystems==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AntisymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the antisymmetric subspace&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermutationOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that permutes subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermuteSystems]]&amp;lt;/tt&amp;gt;: Permutes subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Swap]]&amp;lt;/tt&amp;gt;: Swaps two subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SwapOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that swaps two subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the symmetric subspace&lt;br /&gt;
&lt;br /&gt;
==Polynomial optimization==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CopositivePolynomial]]&amp;lt;/tt&amp;gt;: Creates a homogenous polynomial whose non-negativity is equivalent to copositivity of a given matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialAsMatrix]]&amp;lt;/tt&amp;gt;: Creates a compact fully symmetric matrix representation of a polynomial&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt;: Bounds the optimal value of a homogeneous polynomial on the unit sphere&lt;br /&gt;
&lt;br /&gt;
==Random things==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomDensityMatrix]]&amp;lt;/tt&amp;gt;: Generates a random density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPOVM]]&amp;lt;/tt&amp;gt;: Generates a random POVM (positive-operator valued measure)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPPTState]]&amp;lt;/tt&amp;gt;: Generates a random density matrix with positive partial transpose, and optionally low rank&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomProbabilities]]&amp;lt;/tt&amp;gt;: Computes a random probability vector, distributed uniformly on the unit simplex&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomStateVector]]&amp;lt;/tt&amp;gt;: Generates a random pure state vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomSuperoperator]]&amp;lt;/tt&amp;gt;: Generates a random superoperator (completely positive map)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomUnitary]]&amp;lt;/tt&amp;gt;: Generates a random unitary or orthogonal matrix&lt;br /&gt;
&lt;br /&gt;
==Special states, vectors, and operators==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Bell]]&amp;lt;/tt&amp;gt;: Produces a Bell state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BrauerStates]]&amp;lt;/tt&amp;gt;: Produces all Brauer states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DickeState]]&amp;lt;/tt&amp;gt;: Generates a Dicke state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GHZState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) GHZ state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaxEntangled]]&amp;lt;/tt&amp;gt;: Produces a maximally entangled bipartite pure state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) W-state&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BreuerState]]&amp;lt;/tt&amp;gt;: Generates a Breuer state, which is a specific family of bound entangled states on even local dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChessboardState]]&amp;lt;/tt&amp;gt;: Produces a chessboard state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GisinState]]&amp;lt;/tt&amp;gt;: Generates a 2-qubit Gisin state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[HorodeckiState]]&amp;lt;/tt&amp;gt;: Generates a bound entangled &amp;quot;Horodecki&amp;quot; state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsotropicState]]&amp;lt;/tt&amp;gt;: Produces an isotropic state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WernerState]]&amp;lt;/tt&amp;gt;: Produces a Werner state&lt;br /&gt;
&lt;br /&gt;
===Other operators===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FourierMatrix]]&amp;lt;/tt&amp;gt;: Generates the unitary matrix that implements the quantum Fourier transform&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GellMann]]&amp;lt;/tt&amp;gt;: Produces a Gell-Mann operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenGellMann]]&amp;lt;/tt&amp;gt;: Produces a generalized Gell-Mann operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenPauli]]&amp;lt;/tt&amp;gt;: Produces a generalized Pauli operator (sometimes called a Weyl operator)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Pauli]]&amp;lt;/tt&amp;gt;: Produces a Pauli operator&lt;br /&gt;
&lt;br /&gt;
==Superoperators==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ApplyMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMatrix]]&amp;lt;/tt&amp;gt;: Computes the Choi matrix of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMap]]&amp;lt;/tt&amp;gt;: Produces the Choi map or one of its generalizations&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ComplementaryMap]]&amp;lt;/tt&amp;gt;: Computes the complementary map of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DephasingChannel]]&amp;lt;/tt&amp;gt;: Produces a dephasing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DepolarizingChannel]]&amp;lt;/tt&amp;gt;: Produces a depolarizing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DualMap]]&amp;lt;/tt&amp;gt;: Computes the dual of a superoperator in the Hilbert-Schmidt inner product&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsCP]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is completely positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsHermPreserving]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is Hermiticity preserving&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KrausOperators]]&amp;lt;/tt&amp;gt;: Computes a set of Kraus operators for a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to a subsystem of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTrace]]&amp;lt;/tt&amp;gt;: Computes the partial trace of a vector or a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTranspose]]&amp;lt;/tt&amp;gt;: Computes the partial transpose of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PauliChannel]]&amp;lt;/tt&amp;gt;: Generates a Pauli channel (i.e., a quantum channel with Pauli Kraus operators)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Realignment]]&amp;lt;/tt&amp;gt;: Computes the realignment of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ReductionMap]]&amp;lt;/tt&amp;gt;: Produces the reduction map&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Twirl]]&amp;lt;/tt&amp;gt;: Twirls a bipartite or multipartite operator&lt;br /&gt;
&lt;br /&gt;
==Unextendible product bases==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsUPB]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of product vectors form a UPB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MinUPBSize]]&amp;lt;/tt&amp;gt;: Gives the minimum cardinality of an unextendible product basis in given dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPB]]&amp;lt;/tt&amp;gt;: Generates an unextendible product basis&lt;br /&gt;
&lt;br /&gt;
==Miscellaneous==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Commutant]]&amp;lt;/tt&amp;gt;: Computes the commutant of a set of matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyNonsingular]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally nonsingular&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Majorizes]]&amp;lt;/tt&amp;gt;: Determines whether or not a vector or matrix majorizes another&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSinkhorn]]&amp;lt;/tt&amp;gt;: Performs the operator Sinkhorn iteration, making all single-party reduced states proportional to the identity&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Purity]]&amp;lt;/tt&amp;gt;: Computes the purity of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Helper functions==&lt;br /&gt;
These are functions that only serve auxiliary roles within other functions of QETLAB. As an end-user of QETLAB, you likely won&#039;t have any use for these functions, but they are listed here anyway just in case.&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[bcs_to_nonlocal]]&amp;lt;/tt&amp;gt;: Converts a constraint description of a binary constraint system (BCS) game to a general non-local game description&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[dec_to_bin]]&amp;lt;/tt&amp;gt;: Converts a decimal number to a binary number in a similar way to `de2bi&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt;: Looks up a monomial&#039;s lexicographical index based on a list of exponents&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[iden]]&amp;lt;/tt&amp;gt;: Computes a sparse or full identity matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[jacobi_poly]]&amp;lt;/tt&amp;gt;: Computes the coefficients of Jacobi polynomials&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[normalize_cols]]&amp;lt;/tt&amp;gt;: Scales the columns of a matrix to have norm 1&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[one_factorization]]&amp;lt;/tt&amp;gt;: Computes a 1-factorization of a list of objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_args]]&amp;lt;/tt&amp;gt;: Handles optional input arguments for functions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_disp]]&amp;lt;/tt&amp;gt;: Display a message to the user (sometimes)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pad_array]]&amp;lt;/tt&amp;gt;: Pads an array with zeroes in a similar way to `padarray&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perfect_matchings]]&amp;lt;/tt&amp;gt;: Gives all perfect matchings of N objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_inv]]&amp;lt;/tt&amp;gt;: Computes the inverse of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_sign]]&amp;lt;/tt&amp;gt;: Computes the sign of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pure_to_mixed]]&amp;lt;/tt&amp;gt;: Converts a state vector or density matrix representation of a state to a density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sk_iterate]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[spnull]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the null space&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sporth]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the range&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[superoperator_dims]]&amp;lt;/tt&amp;gt;: Computes the input, output, and environment dimensions of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[update_odometer]]&amp;lt;/tt&amp;gt;: Increases the entries of a vector subject to constraints on how large the entries of that vector can be&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[vec_partitions]]&amp;lt;/tt&amp;gt;: Produces all possible partitions of a vector&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36021</id>
		<title>List of functions</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36021"/>
		<updated>2023-08-01T18:27:46Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: /* Polynomial optimization */ Link to PolynomialOptimization&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a &#039;&#039;&#039;list of functions&#039;&#039;&#039; provided by QETLAB, arranged by category. If you would prefer an alphabetical list of all functions please see [[:Category:Functions|this page]]. Brief descriptions of these functions are provided here, as well as links to their documentation pages, where full details and numerous examples can be found.&lt;br /&gt;
&lt;br /&gt;
==Basic operations==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPSD]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is positive semidefinite&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Tensor]]&amp;lt;/tt&amp;gt;: Kronecker tensor product of two or more matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TensorSum]]&amp;lt;/tt&amp;gt;: Computes a vector or operator from its tensor decomposition&lt;br /&gt;
&lt;br /&gt;
==Coherence and incoherence==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[L1NormCoherence]]&amp;lt;/tt&amp;gt;: Computes the ℓ&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;-norm of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RelEntCoherence]]&amp;lt;/tt&amp;gt;: Computes the relative entropy of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RobustnessCoherence]]&amp;lt;/tt&amp;gt;: Computes the robustness of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceDistanceCoherence]]&amp;lt;/tt&amp;gt;: Computes the trace distance of coherence of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Distinguishing objects==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChannelDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing two quantum channels&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Distinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[LocalDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states by symmetric-extendible and/or PPT measurements&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPBSepDistinguishable]]&amp;lt;/tt&amp;gt;: Determines whether or not an unextendible product basis is distinguishable by separable measurements&lt;br /&gt;
&lt;br /&gt;
==Entanglement and separability==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntangledSubspace]]&amp;lt;/tt&amp;gt;: Creates a basis of an r-entangled subspace of any requested dimension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductVector]]&amp;lt;/tt&amp;gt;: Determines if a pure state is a product vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the Schmidt decomposition of a bipartite vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the Schmidt rank of a bipartite vector&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FilterNormalForm]]&amp;lt;/tt&amp;gt;: Computes the filter normal form of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsBlockPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator is block positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsEntanglingGate]]&amp;lt;/tt&amp;gt;: Determines if a unitary is an entangling gate&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix has positive partial transpose&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductOperator]]&amp;lt;/tt&amp;gt;: Determines if an operator is an elementary tensor&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsSeparable]]&amp;lt;/tt&amp;gt;: Determines whether or not a bipartite operator is separable&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt decomposition of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt rank of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric extension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricInnerExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric inner extension&lt;br /&gt;
&lt;br /&gt;
===Ball of separability===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AbsPPTConstraints]]&amp;lt;/tt&amp;gt;: Builds the eigenvalue matrices that determine whether or not a state is absolutely PPT&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InSeparableBall]]&amp;lt;/tt&amp;gt;: Checks whether or not an operator is in the ball of separability centered at the maximally-mixed state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsAbsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a density matrix is absolutely PPT&lt;br /&gt;
&lt;br /&gt;
===Entanglement measures===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Concurrence]]&amp;lt;/tt&amp;gt;: Computes the concurrence of a 2-qubit state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntFormation]]&amp;lt;/tt&amp;gt;: Computes the entanglement of formation of a bipartite quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Negativity]]&amp;lt;/tt&amp;gt;: Computes the negativity of a bipartite density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomRobustnessEntanglement]]&amp;lt;/tt&amp;gt;: Computes the random robustness of entanglement of a bipartite quantum state&lt;br /&gt;
&lt;br /&gt;
==Information theory==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Entropy]]&amp;lt;/tt&amp;gt;: Computes the von Neumann or Rényi entropy of a density matrix&lt;br /&gt;
&lt;br /&gt;
==Nonlocality and Bell inequalities==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a binary contraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameValue]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a binary constraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMax]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a Bell inequality or nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMaxQubits]]&amp;lt;/tt&amp;gt;: Approximates the optimal value of a Bell inequality in qubit (i.e., 2-dimensional quantum) settings&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NonlocalGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a non-local game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NPAHierarchy]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of probabilities satisfy the conditions of the NPA hierarchy&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ParallelRepetition]]&amp;lt;/tt&amp;gt;: Produces the coefficients of parallel repetitions of a nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[XORGameValue]]&amp;lt;/tt&amp;gt;: Computes the classical or quantum value of a non-local binary XOR game&lt;br /&gt;
&lt;br /&gt;
==Norms and distance measures==&lt;br /&gt;
===Vectors and pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkVectorNorm]]&amp;lt;/tt&amp;gt;: Computes the s(k)-norm of a vector&lt;br /&gt;
&lt;br /&gt;
===Operators and mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Fidelity]]&amp;lt;/tt&amp;gt;: Computes the (Uhlmann) fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedMatrixNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced p&amp;amp;rarr;q norm of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNorm]]&amp;lt;/tt&amp;gt;: Computes the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNormDual]]&amp;lt;/tt&amp;gt;: Computes the dual of the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KyFanNorm]]&amp;lt;/tt&amp;gt;: Computes the Ky Fan k-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MatsumotoFidelity]]&amp;lt;/tt&amp;gt;: Computes the Matsumoto fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkOperatorNorm]]&amp;lt;/tt&amp;gt;: Bounds the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchattenNorm]]&amp;lt;/tt&amp;gt;: Computes the Schatten p-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceNorm]]&amp;lt;/tt&amp;gt;: Computes the trace norm of an operator&lt;br /&gt;
&lt;br /&gt;
===Superoperators and channels===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CBNorm]]&amp;lt;/tt&amp;gt;: Computes the completely bounded norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DiamondNorm]]&amp;lt;/tt&amp;gt;: Computes the diamond norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedSchattenNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced Schatten p&amp;amp;rarr;q norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaximumOutputFidelity]]&amp;lt;/tt&amp;gt;: Computes the maximum output fidelity of two quantum channels&lt;br /&gt;
&lt;br /&gt;
==Permutations and symmetry of subsystems==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AntisymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the antisymmetric subspace&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermutationOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that permutes subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermuteSystems]]&amp;lt;/tt&amp;gt;: Permutes subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Swap]]&amp;lt;/tt&amp;gt;: Swaps two subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SwapOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that swaps two subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the symmetric subspace&lt;br /&gt;
&lt;br /&gt;
==Polynomial optimization==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CopositivePolynomial]]&amp;lt;/tt&amp;gt;: Creates a homogenous polynomial whose non-negativity is equivalent to copositivity of a given matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialAsMatrix]]&amp;lt;/tt&amp;gt;: Creates a compact fully symmetric matrix representation of a polynomial&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialOptimization]]&amp;lt;/tt&amp;gt;: Bounds the optimal value of a homogeneous polynomial on the unit sphere&lt;br /&gt;
&lt;br /&gt;
==Random things==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomDensityMatrix]]&amp;lt;/tt&amp;gt;: Generates a random density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPOVM]]&amp;lt;/tt&amp;gt;: Generates a random POVM (positive-operator valued measure)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPPTState]]&amp;lt;/tt&amp;gt;: Generates a random density matrix with positive partial transpose, and optionally low rank&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomProbabilities]]&amp;lt;/tt&amp;gt;: Computes a random probability vector, distributed uniformly on the unit simplex&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomStateVector]]&amp;lt;/tt&amp;gt;: Generates a random pure state vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomSuperoperator]]&amp;lt;/tt&amp;gt;: Generates a random superoperator (completely positive map)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomUnitary]]&amp;lt;/tt&amp;gt;: Generates a random unitary or orthogonal matrix&lt;br /&gt;
&lt;br /&gt;
==Special states, vectors, and operators==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Bell]]&amp;lt;/tt&amp;gt;: Produces a Bell state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BrauerStates]]&amp;lt;/tt&amp;gt;: Produces all Brauer states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DickeState]]&amp;lt;/tt&amp;gt;: Generates a Dicke state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GHZState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) GHZ state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaxEntangled]]&amp;lt;/tt&amp;gt;: Produces a maximally entangled bipartite pure state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) W-state&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BreuerState]]&amp;lt;/tt&amp;gt;: Generates a Breuer state, which is a specific family of bound entangled states on even local dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChessboardState]]&amp;lt;/tt&amp;gt;: Produces a chessboard state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GisinState]]&amp;lt;/tt&amp;gt;: Generates a 2-qubit Gisin state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[HorodeckiState]]&amp;lt;/tt&amp;gt;: Generates a bound entangled &amp;quot;Horodecki&amp;quot; state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsotropicState]]&amp;lt;/tt&amp;gt;: Produces an isotropic state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WernerState]]&amp;lt;/tt&amp;gt;: Produces a Werner state&lt;br /&gt;
&lt;br /&gt;
===Other operators===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FourierMatrix]]&amp;lt;/tt&amp;gt;: Generates the unitary matrix that implements the quantum Fourier transform&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GellMann]]&amp;lt;/tt&amp;gt;: Produces a Gell-Mann operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenGellMann]]&amp;lt;/tt&amp;gt;: Produces a generalized Gell-Mann operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenPauli]]&amp;lt;/tt&amp;gt;: Produces a generalized Pauli operator (sometimes called a Weyl operator)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Pauli]]&amp;lt;/tt&amp;gt;: Produces a Pauli operator&lt;br /&gt;
&lt;br /&gt;
==Superoperators==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ApplyMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMatrix]]&amp;lt;/tt&amp;gt;: Computes the Choi matrix of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMap]]&amp;lt;/tt&amp;gt;: Produces the Choi map or one of its generalizations&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ComplementaryMap]]&amp;lt;/tt&amp;gt;: Computes the complementary map of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DephasingChannel]]&amp;lt;/tt&amp;gt;: Produces a dephasing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DepolarizingChannel]]&amp;lt;/tt&amp;gt;: Produces a depolarizing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DualMap]]&amp;lt;/tt&amp;gt;: Computes the dual of a superoperator in the Hilbert-Schmidt inner product&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsCP]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is completely positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsHermPreserving]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is Hermiticity preserving&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KrausOperators]]&amp;lt;/tt&amp;gt;: Computes a set of Kraus operators for a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to a subsystem of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTrace]]&amp;lt;/tt&amp;gt;: Computes the partial trace of a vector or a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTranspose]]&amp;lt;/tt&amp;gt;: Computes the partial transpose of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PauliChannel]]&amp;lt;/tt&amp;gt;: Generates a Pauli channel (i.e., a quantum channel with Pauli Kraus operators)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Realignment]]&amp;lt;/tt&amp;gt;: Computes the realignment of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ReductionMap]]&amp;lt;/tt&amp;gt;: Produces the reduction map&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Twirl]]&amp;lt;/tt&amp;gt;: Twirls a bipartite or multipartite operator&lt;br /&gt;
&lt;br /&gt;
==Unextendible product bases==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsUPB]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of product vectors form a UPB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MinUPBSize]]&amp;lt;/tt&amp;gt;: Gives the minimum cardinality of an unextendible product basis in given dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPB]]&amp;lt;/tt&amp;gt;: Generates an unextendible product basis&lt;br /&gt;
&lt;br /&gt;
==Miscellaneous==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Commutant]]&amp;lt;/tt&amp;gt;: Computes the commutant of a set of matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyNonsingular]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally nonsingular&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Majorizes]]&amp;lt;/tt&amp;gt;: Determines whether or not a vector or matrix majorizes another&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSinkhorn]]&amp;lt;/tt&amp;gt;: Performs the operator Sinkhorn iteration, making all single-party reduced states proportional to the identity&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Purity]]&amp;lt;/tt&amp;gt;: Computes the purity of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Helper functions==&lt;br /&gt;
These are functions that only serve auxiliary roles within other functions of QETLAB. As an end-user of QETLAB, you likely won&#039;t have any use for these functions, but they are listed here anyway just in case.&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[bcs_to_nonlocal]]&amp;lt;/tt&amp;gt;: Converts a constraint description of a binary constraint system (BCS) game to a general non-local game description&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[dec_to_bin]]&amp;lt;/tt&amp;gt;: Converts a decimal number to a binary number in a similar way to `de2bi&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt;: Looks up a monomial&#039;s lexicographical index based on a list of exponents&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[iden]]&amp;lt;/tt&amp;gt;: Computes a sparse or full identity matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[jacobi_poly]]&amp;lt;/tt&amp;gt;: Computes the coefficients of Jacobi polynomials&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[normalize_cols]]&amp;lt;/tt&amp;gt;: Scales the columns of a matrix to have norm 1&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[one_factorization]]&amp;lt;/tt&amp;gt;: Computes a 1-factorization of a list of objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_args]]&amp;lt;/tt&amp;gt;: Handles optional input arguments for functions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_disp]]&amp;lt;/tt&amp;gt;: Display a message to the user (sometimes)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pad_array]]&amp;lt;/tt&amp;gt;: Pads an array with zeroes in a similar way to `padarray&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perfect_matchings]]&amp;lt;/tt&amp;gt;: Gives all perfect matchings of N objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_inv]]&amp;lt;/tt&amp;gt;: Computes the inverse of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_sign]]&amp;lt;/tt&amp;gt;: Computes the sign of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pure_to_mixed]]&amp;lt;/tt&amp;gt;: Converts a state vector or density matrix representation of a state to a density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sk_iterate]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[spnull]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the null space&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sporth]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the range&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[superoperator_dims]]&amp;lt;/tt&amp;gt;: Computes the input, output, and environment dimensions of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[update_odometer]]&amp;lt;/tt&amp;gt;: Increases the entries of a vector subject to constraints on how large the entries of that vector can be&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[vec_partitions]]&amp;lt;/tt&amp;gt;: Produces all possible partitions of a vector&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=PolynomialOptimize&amp;diff=36020</id>
		<title>PolynomialOptimize</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=PolynomialOptimize&amp;diff=36020"/>
		<updated>2023-08-01T18:26:55Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=PolynomialOptimize&lt;br /&gt;
|desc=Bounds the optimal value of a homogeneous polynomial on the unit sphere&lt;br /&gt;
|rel=[[CopositivePolynomial]]&amp;lt;br /&amp;gt;[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialSOS]]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 1, 2023&lt;br /&gt;
|cvx=no}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;PolynomialOptimize&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes upper and lower bounds on the optimum (i.e., maximum or minimum) value of an even-degree homogeneous polynomial on the unit sphere. That is, given an even-degree n-variable homogeneous polynomial p, this function bounds the (very difficult to compute in general) quantity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\max\big\{ p(x_1,x_2,\ldots,x_n) : x_1^2 + x_2^2 + \cdots + x_n^2 = 1 \big\},&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or the corresponding minimization problem.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialOptimize(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialOptimize(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialOptimize(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialOptimize(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
===Input arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt;: The polynomial, represented as a vector of coefficients of its monomials in lexicographic order.&lt;br /&gt;
* &amp;lt;tt&amp;gt;N&amp;lt;/tt&amp;gt;: The number of variables in the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;D&amp;lt;/tt&amp;gt;: Half the degree of the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;: A non-negative integer that specifies the level of the hierarchy that is used to compute the bound(s) on the optimal value. Larger values of K result in better bounds at the expense of increases memory usage and longer computation times.&lt;br /&gt;
* &amp;lt;tt&amp;gt;OPTTYPE&amp;lt;/tt&amp;gt; (optional, default &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt;): Either &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&#039;min&#039;&amp;lt;/tt&amp;gt;, indicating whether the polynomial should be maximized or minimized.&lt;br /&gt;
&lt;br /&gt;
===Output arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB&amp;lt;/tt&amp;gt;: An &amp;quot;outer&amp;quot; bound on the optimal value. If maximizing, this is an upper bound on the maximum; if minimizing, this is a lower bound on the minimum.&lt;br /&gt;
* &amp;lt;tt&amp;gt;IB&amp;lt;/tt&amp;gt;: An &amp;quot;inner&amp;quot; bound on the optimal value. If maximizing, this is a lower bound on the maximum; if minimizing, this is an upper bound on the minimum.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Motzkin polynomial===&lt;br /&gt;
The Motzkin polynomial is the following degree-6 homogeneous polynomial: &amp;lt;math&amp;gt;p(x,y,z) = x^4y^2 + x^2y^4 - 3x^2y^2z^2 + z^6&amp;lt;/math&amp;gt;. We can load this polynomial into a list-of-coefficients form that &amp;lt;tt&amp;gt;PolynomialOptimize&amp;lt;/tt&amp;gt; understands via the &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt; helper function:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 3;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; p = zeros(nchoosek(n+2*d-1,2*d),1);% initialize p to have the correct size&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([4 2 0])) = 1;% the &amp;quot;4 2 0&amp;quot; here are the exponents in the term x^4y^2z^0, while the &amp;quot;1&amp;quot; is the coefficient of this term&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 4 0])) = 1;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 2 2])) = -3;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([0 0 6])) = 1;% now p represents the Motzkin polynomial&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Motzkin polynomial, despite the fact that it cannot be written as a sum of squares, is non-negative. In fact, the minimum value of this polynomial over the unit sphere is exactly 0. We can get lower bounds for the optimal value as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialOptimize(p,n,d,0,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.2000&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialOptimize(p,n,d,1,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.1104&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialOptimize(p,n,d,2,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.0780&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see above that increasing the value of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; (i.e., the level of the hierarchy) results in a better lower bound (i.e., a bound that is closer to the true minimum value of 0). This function is fast enough that we can go to a much higher level of the hierarchy, and we can also get upper bounds on this minimum value:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialOptimize(p,n,d,10,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   -0.0158&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    1.6985&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialOptimize(p,n,d,100,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   -0.0017&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    0.2291&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialOptimize(p,n,d,500,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
  -3.3898e-04&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    0.0473&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, by the 500-th level of the hierarchy we have learned that the minimum value of the Motzkin polynomial is between &amp;lt;tt&amp;gt;-3.3898e-04&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;0.0473&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=PolynomialOptimize}}&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
The outer bounds produced by this function are typically better than the inner bounds.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=PolynomialOptimize&amp;diff=36019</id>
		<title>PolynomialOptimize</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=PolynomialOptimize&amp;diff=36019"/>
		<updated>2023-08-01T18:26:29Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Created&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=PolynomialOptimize&lt;br /&gt;
|desc=Bounds the optimal value of a homogeneous polynomial on the unit sphere&lt;br /&gt;
|rel=[[CopositivePolynomial]]&amp;lt;br /&amp;gt;[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialSOS]]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 1, 2023&lt;br /&gt;
|cvx=no}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;PolynomialOptimize&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes upper and lower bounds on the optimum (i.e., maximum or minimum) value of an even-degree homogeneous polynomial on the unit sphere. That is, given an even-degree n-variable homogeneous polynomial p, this function bounds the (very difficult to compute in general) quantity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
\max\big\{ p(x_1,x_2,\ldots,x_n) : x_1^2 + x_2^2 + \cdots + x_n^2 = 1 \big\},&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
or the corresponding minimization problem.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialOptimize(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB = PolynomialOptimize(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialOptimize(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;[OB,IB] = PolynomialOptimize(P,N,D,K,OPTTYPE)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
===Input arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt;: The polynomial, represented as a vector of coefficients of its monomials in lexicographic order.&lt;br /&gt;
* &amp;lt;tt&amp;gt;N&amp;lt;/tt&amp;gt;: The number of variables in the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;D&amp;lt;/tt&amp;gt;: Half the degree of the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt;: A non-negative integer that specifies the level of the hierarchy that is used to compute the bound(s) on the optimal value. Larger values of K result in better bounds at the expense of increases memory usage and longer computation times.&lt;br /&gt;
* &amp;lt;tt&amp;gt;OPTTYPE&amp;lt;/tt&amp;gt; (optional, default &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt;): Either &amp;lt;tt&amp;gt;&#039;max&#039;&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;&#039;min&#039;&amp;lt;/tt&amp;gt;, indicating whether the polynomial should be maximized or minimized.&lt;br /&gt;
&lt;br /&gt;
===Output arguments===&lt;br /&gt;
* &amp;lt;tt&amp;gt;OB&amp;lt;/tt&amp;gt;: An &amp;quot;outer&amp;quot; bound on the optimal value. If maximizing, this is an upper bound on the maximum; if minimizing, this is a lower bound on the minimum.&lt;br /&gt;
* &amp;lt;tt&amp;gt;IB&amp;lt;/tt&amp;gt;: An &amp;quot;inner&amp;quot; bound on the optimal value. If maximizing, this is a lower bound on the maximum; if minimizing, this is an upper bound on the minimum.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Motzkin polynomial===&lt;br /&gt;
The Motzkin polynomial is the following degree-6 homogeneous polynomial: &amp;lt;math&amp;gt;p(x,y,z) = x^4y^2 + x^2y^4 - 3x^2y^2z^2 + z^6&amp;lt;/math&amp;gt;. We can load this polynomial into a list-of-coefficients form that &amp;lt;tt&amp;gt;PolynomialOptimize&amp;lt;/tt&amp;gt; understands via the &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt; helper function:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 3;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; p = zeros(nchoosek(n+2*d-1,2*d),1);% initialize p to have the correct size&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([4 2 0])) = 1;% the &amp;quot;4 2 0&amp;quot; here are the exponents in the term x^4y^2z^0, while the &amp;quot;1&amp;quot; is the coefficient of this term&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 4 0])) = 1;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 2 2])) = -3;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([0 0 6])) = 1;% now p represents the Motzkin polynomial&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Motzkin polynomial, despite the fact that it cannot be written as a sum of squares, is non-negative. In fact, the minimum value of this polynomial over the unit sphere is exactly 0. We can get lower bounds for the optimal value as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialOptimize(p,n,d,0,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.2000&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialOptimize(p,n,d,1,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.1104&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; PolynomialOptimize(p,n,d,2,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   -0.0780&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see above that increasing the value of &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; (i.e., the level of the hierarchy) results in a better lower bound (i.e., a bound that is closer to the true minimum value of 0). This function is fast enough that we can go to a much higher level of the hierarchy, and we can also get upper bounds on this minimum value:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialOptimize(p,n,d,10,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   -0.0158&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    1.6985&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialOptimize(p,n,d,100,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
   -0.0017&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    0.2291&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; [ob,ib] = PolynomialOptimize(p,n,d,500,&#039;min&#039;)&lt;br /&gt;
&lt;br /&gt;
ob =&lt;br /&gt;
&lt;br /&gt;
  -3.3898e-04&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ib =&lt;br /&gt;
&lt;br /&gt;
    0.0473&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In other words, by the 500-th level of the hierarchy we have learned that the minimum value of the Motzkin polynomial is between &amp;lt;tt&amp;gt;-3.3898e-04&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;0.0473&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=PolynomialOptimize}}&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
The outer bounds produced by this function are typically better than the inner bounds.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=CopositivePolynomial&amp;diff=36018</id>
		<title>CopositivePolynomial</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=CopositivePolynomial&amp;diff=36018"/>
		<updated>2023-08-01T14:45:35Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: fix row versus column&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=CopositivePolynomial&lt;br /&gt;
|desc=Creates a homogenous polynomial whose non-negativity is equivalent to copositivity of a given matrix&lt;br /&gt;
|rel=[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialOptimize]]&amp;lt;br /&amp;gt;[[PolynomialSOS]]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 1, 2023&lt;br /&gt;
|cvx=no}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;CopositivePolynomial&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes the standard quartic homogeneous polynomial that is associated with a copositive matrix (or any symmetric matrix, in an hopes of determineing whether or not the matrix is copositive). For example, the Horn matrix&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;C = \begin{bmatrix}1 &amp;amp; -1 &amp;amp; 1 &amp;amp; 1 &amp;amp; -1 \\ -1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; 1 \\ 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 \\ 1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; -1 \\ -1 &amp;amp; 1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1\end{bmatrix}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
is associated with the quartic polynomial&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\displaystyle p(x) = \begin{bmatrix}x_1^2 &amp;amp; x_2^2 &amp;amp; x_3^2 &amp;amp; x_4^2 &amp;amp; x_5^2\end{bmatrix}C\begin{bmatrix}x_1^2 \\ x_2^2 \\ x_3^2 \\ x_4^2 \\ x_5^2\end{bmatrix} = \sum_{i=1}^5 x_i^4 - 2\sum_{i=1}^5x_i^2x_{i+1}^2 + 2\sum_{i=1}^5x_i^2x_{i+2}^2,&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the sums in the subscripts are understood to be modulo 5. Copositivity of &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; is equivalent to non-negativity of the polynomial &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;P = CopositivePolynomial(C)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
* &amp;lt;tt&amp;gt;C&amp;lt;/tt&amp;gt;: A matrix.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Horn matrix===&lt;br /&gt;
Let&#039;s compute the polynomial (as a vector) representation of the Horn matrix.&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; C = [1,-1,1,1,-1;-1,1,-1,1,1;1,-1,1,-1,1;1,1,-1,1,-1;-1,1,1,-1,1];% the Horn matrix&lt;br /&gt;
&amp;gt;&amp;gt; p = CopositivePolynomial(C);&lt;br /&gt;
&amp;gt;&amp;gt; sparse(p)% displays the non-zero coefficients of this polynomial&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   (1,1)        1&lt;br /&gt;
   (6,1)       -2&lt;br /&gt;
  (10,1)        2&lt;br /&gt;
  (13,1)        2&lt;br /&gt;
  (15,1)       -2&lt;br /&gt;
  (36,1)        1&lt;br /&gt;
  (40,1)       -2&lt;br /&gt;
  (43,1)        2&lt;br /&gt;
  (45,1)        2&lt;br /&gt;
  (56,1)        1&lt;br /&gt;
  (59,1)       -2&lt;br /&gt;
  (61,1)        2&lt;br /&gt;
  (66,1)        1&lt;br /&gt;
  (68,1)       -2&lt;br /&gt;
  (70,1)        1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To verify that the above vector of coefficients really does represent the polynomial associated with the Horn matrix, we can perform the follow computation (which requires MATLAB&#039;s symbolic computation package):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; syms x1 x2 x3 x4 x5&lt;br /&gt;
&amp;gt;&amp;gt; x = [x1;x2;x3;x4;x5];&lt;br /&gt;
&amp;gt;&amp;gt; n = 5;% number of variables = size of Horn matrix&lt;br /&gt;
&amp;gt;&amp;gt; d = 2;% half of the degree of the (quartic) polynomial&lt;br /&gt;
&amp;gt;&amp;gt; M = PolynomialAsMatrix(p,n,d);% compute a compact fully symmetric matrix representation of this polynomial&lt;br /&gt;
&amp;gt;&amp;gt; P = SymmetricProjection(n,d,1,0);% used to expand M to non-symmetric coordinates&lt;br /&gt;
&amp;gt;&amp;gt; MF = P*M*P&#039;;% MF is a matrix representation in non-symmetric coordinates&lt;br /&gt;
&amp;gt;&amp;gt; expand(kron(x,x).&#039;*MF*kron(x,x))% expand to a polynomial&lt;br /&gt;
 &lt;br /&gt;
ans =&lt;br /&gt;
 &lt;br /&gt;
x1^4 - 2*x1^2*x2^2 + 2*x1^2*x3^2 + 2*x1^2*x4^2 - 2*x1^2*x5^2 + x2^4 - 2*x2^2*x3^2 + 2*x2^2*x4^2 + 2*x2^2*x5^2 + x3^4 - 2*x3^2*x4^2 + 2*x3^2*x5^2 + x4^4 - 2*x4^2*x5^2 + x5^4&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Regardless of whether or not the above verification is performed, the vector p can now be used in polynomial optimization functions like &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;[[PolynomialSOS]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Clique polynomial===&lt;br /&gt;
To be filled in: an example of using this function to create a polynomial whose maximum value bounds the maximum clique size in a graph.&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=CopositivePolynomial}}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=CopositivePolynomial&amp;diff=36017</id>
		<title>CopositivePolynomial</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=CopositivePolynomial&amp;diff=36017"/>
		<updated>2023-08-01T14:42:16Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Fix exponents&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=CopositivePolynomial&lt;br /&gt;
|desc=Creates a homogenous polynomial whose non-negativity is equivalent to copositivity of a given matrix&lt;br /&gt;
|rel=[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialOptimize]]&amp;lt;br /&amp;gt;[[PolynomialSOS]]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 1, 2023&lt;br /&gt;
|cvx=no}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;CopositivePolynomial&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes the standard quartic homogeneous polynomial that is associated with a copositive matrix (or any symmetric matrix, in an hopes of determineing whether or not the matrix is copositive). For example, the Horn matrix&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;C = \begin{bmatrix}1 &amp;amp; -1 &amp;amp; 1 &amp;amp; 1 &amp;amp; -1 \\ -1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; 1 \\ 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 \\ 1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; -1 \\ -1 &amp;amp; 1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1\end{bmatrix}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
is associated with the quartic polynomial&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\displaystyle p(x) = \begin{bmatrix}x_1^2 \\ x_2^2 \\ x_3^2 \\ x_4^2 \\ x_5^2\end{bmatrix}C\begin{bmatrix}x_1^2 &amp;amp; x_2^2 &amp;amp; x_3^2 &amp;amp; x_4^2 &amp;amp; x_5^2\end{bmatrix} = \sum_{i=1}^5 x_i^4 - 2\sum_{i=1}^5x_i^2x_{i+1}^2 + 2\sum_{i=1}^5x_i^2x_{i+2}^2,&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the sums in the subscripts are understood to be modulo 5. Copositivity of &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; is equivalent to non-negativity of the polynomial &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;P = CopositivePolynomial(C)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
* &amp;lt;tt&amp;gt;C&amp;lt;/tt&amp;gt;: A matrix.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Horn matrix===&lt;br /&gt;
Let&#039;s compute the polynomial (as a vector) representation of the Horn matrix.&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; C = [1,-1,1,1,-1;-1,1,-1,1,1;1,-1,1,-1,1;1,1,-1,1,-1;-1,1,1,-1,1];% the Horn matrix&lt;br /&gt;
&amp;gt;&amp;gt; p = CopositivePolynomial(C);&lt;br /&gt;
&amp;gt;&amp;gt; sparse(p)% displays the non-zero coefficients of this polynomial&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   (1,1)        1&lt;br /&gt;
   (6,1)       -2&lt;br /&gt;
  (10,1)        2&lt;br /&gt;
  (13,1)        2&lt;br /&gt;
  (15,1)       -2&lt;br /&gt;
  (36,1)        1&lt;br /&gt;
  (40,1)       -2&lt;br /&gt;
  (43,1)        2&lt;br /&gt;
  (45,1)        2&lt;br /&gt;
  (56,1)        1&lt;br /&gt;
  (59,1)       -2&lt;br /&gt;
  (61,1)        2&lt;br /&gt;
  (66,1)        1&lt;br /&gt;
  (68,1)       -2&lt;br /&gt;
  (70,1)        1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To verify that the above vector of coefficients really does represent the polynomial associated with the Horn matrix, we can perform the follow computation (which requires MATLAB&#039;s symbolic computation package):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; syms x1 x2 x3 x4 x5&lt;br /&gt;
&amp;gt;&amp;gt; x = [x1;x2;x3;x4;x5];&lt;br /&gt;
&amp;gt;&amp;gt; n = 5;% number of variables = size of Horn matrix&lt;br /&gt;
&amp;gt;&amp;gt; d = 2;% half of the degree of the (quartic) polynomial&lt;br /&gt;
&amp;gt;&amp;gt; M = PolynomialAsMatrix(p,n,d);% compute a compact fully symmetric matrix representation of this polynomial&lt;br /&gt;
&amp;gt;&amp;gt; P = SymmetricProjection(n,d,1,0);% used to expand M to non-symmetric coordinates&lt;br /&gt;
&amp;gt;&amp;gt; MF = P*M*P&#039;;% MF is a matrix representation in non-symmetric coordinates&lt;br /&gt;
&amp;gt;&amp;gt; expand(kron(x,x).&#039;*MF*kron(x,x))% expand to a polynomial&lt;br /&gt;
 &lt;br /&gt;
ans =&lt;br /&gt;
 &lt;br /&gt;
x1^4 - 2*x1^2*x2^2 + 2*x1^2*x3^2 + 2*x1^2*x4^2 - 2*x1^2*x5^2 + x2^4 - 2*x2^2*x3^2 + 2*x2^2*x4^2 + 2*x2^2*x5^2 + x3^4 - 2*x3^2*x4^2 + 2*x3^2*x5^2 + x4^4 - 2*x4^2*x5^2 + x5^4&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Regardless of whether or not the above verification is performed, the vector p can now be used in polynomial optimization functions like &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;[[PolynomialSOS]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Clique polynomial===&lt;br /&gt;
To be filled in: an example of using this function to create a polynomial whose maximum value bounds the maximum clique size in a graph.&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=CopositivePolynomial}}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=CopositivePolynomial&amp;diff=36016</id>
		<title>CopositivePolynomial</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=CopositivePolynomial&amp;diff=36016"/>
		<updated>2023-08-01T14:35:07Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=CopositivePolynomial&lt;br /&gt;
|desc=Creates a homogenous polynomial whose non-negativity is equivalent to copositivity of a given matrix&lt;br /&gt;
|rel=[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialOptimize]]&amp;lt;br /&amp;gt;[[PolynomialSOS]]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 1, 2023&lt;br /&gt;
|cvx=no}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;CopositivePolynomial&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes the standard quartic homogeneous polynomial that is associated with a copositive matrix (or any symmetric matrix, in an hopes of determineing whether or not the matrix is copositive). For example, the Horn matrix&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;C = \begin{bmatrix}1 &amp;amp; -1 &amp;amp; 1 &amp;amp; 1 &amp;amp; -1 \\ -1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; 1 \\ 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 \\ 1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; -1 \\ -1 &amp;amp; 1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1\end{bmatrix}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
is associated with the quartic polynomial&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\displaystyle p(x) = \begin{bmatrix}x_1^2 \\ x_2^2 \\ x_3^2 \\ x_4^2 \\ x_5^2\end{bmatrix}C\begin{bmatrix}x_1^2 &amp;amp; x_2^2 &amp;amp; x_3^2 &amp;amp; x_4^2 &amp;amp; x_5^2\end{bmatrix} = \sum_{i=1}^5 x_i^4 - 2\sum_{i=1}^5x_ix_{i+1} + 2\sum_{i=1}^5x_ix_{i+2},&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the sums in the subscripts are understood to be modulo 5. Copositivity of &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; is equivalent to non-negativity of the polynomial &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;P = CopositivePolynomial(C)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
* &amp;lt;tt&amp;gt;C&amp;lt;/tt&amp;gt;: A matrix.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Horn matrix===&lt;br /&gt;
Let&#039;s compute the polynomial (as a vector) representation of the Horn matrix.&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; C = [1,-1,1,1,-1;-1,1,-1,1,1;1,-1,1,-1,1;1,1,-1,1,-1;-1,1,1,-1,1];% the Horn matrix&lt;br /&gt;
&amp;gt;&amp;gt; p = CopositivePolynomial(C);&lt;br /&gt;
&amp;gt;&amp;gt; sparse(p)% displays the non-zero coefficients of this polynomial&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   (1,1)        1&lt;br /&gt;
   (6,1)       -2&lt;br /&gt;
  (10,1)        2&lt;br /&gt;
  (13,1)        2&lt;br /&gt;
  (15,1)       -2&lt;br /&gt;
  (36,1)        1&lt;br /&gt;
  (40,1)       -2&lt;br /&gt;
  (43,1)        2&lt;br /&gt;
  (45,1)        2&lt;br /&gt;
  (56,1)        1&lt;br /&gt;
  (59,1)       -2&lt;br /&gt;
  (61,1)        2&lt;br /&gt;
  (66,1)        1&lt;br /&gt;
  (68,1)       -2&lt;br /&gt;
  (70,1)        1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To verify that the above vector of coefficients really does represent the polynomial associated with the Horn matrix, we can perform the follow computation (which requires MATLAB&#039;s symbolic computation package):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; syms x1 x2 x3 x4 x5&lt;br /&gt;
&amp;gt;&amp;gt; x = [x1;x2;x3;x4;x5];&lt;br /&gt;
&amp;gt;&amp;gt; n = 5;% number of variables = size of Horn matrix&lt;br /&gt;
&amp;gt;&amp;gt; d = 2;% half of the degree of the (quartic) polynomial&lt;br /&gt;
&amp;gt;&amp;gt; M = PolynomialAsMatrix(p,n,d);% compute a compact fully symmetric matrix representation of this polynomial&lt;br /&gt;
&amp;gt;&amp;gt; P = SymmetricProjection(n,d,1,0);% used to expand M to non-symmetric coordinates&lt;br /&gt;
&amp;gt;&amp;gt; MF = P*M*P&#039;;% MF is a matrix representation in non-symmetric coordinates&lt;br /&gt;
&amp;gt;&amp;gt; expand(kron(x,x).&#039;*MF*kron(x,x))% expand to a polynomial&lt;br /&gt;
 &lt;br /&gt;
ans =&lt;br /&gt;
 &lt;br /&gt;
x1^4 - 2*x1^2*x2^2 + 2*x1^2*x3^2 + 2*x1^2*x4^2 - 2*x1^2*x5^2 + x2^4 - 2*x2^2*x3^2 + 2*x2^2*x4^2 + 2*x2^2*x5^2 + x3^4 - 2*x3^2*x4^2 + 2*x3^2*x5^2 + x4^4 - 2*x4^2*x5^2 + x5^4&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Regardless of whether or not the above verification is performed, the vector p can now be used in polynomial optimization functions like &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;[[PolynomialSOS]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===Clique polynomial===&lt;br /&gt;
To be filled in: an example of using this function to create a polynomial whose maximum value bounds the maximum clique size in a graph.&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=CopositivePolynomial}}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=CopositivePolynomial&amp;diff=36015</id>
		<title>CopositivePolynomial</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=CopositivePolynomial&amp;diff=36015"/>
		<updated>2023-08-01T14:33:52Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: /* The Horn matrix */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=CopositivePolynomial&lt;br /&gt;
|desc=Creates a homogenous polynomial whose non-negativity is equivalent to copositivity of a given matrix&lt;br /&gt;
|rel=[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialOptimize]]&amp;lt;br /&amp;gt;[[PolynomialSOS]]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 1, 2023&lt;br /&gt;
|cvx=no}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;CopositivePolynomial&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes the standard quartic homogeneous polynomial that is associated with a copositive matrix (or any symmetric matrix, in an hopes of determineing whether or not the matrix is copositive). For example, the Horn matrix&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;C = \begin{bmatrix}1 &amp;amp; -1 &amp;amp; 1 &amp;amp; 1 &amp;amp; -1 \\ -1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; 1 \\ 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 \\ 1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; -1 \\ -1 &amp;amp; 1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1\end{bmatrix}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
is associated with the quartic polynomial&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\displaystyle p(x) = \begin{bmatrix}x_1^2 \\ x_2^2 \\ x_3^2 \\ x_4^2 \\ x_5^2\end{bmatrix}C\begin{bmatrix}x_1^2 &amp;amp; x_2^2 &amp;amp; x_3^2 &amp;amp; x_4^2 &amp;amp; x_5^2\end{bmatrix} = \sum_{i=1}^5 x_i^4 - 2\sum_{i=1}^5x_ix_{i+1} + 2\sum_{i=1}^5x_ix_{i+2},&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the sums in the subscripts are understood to be modulo 5. Copositivity of &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; is equivalent to non-negativity of the polynomial &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;P = CopositivePolynomial(C)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
* &amp;lt;tt&amp;gt;C&amp;lt;/tt&amp;gt;: A matrix.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Horn matrix===&lt;br /&gt;
Let&#039;s compute the polynomial (as a vector) representation of the Horn matrix.&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; C = [1,-1,1,1,-1;-1,1,-1,1,1;1,-1,1,-1,1;1,1,-1,1,-1;-1,1,1,-1,1];% the Horn matrix&lt;br /&gt;
&amp;gt;&amp;gt; p = CopositivePolynomial(C);&lt;br /&gt;
&amp;gt;&amp;gt; sparse(p)% displays the non-zero coefficients of this polynomial&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   (1,1)        1&lt;br /&gt;
   (6,1)       -2&lt;br /&gt;
  (10,1)        2&lt;br /&gt;
  (13,1)        2&lt;br /&gt;
  (15,1)       -2&lt;br /&gt;
  (36,1)        1&lt;br /&gt;
  (40,1)       -2&lt;br /&gt;
  (43,1)        2&lt;br /&gt;
  (45,1)        2&lt;br /&gt;
  (56,1)        1&lt;br /&gt;
  (59,1)       -2&lt;br /&gt;
  (61,1)        2&lt;br /&gt;
  (66,1)        1&lt;br /&gt;
  (68,1)       -2&lt;br /&gt;
  (70,1)        1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To verify that the above vector of coefficients really does represent the polynomial associated with the Horn matrix, we can perform the follow computation (which requires MATLAB&#039;s symbolic computation package):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; syms x1 x2 x3 x4 x5&lt;br /&gt;
&amp;gt;&amp;gt; x = [x1;x2;x3;x4;x5];&lt;br /&gt;
&amp;gt;&amp;gt; n = 5;% number of variables = size of Horn matrix&lt;br /&gt;
&amp;gt;&amp;gt; d = 2;% half of the degree of the (quartic) polynomial&lt;br /&gt;
&amp;gt;&amp;gt; M = PolynomialAsMatrix(p,n,d);% compute a compact fully symmetric matrix representation of this polynomial&lt;br /&gt;
&amp;gt;&amp;gt; P = SymmetricProjection(n,d,1,0);% used to expand M to non-symmetric coordinates&lt;br /&gt;
&amp;gt;&amp;gt; MF = P*M*P&#039;;% MF is a matrix representation in non-symmetric coordinates&lt;br /&gt;
&amp;gt;&amp;gt; expand(kron(x,x).&#039;*MF*kron(x,x))% expand to a polynomial&lt;br /&gt;
 &lt;br /&gt;
ans =&lt;br /&gt;
 &lt;br /&gt;
x1^4 - 2*x1^2*x2^2 + 2*x1^2*x3^2 + 2*x1^2*x4^2 - 2*x1^2*x5^2 + x2^4 - 2*x2^2*x3^2 + 2*x2^2*x4^2 + 2*x2^2*x5^2 + x3^4 - 2*x3^2*x4^2 + 2*x3^2*x5^2 + x4^4 - 2*x4^2*x5^2 + x5^4&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Regardless of whether or not the above verification is performed, the vector p can now be used in polynomial optimization functions like &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;[[PolynomialSOS]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=CopositivePolynomial}}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=CopositivePolynomial&amp;diff=36014</id>
		<title>CopositivePolynomial</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=CopositivePolynomial&amp;diff=36014"/>
		<updated>2023-08-01T14:31:25Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: /* The Horn matrix */ finished&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=CopositivePolynomial&lt;br /&gt;
|desc=Creates a homogenous polynomial whose non-negativity is equivalent to copositivity of a given matrix&lt;br /&gt;
|rel=[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialOptimize]]&amp;lt;br /&amp;gt;[[PolynomialSOS]]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 1, 2023&lt;br /&gt;
|cvx=no}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;CopositivePolynomial&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes the standard quartic homogeneous polynomial that is associated with a copositive matrix (or any symmetric matrix, in an hopes of determineing whether or not the matrix is copositive). For example, the Horn matrix&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;C = \begin{bmatrix}1 &amp;amp; -1 &amp;amp; 1 &amp;amp; 1 &amp;amp; -1 \\ -1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; 1 \\ 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 \\ 1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; -1 \\ -1 &amp;amp; 1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1\end{bmatrix}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
is associated with the quartic polynomial&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\displaystyle p(x) = \begin{bmatrix}x_1^2 \\ x_2^2 \\ x_3^2 \\ x_4^2 \\ x_5^2\end{bmatrix}C\begin{bmatrix}x_1^2 &amp;amp; x_2^2 &amp;amp; x_3^2 &amp;amp; x_4^2 &amp;amp; x_5^2\end{bmatrix} = \sum_{i=1}^5 x_i^4 - 2\sum_{i=1}^5x_ix_{i+1} + 2\sum_{i=1}^5x_ix_{i+2},&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the sums in the subscripts are understood to be modulo 5. Copositivity of &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; is equivalent to non-negativity of the polynomial &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;P = CopositivePolynomial(C)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
* &amp;lt;tt&amp;gt;C&amp;lt;/tt&amp;gt;: A matrix.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Horn matrix===&lt;br /&gt;
Let&#039;s compute the polynomial (as a vector) representation of the Horn matrix.&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; C = [1,-1,1,1,-1;-1,1,-1,1,1;1,-1,1,-1,1;1,1,-1,1,-1;-1,1,1,-1,1];% the Horn matrix&lt;br /&gt;
&amp;gt;&amp;gt; p = CopositivePolynomial(C);&lt;br /&gt;
&amp;gt;&amp;gt; sparse(p)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   (1,1)        1&lt;br /&gt;
   (6,1)       -2&lt;br /&gt;
  (10,1)        2&lt;br /&gt;
  (13,1)        2&lt;br /&gt;
  (15,1)       -2&lt;br /&gt;
  (36,1)        1&lt;br /&gt;
  (40,1)       -2&lt;br /&gt;
  (43,1)        2&lt;br /&gt;
  (45,1)        2&lt;br /&gt;
  (56,1)        1&lt;br /&gt;
  (59,1)       -2&lt;br /&gt;
  (61,1)        2&lt;br /&gt;
  (66,1)        1&lt;br /&gt;
  (68,1)       -2&lt;br /&gt;
  (70,1)        1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To verify that the above vector of coefficients really does represent the polynomial associated with the Horn matrix, we can perform the follow computation (which requires MATLAB&#039;s symbolic computation package):&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; syms x1 x2 x3 x4 x5&lt;br /&gt;
&amp;gt;&amp;gt; x = [x1;x2;x3;x4;x5];&lt;br /&gt;
&amp;gt;&amp;gt; n = 5;% number of variables = size of Horn matrix&lt;br /&gt;
&amp;gt;&amp;gt; d = 2;% half of the degree of the (quartic) polynomial&lt;br /&gt;
&amp;gt;&amp;gt; M = PolynomialAsMatrix(p,n,d);% compute a compact fully symmetric matrix representation of this polynomial&lt;br /&gt;
&amp;gt;&amp;gt; P = SymmetricProjection(n,d,1,0);% used to expand M to non-symmetric coordinates&lt;br /&gt;
&amp;gt;&amp;gt; MF = P*M*P&#039;;% MF is a matrix representation in non-symmetric coordinates&lt;br /&gt;
&amp;gt;&amp;gt; expand(kron(x,x).&#039;*MF*kron(x,x))% expand to a polynomial&lt;br /&gt;
 &lt;br /&gt;
ans =&lt;br /&gt;
 &lt;br /&gt;
x1^4 - 2*x1^2*x2^2 + 2*x1^2*x3^2 + 2*x1^2*x4^2 - 2*x1^2*x5^2 + x2^4 - 2*x2^2*x3^2 + 2*x2^2*x4^2 + 2*x2^2*x5^2 + x3^4 - 2*x3^2*x4^2 + 2*x3^2*x5^2 + x4^4 - 2*x4^2*x5^2 + x5^4&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Regardless of whether or not the above verification is performed, the vector p can now be used in polynomial optimization functions like &amp;lt;tt&amp;gt;[[PolynomialOptimize]]&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;[[PolynomialSOS]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=CopositivePolynomial}}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=CopositivePolynomial&amp;diff=36013</id>
		<title>CopositivePolynomial</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=CopositivePolynomial&amp;diff=36013"/>
		<updated>2023-08-01T14:23:59Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Started&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=CopositivePolynomial&lt;br /&gt;
|desc=Creates a homogenous polynomial whose non-negativity is equivalent to copositivity of a given matrix&lt;br /&gt;
|rel=[[PolynomialAsMatrix]]&amp;lt;br /&amp;gt;[[PolynomialOptimize]]&amp;lt;br /&amp;gt;[[PolynomialSOS]]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=August 1, 2023&lt;br /&gt;
|cvx=no}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;CopositivePolynomial&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes the standard quartic homogeneous polynomial that is associated with a copositive matrix (or any symmetric matrix, in an hopes of determineing whether or not the matrix is copositive). For example, the Horn matrix&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;C = \begin{bmatrix}1 &amp;amp; -1 &amp;amp; 1 &amp;amp; 1 &amp;amp; -1 \\ -1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; 1 \\ 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 \\ 1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1 &amp;amp; -1 \\ -1 &amp;amp; 1 &amp;amp; 1 &amp;amp; -1 &amp;amp; 1\end{bmatrix}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
is associated with the quartic polynomial&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\displaystyle p(x) = \begin{bmatrix}x_1^2 \\ x_2^2 \\ x_3^2 \\ x_4^2 \\ x_5^2\end{bmatrix}C\begin{bmatrix}x_1^2 &amp;amp; x_2^2 &amp;amp; x_3^2 &amp;amp; x_4^2 &amp;amp; x_5^2\end{bmatrix} = \sum_{i=1}^5 x_i^4 - 2\sum_{i=1}^5x_ix_{i+1} + 2\sum_{i=1}^5x_ix_{i+2},&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the sums in the subscripts are understood to be modulo 5. Copositivity of &amp;lt;math&amp;gt;C&amp;lt;/math&amp;gt; is equivalent to non-negativity of the polynomial &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;P = CopositivePolynomial(C)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
* &amp;lt;tt&amp;gt;C&amp;lt;/tt&amp;gt;: A matrix.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===The Horn matrix===&lt;br /&gt;
Let&#039;s compute the polynomial (as a vector) representation of the Horn matrix.&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; C = [1,-1,1,1,-1;-1,1,-1,1,1;1,-1,1,-1,1;1,1,-1,1,-1;-1,1,1,-1,1];% the Horn matrix&lt;br /&gt;
&amp;gt;&amp;gt; More coming soon.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=CopositivePolynomial}}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36012</id>
		<title>List of functions</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36012"/>
		<updated>2023-08-01T14:01:50Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: /* Polynomial optimization */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a &#039;&#039;&#039;list of functions&#039;&#039;&#039; provided by QETLAB, arranged by category. If you would prefer an alphabetical list of all functions please see [[:Category:Functions|this page]]. Brief descriptions of these functions are provided here, as well as links to their documentation pages, where full details and numerous examples can be found.&lt;br /&gt;
&lt;br /&gt;
==Basic operations==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPSD]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is positive semidefinite&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Tensor]]&amp;lt;/tt&amp;gt;: Kronecker tensor product of two or more matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TensorSum]]&amp;lt;/tt&amp;gt;: Computes a vector or operator from its tensor decomposition&lt;br /&gt;
&lt;br /&gt;
==Coherence and incoherence==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[L1NormCoherence]]&amp;lt;/tt&amp;gt;: Computes the ℓ&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;-norm of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RelEntCoherence]]&amp;lt;/tt&amp;gt;: Computes the relative entropy of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RobustnessCoherence]]&amp;lt;/tt&amp;gt;: Computes the robustness of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceDistanceCoherence]]&amp;lt;/tt&amp;gt;: Computes the trace distance of coherence of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Distinguishing objects==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChannelDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing two quantum channels&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Distinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[LocalDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states by symmetric-extendible and/or PPT measurements&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPBSepDistinguishable]]&amp;lt;/tt&amp;gt;: Determines whether or not an unextendible product basis is distinguishable by separable measurements&lt;br /&gt;
&lt;br /&gt;
==Entanglement and separability==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntangledSubspace]]&amp;lt;/tt&amp;gt;: Creates a basis of an r-entangled subspace of any requested dimension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductVector]]&amp;lt;/tt&amp;gt;: Determines if a pure state is a product vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the Schmidt decomposition of a bipartite vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the Schmidt rank of a bipartite vector&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FilterNormalForm]]&amp;lt;/tt&amp;gt;: Computes the filter normal form of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsBlockPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator is block positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsEntanglingGate]]&amp;lt;/tt&amp;gt;: Determines if a unitary is an entangling gate&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix has positive partial transpose&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductOperator]]&amp;lt;/tt&amp;gt;: Determines if an operator is an elementary tensor&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsSeparable]]&amp;lt;/tt&amp;gt;: Determines whether or not a bipartite operator is separable&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt decomposition of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt rank of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric extension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricInnerExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric inner extension&lt;br /&gt;
&lt;br /&gt;
===Ball of separability===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AbsPPTConstraints]]&amp;lt;/tt&amp;gt;: Builds the eigenvalue matrices that determine whether or not a state is absolutely PPT&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InSeparableBall]]&amp;lt;/tt&amp;gt;: Checks whether or not an operator is in the ball of separability centered at the maximally-mixed state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsAbsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a density matrix is absolutely PPT&lt;br /&gt;
&lt;br /&gt;
===Entanglement measures===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Concurrence]]&amp;lt;/tt&amp;gt;: Computes the concurrence of a 2-qubit state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntFormation]]&amp;lt;/tt&amp;gt;: Computes the entanglement of formation of a bipartite quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Negativity]]&amp;lt;/tt&amp;gt;: Computes the negativity of a bipartite density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomRobustnessEntanglement]]&amp;lt;/tt&amp;gt;: Computes the random robustness of entanglement of a bipartite quantum state&lt;br /&gt;
&lt;br /&gt;
==Information theory==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Entropy]]&amp;lt;/tt&amp;gt;: Computes the von Neumann or Rényi entropy of a density matrix&lt;br /&gt;
&lt;br /&gt;
==Nonlocality and Bell inequalities==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a binary contraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameValue]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a binary constraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMax]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a Bell inequality or nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMaxQubits]]&amp;lt;/tt&amp;gt;: Approximates the optimal value of a Bell inequality in qubit (i.e., 2-dimensional quantum) settings&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NonlocalGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a non-local game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NPAHierarchy]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of probabilities satisfy the conditions of the NPA hierarchy&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ParallelRepetition]]&amp;lt;/tt&amp;gt;: Produces the coefficients of parallel repetitions of a nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[XORGameValue]]&amp;lt;/tt&amp;gt;: Computes the classical or quantum value of a non-local binary XOR game&lt;br /&gt;
&lt;br /&gt;
==Norms and distance measures==&lt;br /&gt;
===Vectors and pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkVectorNorm]]&amp;lt;/tt&amp;gt;: Computes the s(k)-norm of a vector&lt;br /&gt;
&lt;br /&gt;
===Operators and mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Fidelity]]&amp;lt;/tt&amp;gt;: Computes the (Uhlmann) fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedMatrixNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced p&amp;amp;rarr;q norm of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNorm]]&amp;lt;/tt&amp;gt;: Computes the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNormDual]]&amp;lt;/tt&amp;gt;: Computes the dual of the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KyFanNorm]]&amp;lt;/tt&amp;gt;: Computes the Ky Fan k-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MatsumotoFidelity]]&amp;lt;/tt&amp;gt;: Computes the Matsumoto fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkOperatorNorm]]&amp;lt;/tt&amp;gt;: Bounds the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchattenNorm]]&amp;lt;/tt&amp;gt;: Computes the Schatten p-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceNorm]]&amp;lt;/tt&amp;gt;: Computes the trace norm of an operator&lt;br /&gt;
&lt;br /&gt;
===Superoperators and channels===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CBNorm]]&amp;lt;/tt&amp;gt;: Computes the completely bounded norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DiamondNorm]]&amp;lt;/tt&amp;gt;: Computes the diamond norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedSchattenNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced Schatten p&amp;amp;rarr;q norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaximumOutputFidelity]]&amp;lt;/tt&amp;gt;: Computes the maximum output fidelity of two quantum channels&lt;br /&gt;
&lt;br /&gt;
==Permutations and symmetry of subsystems==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AntisymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the antisymmetric subspace&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermutationOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that permutes subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermuteSystems]]&amp;lt;/tt&amp;gt;: Permutes subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Swap]]&amp;lt;/tt&amp;gt;: Swaps two subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SwapOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that swaps two subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the symmetric subspace&lt;br /&gt;
&lt;br /&gt;
==Polynomial optimization==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CopositivePolynomial]]&amp;lt;/tt&amp;gt;: Creates a homogenous polynomial whose non-negativity is equivalent to copositivity of a given matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialAsMatrix]]&amp;lt;/tt&amp;gt;: Creates a compact fully symmetric matrix representation of a polynomial&lt;br /&gt;
&lt;br /&gt;
==Random things==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomDensityMatrix]]&amp;lt;/tt&amp;gt;: Generates a random density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPOVM]]&amp;lt;/tt&amp;gt;: Generates a random POVM (positive-operator valued measure)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPPTState]]&amp;lt;/tt&amp;gt;: Generates a random density matrix with positive partial transpose, and optionally low rank&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomProbabilities]]&amp;lt;/tt&amp;gt;: Computes a random probability vector, distributed uniformly on the unit simplex&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomStateVector]]&amp;lt;/tt&amp;gt;: Generates a random pure state vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomSuperoperator]]&amp;lt;/tt&amp;gt;: Generates a random superoperator (completely positive map)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomUnitary]]&amp;lt;/tt&amp;gt;: Generates a random unitary or orthogonal matrix&lt;br /&gt;
&lt;br /&gt;
==Special states, vectors, and operators==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Bell]]&amp;lt;/tt&amp;gt;: Produces a Bell state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BrauerStates]]&amp;lt;/tt&amp;gt;: Produces all Brauer states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DickeState]]&amp;lt;/tt&amp;gt;: Generates a Dicke state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GHZState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) GHZ state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaxEntangled]]&amp;lt;/tt&amp;gt;: Produces a maximally entangled bipartite pure state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) W-state&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BreuerState]]&amp;lt;/tt&amp;gt;: Generates a Breuer state, which is a specific family of bound entangled states on even local dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChessboardState]]&amp;lt;/tt&amp;gt;: Produces a chessboard state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GisinState]]&amp;lt;/tt&amp;gt;: Generates a 2-qubit Gisin state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[HorodeckiState]]&amp;lt;/tt&amp;gt;: Generates a bound entangled &amp;quot;Horodecki&amp;quot; state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsotropicState]]&amp;lt;/tt&amp;gt;: Produces an isotropic state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WernerState]]&amp;lt;/tt&amp;gt;: Produces a Werner state&lt;br /&gt;
&lt;br /&gt;
===Other operators===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FourierMatrix]]&amp;lt;/tt&amp;gt;: Generates the unitary matrix that implements the quantum Fourier transform&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GellMann]]&amp;lt;/tt&amp;gt;: Produces a Gell-Mann operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenGellMann]]&amp;lt;/tt&amp;gt;: Produces a generalized Gell-Mann operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenPauli]]&amp;lt;/tt&amp;gt;: Produces a generalized Pauli operator (sometimes called a Weyl operator)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Pauli]]&amp;lt;/tt&amp;gt;: Produces a Pauli operator&lt;br /&gt;
&lt;br /&gt;
==Superoperators==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ApplyMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMatrix]]&amp;lt;/tt&amp;gt;: Computes the Choi matrix of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMap]]&amp;lt;/tt&amp;gt;: Produces the Choi map or one of its generalizations&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ComplementaryMap]]&amp;lt;/tt&amp;gt;: Computes the complementary map of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DephasingChannel]]&amp;lt;/tt&amp;gt;: Produces a dephasing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DepolarizingChannel]]&amp;lt;/tt&amp;gt;: Produces a depolarizing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DualMap]]&amp;lt;/tt&amp;gt;: Computes the dual of a superoperator in the Hilbert-Schmidt inner product&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsCP]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is completely positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsHermPreserving]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is Hermiticity preserving&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KrausOperators]]&amp;lt;/tt&amp;gt;: Computes a set of Kraus operators for a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to a subsystem of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTrace]]&amp;lt;/tt&amp;gt;: Computes the partial trace of a vector or a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTranspose]]&amp;lt;/tt&amp;gt;: Computes the partial transpose of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PauliChannel]]&amp;lt;/tt&amp;gt;: Generates a Pauli channel (i.e., a quantum channel with Pauli Kraus operators)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Realignment]]&amp;lt;/tt&amp;gt;: Computes the realignment of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ReductionMap]]&amp;lt;/tt&amp;gt;: Produces the reduction map&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Twirl]]&amp;lt;/tt&amp;gt;: Twirls a bipartite or multipartite operator&lt;br /&gt;
&lt;br /&gt;
==Unextendible product bases==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsUPB]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of product vectors form a UPB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MinUPBSize]]&amp;lt;/tt&amp;gt;: Gives the minimum cardinality of an unextendible product basis in given dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPB]]&amp;lt;/tt&amp;gt;: Generates an unextendible product basis&lt;br /&gt;
&lt;br /&gt;
==Miscellaneous==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Commutant]]&amp;lt;/tt&amp;gt;: Computes the commutant of a set of matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyNonsingular]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally nonsingular&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Majorizes]]&amp;lt;/tt&amp;gt;: Determines whether or not a vector or matrix majorizes another&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSinkhorn]]&amp;lt;/tt&amp;gt;: Performs the operator Sinkhorn iteration, making all single-party reduced states proportional to the identity&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Purity]]&amp;lt;/tt&amp;gt;: Computes the purity of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Helper functions==&lt;br /&gt;
These are functions that only serve auxiliary roles within other functions of QETLAB. As an end-user of QETLAB, you likely won&#039;t have any use for these functions, but they are listed here anyway just in case.&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[bcs_to_nonlocal]]&amp;lt;/tt&amp;gt;: Converts a constraint description of a binary constraint system (BCS) game to a general non-local game description&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[dec_to_bin]]&amp;lt;/tt&amp;gt;: Converts a decimal number to a binary number in a similar way to `de2bi&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt;: Looks up a monomial&#039;s lexicographical index based on a list of exponents&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[iden]]&amp;lt;/tt&amp;gt;: Computes a sparse or full identity matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[jacobi_poly]]&amp;lt;/tt&amp;gt;: Computes the coefficients of Jacobi polynomials&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[normalize_cols]]&amp;lt;/tt&amp;gt;: Scales the columns of a matrix to have norm 1&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[one_factorization]]&amp;lt;/tt&amp;gt;: Computes a 1-factorization of a list of objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_args]]&amp;lt;/tt&amp;gt;: Handles optional input arguments for functions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_disp]]&amp;lt;/tt&amp;gt;: Display a message to the user (sometimes)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pad_array]]&amp;lt;/tt&amp;gt;: Pads an array with zeroes in a similar way to `padarray&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perfect_matchings]]&amp;lt;/tt&amp;gt;: Gives all perfect matchings of N objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_inv]]&amp;lt;/tt&amp;gt;: Computes the inverse of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_sign]]&amp;lt;/tt&amp;gt;: Computes the sign of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pure_to_mixed]]&amp;lt;/tt&amp;gt;: Converts a state vector or density matrix representation of a state to a density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sk_iterate]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[spnull]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the null space&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sporth]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the range&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[superoperator_dims]]&amp;lt;/tt&amp;gt;: Computes the input, output, and environment dimensions of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[update_odometer]]&amp;lt;/tt&amp;gt;: Increases the entries of a vector subject to constraints on how large the entries of that vector can be&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[vec_partitions]]&amp;lt;/tt&amp;gt;: Produces all possible partitions of a vector&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36011</id>
		<title>List of functions</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36011"/>
		<updated>2023-08-01T13:58:53Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Added link to CopositivePolynomial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a &#039;&#039;&#039;list of functions&#039;&#039;&#039; provided by QETLAB, arranged by category. If you would prefer an alphabetical list of all functions please see [[:Category:Functions|this page]]. Brief descriptions of these functions are provided here, as well as links to their documentation pages, where full details and numerous examples can be found.&lt;br /&gt;
&lt;br /&gt;
==Basic operations==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPSD]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is positive semidefinite&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Tensor]]&amp;lt;/tt&amp;gt;: Kronecker tensor product of two or more matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TensorSum]]&amp;lt;/tt&amp;gt;: Computes a vector or operator from its tensor decomposition&lt;br /&gt;
&lt;br /&gt;
==Coherence and incoherence==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[L1NormCoherence]]&amp;lt;/tt&amp;gt;: Computes the ℓ&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;-norm of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RelEntCoherence]]&amp;lt;/tt&amp;gt;: Computes the relative entropy of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RobustnessCoherence]]&amp;lt;/tt&amp;gt;: Computes the robustness of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceDistanceCoherence]]&amp;lt;/tt&amp;gt;: Computes the trace distance of coherence of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Distinguishing objects==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChannelDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing two quantum channels&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Distinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[LocalDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states by symmetric-extendible and/or PPT measurements&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPBSepDistinguishable]]&amp;lt;/tt&amp;gt;: Determines whether or not an unextendible product basis is distinguishable by separable measurements&lt;br /&gt;
&lt;br /&gt;
==Entanglement and separability==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntangledSubspace]]&amp;lt;/tt&amp;gt;: Creates a basis of an r-entangled subspace of any requested dimension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductVector]]&amp;lt;/tt&amp;gt;: Determines if a pure state is a product vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the Schmidt decomposition of a bipartite vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the Schmidt rank of a bipartite vector&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FilterNormalForm]]&amp;lt;/tt&amp;gt;: Computes the filter normal form of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsBlockPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator is block positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsEntanglingGate]]&amp;lt;/tt&amp;gt;: Determines if a unitary is an entangling gate&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix has positive partial transpose&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductOperator]]&amp;lt;/tt&amp;gt;: Determines if an operator is an elementary tensor&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsSeparable]]&amp;lt;/tt&amp;gt;: Determines whether or not a bipartite operator is separable&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt decomposition of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt rank of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric extension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricInnerExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric inner extension&lt;br /&gt;
&lt;br /&gt;
===Ball of separability===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AbsPPTConstraints]]&amp;lt;/tt&amp;gt;: Builds the eigenvalue matrices that determine whether or not a state is absolutely PPT&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InSeparableBall]]&amp;lt;/tt&amp;gt;: Checks whether or not an operator is in the ball of separability centered at the maximally-mixed state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsAbsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a density matrix is absolutely PPT&lt;br /&gt;
&lt;br /&gt;
===Entanglement measures===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Concurrence]]&amp;lt;/tt&amp;gt;: Computes the concurrence of a 2-qubit state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntFormation]]&amp;lt;/tt&amp;gt;: Computes the entanglement of formation of a bipartite quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Negativity]]&amp;lt;/tt&amp;gt;: Computes the negativity of a bipartite density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomRobustnessEntanglement]]&amp;lt;/tt&amp;gt;: Computes the random robustness of entanglement of a bipartite quantum state&lt;br /&gt;
&lt;br /&gt;
==Information theory==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Entropy]]&amp;lt;/tt&amp;gt;: Computes the von Neumann or Rényi entropy of a density matrix&lt;br /&gt;
&lt;br /&gt;
==Nonlocality and Bell inequalities==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a binary contraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameValue]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a binary constraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMax]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a Bell inequality or nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMaxQubits]]&amp;lt;/tt&amp;gt;: Approximates the optimal value of a Bell inequality in qubit (i.e., 2-dimensional quantum) settings&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NonlocalGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a non-local game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NPAHierarchy]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of probabilities satisfy the conditions of the NPA hierarchy&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ParallelRepetition]]&amp;lt;/tt&amp;gt;: Produces the coefficients of parallel repetitions of a nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[XORGameValue]]&amp;lt;/tt&amp;gt;: Computes the classical or quantum value of a non-local binary XOR game&lt;br /&gt;
&lt;br /&gt;
==Norms and distance measures==&lt;br /&gt;
===Vectors and pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkVectorNorm]]&amp;lt;/tt&amp;gt;: Computes the s(k)-norm of a vector&lt;br /&gt;
&lt;br /&gt;
===Operators and mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Fidelity]]&amp;lt;/tt&amp;gt;: Computes the (Uhlmann) fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedMatrixNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced p&amp;amp;rarr;q norm of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNorm]]&amp;lt;/tt&amp;gt;: Computes the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNormDual]]&amp;lt;/tt&amp;gt;: Computes the dual of the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KyFanNorm]]&amp;lt;/tt&amp;gt;: Computes the Ky Fan k-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MatsumotoFidelity]]&amp;lt;/tt&amp;gt;: Computes the Matsumoto fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkOperatorNorm]]&amp;lt;/tt&amp;gt;: Bounds the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchattenNorm]]&amp;lt;/tt&amp;gt;: Computes the Schatten p-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceNorm]]&amp;lt;/tt&amp;gt;: Computes the trace norm of an operator&lt;br /&gt;
&lt;br /&gt;
===Superoperators and channels===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CBNorm]]&amp;lt;/tt&amp;gt;: Computes the completely bounded norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DiamondNorm]]&amp;lt;/tt&amp;gt;: Computes the diamond norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedSchattenNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced Schatten p&amp;amp;rarr;q norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaximumOutputFidelity]]&amp;lt;/tt&amp;gt;: Computes the maximum output fidelity of two quantum channels&lt;br /&gt;
&lt;br /&gt;
==Permutations and symmetry of subsystems==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AntisymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the antisymmetric subspace&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermutationOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that permutes subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermuteSystems]]&amp;lt;/tt&amp;gt;: Permutes subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Swap]]&amp;lt;/tt&amp;gt;: Swaps two subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SwapOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that swaps two subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the symmetric subspace&lt;br /&gt;
&lt;br /&gt;
==Polynomial optimization==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CopositivePolynomial]]&amp;lt;/tt&amp;gt;: Creates a homogenous polynomial whose non-negativity is equivalent to copositivity of a given matrix.&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialAsMatrix]]&amp;lt;/tt&amp;gt;: Creates a compact fully symmetric matrix representation of a polynomial.&lt;br /&gt;
&lt;br /&gt;
==Random things==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomDensityMatrix]]&amp;lt;/tt&amp;gt;: Generates a random density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPOVM]]&amp;lt;/tt&amp;gt;: Generates a random POVM (positive-operator valued measure)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPPTState]]&amp;lt;/tt&amp;gt;: Generates a random density matrix with positive partial transpose, and optionally low rank&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomProbabilities]]&amp;lt;/tt&amp;gt;: Computes a random probability vector, distributed uniformly on the unit simplex&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomStateVector]]&amp;lt;/tt&amp;gt;: Generates a random pure state vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomSuperoperator]]&amp;lt;/tt&amp;gt;: Generates a random superoperator (completely positive map)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomUnitary]]&amp;lt;/tt&amp;gt;: Generates a random unitary or orthogonal matrix&lt;br /&gt;
&lt;br /&gt;
==Special states, vectors, and operators==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Bell]]&amp;lt;/tt&amp;gt;: Produces a Bell state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BrauerStates]]&amp;lt;/tt&amp;gt;: Produces all Brauer states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DickeState]]&amp;lt;/tt&amp;gt;: Generates a Dicke state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GHZState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) GHZ state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaxEntangled]]&amp;lt;/tt&amp;gt;: Produces a maximally entangled bipartite pure state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) W-state&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BreuerState]]&amp;lt;/tt&amp;gt;: Generates a Breuer state, which is a specific family of bound entangled states on even local dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChessboardState]]&amp;lt;/tt&amp;gt;: Produces a chessboard state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GisinState]]&amp;lt;/tt&amp;gt;: Generates a 2-qubit Gisin state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[HorodeckiState]]&amp;lt;/tt&amp;gt;: Generates a bound entangled &amp;quot;Horodecki&amp;quot; state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsotropicState]]&amp;lt;/tt&amp;gt;: Produces an isotropic state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WernerState]]&amp;lt;/tt&amp;gt;: Produces a Werner state&lt;br /&gt;
&lt;br /&gt;
===Other operators===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FourierMatrix]]&amp;lt;/tt&amp;gt;: Generates the unitary matrix that implements the quantum Fourier transform&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GellMann]]&amp;lt;/tt&amp;gt;: Produces a Gell-Mann operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenGellMann]]&amp;lt;/tt&amp;gt;: Produces a generalized Gell-Mann operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenPauli]]&amp;lt;/tt&amp;gt;: Produces a generalized Pauli operator (sometimes called a Weyl operator)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Pauli]]&amp;lt;/tt&amp;gt;: Produces a Pauli operator&lt;br /&gt;
&lt;br /&gt;
==Superoperators==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ApplyMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMatrix]]&amp;lt;/tt&amp;gt;: Computes the Choi matrix of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMap]]&amp;lt;/tt&amp;gt;: Produces the Choi map or one of its generalizations&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ComplementaryMap]]&amp;lt;/tt&amp;gt;: Computes the complementary map of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DephasingChannel]]&amp;lt;/tt&amp;gt;: Produces a dephasing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DepolarizingChannel]]&amp;lt;/tt&amp;gt;: Produces a depolarizing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DualMap]]&amp;lt;/tt&amp;gt;: Computes the dual of a superoperator in the Hilbert-Schmidt inner product&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsCP]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is completely positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsHermPreserving]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is Hermiticity preserving&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KrausOperators]]&amp;lt;/tt&amp;gt;: Computes a set of Kraus operators for a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to a subsystem of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTrace]]&amp;lt;/tt&amp;gt;: Computes the partial trace of a vector or a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTranspose]]&amp;lt;/tt&amp;gt;: Computes the partial transpose of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PauliChannel]]&amp;lt;/tt&amp;gt;: Generates a Pauli channel (i.e., a quantum channel with Pauli Kraus operators)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Realignment]]&amp;lt;/tt&amp;gt;: Computes the realignment of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ReductionMap]]&amp;lt;/tt&amp;gt;: Produces the reduction map&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Twirl]]&amp;lt;/tt&amp;gt;: Twirls a bipartite or multipartite operator&lt;br /&gt;
&lt;br /&gt;
==Unextendible product bases==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsUPB]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of product vectors form a UPB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MinUPBSize]]&amp;lt;/tt&amp;gt;: Gives the minimum cardinality of an unextendible product basis in given dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPB]]&amp;lt;/tt&amp;gt;: Generates an unextendible product basis&lt;br /&gt;
&lt;br /&gt;
==Miscellaneous==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Commutant]]&amp;lt;/tt&amp;gt;: Computes the commutant of a set of matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyNonsingular]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally nonsingular&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Majorizes]]&amp;lt;/tt&amp;gt;: Determines whether or not a vector or matrix majorizes another&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSinkhorn]]&amp;lt;/tt&amp;gt;: Performs the operator Sinkhorn iteration, making all single-party reduced states proportional to the identity&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Purity]]&amp;lt;/tt&amp;gt;: Computes the purity of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Helper functions==&lt;br /&gt;
These are functions that only serve auxiliary roles within other functions of QETLAB. As an end-user of QETLAB, you likely won&#039;t have any use for these functions, but they are listed here anyway just in case.&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[bcs_to_nonlocal]]&amp;lt;/tt&amp;gt;: Converts a constraint description of a binary constraint system (BCS) game to a general non-local game description&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[dec_to_bin]]&amp;lt;/tt&amp;gt;: Converts a decimal number to a binary number in a similar way to `de2bi&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt;: Looks up a monomial&#039;s lexicographical index based on a list of exponents&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[iden]]&amp;lt;/tt&amp;gt;: Computes a sparse or full identity matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[jacobi_poly]]&amp;lt;/tt&amp;gt;: Computes the coefficients of Jacobi polynomials&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[normalize_cols]]&amp;lt;/tt&amp;gt;: Scales the columns of a matrix to have norm 1&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[one_factorization]]&amp;lt;/tt&amp;gt;: Computes a 1-factorization of a list of objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_args]]&amp;lt;/tt&amp;gt;: Handles optional input arguments for functions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_disp]]&amp;lt;/tt&amp;gt;: Display a message to the user (sometimes)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pad_array]]&amp;lt;/tt&amp;gt;: Pads an array with zeroes in a similar way to `padarray&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perfect_matchings]]&amp;lt;/tt&amp;gt;: Gives all perfect matchings of N objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_inv]]&amp;lt;/tt&amp;gt;: Computes the inverse of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_sign]]&amp;lt;/tt&amp;gt;: Computes the sign of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pure_to_mixed]]&amp;lt;/tt&amp;gt;: Converts a state vector or density matrix representation of a state to a density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sk_iterate]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[spnull]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the null space&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sporth]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the range&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[superoperator_dims]]&amp;lt;/tt&amp;gt;: Computes the input, output, and environment dimensions of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[update_odometer]]&amp;lt;/tt&amp;gt;: Increases the entries of a vector subject to constraints on how large the entries of that vector can be&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[vec_partitions]]&amp;lt;/tt&amp;gt;: Produces all possible partitions of a vector&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36010</id>
		<title>List of functions</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=List_of_functions&amp;diff=36010"/>
		<updated>2023-08-01T13:30:06Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: Added link to exp2ind&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a &#039;&#039;&#039;list of functions&#039;&#039;&#039; provided by QETLAB, arranged by category. If you would prefer an alphabetical list of all functions please see [[:Category:Functions|this page]]. Brief descriptions of these functions are provided here, as well as links to their documentation pages, where full details and numerous examples can be found.&lt;br /&gt;
&lt;br /&gt;
==Basic operations==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPSD]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is positive semidefinite&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Tensor]]&amp;lt;/tt&amp;gt;: Kronecker tensor product of two or more matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TensorSum]]&amp;lt;/tt&amp;gt;: Computes a vector or operator from its tensor decomposition&lt;br /&gt;
&lt;br /&gt;
==Coherence and incoherence==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[L1NormCoherence]]&amp;lt;/tt&amp;gt;: Computes the ℓ&amp;lt;sub&amp;gt;1&amp;lt;/sub&amp;gt;-norm of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RelEntCoherence]]&amp;lt;/tt&amp;gt;: Computes the relative entropy of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RobustnessCoherence]]&amp;lt;/tt&amp;gt;: Computes the robustness of coherence of a quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceDistanceCoherence]]&amp;lt;/tt&amp;gt;: Computes the trace distance of coherence of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Distinguishing objects==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChannelDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing two quantum channels&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Distinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[LocalDistinguishability]]&amp;lt;/tt&amp;gt;: Computes the maximum probability of distinguishing quantum states by symmetric-extendible and/or PPT measurements&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPBSepDistinguishable]]&amp;lt;/tt&amp;gt;: Determines whether or not an unextendible product basis is distinguishable by separable measurements&lt;br /&gt;
&lt;br /&gt;
==Entanglement and separability==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntangledSubspace]]&amp;lt;/tt&amp;gt;: Creates a basis of an r-entangled subspace of any requested dimension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductVector]]&amp;lt;/tt&amp;gt;: Determines if a pure state is a product vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the Schmidt decomposition of a bipartite vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the Schmidt rank of a bipartite vector&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FilterNormalForm]]&amp;lt;/tt&amp;gt;: Computes the filter normal form of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsBlockPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator is block positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsEntanglingGate]]&amp;lt;/tt&amp;gt;: Determines if a unitary is an entangling gate&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix has positive partial transpose&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsProductOperator]]&amp;lt;/tt&amp;gt;: Determines if an operator is an elementary tensor&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsSeparable]]&amp;lt;/tt&amp;gt;: Determines whether or not a bipartite operator is separable&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtDecomposition]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt decomposition of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSchmidtRank]]&amp;lt;/tt&amp;gt;: Computes the operator Schmidt rank of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric extension&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricInnerExtension]]&amp;lt;/tt&amp;gt;: Determines whether or not an operator has a symmetric inner extension&lt;br /&gt;
&lt;br /&gt;
===Ball of separability===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AbsPPTConstraints]]&amp;lt;/tt&amp;gt;: Builds the eigenvalue matrices that determine whether or not a state is absolutely PPT&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InSeparableBall]]&amp;lt;/tt&amp;gt;: Checks whether or not an operator is in the ball of separability centered at the maximally-mixed state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsAbsPPT]]&amp;lt;/tt&amp;gt;: Determines whether or not a density matrix is absolutely PPT&lt;br /&gt;
&lt;br /&gt;
===Entanglement measures===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Concurrence]]&amp;lt;/tt&amp;gt;: Computes the concurrence of a 2-qubit state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[EntFormation]]&amp;lt;/tt&amp;gt;: Computes the entanglement of formation of a bipartite quantum state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Negativity]]&amp;lt;/tt&amp;gt;: Computes the negativity of a bipartite density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomRobustnessEntanglement]]&amp;lt;/tt&amp;gt;: Computes the random robustness of entanglement of a bipartite quantum state&lt;br /&gt;
&lt;br /&gt;
==Information theory==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Entropy]]&amp;lt;/tt&amp;gt;: Computes the von Neumann or Rényi entropy of a density matrix&lt;br /&gt;
&lt;br /&gt;
==Nonlocality and Bell inequalities==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a binary contraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BCSGameValue]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a binary constraint system (BCS) game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMax]]&amp;lt;/tt&amp;gt;: Computes the maximum value of a Bell inequality or nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BellInequalityMaxQubits]]&amp;lt;/tt&amp;gt;: Approximates the optimal value of a Bell inequality in qubit (i.e., 2-dimensional quantum) settings&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NonlocalGameLB]]&amp;lt;/tt&amp;gt;: Computes a lower bound on the quantum value of a non-local game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[NPAHierarchy]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of probabilities satisfy the conditions of the NPA hierarchy&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ParallelRepetition]]&amp;lt;/tt&amp;gt;: Produces the coefficients of parallel repetitions of a nonlocal game&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[XORGameValue]]&amp;lt;/tt&amp;gt;: Computes the classical or quantum value of a non-local binary XOR game&lt;br /&gt;
&lt;br /&gt;
==Norms and distance measures==&lt;br /&gt;
===Vectors and pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkVectorNorm]]&amp;lt;/tt&amp;gt;: Computes the s(k)-norm of a vector&lt;br /&gt;
&lt;br /&gt;
===Operators and mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Fidelity]]&amp;lt;/tt&amp;gt;: Computes the (Uhlmann) fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedMatrixNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced p&amp;amp;rarr;q norm of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNorm]]&amp;lt;/tt&amp;gt;: Computes the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[kpNormDual]]&amp;lt;/tt&amp;gt;: Computes the dual of the (k,p)-norm of a vector or matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KyFanNorm]]&amp;lt;/tt&amp;gt;: Computes the Ky Fan k-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MatsumotoFidelity]]&amp;lt;/tt&amp;gt;: Computes the Matsumoto fidelity of two density matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SkOperatorNorm]]&amp;lt;/tt&amp;gt;: Bounds the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SchattenNorm]]&amp;lt;/tt&amp;gt;: Computes the Schatten p-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[TraceNorm]]&amp;lt;/tt&amp;gt;: Computes the trace norm of an operator&lt;br /&gt;
&lt;br /&gt;
===Superoperators and channels===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[CBNorm]]&amp;lt;/tt&amp;gt;: Computes the completely bounded norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DiamondNorm]]&amp;lt;/tt&amp;gt;: Computes the diamond norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[InducedSchattenNorm]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the induced Schatten p&amp;amp;rarr;q norm of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaximumOutputFidelity]]&amp;lt;/tt&amp;gt;: Computes the maximum output fidelity of two quantum channels&lt;br /&gt;
&lt;br /&gt;
==Permutations and symmetry of subsystems==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[AntisymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the antisymmetric subspace&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermutationOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that permutes subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PermuteSystems]]&amp;lt;/tt&amp;gt;: Permutes subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Swap]]&amp;lt;/tt&amp;gt;: Swaps two subsystems within a state or operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SwapOperator]]&amp;lt;/tt&amp;gt;: Produces a unitary operator that swaps two subsystems&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[SymmetricProjection]]&amp;lt;/tt&amp;gt;: Produces the projection onto the symmetric subspace&lt;br /&gt;
&lt;br /&gt;
==Polynomial optimization==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PolynomialAsMatrix]]&amp;lt;/tt&amp;gt;: Creates a compact fully symmetric matrix representation of a polynomial.&lt;br /&gt;
&lt;br /&gt;
==Random things==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomDensityMatrix]]&amp;lt;/tt&amp;gt;: Generates a random density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPOVM]]&amp;lt;/tt&amp;gt;: Generates a random POVM (positive-operator valued measure)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomPPTState]]&amp;lt;/tt&amp;gt;: Generates a random density matrix with positive partial transpose, and optionally low rank&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomProbabilities]]&amp;lt;/tt&amp;gt;: Computes a random probability vector, distributed uniformly on the unit simplex&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomStateVector]]&amp;lt;/tt&amp;gt;: Generates a random pure state vector&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomSuperoperator]]&amp;lt;/tt&amp;gt;: Generates a random superoperator (completely positive map)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[RandomUnitary]]&amp;lt;/tt&amp;gt;: Generates a random unitary or orthogonal matrix&lt;br /&gt;
&lt;br /&gt;
==Special states, vectors, and operators==&lt;br /&gt;
===Pure states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Bell]]&amp;lt;/tt&amp;gt;: Produces a Bell state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BrauerStates]]&amp;lt;/tt&amp;gt;: Produces all Brauer states&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DickeState]]&amp;lt;/tt&amp;gt;: Generates a Dicke state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GHZState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) GHZ state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MaxEntangled]]&amp;lt;/tt&amp;gt;: Produces a maximally entangled bipartite pure state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WState]]&amp;lt;/tt&amp;gt;: Generates a (generalized) W-state&lt;br /&gt;
&lt;br /&gt;
===Mixed states===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[BreuerState]]&amp;lt;/tt&amp;gt;: Generates a Breuer state, which is a specific family of bound entangled states on even local dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChessboardState]]&amp;lt;/tt&amp;gt;: Produces a chessboard state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GisinState]]&amp;lt;/tt&amp;gt;: Generates a 2-qubit Gisin state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[HorodeckiState]]&amp;lt;/tt&amp;gt;: Generates a bound entangled &amp;quot;Horodecki&amp;quot; state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsotropicState]]&amp;lt;/tt&amp;gt;: Produces an isotropic state&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[WernerState]]&amp;lt;/tt&amp;gt;: Produces a Werner state&lt;br /&gt;
&lt;br /&gt;
===Other operators===&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[FourierMatrix]]&amp;lt;/tt&amp;gt;: Generates the unitary matrix that implements the quantum Fourier transform&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GellMann]]&amp;lt;/tt&amp;gt;: Produces a Gell-Mann operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenGellMann]]&amp;lt;/tt&amp;gt;: Produces a generalized Gell-Mann operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[GenPauli]]&amp;lt;/tt&amp;gt;: Produces a generalized Pauli operator (sometimes called a Weyl operator)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Pauli]]&amp;lt;/tt&amp;gt;: Produces a Pauli operator&lt;br /&gt;
&lt;br /&gt;
==Superoperators==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ApplyMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMatrix]]&amp;lt;/tt&amp;gt;: Computes the Choi matrix of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ChoiMap]]&amp;lt;/tt&amp;gt;: Produces the Choi map or one of its generalizations&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ComplementaryMap]]&amp;lt;/tt&amp;gt;: Computes the complementary map of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DephasingChannel]]&amp;lt;/tt&amp;gt;: Produces a dephasing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DepolarizingChannel]]&amp;lt;/tt&amp;gt;: Produces a depolarizing channel&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[DualMap]]&amp;lt;/tt&amp;gt;: Computes the dual of a superoperator in the Hilbert-Schmidt inner product&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsCP]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is completely positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsHermPreserving]]&amp;lt;/tt&amp;gt;: Determines whether or not a superoperator is Hermiticity preserving&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[KrausOperators]]&amp;lt;/tt&amp;gt;: Computes a set of Kraus operators for a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialMap]]&amp;lt;/tt&amp;gt;: Applies a superoperator to a subsystem of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTrace]]&amp;lt;/tt&amp;gt;: Computes the partial trace of a vector or a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PartialTranspose]]&amp;lt;/tt&amp;gt;: Computes the partial transpose of a matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[PauliChannel]]&amp;lt;/tt&amp;gt;: Generates a Pauli channel (i.e., a quantum channel with Pauli Kraus operators)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Realignment]]&amp;lt;/tt&amp;gt;: Computes the realignment of a bipartite operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[ReductionMap]]&amp;lt;/tt&amp;gt;: Produces the reduction map&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Twirl]]&amp;lt;/tt&amp;gt;: Twirls a bipartite or multipartite operator&lt;br /&gt;
&lt;br /&gt;
==Unextendible product bases==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsUPB]]&amp;lt;/tt&amp;gt;: Determines whether or not a set of product vectors form a UPB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[MinUPBSize]]&amp;lt;/tt&amp;gt;: Gives the minimum cardinality of an unextendible product basis in given dimensions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[UPB]]&amp;lt;/tt&amp;gt;: Generates an unextendible product basis&lt;br /&gt;
&lt;br /&gt;
==Miscellaneous==&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Commutant]]&amp;lt;/tt&amp;gt;: Computes the commutant of a set of matrices&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyNonsingular]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally nonsingular&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[IsTotallyPositive]]&amp;lt;/tt&amp;gt;: Determines whether or not a matrix is totally positive&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Majorizes]]&amp;lt;/tt&amp;gt;: Determines whether or not a vector or matrix majorizes another&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[OperatorSinkhorn]]&amp;lt;/tt&amp;gt;: Performs the operator Sinkhorn iteration, making all single-party reduced states proportional to the identity&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[Purity]]&amp;lt;/tt&amp;gt;: Computes the purity of a quantum state&lt;br /&gt;
&lt;br /&gt;
==Helper functions==&lt;br /&gt;
These are functions that only serve auxiliary roles within other functions of QETLAB. As an end-user of QETLAB, you likely won&#039;t have any use for these functions, but they are listed here anyway just in case.&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[bcs_to_nonlocal]]&amp;lt;/tt&amp;gt;: Converts a constraint description of a binary constraint system (BCS) game to a general non-local game description&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[dec_to_bin]]&amp;lt;/tt&amp;gt;: Converts a decimal number to a binary number in a similar way to `de2bi&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt;: Looks up a monomial&#039;s lexicographical index based on a list of exponents&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[iden]]&amp;lt;/tt&amp;gt;: Computes a sparse or full identity matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[jacobi_poly]]&amp;lt;/tt&amp;gt;: Computes the coefficients of Jacobi polynomials&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[normalize_cols]]&amp;lt;/tt&amp;gt;: Scales the columns of a matrix to have norm 1&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[one_factorization]]&amp;lt;/tt&amp;gt;: Computes a 1-factorization of a list of objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_args]]&amp;lt;/tt&amp;gt;: Handles optional input arguments for functions&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[opt_disp]]&amp;lt;/tt&amp;gt;: Display a message to the user (sometimes)&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pad_array]]&amp;lt;/tt&amp;gt;: Pads an array with zeroes in a similar way to `padarray&#039; in MATLAB&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perfect_matchings]]&amp;lt;/tt&amp;gt;: Gives all perfect matchings of N objects&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_inv]]&amp;lt;/tt&amp;gt;: Computes the inverse of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[perm_sign]]&amp;lt;/tt&amp;gt;: Computes the sign of a permutation&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[pure_to_mixed]]&amp;lt;/tt&amp;gt;: Converts a state vector or density matrix representation of a state to a density matrix&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sk_iterate]]&amp;lt;/tt&amp;gt;: Computes a lower bound of the S(k)-norm of an operator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[spnull]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the null space&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[sporth]]&amp;lt;/tt&amp;gt;: Returns a sparse orthonormal basis for the range&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[superoperator_dims]]&amp;lt;/tt&amp;gt;: Computes the input, output, and environment dimensions of a superoperator&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[update_odometer]]&amp;lt;/tt&amp;gt;: Increases the entries of a vector subject to constraints on how large the entries of that vector can be&lt;br /&gt;
* &amp;lt;tt&amp;gt;[[vec_partitions]]&amp;lt;/tt&amp;gt;: Produces all possible partitions of a vector&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=PolynomialAsMatrix&amp;diff=36009</id>
		<title>PolynomialAsMatrix</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=PolynomialAsMatrix&amp;diff=36009"/>
		<updated>2023-08-01T13:23:02Z</updated>

		<summary type="html">&lt;p&gt;Nathaniel: /* The Motzkin polynomial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Function&lt;br /&gt;
|name=PolynomialAsMatrix&lt;br /&gt;
|desc=Creates a compact fully symmetric matrix representation of a polynomial&lt;br /&gt;
|rel=[[CopositivePolynomial]]&amp;lt;br /&amp;gt;[[PolynomialOptimize]]&amp;lt;br /&amp;gt;[[PolynomialSOS]]&lt;br /&gt;
|cat=[[List of functions#Polynomial_optimization|Polynomial optimization]]&lt;br /&gt;
|upd=July 31, 2023&lt;br /&gt;
|cvx=no}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&#039;&#039;&#039;PolynomialAsMatrix&#039;&#039;&#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that computes a compact form of a fully symmetric matrix representation of an even-degree homogeneous polynomial. More specifically, if p is a homogeneous polynomial of degree 2d then there is a unique fully symmetric matrix &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; with the property that &amp;lt;math&amp;gt;p(x_1,x_2,\ldots,x_n) = (\mathbf{x}^{\otimes d})^T M(\mathbf{x}^{\otimes d})&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;\mathbf{x} = (x_1,x_2,\ldots,x_n)&amp;lt;/math&amp;gt; as a column vector. Here, &amp;quot;fully symmetric&amp;quot; means that &amp;lt;math&amp;gt;M^T = M&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; is supported on the [[symmetric subspace]] (i.e., &amp;lt;math&amp;gt;PMP = M&amp;lt;/math&amp;gt;, where &amp;lt;math&amp;gt;P&amp;lt;/math&amp;gt; is the [[SymmetricProjection|symmetric projection]]), and &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt; equals its own [[PartialTranspose|partial transpose]] (across any bipartition).&lt;br /&gt;
&lt;br /&gt;
This function returns this fully symmetric matrix &amp;lt;math&amp;gt;M&amp;lt;/math&amp;gt;, in symmetric coordinates. That is, there is an isometry &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; from the symmetric subspace of &amp;lt;math&amp;gt;(\mathbb{C}^n)^{\otimes d}&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;(\mathbb{C}^n)^{\otimes d}&amp;lt;/math&amp;gt; itself with the property that the output of this function equals &amp;lt;math&amp;gt;V^*MV&amp;lt;/math&amp;gt;. This isometry &amp;lt;math&amp;gt;V&amp;lt;/math&amp;gt; is computed by &amp;lt;tt&amp;gt;[[SymmetricProjection]](N,D,1,0)&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;M = PolynomialAsMatrix(P,N,D)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;M = PolynomialAsMatrix(P,N,D,K)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
* &amp;lt;tt&amp;gt;P&amp;lt;/tt&amp;gt;: The polynomial, represented as a vector of coefficients of its monomials in lexicographic order.&lt;br /&gt;
* &amp;lt;tt&amp;gt;N&amp;lt;/tt&amp;gt;: The number of variables in the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;D&amp;lt;/tt&amp;gt;: Half the degree of the polynomial.&lt;br /&gt;
* &amp;lt;tt&amp;gt;K&amp;lt;/tt&amp;gt; (optional, default 0): A non-negative integer that indicates the level of the SOS or SOS-type hierarchy. More specifically, this input argument causes the output matrix to represent the polynomial (S(x))^K * P(x) instead of P(x) itself, where S(x) = x1^2 + x2^2 + ... + xN^2.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===A simple low-degree polynomial===&lt;br /&gt;
Let&#039;s turn the homogeneous polynomial &amp;lt;math&amp;gt;p(x,y,z) = x^2 + 2xy + 3xz + 4y^2 + 5yz + 6z^2&amp;lt;/math&amp;gt; into its fully symmetric matrix representation.&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 1;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; p = [1;2;3;4;5;6];% coefficients of the polynomial, in lexicographical order of the monomials&lt;br /&gt;
&amp;gt;&amp;gt; M = full(PolynomialAsMatrix(p,n,d))&lt;br /&gt;
&lt;br /&gt;
M =&lt;br /&gt;
&lt;br /&gt;
    1.0000    1.0000    1.5000&lt;br /&gt;
    1.0000    4.0000    2.5000&lt;br /&gt;
    1.5000    2.5000    6.0000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The output of this function is always sparse, so we used the &amp;lt;tt&amp;gt;full&amp;lt;/tt&amp;gt; function around the output above just to make the output easier to see. Since &amp;lt;math&amp;gt;d = 1&amp;lt;/math&amp;gt;, the above matrix is the usual symmetric matrix representation of the quadratric form &amp;lt;math&amp;gt;p&amp;lt;/math&amp;gt;. The following verification of this fact requires MATLAB&#039;s symbolic toolbox:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; syms x y z&lt;br /&gt;
&amp;gt;&amp;gt; expand([x y z]*M*[x;y;z])&lt;br /&gt;
 &lt;br /&gt;
ans =&lt;br /&gt;
 &lt;br /&gt;
x^2 + 2*x*y + 3*x*z + 4*y^2 + 5*y*z + 6*z^2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===The Motzkin polynomial===&lt;br /&gt;
The Motzkin polynomial is the following degree-6 homogeneous polynomial: &amp;lt;math&amp;gt;p(x,y,z) = x^4y^2 + x^2y^4 - 3x^2y^2z^2 + z^6&amp;lt;/math&amp;gt;. To use this &amp;lt;tt&amp;gt;PolynomialAsMatrix&amp;lt;/tt&amp;gt; function, we have to first arrange the monomials of p (even the ones with coefficient 0) in lexicographical order and list them in a vector. To make this task (much!) easier, we use the &amp;lt;tt&amp;gt;[[exp2ind]]&amp;lt;/tt&amp;gt; helper function:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; n = 3;% number of variables&lt;br /&gt;
&amp;gt;&amp;gt; d = 3;% half the degree of the polynomial&lt;br /&gt;
&amp;gt;&amp;gt; p = zeros(nchoosek(n+2*d-1,2*d),1);% initialize p to have the correct size&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([4 2 0])) = 1;% the &amp;quot;4 2 0&amp;quot; here are the exponents in the term x^4y^2z^0, while the &amp;quot;1&amp;quot; is the coefficient of this term&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 4 0])) = 1;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([2 2 2])) = -3;&lt;br /&gt;
&amp;gt;&amp;gt; p(exp2ind([0 0 6])) = 1;% now p represents the Motzkin polynomial&lt;br /&gt;
&amp;gt;&amp;gt; M = full(PolynomialAsMatrix(p,n,d))&lt;br /&gt;
&lt;br /&gt;
M =&lt;br /&gt;
&lt;br /&gt;
         0         0         0    0.1155         0         0         0         0         0         0&lt;br /&gt;
         0    0.2000         0         0         0         0    0.1155         0   -0.1000         0&lt;br /&gt;
         0         0         0         0         0         0         0   -0.1000         0         0&lt;br /&gt;
    0.1155         0         0    0.2000         0   -0.1000         0         0         0         0&lt;br /&gt;
         0         0         0         0   -0.2000         0         0         0         0         0&lt;br /&gt;
         0         0         0   -0.1000         0         0         0         0         0         0&lt;br /&gt;
         0    0.1155         0         0         0         0         0         0         0         0&lt;br /&gt;
         0         0   -0.1000         0         0         0         0         0         0         0&lt;br /&gt;
         0   -0.1000         0         0         0         0         0         0         0         0&lt;br /&gt;
         0         0         0         0         0         0         0         0         0    1.0000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output of this function is always sparse, so we used the &amp;lt;tt&amp;gt;full&amp;lt;/tt&amp;gt; function around the output above just to make the output easier to see. When &amp;lt;math&amp;gt;d &amp;gt; 1&amp;lt;/math&amp;gt; (like in this example), we can verify that the above matrix represents the given polynomial via the isometry created by the [[SymmetricProjection]] function. The following verification of this fact requires MATLAB&#039;s symbolic toolbox:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; P = SymmetricProjection(n,d,1,0);&lt;br /&gt;
&amp;gt;&amp;gt; MF = P*M*P&#039;;&lt;br /&gt;
&amp;gt;&amp;gt; syms x y z&lt;br /&gt;
&amp;gt;&amp;gt; v = [x;y;z];&lt;br /&gt;
&amp;gt;&amp;gt; expand(Tensor(v,3).&#039;*MF*Tensor(v,3))&lt;br /&gt;
 &lt;br /&gt;
ans =&lt;br /&gt;
 &lt;br /&gt;
x^4*y^2 + x^2*y^4 - 3*x^2*y^2*z^2 + z^6&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=PolynomialAsMatrix}}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
Coming soon.&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
</feed>