# Challenge: "Revisiting Schrodinger's cat"

**URL:** <https://discuss.pennylane.ai/t/challenge-revisiting-schrodingers-cat/4362>\
**Category:** PennyLane Help\
**Created:** [March 27, 2024, 8:21pm UTC](https://discuss.pennylane.ai/t/challenge-revisiting-schrodingers-cat/4362 "2024-03-27T20:21:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpinilla](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@jpinilla](https://discuss.pennylane.ai/u/jpinilla)\
**Post date:** [March 27, 2024, 8:21pm UTC](https://discuss.pennylane.ai/t/challenge-revisiting-schrodingers-cat/4362/1 "2024-03-27T20:21:13Z")

</div>

Hi! I’ve been working on the [Coding Challenges](https://pennylane.ai/challenges/) and I have doubts about the results in [Revisiting Schrodinger’s cat](https://pennylane.ai/challenges/schrodingers_cat/).

I’ll try to ask my question without revealing too much of the code and keep the challenge interesting.

As I understand it, the challenge asks for an optimization of the parameters of the U3 gate, such that: if the state |0\rangle is read on the “atom” qubit, then the “cat” qubit is known to be in |+\rangle.

Initially, I made my algorithm such that it optimized the U3 parameters to minimize err:

diff = evolve\_atom\_cat(unitary, params) - [\frac{1}{\sqrt{2}}, \frac{1}{\sqrt{2}}, 0 ,0]

err = \overline{|diff|}

I tried multiple optimization methods but didn’t get them to converge.

1. Is it possible to optimize the parameters of the U3 such that it creates the state [\frac{1}{\sqrt{2}}, \frac{1}{\sqrt{2}}, 0 ,0]?

Instead, I figured I could optimize them such that the probability of p(|00\rangle) == p(|01\rangle), which means there’s a superposition on the ‘cat’ qubit. This passes the tests… However, I’m not convinced this is the right answer.

1. Does p(|00\rangle) == p(|01\rangle) guarantee that reading ‘atom’ as |0\rangle, we have 50% probability of sampling ‘cat’ in 0 or 1, i.e. it’s in the |+⟩ state?

---

<div class="post-metadata">

**Author:** ![Alvaro\_Ballon](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/alvaro_ballon/32/874_2.png) [@Alvaro\_Ballon](https://discuss.pennylane.ai/u/Alvaro_Ballon)\
**Post date:** [March 28, 2024, 2:59pm UTC](https://discuss.pennylane.ai/t/challenge-revisiting-schrodingers-cat/4362/2 "2024-03-28T14:59:48Z")

</div>

Hello @jpinilla! Welcome to the forum!

It seems approach 2. may have worked due to a fluke! There could be a phase difference between the amplitudes, which wouldn’t give you the correct state. The correct approach is 1. It is possible to make it converge!

Cheers,

Alvaro

---

<div class="post-metadata">

**Author:** ![jpinilla](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@jpinilla](https://discuss.pennylane.ai/u/jpinilla)\
**Post date:** [March 28, 2024, 5:18pm UTC](https://discuss.pennylane.ai/t/challenge-revisiting-schrodingers-cat/4362/3 "2024-03-28T17:18:34Z")

</div>

Thanks @Alvaro_Ballon ! I accidentally bumped into that “solution”, so maybe it’s worth changing the check() method?

---

<div class="post-metadata">

**Author:** ![Alvaro\_Ballon](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/alvaro_ballon/32/874_2.png) [@Alvaro\_Ballon](https://discuss.pennylane.ai/u/Alvaro_Ballon)\
**Post date:** [April 1, 2024, 6:25pm UTC](https://discuss.pennylane.ai/t/challenge-revisiting-schrodingers-cat/4362/4 "2024-04-01T18:25:57Z")

</div>

Agreed! Thanks @jpinilla !
