qml.pow

pow(base, z=1, lazy=True, do_queue=True, id=None)[source]

Raise an Operator to a power.

Parameters
  • base (Operator) – the operator to be raised to a power

  • z (float) – the exponent (default value is 1)

Keyword Arguments
  • lazy=True (bool) – In lazy mode, all operations are wrapped in a Pow class and handled later. If lazy=False, operation-specific simplifications are first attempted.

  • do_queue (bool) – indicates whether the operator should be recorded when created in a tape context

  • id (str) – custom label given to an operator instance, can be useful for some applications where the instance has to be identified

Returns

Operator

Note

This operator supports a batched base, a batched coefficient and a combination of both:

>>> op = qml.pow(qml.RX([1, 2, 3], wires=0), z=4)
>>> qml.matrix(op).shape
(3, 2, 2)
>>> op = qml.pow(qml.RX(1, wires=0), z=[1, 2, 3])
>>> qml.matrix(op).shape
(3, 2, 2)
>>> op = qml.pow(qml.RX([1, 2, 3], wires=0), z=[4, 5, 6])
>>> qml.matrix(op).shape
(3, 2, 2)

But it doesn’t support batching of operators:

>>> op = qml.pow([qml.RX(1, wires=0), qml.RX(2, wires=0)], z=4)
AttributeError: 'list' object has no attribute 'name'

See also

Pow, pow().

Example

>>> qml.pow(qml.PauliX(0), 0.5)
PauliX(wires=[0])**0.5
>>> qml.pow(qml.PauliX(0), 0.5, lazy=False)
SX(wires=[0])
>>> qml.pow(qml.PauliX(0), 0.1, lazy=False)
PauliX(wires=[0])**0.1
>>> qml.pow(qml.PauliX(0), 2, lazy=False)
Identity(wires=[0])

Lazy behavior can also be accessed via op ** z.