Skip to content

Quantum Software Development Journey:

View on GitHub

From Theory to Application with Classiq

Final Assignment - Overview

In this homework assignment, you have the opportunity to implement something meaningful, be creative, and practice your new skills and knowledge! You can apply your knowledge from the course and contribute to the Classiq community. Details are provided below.

Successful contributions will have the opportunity to earn SWAG credits and potentially more advanced certificates.

The Project

Goal

The main goal is to be creative, collaborate with each other and with the community, and to apply your knowledge to bridge the gap between theory and application! Focus on the last two weeks of the course, using this assignment to solidify and expand your knowledge and skills.

Optional Projects

You may choose a project from the following list, or come up with your own idea. Just please make sure to consult with us before you start!

  • Domain of Expertise:

  • Use your background in neural networks, chemistry, biology, or any other field to implement something new. We are here to support you!

  • Example: An advanced application of VQE for a more complex molecule.

  • Implementation of different QNN or QAE architectures.

  • Combine your domain of expertise with the power of Classiq!

  • QNN for XOR Problem:

  • Classiq has an available dataset for training PQC to imitate the XOR gate, similar to how we trained a U-gate to act as a NOT gate. Design a QNN to solve the XOR problem. Read more on the dataset here.

  • QNN as VQE:

  • Like VQE, QNNs with well-suited loss functions and data can be used to find minima of a system. Can you solve one of the problems from week 3 (in class or HW3) by implementing it with QNN?

  • Review the materials from weeks 3 and 4 and tackle this problem!

  • If needed, you may create synthetic data.

  • Do you have another example to show how QNN can generalize VQE? Show us!

  • Noise Reduction Using Quantum Auto-Encoders:

  • Quantum Auto-Encoders can be used to reduce noise!

  • Create code that generates a quantum state, adds random noise to it, and tries to reconstruct it using a Quantum Auto-Encoder.

  • If needed, you may create synthetic data.

  • Contribute to Quantum Algorithm Zoo:

  • Implement one of the algorithms in the Quantum Algorithm Zoo that has not been implemented yet using Classiq.

  • By doing so, you will have the opportunity to contribute to one of the main resources on quantum algorithms! (your Implementation will be linked to their website!)

  • New Algorithm Implementation:

  • Choose a research paper (you may consult us) and try to implement it using Classiq's SDK.

Note

  • For those who choose a more extensive project, you will have a discussion with me or another Classiq member to fine-tune your project's purpose and set a deadline. This collaborative approach ensures your project aligns with course objectives and maximizes your learning experience.

  • You are allowed to work in teams of up to 3 members!

Deadline & Submission

  • Important Dates:

  • Assignment Release: 29.5.2024

  • Submission Deadline: 10.6.2024 (7 A.M GMT+3)

  • Consult with us before submitting your project, and we will direct you to the right place in the Classiq Library.

  • You might get an extension to the deadline based on your specific project and progress.

Conclusion

Choose the project that best aligns with your interests and career goals. This project provides a valuable opportunity to deepen your understanding of QML and quantum computing in general, while contributing to the Classiq community.

If you have any questions or need further clarification, feel free to reach out.

Happy coding!

VQE for a more Complex Molecule:

Hamiltonian of the Water (H₂O) Molecule

