The unitary group \(U(n)\) describes the possible change of basis in the complex Hilbert space of dimension \(n\). For \(n=2\), this captures the possible choices of basis in the qubit space \(C^2\). For a system composed of two qubits, we can similarly define the effect of a joint change of basis performed on both subsystems simultaneously. It is known that a single state is invariant under such joint change of basis. Here, we identify this state by extracting the subspace of \((C^2)^{\otimes 2}\) which is invariant under the joint change of basis for both subsystems.

Before trying any of the *RepLAB* commands, we must initialize the library:

```
[1]:
```

```
addpath([pwd, '/../../../external/replab']);
replab_init('verbose', 0);
```

```
replab_init: Initialization done.
```

Changes of bases for one system are described by the group \(U(2)\)

```
[2]:
```

```
d = 2;
U2 = replab.U(d);
```

We construct the defining representation of this group, which acts on \(C^2\):

```
[3]:
```

```
U2Rep = U2.definingRep;
```

We can now construct the representation which acts jointly on two subsystems of dimension 2:

```
[4]:
```

```
U2TensorRep = kron(U2Rep, U2Rep);
```

To identify the subspaces which are invariant under this group, we decompose the representation:

```
[5]:
```

```
dec = U2TensorRep.decomposition.nice;
```

The decomposition has

```
[6]:
```

```
dec.nComponents
```

```
ans = 2
```

components, of dimension

```
[7]:
```

```
dec.component(1).irrepDimension
```

```
ans = 1
```

and

```
[8]:
```

```
dec.component(2).irrepDimension
```

```
ans = 3
```

These are the antisymmetric and symmetric subspaces respectively. The change of basis into the first component identifies the antisymetric subspace, also known as the *singlet state*:

```
[9]:
```

```
singletBasis = dec.component(1).basis
rest = dec.component(2).basis
```

```
singletBasis =
0
0.5000
-0.5000
0
rest =
1.0000 0 0
0 0 0.5000
0 0 0.5000
0 1.0000 0
```