# Learning about quantum CZ gate

### Introduction

This time we learn a little about CZ gate.

### CZ gate?

CZ gate has controlled gate and target gate. If the controlled gate is 1, qubit on target gate was applied Z gate.

``a -----*-----       |b -----Z-----``

It is realized by applying H gate on CX gate.

``a -----*-----       |b ---H-X-H---``

### CZ is reversible.

CZ gate is reversible on controlled gate and target gate.

``a -----*-----     a -----Z-----       |       =         |b -----Z-----     b -----*-----``

so,

``a -----*-----       |b -----*-----``

Usually we can write it like that.

### Check the Unitary operator

CZ unitary operator is

``CZ = [[1  0  0  0]      [0  1  0  0]      [0  0  1  0]      [0  0  0 -1]]``

If we apply state vector [a,b,c,d], we get [a’,b’,c’,d’]

``[a'  =  [[1  0  0  0]  @ [a b'      [0  1  0  0]     b c'      [0  0  1  0]     c d']     [0  0  0 -1]]    d]``

The cols are input and rows are output

``a  b  c  d[[1  0  0  0]  a'  [0  1  0  0]  b' [0  0  1  0]  c' [0  0  0 -1]] d'``

The state vector in other expression

``|00> |01> |10> |11>[[1   0    0    0]  |00>'  [0   1    0    0]  |01>' [0   0    1    0]  |10>' [0   0    0   -1]] |11>'``

CZ gate affect only the both qubits are 1.

CZ(01)(a|00>+b|01>+c|10>+d|11>) = a|00>+b|01>+c|10>-d|11>

CZ(10)(a|00>+b|01>+c|10>+d|11>) = a|00>+b|01>+c|10>-d|11>