Skip to content

Instantly share code, notes, and snippets.

@cgranade
Created September 4, 2020 16:53
Show Gist options
  • Save cgranade/b8cefb19b63154f343c790c035a8e161 to your computer and use it in GitHub Desktop.
Save cgranade/b8cefb19b63154f343c790c035a8e161 to your computer and use it in GitHub Desktop.
qcstackexchange-13581
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"application/json": "{\"LastUpdated\":\"2020-09-04T09:52:33.1468252-07:00\",\"IsCompleted\":true,\"Description\":\"Adding package Microsoft.Quantum.Standard.Visualization\",\"Subtask\":\"done\"}",
"text/plain": [
"Adding package Microsoft.Quantum.Standard.Visualization: done!"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/json": "[\"Microsoft.Quantum.Standard::0.12.20082513\",\"Microsoft.Quantum.Standard.Visualization::0.12.20082513\"]",
"text/html": [
"<ul><li>Microsoft.Quantum.Standard::0.12.20082513</li><li>Microsoft.Quantum.Standard.Visualization::0.12.20082513</li></ul>"
],
"text/plain": [
"Microsoft.Quantum.Standard::0.12.20082513, Microsoft.Quantum.Standard.Visualization::0.12.20082513"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%package Microsoft.Quantum.Standard.Visualization"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"application/json": "[]",
"text/html": [
"<ul></ul>"
],
"text/plain": []
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"open Microsoft.Quantum.Math as Math;\n",
"open Microsoft.Quantum.Diagnostics as Diag;"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"application/json": "[\"ApplyCZPow\"]",
"text/html": [
"<ul><li>ApplyCZPow</li></ul>"
],
"text/plain": [
"ApplyCZPow"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"operation ApplyCZPow(t : Double, control : Qubit, target : Qubit) : Unit is Adj + Ctl {\n",
" Controlled R1([control], (t * Math.PI(), target));\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"application/json": "[\"DumpApplyCZPow\"]",
"text/html": [
"<ul><li>DumpApplyCZPow</li></ul>"
],
"text/plain": [
"DumpApplyCZPow"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"operation DumpApplyCZPow(t : Double) : Unit {\n",
" Diag.DumpOperation(2, ApplyToFirstTwoQubitsCA(ApplyCZPow(t, _, _), _));\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\r\n",
" <table>\r\n",
" <tr>\r\n",
" <th>Qubit IDs</th>\r\n",
" <td>2, 3\r\n",
" </tr>\r\n",
"\r\n",
" <tr>\r\n",
" <th>Unitary representation</th>\r\n",
" <td>$$\r\n",
" \\left(\\begin{matrix}\r\n",
" 1 & 0 & 0 & 0 \\\\\n",
"0 & 1 & 0 & 0 \\\\\n",
"0 & 0 & 1 & 0 \\\\\n",
"0 & 0 & 0 & 1i\r\n",
" \\end{matrix}\\right)\r\n",
" $$</td>\r\n",
" </tr>\r\n",
" </table>\r\n",
" "
],
"text/plain": [
"Real:\n",
"[[1, 0, 0, 0], \r\n",
"[0, 1, 0, 0], \r\n",
"[0, 0, 1, 0], \r\n",
"[0, 0, 0, 0]]\n",
"Imag:\n",
"[[0, 0, 0, 0], \r\n",
"[0, 0, 0, 0], \r\n",
"[0, 0, 0, 0], \r\n",
"[0, 0, 0, 1]]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/json": "{\"@type\":\"tuple\"}",
"text/plain": [
"()"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%simulate DumpApplyCZPow t=0.5"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\r\n",
" <table>\r\n",
" <tr>\r\n",
" <th>Qubit IDs</th>\r\n",
" <td>2, 3\r\n",
" </tr>\r\n",
"\r\n",
" <tr>\r\n",
" <th>Unitary representation</th>\r\n",
" <td>$$\r\n",
" \\left(\\begin{matrix}\r\n",
" 1 & 0 & 0 & 0 \\\\\n",
"0 & 1 & 0 & 0 \\\\\n",
"0 & 0 & 1 & 0 \\\\\n",
"0 & 0 & 0 & -1\r\n",
" \\end{matrix}\\right)\r\n",
" $$</td>\r\n",
" </tr>\r\n",
" </table>\r\n",
" "
],
"text/plain": [
"Real:\n",
"[[1, 0, 0, 0], \r\n",
"[0, 1, 0, 0], \r\n",
"[0, 0, 1, 0], \r\n",
"[0, 0, 0, -1]]\n",
"Imag:\n",
"[[0, 0, 0, 0], \r\n",
"[0, 0, 0, 0], \r\n",
"[0, 0, 0, 0], \r\n",
"[0, 0, 0, 1.2246467991473532E-16]]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/json": "{\"@type\":\"tuple\"}",
"text/plain": [
"()"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%simulate DumpApplyCZPow t=1.0"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\r\n",
" <table>\r\n",
" <tr>\r\n",
" <th>Qubit IDs</th>\r\n",
" <td>2, 3\r\n",
" </tr>\r\n",
"\r\n",
" <tr>\r\n",
" <th>Unitary representation</th>\r\n",
" <td>$$\r\n",
" \\left(\\begin{matrix}\r\n",
" 1 & 0 & 0 & 0 \\\\\n",
"0 & 1 & 0 & 0 \\\\\n",
"0 & 0 & 1 & 0 \\\\\n",
"0 & 0 & 0 & -0.605 + 0.796i\r\n",
" \\end{matrix}\\right)\r\n",
" $$</td>\r\n",
" </tr>\r\n",
" </table>\r\n",
" "
],
"text/plain": [
"Real:\n",
"[[1, 0, 0, 0], \r\n",
"[0, 1, 0, 0], \r\n",
"[0, 0, 1, 0], \r\n",
"[0, 0, 0, -0.6054329073810013]]\n",
"Imag:\n",
"[[0, 0, 0, 0], \r\n",
"[0, 0, 0, 0], \r\n",
"[0, 0, 0, 0], \r\n",
"[0, 0, 0, 0.7958963466810159]]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/json": "{\"@type\":\"tuple\"}",
"text/plain": [
"()"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%simulate DumpApplyCZPow t=0.707"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"application/json": "{\"rows\":[{\"@type\":\"@tuple\",\"Item1\":\"iqsharp\",\"Item2\":\"0.12.20082513\"},{\"@type\":\"@tuple\",\"Item1\":\"Jupyter Core\",\"Item2\":\"1.4.0.0\"},{\"@type\":\"@tuple\",\"Item1\":\".NET Runtime\",\"Item2\":\".NETCoreApp,Version=v3.1\"}]}",
"text/html": [
"<table><thead><tr><th style=\"text-align: start;\">Component</th><th style=\"text-align: start;\">Version</th></tr></thead><tbody><tr><td style=\"text-align: start;\">iqsharp</td><td style=\"text-align: start;\">0.12.20082513</td></tr><tr><td style=\"text-align: start;\">Jupyter Core</td><td style=\"text-align: start;\">1.4.0.0</td></tr><tr><td style=\"text-align: start;\">.NET Runtime</td><td style=\"text-align: start;\">.NETCoreApp,Version=v3.1</td></tr></tbody></table>"
],
"text/plain": [
"Component Version\r\n",
"------------ ------------------------\r\n",
"iqsharp 0.12.20082513\r\n",
"Jupyter Core 1.4.0.0\r\n",
".NET Runtime .NETCoreApp,Version=v3.1\r\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%version"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Q#",
"language": "qsharp",
"name": "iqsharp"
},
"language_info": {
"file_extension": ".qs",
"mimetype": "text/x-qsharp",
"name": "qsharp",
"version": "0.12"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
FROM mcr.microsoft.com/quantum/iqsharp-base:0.12.20082513
ENV IQSHARP_HOSTING_ENV=qcstackexchange-13581
# Make sure the contents of our repo are in ${HOME}.
# These steps are required for use on mybinder.org.
USER root
COPY . ${HOME}
RUN chown -R ${USER} ${HOME}
USER ${USER}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment