The Variational Quantum Algorithm, Explained for Dummies
Enlighten yourself
You’ve probably seen these pretty pictures of a hydrogen atom. In a nutshell, the hydrogen atom has many different states, in which it can have many different energies. An excited hydrogen atom has more energy than ground state hydrogen.
The VQA, variational quantum algorithm, is an active area of research for all stuff quantum. Combining both quantum and classical (normal) computing, it is an exciting field.
The intuition behind is not particularly difficult to understand. The math? Maybe not so, but I’m not getting into that today. Instead, let’s just immerse ourselves in the magic of quantum.
The VQA is essentially trying to find the minimum (or maximum) value of a function.
For instance, in this function, the blue line shows the maximum value, and the green line, its minimum.
But, the function for which VQAs are trying to find the minimum/maximum is much more complicated. Stuff such as the max-cut problem in graph theory, or some energy state in chemistry.
Let’s skip all of that. Let’s just assume our VQA is finding the minimum of a cost function, C. I’ll keep referring back to C.
So now we look at our VQA steps.
- Initialize a quantum state
- Prepare an ansatz
- Evaluate the cost function
- Optimize
- Repeat
Let’s dive in.
1. Initializing
Initializing is like preparing a basic starting state to evaluate C. This can be random, or it could be found through carefully examining C. This is one of the less important steps. Let’s call this initial state x.
2 & 3. Prepare an Ansatz & Evaluate Cost Function
This idea skipped my mind the first time I looked at it. But it’s simple. It is literally a guessing machine.
For instance, if we were playing the guessing game and I had a number from 1 to 100. You try to guess my number. But. I won’t say “higher/lower” or give you any information about my number. Your only choice is to guess all values.
So let’s say you started at 1. Your initial state x is 1. Now if you go up by fours, you would guess 1, 5, 9, 13… etc. This strategy is pretty fast, but you may not guess my number.
But if you went up by twos, you would guess 1, 3, 5, all the odd numbers. This strategy is twice as slow, but twice as accurate.
And to guarantee success, you would have to guess all 100 numbers: 1, 2, 3 and so on. Twice as slow, but twice as accurate.
This is like what the ansatz is. Trading speed for accuracy. If you go fast, you might find the minimum value of your cost function, but you also may not. If you go slow, you probably will find the minimum value of C, but you’ll take a long time.
The ansatz is choosing what values to try, and you evaluate it on the cost function.
4. Optimize
After evaluating the cost function at some points, we now have some information about it. This allows us to optimize the ansatz (guessing by fours or guessing by twos? Maybe we should guess by threes?). Now that our ansatz is guessing differently, we can…
5. Repeat!
Yup! Go back to step two! Try the ansatz again, and see if our values are better.
And that’s all? That’s all! This is the heart of what a VQA is. Of course, I’ve skipped over basically every detail, but this is the bare minimum needed to understand it.
I hope that this article will have made you a little curious about quantum. Please do continue fueling your interest.