Pauli-Y Gate

QSharp

On this page:

The Pauli-Y Gate

The Pauli-Y gate acts on a single qubit. It maps |0› to i|1› and |1› to -i|0›. The Pauli-Y gate is represented by the following matrix:

The Pauli-Y matrix

//	One-line notation
{{0, -i}, {i, 0}}

//	Expanded notation
{
{0,-i},
{i, 0}
}

Manipulation of a register takes the form of matrix algebra. In order for the mathematics to take place, matricies of appropriate size must be constructed. This can be a tedious and time consuming process.

Thankfully, there is an easier way to compute these outcomes, as will be demonstrated.

If you are unfamiliar with either tensor products or matrix multiplication, then I would suggest revising those topics first, otherwise a lot of this will look like magic.

Imaginary Numbers

The Pauli-Y gate makes use of the imaginary number i. This number has the following property:

i2 = -1

The effect this has is that essentially, whenever i is squared, it changes the sign of the term.

Example 1

5i2
= 5 * (-1)	//	Substitute in -1 for i
= -5

Example 2

(5i)2		//	Compute the brackets first
= (52) * (i2)	//	Distribute the exponent
= (25) * (-1)	//	Substitute in -1 for i
= -25

Example 3

(2 + 3i)(4 - i)

Let a = 2
Let bi = 3i
Let c = 4
Let di = -i

//	FOIL - First, Outside, Inside, Last
(a + bi)(c + di) = ac + adi + bci + bdi2
(2 + 3i) * (4 - i)
= (2 * 4) + (2 * -i) + (3i * 4) + (3i * -i)
= (8) + (-2i) + (12i) + -3i2)
= 8 + 10i - 3i2
= 8 + 10i - 3(-1)
= 8 + 3 + 10i
= 11 + 10i

Example 4

(1 + 7i)/(3 + 2i)

//	Multiply the numerator and denominator by the conjugate of the denominator
//	A conjugate is a binomial formed by negating the second term of a binomial
//	The denominator is (3 + 2i), so the conjugate is (3 - 2i)

//	Numerator
(1 + 7i) * (3 - 2i)
= 1(3 - 2i) + 7i(3 - 2i)
= 3 - 2i + 21i - 14i2
= 3 + 19i - 14(-1)
= 3 + 19i +14
= 17 + 19i

//	Denominator
(3 + 2i) * (3 - 2i)
= 3(3 - 2i) + 2i(3 - 2i)
= 9 - 6i + 6i -4i2
= 9 -4(-1)
= 9 + 4
= 13

//	Therefore
= (17 + 19i) / 13

The Imaginary Number Short-Cut

There is a pattern with i2, or a 'short-cut' - whenever i2, it changes the sign of the term, and the exponent is removed in the process, such that:

15i2

//	Compute the exponent
152 = 225

//	Flip the sign of the term by multiplying by -1
= -1 * 225
= -225

Syntax

The Quantum Console syntax for this operation is:

Y(n);

Where n specifies the number (or index) of the qubit we wish to manipulate.

* Note that this index is 0 based, not 1 based as represented in most examples.

1 Qubit Register

Performing this calculation on a single qubit is fairly straight forward, as the rules for matrix multiplication (number of columns from matrix A must match the number of rows from matrix B) are satisfied.

In other words, the number of columns in the Pauli-Y matrix match the number of rows in the state vector.

Matrix mathematics

{
{0,-i},
{i, 0}
}
*
{
{A|0›},
{B|1›}
}
=
Show intermediate working
{
{-iB|1›},
{ iA|0›}
}

Performing the operation in Quantum Console

//	Qubits
(A|0› + B|1›)

//	Computational Basis States - Input
A|0› + B|1›

//	Quantum Console syntax
//	Apply Y to qubit 0
Y(0);

//	Computational Basis States - Ouput
-iB|0› + iA|1›

2 Qubit Register

Performing this calculation becomes a little bit trickier, as our state vector is now larger (2n, n = 2) at 4 rows.