\[\begin{align*} \hat{H} =& - 73.13873 (I\otimes I\otimes I\otimes I\otimes I\otimes I\otimes I\otimes I) + 0.22757 (Z\otimes I\otimes I\otimes I\otimes I\otimes I\otimes I\otimes I)\\ &- 0.04375 (Y\otimes Z\otimes Z\otimes Z\otimes Y\otimes I\otimes I\otimes I) - 0.04375 (X\otimes Z\otimes Z\otimes Z\otimes X\otimes I\otimes I\otimes I)\\ &+ 0.17420 (I\otimes I\otimes Z\otimes I\otimes I\otimes I\otimes I\otimes I) + 0.16757 (Z\otimes I\otimes Z\otimes I\otimes I\otimes I\otimes I\otimes I)\\ &- 0.15961 (I\otimes I\otimes I\otimes I\otimes Z\otimes I\otimes I\otimes I) + 0.11952 (Z\otimes I\otimes I\otimes I\otimes Z\otimes I\otimes I\otimes I)\\ &- 0.18067 (I\otimes I\otimes I\otimes I\otimes I\otimes I\otimes Z\otimes I) + 0.13402 (Z\otimes I\otimes I\otimes I\otimes I\otimes I\otimes Z\otimes I)\\ &+ 0.22757 (I\otimes Z\otimes I\otimes I\otimes I\otimes I\otimes I\otimes I) + 0.19393 (Z\otimes Z\otimes I\otimes I\otimes I\otimes I\otimes I\otimes I)\\ &- 0.03079 (Y\otimes I\otimes Z\otimes Z\otimes Y\otimes I\otimes I\otimes I) - 0.03079 (X\otimes I\otimes Z\otimes Z\otimes X\otimes I\otimes I\otimes I)\\ &+ 0.01387 (Y\otimes X\otimes X\otimes Y\otimes I\otimes I\otimes I\otimes I) - 0.01387 (Y\otimes Y\otimes X\otimes X\otimes I\otimes I\otimes I\otimes I)\\ &- 0.01387 (X\otimes X\otimes Y\otimes Y\otimes I\otimes I\otimes I\otimes I) + 0.01387 (X\otimes Y\otimes Y\otimes X\otimes I\otimes I\otimes I\otimes I)\\ &- 0.04375 (I\otimes Y\otimes Z\otimes Z\otimes Z\otimes Y\otimes I\otimes I) - 0.03079 (Z\otimes Y\otimes Z\otimes Z\otimes Z\otimes Y\otimes I\otimes I)\\ &- 0.04375 (I\otimes X\otimes Z\otimes Z\otimes Z\otimes X\otimes I\otimes I) - 0.03079 (Z\otimes X\otimes Z\otimes Z\otimes Z\otimes X\otimes I\otimes I)\\ &+ 0.01783 (Y\otimes X\otimes I\otimes I\otimes X\otimes Y\otimes I\otimes I) - 0.01783 (Y\otimes Y\otimes I\otimes I\otimes X\otimes X\otimes I\otimes I)\\ &- 0.01783 (X\otimes X\otimes I\otimes I\otimes Y\otimes Y\otimes I\otimes I) + 0.01783 (X\otimes Y\otimes I\otimes I\otimes Y\otimes X\otimes I\otimes I)\\ &+ 0.01737 (Y\otimes X\otimes I\otimes I\otimes I\otimes I\otimes X\otimes Y) - 0.01737 (Y\otimes Y\otimes I\otimes I\otimes I\otimes I\otimes X\otimes X)\\ &- 0.01737 (X\otimes X\otimes I\otimes I\otimes I\otimes I\otimes Y\otimes Y) + 0.01737 (X\otimes Y\otimes I\otimes I\otimes I\otimes I\otimes Y\otimes X)\\ &- 0.03010 (Y\otimes Z\otimes I\otimes Z\otimes Y\otimes I\otimes I\otimes I) - 0.03010 (X\otimes Z\otimes I\otimes Z\otimes X\otimes I\otimes I\otimes I)\\ &+ 0.17420 (I\otimes I\otimes I\otimes Z\otimes I\otimes I\otimes I\otimes I) + 0.18144 (Z\otimes I\otimes I\otimes Z\otimes I\otimes I\otimes I\otimes I)\\ &- 0.02981 (Y\otimes Z\otimes Z\otimes I\otimes Y\otimes I\otimes I\otimes I) - 0.02981 (X\otimes Z\otimes Z\otimes I\otimes X\otimes I\otimes I\otimes I)\\ &- 0.00029 (Y\otimes Z\otimes Y\otimes Y\otimes Z\otimes Y\otimes I\otimes I) - 0.00029 (Y\otimes Z\otimes Y\otimes X\otimes Z\otimes X\otimes I\otimes I)\\ &- 0.00029 (X\otimes Z\otimes X\otimes Y\otimes Z\otimes Y\otimes I\otimes I) - 0.00029 (X\otimes Z\otimes X\otimes X\otimes Z\otimes X\otimes I\otimes I)\\ &- 0.02510 (Y\otimes Z\otimes Z\otimes Z\otimes Y\otimes I\otimes Z\otimes I) - 0.02510 (X\otimes Z\otimes Z\otimes Z\otimes X\otimes I\otimes Z\otimes I)\\ &- 0.15961 (I\otimes I\otimes I\otimes I\otimes I\otimes Z\otimes I\otimes I) + 0.13735 (Z\otimes I\otimes I\otimes I\otimes I\otimes Z\otimes I\otimes I)\\ &- 0.01131 (Y\otimes Z\otimes Z\otimes Z\otimes Y\otimes Z\otimes I\otimes I) - 0.01131 (X\otimes Z\otimes Z\otimes Z\otimes X\otimes Z\otimes I\otimes I)\\ &- 0.01456 (Y\otimes Z\otimes Z\otimes Z\otimes Z\otimes X\otimes X\otimes Y) + 0.01456 (Y\otimes Z\otimes Z\otimes Z\otimes Z\otimes Y\otimes X\otimes X)\\ &+ 0.01456 (X\otimes Z\otimes Z\otimes Z\otimes Z\otimes X\otimes Y\otimes Y) - 0.01456 (X\otimes Z\otimes Z\otimes Z\otimes Z\otimes Y\otimes Y\otimes X)\\ &- 0.18067 (I\otimes I\otimes I\otimes I\otimes I\otimes I\otimes I\otimes Z) + 0.15138 (Z\otimes I\otimes I\otimes I\otimes I\otimes I\otimes I\otimes Z)\\ &- 0.01054 (Y\otimes Z\otimes Z\otimes Z\otimes Y\otimes I\otimes I\otimes Z) - 0.01054 (X\otimes Z\otimes Z\otimes Z\otimes X\otimes I\otimes I\otimes Z)\\ &+ 0.16757 (I\otimes Z\otimes I\otimes Z\otimes I\otimes I\otimes I\otimes I) + 0.11952 (I\otimes Z\otimes I\otimes I\otimes I\otimes Z\otimes I\otimes I)\\ &+ 0.13402 (I\otimes Z\otimes I\otimes I\otimes I\otimes I\otimes I\otimes Z) + 0.18144 (I\otimes Z\otimes Z\otimes I\otimes I\otimes I\otimes I\otimes I)\\ &- 0.02981 (I\otimes Y\otimes I\otimes Z\otimes Z\otimes Y\otimes I\otimes I) - 0.02981 (I\otimes X\otimes I\otimes Z\otimes Z\otimes X\otimes I\otimes I)\\ &- 0.00029 (I\otimes Y\otimes X\otimes X\otimes Y\otimes I\otimes I\otimes I) + 0.00029 (I\otimes Y\otimes Y\otimes X\otimes X\otimes I\otimes I\otimes I)\\ &+ 0.00029 (I\otimes X\otimes X\otimes Y\otimes Y\otimes I\otimes I\otimes I) - 0.00029 (I\otimes X\otimes Y\otimes Y\otimes X\otimes I\otimes I\otimes I)\\ &- 0.03010 (I\otimes Y\otimes Z\otimes I\otimes Z\otimes Y\otimes I\otimes I) - 0.03010 (I\otimes X\otimes Z\otimes I\otimes Z\otimes X\otimes I\otimes I)\\ &+ 0.13735 (I\otimes Z\otimes I\otimes I\otimes Z\otimes I\otimes I\otimes I) - 0.01131 (I\otimes Y\otimes Z\otimes Z\otimes I\otimes Y\otimes I\otimes I)\\ &- 0.01131 (I\otimes X\otimes Z\otimes Z\otimes I\otimes X\otimes I\otimes I) + 0.01456 (I\otimes Y\otimes Z\otimes Z\otimes X\otimes I\otimes X\otimes Y)\\ &+ 0.01456 (I\otimes Y\otimes Z\otimes Z\otimes Y\otimes I\otimes Y\otimes Y) + 0.01456 (I\otimes X\otimes Z\otimes Z\otimes X\otimes I\otimes X\otimes X)\\ &+ 0.01456 (I\otimes X\otimes Z\otimes Z\otimes Y\otimes I\otimes Y\otimes X) - 0.02510 (I\otimes Y\otimes Z\otimes Z\otimes Z\otimes Y\otimes I\otimes Z)\\ &- 0.02510 (I\otimes X\otimes Z\otimes Z\otimes Z\otimes X\otimes I\otimes Z) + 0.15138 (I\otimes Z\otimes I\otimes I\otimes I\otimes I\otimes Z\otimes I)\\ &- 0.01054 (I\otimes Y\otimes Z\otimes Z\otimes Z\otimes Y\otimes Z\otimes I) - 0.01054 (I\otimes X\otimes Z\otimes Z\otimes Z\otimes X\otimes Z\otimes I)\\ &+ 0.13767 (I\otimes I\otimes Z\otimes I\otimes Z\otimes I\otimes I\otimes I) + 0.14973 (I\otimes I\otimes Z\otimes I\otimes I\otimes I\otimes Z\otimes I)\\ &+ 0.22004 (I\otimes I\otimes Z\otimes Z\otimes I\otimes I\otimes I\otimes I) + 0.00956 (I\otimes I\otimes Y\otimes X\otimes X\otimes Y\otimes I\otimes I)\\ &- 0.00956 (I\otimes I\otimes Y\otimes Y\otimes X\otimes X\otimes I\otimes I) - 0.00956 (I\otimes I\otimes X\otimes X\otimes Y\otimes Y\otimes I\otimes I)\\ &+ 0.00956 (I\otimes I\otimes X\otimes Y\otimes Y\otimes X\otimes I\otimes I) + 0.00609 (I\otimes I\otimes Y\otimes X\otimes I\otimes I\otimes X\otimes Y)\\ &- 0.00609 (I\otimes I\otimes Y\otimes Y\otimes I\otimes I\otimes X\otimes X) - 0.00609 (I\otimes I\otimes X\otimes X\otimes I\otimes I\otimes Y\otimes Y)\\ &+ 0.00609 (I\otimes I\otimes X\otimes Y\otimes I\otimes I\otimes Y\otimes X) + 0.14723 (I\otimes I\otimes Z\otimes I\otimes I\otimes Z\otimes I\otimes I)\\ &+ 0.15582 (I\otimes I\otimes Z\otimes I\otimes I\otimes I\otimes I\otimes Z) + 0.13767 (I\otimes I\otimes I\otimes Z\otimes I\otimes Z\otimes I\otimes I)\\ &+ 0.14973 (I\otimes I\otimes I\otimes Z\otimes I\otimes I\otimes I\otimes Z) + 0.14723 (I\otimes I\otimes I\otimes Z\otimes Z\otimes I\otimes I\otimes I)\\ &+ 0.15582 (I\otimes I\otimes I\otimes Z\otimes I\otimes I\otimes Z\otimes I) + 0.11270 (I\otimes I\otimes I\otimes I\otimes Z\otimes I\otimes Z\otimes I)\\ &+ 0.14926 (I\otimes I\otimes I\otimes I\otimes Z\otimes Z\otimes I\otimes I) + 0.02869 (I\otimes I\otimes I\otimes I\otimes Y\otimes X\otimes X\otimes Y)\\ &- 0.02869 (I\otimes I\otimes I\otimes I\otimes Y\otimes Y\otimes X\otimes X) - 0.02869 (I\otimes I\otimes I\otimes I\otimes X\otimes X\otimes Y\otimes Y)\\ &+ 0.02869 (I\otimes I\otimes I\otimes I\otimes X\otimes Y\otimes Y\otimes X) + 0.14139 (I\otimes I\otimes I\otimes I\otimes Z\otimes I\otimes I\otimes Z)\\ &+ 0.11270 (I\otimes I\otimes I\otimes I\otimes I\otimes Z\otimes I\otimes Z) + 0.14139 (I\otimes I\otimes I\otimes I\otimes I\otimes Z\otimes Z\otimes I)\\ &+ 0.15436 (I\otimes I\otimes I\otimes I\otimes I\otimes I\otimes Z\otimes Z) \end{align*}\]
# !pip install -U classiq
# import classiq
# classiq.authenticate()
from typing import List

