<?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=Etanjk</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=Etanjk"/>
	<link rel="alternate" type="text/html" href="https://qetlab.com/Special:Contributions/Etanjk"/>
	<updated>2026-10-23T14:07:17Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=Fidelity&amp;diff=967</id>
		<title>Fidelity</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=Fidelity&amp;diff=967"/>
		<updated>2020-09-14T05:46:55Z</updated>

		<summary type="html">&lt;p&gt;Etanjk: The definition of fidelity needs to be squared after tracing according to Josza&amp;#039;s paper.&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)]^2.&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>Etanjk</name></author>
	</entry>
</feed>