# qml.ops.op_math.ctrl_decomp_zyz¶

ctrl_decomp_zyz(target_operation, control_wires)[source]

Decompose the controlled version of a target single-qubit operation

This function decomposes a controlled single-qubit target operation using the decomposition defined in section 5 of Barenco et al. (1995).

Warning

This method will add a global phase for target operations that do not belong to the SU(2) group.

Parameters
• target_operation (Operator) – the target operation to decompose

• control_wires (Wires) – the control wires of the operation

Returns

the decomposed operations

Return type

list[Operation]

Raises

ValueError – if target_operation is not a single-qubit operation

Example

We can create a controlled operation using qml.ctrl, or by creating the decomposed controlled version of using qml.ctrl_decomp_zyz.

dev = qml.device("default.qubit", wires=3)

@qml.qnode(dev)
def expected_circuit(op):
qml.ctrl(op, [0,1])
return qml.probs()

@qml.qnode(dev)
def decomp_circuit(op):
qml.ops.ctrl_decomp_zyz(op, [0,1])
return qml.probs()


Measurements on both circuits will give us the same results:

>>> op = qml.RX(0.123, wires=2)
>>> expected_circuit(op)
tensor([0.25      , 0.        , 0.25      , 0.        , 0.25      ,
>>> decomp_circuit(op)
tensor([0.25      , 0.        , 0.25      , 0.        , 0.25      ,