from classiq import *

HAMILTONIAN = QConstant(
    "HAMILTONIAN",
    List[PauliTerm],
    [
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-73.13873,
        ),
        PauliTerm(
            pauli=[
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.22757,
        ),
        PauliTerm(
            pauli=[
                Pauli.Y,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.04375,
        ),
        PauliTerm(
            pauli=[
                Pauli.X,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.X,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.04375,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.17420,
        ),
        PauliTerm(
            pauli=[
                Pauli.Z,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.16757,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.15961,
        ),
        PauliTerm(
            pauli=[
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.11952,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
            ],
            coefficient=-0.18067,
        ),
        PauliTerm(
            pauli=[
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
            ],
            coefficient=0.13402,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.22757,
        ),
        PauliTerm(
            pauli=[
                Pauli.Z,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.19393,
        ),
        PauliTerm(
            pauli=[
                Pauli.Y,
                Pauli.I,
                Pauli.Z,
                Pauli.Z,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.03079,
        ),
        PauliTerm(
            pauli=[
                Pauli.X,
                Pauli.I,
                Pauli.Z,
                Pauli.Z,
                Pauli.X,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.03079,
        ),
        PauliTerm(
            pauli=[
                Pauli.Y,
                Pauli.X,
                Pauli.X,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.01387,
        ),
        PauliTerm(
            pauli=[
                Pauli.Y,
                Pauli.Y,
                Pauli.X,
                Pauli.X,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.01387,
        ),
        PauliTerm(
            pauli=[
                Pauli.X,
                Pauli.X,
                Pauli.Y,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.01387,
        ),
        PauliTerm(
            pauli=[
                Pauli.X,
                Pauli.Y,
                Pauli.Y,
                Pauli.X,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.01387,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.Y,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.04375,
        ),
        PauliTerm(
            pauli=[
                Pauli.Z,
                Pauli.Y,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.03079,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.X,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.X,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.04375,
        ),
        PauliTerm(
            pauli=[
                Pauli.Z,
                Pauli.X,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.X,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.03079,
        ),
        PauliTerm(
            pauli=[
                Pauli.Y,
                Pauli.X,
                Pauli.I,
                Pauli.I,
                Pauli.X,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.01783,
        ),
        PauliTerm(
            pauli=[
                Pauli.Y,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
                Pauli.X,
                Pauli.X,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.01783,
        ),
        PauliTerm(
            pauli=[
                Pauli.X,
                Pauli.X,
                Pauli.I,
                Pauli.I,
                Pauli.Y,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.01783,
        ),
        PauliTerm(
            pauli=[
                Pauli.X,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
                Pauli.Y,
                Pauli.X,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.01783,
        ),
        PauliTerm(
            pauli=[
                Pauli.Y,
                Pauli.X,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.X,
                Pauli.Y,
            ],
            coefficient=0.01737,
        ),
        PauliTerm(
            pauli=[
                Pauli.Y,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.X,
                Pauli.X,
            ],
            coefficient=-0.01737,
        ),
        PauliTerm(
            pauli=[
                Pauli.X,
                Pauli.X,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Y,
                Pauli.Y,
            ],
            coefficient=-0.01737,
        ),
        PauliTerm(
            pauli=[
                Pauli.X,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Y,
                Pauli.X,
            ],
            coefficient=0.01737,
        ),
        PauliTerm(
            pauli=[
                Pauli.Y,
                Pauli.Z,
                Pauli.I,
                Pauli.Z,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.03010,
        ),
        PauliTerm(
            pauli=[
                Pauli.X,
                Pauli.Z,
                Pauli.I,
                Pauli.Z,
                Pauli.X,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.03010,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.17420,
        ),
        PauliTerm(
            pauli=[
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.18144,
        ),
        PauliTerm(
            pauli=[
                Pauli.Y,
                Pauli.Z,
                Pauli.Z,
                Pauli.I,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.02981,
        ),
        PauliTerm(
            pauli=[
                Pauli.X,
                Pauli.Z,
                Pauli.Z,
                Pauli.I,
                Pauli.X,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.02981,
        ),
        PauliTerm(
            pauli=[
                Pauli.Y,
                Pauli.Z,
                Pauli.Y,
                Pauli.Y,
                Pauli.Z,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.00029,
        ),
        PauliTerm(
            pauli=[
                Pauli.Y,
                Pauli.Z,
                Pauli.Y,
                Pauli.X,
                Pauli.Z,
                Pauli.X,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.00029,
        ),
        PauliTerm(
            pauli=[
                Pauli.X,
                Pauli.Z,
                Pauli.X,
                Pauli.Y,
                Pauli.Z,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.00029,
        ),
        PauliTerm(
            pauli=[
                Pauli.X,
                Pauli.Z,
                Pauli.X,
                Pauli.X,
                Pauli.Z,
                Pauli.X,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.00029,
        ),
        PauliTerm(
            pauli=[
                Pauli.Y,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.Y,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
            ],
            coefficient=-0.02510,
        ),
        PauliTerm(
            pauli=[
                Pauli.X,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.X,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
            ],
            coefficient=-0.02510,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.15961,
        ),
        PauliTerm(
            pauli=[
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.13735,
        ),
        PauliTerm(
            pauli=[
                Pauli.Y,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.Y,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.01131,
        ),
        PauliTerm(
            pauli=[
                Pauli.X,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.X,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.01131,
        ),
        PauliTerm(
            pauli=[
                Pauli.Y,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.X,
                Pauli.X,
                Pauli.Y,
            ],
            coefficient=-0.01456,
        ),
        PauliTerm(
            pauli=[
                Pauli.Y,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.Y,
                Pauli.X,
                Pauli.X,
            ],
            coefficient=0.01456,
        ),
        PauliTerm(
            pauli=[
                Pauli.X,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.X,
                Pauli.Y,
                Pauli.Y,
            ],
            coefficient=0.01456,
        ),
        PauliTerm(
            pauli=[
                Pauli.X,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.Y,
                Pauli.Y,
                Pauli.X,
            ],
            coefficient=-0.01456,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
            ],
            coefficient=-0.18067,
        ),
        PauliTerm(
            pauli=[
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
            ],
            coefficient=0.15138,
        ),
        PauliTerm(
            pauli=[
                Pauli.Y,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
            ],
            coefficient=-0.01054,
        ),
        PauliTerm(
            pauli=[
                Pauli.X,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.X,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
            ],
            coefficient=-0.01054,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.16757,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.11952,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
            ],
            coefficient=0.13402,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.Z,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.18144,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.Y,
                Pauli.I,
                Pauli.Z,
                Pauli.Z,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.02981,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.X,
                Pauli.I,
                Pauli.Z,
                Pauli.Z,
                Pauli.X,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.02981,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.Y,
                Pauli.X,
                Pauli.X,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.00029,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.Y,
                Pauli.Y,
                Pauli.X,
                Pauli.X,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.00029,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.X,
                Pauli.X,
                Pauli.Y,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.00029,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.X,
                Pauli.Y,
                Pauli.Y,
                Pauli.X,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.00029,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.Y,
                Pauli.Z,
                Pauli.I,
                Pauli.Z,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.03010,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.X,
                Pauli.Z,
                Pauli.I,
                Pauli.Z,
                Pauli.X,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.03010,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.13735,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.Y,
                Pauli.Z,
                Pauli.Z,
                Pauli.I,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.01131,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.X,
                Pauli.Z,
                Pauli.Z,
                Pauli.I,
                Pauli.X,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.01131,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.Y,
                Pauli.Z,
                Pauli.Z,
                Pauli.X,
                Pauli.I,
                Pauli.X,
                Pauli.Y,
            ],
            coefficient=0.01456,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.Y,
                Pauli.Z,
                Pauli.Z,
                Pauli.Y,
                Pauli.I,
                Pauli.Y,
                Pauli.Y,
            ],
            coefficient=0.01456,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.X,
                Pauli.Z,
                Pauli.Z,
                Pauli.X,
                Pauli.I,
                Pauli.X,
                Pauli.X,
            ],
            coefficient=0.01456,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.X,
                Pauli.Z,
                Pauli.Z,
                Pauli.Y,
                Pauli.I,
                Pauli.Y,
                Pauli.X,
            ],
            coefficient=0.01456,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.Y,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.Y,
                Pauli.I,
                Pauli.Z,
            ],
            coefficient=-0.02510,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.X,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.X,
                Pauli.I,
                Pauli.Z,
            ],
            coefficient=-0.02510,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
            ],
            coefficient=0.15138,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.Y,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.Y,
                Pauli.Z,
                Pauli.I,
            ],
            coefficient=-0.01054,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.X,
                Pauli.Z,
                Pauli.Z,
                Pauli.Z,
                Pauli.X,
                Pauli.Z,
                Pauli.I,
            ],
            coefficient=-0.01054,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.13767,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
            ],
            coefficient=0.14973,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.22004,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.Y,
                Pauli.X,
                Pauli.X,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.00956,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.Y,
                Pauli.Y,
                Pauli.X,
                Pauli.X,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.00956,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.X,
                Pauli.X,
                Pauli.Y,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=-0.00956,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.X,
                Pauli.Y,
                Pauli.Y,
                Pauli.X,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.00956,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.Y,
                Pauli.X,
                Pauli.I,
                Pauli.I,
                Pauli.X,
                Pauli.Y,
            ],
            coefficient=0.00609,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.Y,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
                Pauli.X,
                Pauli.X,
            ],
            coefficient=-0.00609,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.X,
                Pauli.X,
                Pauli.I,
                Pauli.I,
                Pauli.Y,
                Pauli.Y,
            ],
            coefficient=-0.00609,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.X,
                Pauli.Y,
                Pauli.I,
                Pauli.I,
                Pauli.Y,
                Pauli.X,
            ],
            coefficient=0.00609,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.14723,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
            ],
            coefficient=0.15582,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.13767,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
            ],
            coefficient=0.14973,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.14723,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
            ],
            coefficient=0.15582,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
            ],
            coefficient=0.11270,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
            ],
            coefficient=0.14926,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Y,
                Pauli.X,
                Pauli.X,
                Pauli.Y,
            ],
            coefficient=0.02869,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Y,
                Pauli.Y,
                Pauli.X,
                Pauli.X,
            ],
            coefficient=-0.02869,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.X,
                Pauli.X,
                Pauli.Y,
                Pauli.Y,
            ],
            coefficient=-0.02869,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.X,
                Pauli.Y,
                Pauli.Y,
                Pauli.X,
            ],
            coefficient=0.02869,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
            ],
            coefficient=0.14139,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.I,
                Pauli.Z,
            ],
            coefficient=0.11270,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.Z,
                Pauli.I,
            ],
            coefficient=0.14139,
        ),
        PauliTerm(
            pauli=[
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.I,
                Pauli.Z,
                Pauli.Z,
            ],
            coefficient=0.15436,
        ),
    ],
)
@qfunc
def main(q: Output[QArray[QBit]], angles: CArray[CReal, 6]) -> None:
    allocate(8, q)
    # U(angles[0], angles[1], angles[2], 0, q[0])
    # U(angles[3], angles[4], angles[5], 0, q[1])
    # U(angles[6], angles[7], angles[8], 0, q[2])
    # U(angles[9], angles[10], angles[11], 0, q[3])
    # U(angles[12], angles[13], angles[14], 0, q[4])
    # U(angles[15], angles[16], angles[17], 0, q[5])
    # U(angles[18], angles[19], angles[20], 0, q[6])
    # U(angles[21], angles[22], angles[23], 0, q[7])
    repeat(q.len, lambda i: U(angles[0], angles[1], angles[2], 0, q[i]))
    repeat(q.len - 1, lambda i: repeat(q.len - i - 1, lambda j: CX(q[i], q[i + j + 1])))
    repeat(q.len, lambda i: U(angles[3], angles[4], angles[5], 0, q[i]))
    # repeat(q.len-1, lambda i: repeat(q.len-i-1, lambda j: CX(q[i], q[i+j+1])))
    # repeat(q.len, lambda i: U(angles[6], angles[7], angles[8], 0, q[i]))