Consequently, as the state vector now has 4 rows, so a Y gate cannot be applied to it, as the number of columns from matrix A (2) does not match the number of rows from matrix B (4).

To work around this, it is necessary to tensor an I (identity) matrix for each other qubit in order to construct the matrix of the appropriate size.

In this example, the Y gate is applied to the qubit in position 1, and as the identity matrices are inferred, the operation could be written as:

IY

If the Y gate was to be applied to the qubit in position 0, and as the identity matrices are inferred, the operation could be written as:

YI

Matrix mathematics

First, tensor the gate with an identity matrix:

{
{1, 0},
{0, 1}
}
(x)
{
{0,-i},
{i, 0}
}
=
{
{0, 0,-i  0},
{0, 0, 0,-i},
{i, 0, 0, 0},
{0, i, 0, 0}
}

Now apply the result to the state vector:

{
{0, 0,-i  0},
{0, 0, 0,-i},
{i, 0, 0, 0},
{0, i, 0, 0}
}
(x)
{
{AC|00›},
{AD|01›},
{BC|10›},
{BD|11›}
}
=
Show intermediate working
{
{-iBC|10›},
{-iBD|11›}
{ iAC|00›},
{ iAD|01›},
}

Performing the operation in Quantum Console

//	Qubits
(A|0› + B|1›) (x) (C|0› + D|1›)

//	Computational Basis States - Input
AC|00› + AD|01› + BC|10› + BD|11›

//	Quantum Console syntax
//	Apply Y to qubit 1
Y(1);

//	Computational Basis States - Ouput
-iAD|00› + -iAC|01› + iBD|10› + iBC|11›

3 Qubit Register

This time, the state vector is larger again (2n, n = 3), at 8 rows, and due to this an Y gate cannot be applied as the number of columns from matrix A (2) does not match the number of rows from matrix B (8).

To work around this, as before, tensor an I (identity) matrix for each qubit involved that we are not manipulating in order to construct the matrix of the appropriate size.

In this example, the Y gate is applied to the qubit in position 1, and as the identity matrices are inferred, the operation could be written as:

IYI

If the Y gate were to be applied to the qubit in position 0, and as the identity matrices are inferred, the operation could be written as:

YII

Matrix mathematics

Tensor the gate with an identity.

Tensor products are produced by applying the left matrix to the right. So in this instance, we apply I to Y first, then IY to I.

I (step 1: tensor) Y (step 2: tensor) I

{
{1, 0},
{0, 1}
}
(x)
{
{0,-i},
{i, 0}
}
=
{
{0,-i, 0, 0},
{i, 0, 0, 0},
{0, 0, 0,-i},
{0, 0, i, 0}
}

Tensor the product with another identity:

{
{0,-i, 0, 0},
{i, 0, 0, 0},
{0, 0, 0,-i},
{0, 0, i, 0}
}
(x)
{
{1, 0},
{0, 1}
}
=
{
{0, 0,-i, 0, 0, 0, 0, 0},
{0, 0, 0,-i, 0, 0, 0, 0},
{i, 0, 0, 0, 0, 0, 0, 0},
{0, i, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0,-i, 0},
{0, 0, 0, 0, 0, 0, 0,-i},
{0, 0, 0, 0, i, 0, 0, 0},
{0, 0, 0, 0, 0, i, 0, 0}
}

The matrix is now the correct size to be applied to the state vector:

{
{0, 0,-i, 0, 0, 0, 0, 0},
{0, 0, 0,-i, 0, 0, 0, 0},
{i, 0, 0, 0, 0, 0, 0, 0},
{0, i, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0,-i, 0},
{0, 0, 0, 0, 0, 0, 0,-i},
{0, 0, 0, 0, i, 0, 0, 0},
{0, 0, 0, 0, 0, i, 0, 0}
}
*
{
{ACE|000›},
{ACF|001›},
{ADE|010›},
{ADF|011›},
{BCE|100›},
{BCF|101›},
{BDE|110›},
{BDF|111›}
}
=
Show intermediate working
{
{-iADE|010›},
{-iADF|011›},
{ iACE|000›},
{ iACF|001›},
{-iBDE|110›},
{-iBDF|111›}
{ iBCE|100›},
{ iBCF|101›},
}

