# Bell

Jump to: navigation, search
 Other toolboxes required Bell Produces a Bell state none MaxEntangled Special states, vectors, and operators

Bell is a function that returns one of the four Bell states in 2-qubit space:

\displaystyle\begin{align*}|\phi_0\rangle = \frac{1}{\sqrt{2}}(|0\rangle\otimes|0\rangle + |1\rangle\otimes|1\rangle) & & & & |\phi_2\rangle = \frac{1}{\sqrt{2}}(|0\rangle\otimes|1\rangle + |1\rangle\otimes|0\rangle) \\ |\phi_1\rangle = \frac{1}{\sqrt{2}}(|0\rangle\otimes|0\rangle - |1\rangle\otimes|1\rangle) & & & & |\phi_3\rangle = \frac{1}{\sqrt{2}}(|0\rangle\otimes|1\rangle - |1\rangle\otimes|0\rangle) \\\end{align*}

## Syntax

• PHI = Bell()
• PHI = Bell(IND)
• PHI = Bell(IND,SP)
• PHI = Bell(IND,SP,NRML)

## Argument descriptions

• IND (optional, default 0): The index of the Bell state (i.e., the subscript, from 0 to 3, of the Bell state that you would like, as indicated above).
• SP (optional, default 0): A flag (either 1 or 0) indicating that PHI should or should not be sparse.
• NRML (optional, default 1): A flag (either 1 or 0) indicating that PHI should or should not be scaled to have Euclidean norm 1. If NRML=0 then each entry of PHI is 0 or 1, so it has norm $\sqrt{2}$.

## Examples

The following code generates a matrix whose columns are the four different Bell states:

>> [Bell(0),Bell(1),Bell(2),Bell(3)]

ans =

0.7071    0.7071         0         0
0         0    0.7071    0.7071
0         0    0.7071   -0.7071
0.7071   -0.7071         0         0

## Source code

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

1. %%  BELL    Produces a Bell state
2. %   This function has no required arguments.
3. %
4. %   PHI = Bell() is the Bell state (|0>|0> + |1>|1>)/sqrt(2)
5. %
6. %   This function has three optional arguments:
7. %     IND (default 0)
8. %     SP (default 0)
9. %     NRML (default 1)
10. %
11. %   PHI = Bell(IND,SP,NRML) produces one of the following four Bell states,
12. %   depending on the value of IND:
13. %     0: (|0>|0> + |1>|1>)/sqrt(2)
14. %     1: (|0>|0> - |1>|1>)/sqrt(2)
15. %     2: (|0>|1> + |1>|0>)/sqrt(2)
16. %     3: (|0>|1> - |1>|0>)/sqrt(2)
17. %   The Bell state is sparse if SP = 1 and is full if SP = 0. It is
18. %   normalized to have Euclidean norm 1 if NRML = 1, and it is unnormalized
19. %   (i.e., each entry in the vector is 0 or 1) if NRML = 0.
20. %
21. %   URL: http://www.qetlab.com/Bell
22. 
23. %   requires: iden.m, opt_args.m
24. %   author: Nathaniel Johnston (nathaniel@njohnston.ca)
25. %   package: QETLAB
26. %   last updated: September 23, 2014
27. 
28. function phi = Bell(varargin)
29. 
30. % set optional argument defaults: ind=0, sp=0, nrml=1
31. [ind,sp,nrml] = opt_args({ 0, 0, 1 },varargin{:});
32. 
33. % construct an identity matrix, whose columns will be the local vectors
34. id = iden(2,sp);
35. colmod = mod(floor(ind/2),2); % we do (mod 2) so that values of ind > 3 work too
36. 
37. % construct the Bell state
38. phi = kron(id(:,1),id(:,1+colmod)) + ((-1)^ind)*kron(id(:,2),id(:,2-colmod));
39. if(nrml == 1)
40.     phi = phi/sqrt(2);
41. end