{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"#Installing all dependencies\n",
"\n",
"import strawberryfields as sf\n",
"from strawberryfields.ops import *\n",
"from strawberryfields.utils import scale\n",
"from numpy import pi, sqrt\n",
"import math\n",
"import random\n",
"from scipy.optimize import minimize\n",
"\n",
"import numpy as np\n",
"\n",
"from matplotlib import pyplot as plt\n",
"from mpl_toolkits.mplot3d import Axes3D"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Table of Contents**\n",
"\n",
"**Part 1: Theory**\n",
"\n",
"1. The Variational Quantum Eigensolver\n",
"2. The Quantum Approximate Optimization Algorithm\n",
"3. Continuous-Variable QAOA\n",
"\n",
"**Part 2: Simulations**\n",
"\n",
"4. A Small Tangent: Creating Quadrature Plots With Strawberry Fields and Matplotlib\n",
"5. Simulating Continuous-Variable QAOA For a Simple Problem\n",
"6. Simulating Continuous-Variable QAOA For Harder Problems\n",
"7. The Not-So Grand Finale: A Quartic Function With Two Global Minima\n",
"8. Another Small Tangent: Higher-Order Gate Decomposition\n",
"9. I Promise This is Our Last Detour: Numerically Calculating the Cost Hamiltonian Expectation Value\n",
"
\n",
"10. Conclusion\n",
"11. Acknowledgments and References\n",
"\n",
"\n",
"
\n",
"\n",
"**Introduction**\n",
"\n",
"The goal of this notebook is to provide the reader with a concrete understanding of QAOA over Continuous Variables. Despite this, the first section of this notebook is dedicated to understanding the **physics** that allows algorithms like QAOA to function properly. The reason I have included this is because I want to provide an end-to-end explanation of why CV QAOA works, starting from first principles with the variational principle and AQT, working up to the theory behind CV QAOA, then in Part 2, launching into actual concrete simulations of the CV QAOA problem applied to different problems.\n",
"\n",
"This is the **first version** of this notebook. Becausse it is so long, I am almost 100% sure that I will find mistakes in it somewhere as I edit it over the coming weeks. I will try to keep an Erratum at the bottom of this notebook, as I make updates! I also welcome feedback, suggestions, and people pointing our where I made mistakes, so do not hesitate to reach out!\n",
"\n",
"Without further delay, let's get started!\n",
"\n",
"**The Variational Quantum Eigensolver**