@cfunc
def cmain() -> None:
    res = vqe(
        HAMILTONIAN,
        False,
        [],
        optimizer=Optimizer.COBYLA,
        max_iteration=5000,
        tolerance=0.001,
        step_size=0,
        skip_compute_variance=False,
        alpha_cvar=1.0,
    )
    save({"result": res})


qmod = create_model(main, classical_execution_function=cmain)
qprog = synthesize(qmod)
# show(qprog)
execution = execute(qprog)
res = execution.result()
# execution.open_in_ide()
vqe_result = res[0].value
print(f"Optimal energy: {vqe_result.energy}")
print(f"Optimal parameters: {vqe_result.optimal_parameters}")
print(f"Eigenstate: {vqe_result.eigenstate}")
Optimal energy: -74.0387620605469
Optimal parameters: {'angles_0': -1.6244327148424826, 'angles_1': 0.0029992440706366028, 'angles_2': -3.0176878190240437, 'angles_3': 4.742160511370476, 'angles_4': -0.027681125858615045, 'angles_5': -3.186328011179737}
Eigenstate: {'00010101': (0.02209708691207961+0j), '00101010': (0.02209708691207961+0j), '10101010': (0.03125+0j), '01011010': (0.03125+0j), '01010100': (0.02209708691207961+0j), '01010111': (0.038273277230987154+0j), '01000101': (0.02209708691207961+0j), '01011101': (0.02209708691207961+0j), '11010101': (0.02209708691207961+0j), '01001010': (0.03125+0j), '01010001': (0.04419417382415922+0j), '01010101': (0.9953505192895616+0j)}