# qml.simplify¶

simplify(input)[source]

Simplifies an operator, tape, qnode or quantum function by reducing its arithmetic depth or number of rotation parameters.

Parameters

input (Operator, pennylane.QNode, QuantumTape, or Callable) – an operator, quantum node, tape or function that applies quantum operations

Returns

Simplified input.

Return type

(Operator, pennylane.QNode, QuantumTape, or Callable)

Example

Given an instantiated operator, qml.simplify reduces the operator’s arithmetic depth:

>>> op = qml.adjoint(qml.RX(0.54, wires=0) + qml.PauliX(0) + qml.PauliZ(1))
>>> op.arithmetic_depth
3
>>> sim_op = qml.simplify(op)
>>> sim_op.arithmetic_depth
2
>>> type(sim_op)
pennylane.ops.op_math.sum.Sum
>>> sim_op.operands


This function can also simplify the number of rotation gate parameters:

>>> qml.simplify(qml.Rot(np.pi / 2, 0.1, -np.pi / 2, wires=0))
RX(0.1, wires=)


Both types of simplification occur together:

>>> op = qml.adjoint(qml.U2(-np.pi/2, np.pi/2, wires=0) + qml.PauliX(0))
>>> op
>>> qml.simplify(op)


Moreover, qml.simplify can be used to simplify QNodes or quantum functions:

>>> dev = qml.device("default.qubit", wires=2)
>>> @qml.simplify
@qml.qnode(dev)
def circuit():
qml.adjoint(qml.prod(qml.RX(1, 0) ** 1, qml.RY(1, 0), qml.RZ(1, 0)))
return qml.probs(wires=0)
>>> circuit()