A Simple Guide to VQEs

Explaining VQEs and how I used them to find the ground state of N2, LiH and O2

Thomas Lawrence
May 14 · 7 min read

If you have tried to learn about VQEs you’ve probably been really confused about what they are. I know I was. This is largely due to the big words that get thrown around. So I’ll try to provide an easy understanding with minimal long words. So how do VQEs work?

How VQEs work

Hamiltonian: The hamiltonian is a matrix that discribes the possible energies of a molecule

Qubit Mapping: Is a process to encode information on a qubit

Ansatz: This is an educated guess of something like the wave function of a molecule

Eigenvalues: Scalars associated with a linear system of equation, best to think of them just as Scalars for simplcity

In theory, VQEs work by varying a parameter, then optimizing for the lowest energy. Thus giving you the lowest Eigenvalue. Sounds simple but there is so much more. So let’s dive deeper.

VQE stands for Variational Quantum Eigensolver. Here’s why:

  • Variational: Because the VQE varies parameters in order to find the true value
  • Quantum: Because it is a quantum algorithm
  • Eigensolver: Because we are solving for the lowest eigenvalue

The VQE is a quantum machine learning algorithm. This means it uses both quantum computations and classical computations.

To explain I’ll use an analogy:

  1. Encode yourself into a qubit in the quantum computer
  2. Find a range of all the possible heights of the limbo pole where you could have your lowest limbo
  3. Simulate yourself doing limbos many, many times at varying limbo pole heights on the quantum computer
  4. Then measure the results from the quantum computer
  5. Finally, send the results to the classical computer and then the classical computer uses an optimization method like gradient descent to optimize for the lowest possible limbo pole height that you can limbo
  6. Then repeat step 3–5 till you have found your lowest limbo point

In this example:

  • Your lowest limbo point is equal to the lowest eigenvalue. ex: a molecule's ground state.
  • You are equal to the thing you’re trying to simulate. ex: a molecule.
  • The range of your potential lowest limbo point is equal to the range of ansatz.

If you understood that example you can understand how a VQE works.

To explain how a VQE works, I’ll explain how a VQE can be used to simulate a molecule with the goal to find the ground state (lowest energy state of the molecule). These are the steps that are taken to make a VQE:

  1. Encode the hamiltonian (which is a matrix that describes the possible energies of the molecules) on the qubit with qubit mapping
  2. Find the ansatz (which is just an educated guess) of the distance between the molecules that the ground state will be found in
  3. Simulate the molecules at a bunch of different distances on the quantum computer within the ansatz
  4. Measure the results on the quantum computer. This cause qubit to collapse to 0s and 1s
  5. Finally, you send the results to the classical computer. The classical computer, using an optimization method like gradient descent optimizes for the lowest possible energy state in the molecule.
  6. Repeat step 3–5 until you have the ground state of the molecule

So now that you have an intuitive understanding of how a VQE works I’ll explain how it works in Math terms.

Why do VQEs work

First of all, we need to understand that a Matrix is a Hermitian that is equal to its conjugate transpose. So:

All you need to know about this is it allows us to use the spectral theorem. This allows us to state that the eigenvalues of a hermitian matrix have to be real values. This means that we can use a hermitian matrix to describe our hamiltonians. We can express our hamiltonians as:

To break this down:

  • λ¡ = Eigenvalue
  • |Ψ¡⟩ = The Eigenvector

The eigenvalue is comparable to the eigenvector. Aswell we can represent the hamiltonian as this:

Then with the previous two-equation, we can combine them and make this equation:

This equation tells us the expectation value of any observable state. Which since |⟨Ψ¡⟩⟨Ψ⟩|² is equal to or greater than 0. We can say this:

This is the most important equation of them all. This is the variational method or variational principle equation that tells us that the expectation value of any wave function. This is equal to or less than the eigenvalue with the Hamiltonian. This final equation is what makes the whole VQE work.

Why VQEs are awesome

Quantum Chemistry

We can expand this even further in the future by eventually being able to make our own materials with the special property that we want. Materials like specialized superconducting materials, space-grade flexible materials, specialized qubits that have longer coherence times or anything you can imagine.

We go even further! Eventually, we could be able to simulate whole systems like batteries and be able to optimize for the materials to make them last longer or understand how certain molecules react with our body like caffeine.

Finance

My Results

The results for N2:

The results for HLi:

The results for O2:

TD;LR

  • VQEs have lots of application in quantum chemistry to help us understand the things we interact with daily on a molecule level and to potentially find new materials
  • VQEs can be used in finance to optimize portfolios
  • VQEs main principle that causes them to work is the variational principle

Geek Culture

Proud to geek out. Follow to join our +500K monthly readers.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store