# H.5.2 (Hamiltonian Simulation)

**URL:** <https://discuss.pennylane.ai/t/h-5-2-hamiltonian-simulation/1494>\
**Category:** Codebook\
**Created:** [November 22, 2021, 9:07am UTC](https://discuss.pennylane.ai/t/h-5-2-hamiltonian-simulation/1494 "2021-11-22T09:07:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![qreg](https://avatars.discourse-cdn.com/v4/letter/q/bbe5ce/32.png) [@qreg](https://discuss.pennylane.ai/u/qreg)\
**Post date:** [November 22, 2021, 9:07am UTC](https://discuss.pennylane.ai/t/h-5-2-hamiltonian-simulation/1494/1 "2021-11-22T09:07:10Z")

</div>

Hello. I am stuck in the exercise on Trotterization. Any suggestions?

 ![Screenshot%202021-11-22%20170308](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/1X/a63e153d1aa14a4e2ec87b5ae94a6149455e0b42.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 22, 2021, 2:31pm UTC](https://discuss.pennylane.ai/t/h-5-2-hamiltonian-simulation/1494/2 "2021-11-22T14:31:23Z")

</div>

Hi @qreg, welcome to the forum! You are on the right track 🙂 I can provide a couple hints.

- The main one is the evolution time. In Trotterization, the operation is split up into n _identical_ steps.
- Recall that while circuits are read from left to right, when we write out the representation of a circuit as matrix multiplication, it is written from right to left.
- Double check the definition of RZ and the other Pauli rotations expressed as a matrix exponential (e.g., see the text panel of I.6.5); then, compare it to the expression of e^{-iHt/\hbar} for the Hamiltonian we are working with here. What parameters do you need to pass to `RZ` to rotate the qubits in the correction direction?

Hope that helps, please let us know if you have any further questions!

---

<div class="post-metadata">

**Author:** ![qreg](https://avatars.discourse-cdn.com/v4/letter/q/bbe5ce/32.png) [@qreg](https://discuss.pennylane.ai/u/qreg)\
**Post date:** [November 23, 2021, 6:51am UTC](https://discuss.pennylane.ai/t/h-5-2-hamiltonian-simulation/1494/3 "2021-11-23T06:51:28Z")

</div>

Thank you, @glassnotes ! I will rewrite the code to conform to your hints. All the best!

---

<div class="post-metadata">

**Author:** ![qreg](https://avatars.discourse-cdn.com/v4/letter/q/bbe5ce/32.png) [@qreg](https://discuss.pennylane.ai/u/qreg)\
**Post date:** [November 23, 2021, 7:00am UTC](https://discuss.pennylane.ai/t/h-5-2-hamiltonian-simulation/1494/4 "2021-11-23T07:00:47Z")

</div>

OK, I solved the challenge. Thanks again for your help, @glassnotes.

---

<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 23, 2021, 1:31pm UTC](https://discuss.pennylane.ai/t/h-5-2-hamiltonian-simulation/1494/5 "2021-11-23T13:31:00Z")

</div>

No problem, glad to hear you solved it!
