<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://qetlab.com/wiki/index.php?action=history&amp;feed=atom&amp;title=WState</id>
	<title>WState - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://qetlab.com/wiki/index.php?action=history&amp;feed=atom&amp;title=WState"/>
	<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=WState&amp;action=history"/>
	<updated>2026-07-19T16:00:54Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://qetlab.com/wiki/index.php?title=WState&amp;diff=694&amp;oldid=prev</id>
		<title>Nathaniel: Created page with &quot;{{Function |name=WState |desc=Generates a (generalized) W-state |rel=DickeState&lt;br /&gt;GHZState&lt;br /&gt;MaxEntangled |cat=List of functions#Special_states,_vectors,_a...&quot;</title>
		<link rel="alternate" type="text/html" href="https://qetlab.com/wiki/index.php?title=WState&amp;diff=694&amp;oldid=prev"/>
		<updated>2014-12-24T16:20:24Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Function |name=WState |desc=Generates a (generalized) W-state |rel=&lt;a href=&quot;/DickeState&quot; title=&quot;DickeState&quot;&gt;DickeState&lt;/a&gt;&amp;lt;br /&amp;gt;&lt;a href=&quot;/GHZState&quot; title=&quot;GHZState&quot;&gt;GHZState&lt;/a&gt;&amp;lt;br /&amp;gt;&lt;a href=&quot;/MaxEntangled&quot; title=&quot;MaxEntangled&quot;&gt;MaxEntangled&lt;/a&gt; |cat=List of functions#Special_states,_vectors,_a...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Function&lt;br /&gt;
|name=WState&lt;br /&gt;
|desc=Generates a (generalized) W-state&lt;br /&gt;
|rel=[[DickeState]]&amp;lt;br /&amp;gt;[[GHZState]]&amp;lt;br /&amp;gt;[[MaxEntangled]]&lt;br /&gt;
|cat=[[List of functions#Special_states,_vectors,_and_operators|Special states, vectors, and operators]]&lt;br /&gt;
|upd=December 24, 2014}}&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;#039;&amp;#039;&amp;#039;WState&amp;#039;&amp;#039;&amp;#039;&amp;lt;/tt&amp;gt; is a [[List of functions|function]] that returns a [http://en.wikipedia.org/wiki/W_state W-state] on a given number of qubits. For example, the usual $3$-qubit W-state is $\frac{1}{\sqrt{3}}(|100\rangle + |010\rangle + |001\rangle)$. More generally, the W-state on $q$ qudits is $\frac{1}{\sqrt{q}}(|10\cdots 00\rangle + |01\cdots 00\rangle + \cdots + |00\cdots 01\rangle)$. The output of this function is a sparse vector.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
* &amp;lt;tt&amp;gt;W_STATE = WState(Q)&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;W_STATE = WState(Q,COEFF)&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Argument descriptions==&lt;br /&gt;
* &amp;lt;tt&amp;gt;Q&amp;lt;/tt&amp;gt;: The number of qubits.&lt;br /&gt;
* &amp;lt;tt&amp;gt;COEFF&amp;lt;/tt&amp;gt; (optional, default &amp;lt;tt&amp;gt;[1,1,...,1]/sqrt(Q)&amp;lt;/tt&amp;gt;): A vector whose $j$-th entry is the coefficient of the term $|0\rangle^{\otimes (j-1)} \otimes |1\rangle \otimes |0\rangle^{\otimes q-j}$ in the sum that defines the W-state.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===3-qubit W-state===&lt;br /&gt;
The following code generates the usual 3-qubit GHZ state:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; full(WState(3))&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
         0&lt;br /&gt;
    0.5774&lt;br /&gt;
    0.5774&lt;br /&gt;
         0&lt;br /&gt;
    0.5774&lt;br /&gt;
         0&lt;br /&gt;
         0&lt;br /&gt;
         0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===A generalized W-state===&lt;br /&gt;
The following code generates the following generalized 4-qubit W-state:&lt;br /&gt;
: &amp;lt;math&amp;gt;\frac{1}{\sqrt{30}}\big( |1000\rangle + 2|0100\rangle + 3|0010\rangle + 4|0001\rangle \big).&amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; WState(4,[1,2,3,4]/sqrt(30))&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
   (2,1)       0.7303&lt;br /&gt;
   (3,1)       0.5477&lt;br /&gt;
   (5,1)       0.3651&lt;br /&gt;
   (9,1)       0.1826&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===A very large W-state===&lt;br /&gt;
This script has no trouble creating W-states on very large numbers of qubits. The following code generates the 30-qubit W-state:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; WState(30)&lt;br /&gt;
&lt;br /&gt;
ans =&lt;br /&gt;
&lt;br /&gt;
                  (2,1)                      0.1826&lt;br /&gt;
                  (3,1)                      0.1826&lt;br /&gt;
                  (5,1)                      0.1826&lt;br /&gt;
                  (9,1)                      0.1826&lt;br /&gt;
                 (17,1)                      0.1826&lt;br /&gt;
                 (33,1)                      0.1826&lt;br /&gt;
                 (65,1)                      0.1826&lt;br /&gt;
                (129,1)                      0.1826&lt;br /&gt;
                (257,1)                      0.1826&lt;br /&gt;
                (513,1)                      0.1826&lt;br /&gt;
               (1025,1)                      0.1826&lt;br /&gt;
               (2049,1)                      0.1826&lt;br /&gt;
               (4097,1)                      0.1826&lt;br /&gt;
               (8193,1)                      0.1826&lt;br /&gt;
              (16385,1)                      0.1826&lt;br /&gt;
              (32769,1)                      0.1826&lt;br /&gt;
              (65537,1)                      0.1826&lt;br /&gt;
             (131073,1)                      0.1826&lt;br /&gt;
             (262145,1)                      0.1826&lt;br /&gt;
             (524289,1)                      0.1826&lt;br /&gt;
            (1048577,1)                      0.1826&lt;br /&gt;
            (2097153,1)                      0.1826&lt;br /&gt;
            (4194305,1)                      0.1826&lt;br /&gt;
            (8388609,1)                      0.1826&lt;br /&gt;
           (16777217,1)                      0.1826&lt;br /&gt;
           (33554433,1)                      0.1826&lt;br /&gt;
           (67108865,1)                      0.1826&lt;br /&gt;
          (134217729,1)                      0.1826&lt;br /&gt;
          (268435457,1)                      0.1826&lt;br /&gt;
          (536870913,1)                      0.1826&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{SourceCode|name=WState}}&lt;/div&gt;</summary>
		<author><name>Nathaniel</name></author>
	</entry>
</feed>