# Standard Gates¶

The Classiq platform provides many standard gates to the user. Some key standard gates will be shown here in detail. All gates can be seen in the reference manual.

## X Gate¶

The Pauli-X Gate

$\begin{split}X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}\end{split}$

### Syntax¶

Function: XGate

Parameters: None

{
"function": "XGate",
"function_params": {}
}


## Y Gate¶

The Pauli-Y Gate

$\begin{split}Y = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix}\end{split}$

### Syntax¶

Function: YGate

Parameters: None

{
"function": "YGate",
"function_params": {}
}


## Z Gate¶

The Pauli-Z Gate

$\begin{split}Z = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}\end{split}$

### Syntax¶

Function: ZGate

Parameters: None

{
"function": "ZGate",
"function_params": {}
}


## H Gate¶

This gate converts $$|0\rangle$$ to $$|+\rangle$$ and $$|1\rangle$$ to $$|-\rangle$$

$\begin{split}H = \frac{1}{\sqrt{2}}*\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}\end{split}$

### Syntax¶

Function: HGate

Parameters: None

{
"function": "HGate",
"function_params": {}
}


## RZ Gate¶

Rotation around the Z axis by a given angle $$\varphi$$.

$\begin{split}{RZ(\varphi)} = \begin{pmatrix} {e^{-i\frac{\varphi}{2}}} & 0 \\ 0 & {e^{i\frac{\varphi}{2}}} \end{pmatrix}\end{split}$

### Syntax¶

Function: RZGate

Parameters:

• phi: ParameterFloatType
The angle in a parameter type or a float.

## CX Gate¶

The Controlled X Gate.

Applies X Gate on the target qubit based on the state of the control qubit (by default if the controlled state is $$|1\rangle$$)

$\begin{split}CX = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ \end{pmatrix}\end{split}$

### Syntax¶

Function: CXGate

Parameters:

• ctrl_state: Optional[Union[str, PositiveOrZeroInt]]
The control state in decimal or as a bit string (e.g. ‘0’). If not specified, the control state is 1. The gate will be performed if the state of the control qubits matches the control state.
{
"function": "CXGate",
"function_params": {
"ctrl_state": "0"
}
}


## Example¶

The following example shows a circuit built with several standard gates, both controlled and uncontrolled.

{
"logic_flow": [
{
"function": "CCXGate",
"function_params": {},
"outputs": {"CTRL": "ccx_ctrl_out", "TARGET": "ccx_target_out"}
},
{
"function": "RZGate",
"function_params": {"phi": 1.9},
"inputs": "ccx_target_out"
},
{
"function": "SwapGate",
"function_params": {},
"inputs": "ccx_ctrl_out"
}
]
}

from classiq import ModelDesigner
from classiq.builtin_functions import CCXGate, SwapGate, RZGate
from classiq.model import Constraints

constraints = Constraints(max_width=4, max_depth=50)
model_designer = ModelDesigner(constraints=constraints)

ccx_params = CCXGate()
ccx_out = model_designer.CCXGate(ccx_params)
ccx_target_out = ccx_out["TARGET"]
ccx_ctrl_out = ccx_out["CTRL"]

rz_params = RZGate(phi=1.9)
model_designer.RZGate(rz_params, in_wires={"TARGET": ccx_target_out})

swap_params = SwapGate()
model_designer.SwapGate(swap_params, in_wires={"TARGET": ccx_ctrl_out})

circuit = model_designer.synthesize()

circuit.show_interactive() 