Performing the operation in Quantum Console

//	Qubits
(A|0› + B|1›) (x) (C|0› + D|1›) (x) (E|0› + F|1›)

//	Computational Basis States - Input
ACE|000› + ACF|001› + ADE|010› + ADF|011› + BCE|100› + BCF|101› + BDE|110› + BDF|111›

//	Quantum Console syntax
//	Apply Y to qubit 1
Y(1);

//	Computational Basis States - Ouput
-iADE|000› + -iADF|001› + iACE|010› + iACF|011› + -iBDE|100› + -iBDF|101› + iBCE|110› + iBCF|111›

n Qubit Register

As you can see from the previous examples, performing manual matrix arthimetic for each step becomes tedious and time consuming, however it is important to acknowledge that this process takes place in the first instance.

Thankfully, there is a much simpler way of performing this operation as we shall discover for an n qubit register.

Suppose a Y gate is to be applied to qubit 1 in a register, as with the previous examples.

For a 2 qubit system, we apply the Y logic to the each bit indicated in the operation. Y(1) for example, applies an Y gate to every bit in position 1.

//	State vector
|ψ› = (AC|00› + AD|01› + BC|10› + BD|11›)

//	1 bit positions bolded - these are the bits that will be affected by the X operation
(AC|00› + AD|01› + BC|10› + BD|11›)

//	Apply the Y to every bit that occupies the 1 position
Y(1);

//	Intermediate working, to be rearranged
(AC|01› + AD|00› + BC|11› + BD|10›)

//	State vector - compare this to the matrix calculations above
|ψ› = (-iAD|00› + iAC|01› + -iBD|10› + iBC|11›)

Using the same methodology on a larger system reduces the amount of manual work. For a 3 qubit register:

//	State vector
|ψ› = (ACE|000› + ACF|001› + ADE|010› + ADF|011› + BCE|100› + BCF|101› + BDE|110› + BDF|111›)

//	1 bit positions bolded
(ACE|000› + ACF|001› + ADE|010› + ADF|011› + BCE|100› + BCF|101› + BDE|110› + BDF|111›)

//	Apply the Y to every bit that occupies the 1 position
Y(1);

//	Intermediate working, to be rearranged
(-iACE|010› + -iACF|011› + iADE|000› + iADF|001› + -iBCE|110› + -iBCF|111› + iBDE|100› + iBDF|101›)

//	State vector - compare this to the matrix calculations above
|ψ› = (-iADE|000› + -iADF|001› + iACE|010› + iACF|011› + -iBDE|100› + -iBDF|101› + iBCE|110› + iBCF|111›)

The Column Method

You might find that using the column method is easier and faster - it took a while for me to develop, but I find it easier to use than other methods.

To use the column method:

  1. Write your state vector vertically down the page
  2. Write an index over each bit column
  3. Write the gate over the bit to be operated on
  4. Now, work out the result of the operation, one element at a time, and write these into a new column

Applying the column method to the 3 qubit example from above:

//	Y(1);
//	Apply the Y gate, one element at a time

 Y
012

000  0-i10	//	Remember the Y gate takes 0 to i1 and 1 to -i0
001  0-i11
010  0 i00
011  0 i01
100  1-i10
101  1-i11
110  1 i00
111  1 i01

Now, all that is left is to take the values from the left column and plug them into the right column:

     Y
    012

ACE|000  -iADE|010
ACF|001  -iADF|011
ADE|010   iACE|000
ADF|011   iACF|001
BCE|100  -iBDE|110
BCF|101  -iBDF|111
BDE|110   iBCE|100
BDF|111   iBCF|101

And finally adjust the state vector (using the binary index) to match the new order:

-iADE|000
-iADF|001
 iACE|010
 iACF|011
-iBDE|100
-iBDF|101
 iBCE|110
 iBCF|111

The manipulation of the state vector is now complete.


 

Copyright © 2024 carlbelle.com