# What is wrong in this

**URL:** <https://discuss.pennylane.ai/t/what-is-wrong-in-this/1501>\
**Category:** Codebook\
**Created:** [November 23, 2021, 8:49pm UTC](https://discuss.pennylane.ai/t/what-is-wrong-in-this/1501 "2021-11-23T20:49:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vedant\_Dwivedi](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/vedant_dwivedi/32/813_2.png) [@Vedant\_Dwivedi](https://discuss.pennylane.ai/u/Vedant_Dwivedi)\
**Post date:** [November 23, 2021, 8:49pm UTC](https://discuss.pennylane.ai/t/what-is-wrong-in-this/1501/1 "2021-11-23T20:49:25Z")

</div>

![43%20AM](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/1X/ad7d017135e0272acc537fb256c8a6cc79849506.png)

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [November 23, 2021, 11:12pm UTC](https://discuss.pennylane.ai/t/what-is-wrong-in-this/1501/2 "2021-11-23T23:12:47Z")

</div>

Hi @Vedant_Dwivedi. Thank you for posting your question here and welcome to the forum!

What node does this coding exercise correspond to?

---

<div class="post-metadata">

**Author:** ![Vedant\_Dwivedi](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/vedant_dwivedi/32/813_2.png) [@Vedant\_Dwivedi](https://discuss.pennylane.ai/u/Vedant_Dwivedi)\
**Post date:** [November 24, 2021, 4:48am UTC](https://discuss.pennylane.ai/t/what-is-wrong-in-this/1501/3 "2021-11-24T04:48:14Z")

</div>

I.9 Measurements. I think my y\_basis rotation is wrong but somehow in exercise previous to this(attached) is made to pass correct.

 ![09%20AM](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/1X/4a100782ffffc0eed1178358792765fea58f7752.png)

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [November 24, 2021, 3:58pm UTC](https://discuss.pennylane.ai/t/what-is-wrong-in-this/1501/4 "2021-11-24T15:58:25Z")

</div>

Hi @Vedant_Dwivedi.  
Your solution to the previous exercise is in fact correct.

In the last exercise look carefully into the rotation back to the computational basis. What is the effect of the operations you are using? What happens if you do an operation and then its adjoint? Do you really need to do both?

I hope this helps you!

---

<div class="post-metadata">

**Author:** ![Guillem](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/guillem/32/822_2.png) [@Guillem](https://discuss.pennylane.ai/u/Guillem)\
**Post date:** [November 25, 2021, 1:35pm UTC](https://discuss.pennylane.ai/t/what-is-wrong-in-this/1501/5 "2021-11-25T13:35:12Z")

</div>

> [@CatalinaAlbornoz](#):
>
> to the rotation back to the computational basis. What is the effect of the operations you are using? What happens if you

I have been stuck in this exercise for quite a lot of time, and I think that the problem is either that the line:

> qml.adjoint(y\_basis\_rotation())

is not working properly or I haven’t understood how to use it.

In the following image, I use what I was expecting from the adjoint and I finally get this exercise correctly.

 ![measurment_y](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/1X/1a0a0af957a1bf12c644e3c9579bed0aa2603cd2.png)

---

<div class="post-metadata">

**Author:** ![glassnotes](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/glassnotes/32/327_2.png) [@glassnotes](https://discuss.pennylane.ai/u/glassnotes)\
**Post date:** [November 25, 2021, 2:27pm UTC](https://discuss.pennylane.ai/t/what-is-wrong-in-this/1501/6 "2021-11-25T14:27:01Z")

</div>

@Guillem, `qml.adjoint` is a type of operation in PennyLane that we call a _transform_. Loosely, transforms take functions as input, and return _functions_ as outputs. What `qml.adjoint` does is take a function (or operation) as input and returns a function that constructs the adjoint:

```auto
adjoint_of_S = qml.adjoint(qml.S)
adjoint_of_y_basis_rotation = qml.adjoint(y_basis_rotation)

```

But these are just functions - they don’t actually execute anything unless you call them; the new functions take exactly the same arguments as the old ones. `qml.S` normally takes just a wires argument, so we use:

```auto
adjoint_of_S(wires=0)

```

and this is equivalent to just doing

```auto
qml.adjoint(qml.S)(wires=0)

```

And similarly for the `y_basis_rotation`, which takes no arguments,

```auto
adjoint_of_y_basis_rotation()

```

or all in one line,

```auto
qml.adjoint(y_basis_rotation)()

```

There is some more information, and other examples in the [PennyLane docs for the transforms module](https://pennylane.readthedocs.io/en/stable/code/qml_transforms.html). (In particular, `qml.ctrl` is a similar case, which you will find in later exercises in the Codebook!)

---

<div class="post-metadata">

**Author:** ![Guillem](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/guillem/32/822_2.png) [@Guillem](https://discuss.pennylane.ai/u/Guillem)\
**Post date:** [November 25, 2021, 3:16pm UTC](https://discuss.pennylane.ai/t/what-is-wrong-in-this/1501/7 "2021-11-25T15:16:24Z")

</div>

Aaaahh I see, thank you ^^

I didn’t notice I wrote qml.adjoint(y\_basis\_rotation()) instead of qml.adjoint(y\_basis\_rotation)()

Thanks a lot

---

<div class="post-metadata">

**Author:** ![CatalinaAlbornoz](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/catalinaalbornoz/32/1196_2.png) [@CatalinaAlbornoz](https://discuss.pennylane.ai/u/CatalinaAlbornoz)\
**Post date:** [November 25, 2021, 3:19pm UTC](https://discuss.pennylane.ai/t/what-is-wrong-in-this/1501/8 "2021-11-25T15:19:12Z")

</div>

Hi @Guillem!

Just to complement the answer, notice how in the first image you posted here you had line 12 where you performed a rotation and then in line 13 you basically reversed it using the adjoint.

Aside from the small detail of the parenthesis you can also notice that in your last try you removed line 12, which helped you get to the correct answer!
