# Controlled Hadamard Gate

**URL:** https://discuss.pennylane.ai/t/controlled-hadamard-gate/1433
**Category:** PennyLane Help
**Created:** [October 23, 2021, 2:20am UTC](https://discuss.pennylane.ai/t/controlled-hadamard-gate/1433 "2021-10-23T02:20:56Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![leongfy](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/leongfy/32/1911_2.png) [@leongfy](https://discuss.pennylane.ai/u/leongfy)
#### Post date: [October 23, 2021, 2:20am UTC](https://discuss.pennylane.ai/t/controlled-hadamard-gate/1433/1 "2021-10-23T02:20:56Z")

</div>

Hi sorry I am new here but is there an existing controlled Hadamard gate, or do I have to program one using QubitUnitary?

---

<div class="post-metadata">

### Author: ![josh](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/josh/32/100_2.png) [@josh](https://discuss.pennylane.ai/u/josh)
#### Post date: [October 23, 2021, 2:28pm UTC](https://discuss.pennylane.ai/t/controlled-hadamard-gate/1433/2 "2021-10-23T14:28:51Z")

</div>

Hi @leongfy! You can use [`qml.ctrl`](https://pennylane.readthedocs.io/en/stable/code/api/pennylane.ctrl.html) to create a controlled Hadamard gate 🙂

```python
@qml.qnode(dev)
def circuit(x):
    qml.RY(x, wires=0)
    qml.ctrl(qml.Hadamard, control=0)(wires=1)
    return qml.expval(qml.PauliZ(1))

>>> circuit(0.3)
tensor(0.97766824, requires_grad=True)

```

Since PennyLane does not have a native controlled Hadamard gate, this is being decomposed under-the-hood:

```python
>>> print(qml.draw(circuit)(0.3))
 0: ──RY(0.3)──╭ControlledPhaseShift(1.57)──╭C─────────╭ControlledPhaseShift(1.57)──┤
 1: ───────────╰ControlledPhaseShift(1.57)──╰RX(1.57)──╰ControlledPhaseShift(1.57)──┤ ⟨Z⟩

```
