Created
October 26, 2019 01:53
-
-
Save Miura-KR/38ce66586acf264914e52ea666159ae3 to your computer and use it in GitHub Desktop.
shor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Shor のクラス\n", | |
"\n", | |
"参考\n", | |
"\n", | |
"https://qiskit.org/documentation/api/qiskit.aqua.algorithms.Shor.html?highlight=shor#qiskit.aqua.algorithms.Shor\n", | |
"\n", | |
"https://github.com/Qiskit/qiskit-community-tutorials/blob/master/aqua/shors.ipynb" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"{'qiskit-terra': '0.9.0',\n", | |
" 'qiskit-ignis': '0.2.0',\n", | |
" 'qiskit-aqua': '0.6.0',\n", | |
" 'qiskit': '0.12.0',\n", | |
" 'qiskit-aer': '0.3.0',\n", | |
" 'qiskit-ibmq-provider': '0.3.2'}" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"import qiskit\n", | |
"qiskit.__qiskit_version__" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from qiskit.aqua.algorithms import Shor\n", | |
"from qiskit import Aer" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"factorize = Shor()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"circ = factorize.construct_circuit()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Wall time: 1min 16s\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"{'factors': [[3, 5]],\n", | |
" 'results': {'00000000': 'x_value is <= 0, there are no continued fractions.',\n", | |
" '10000000': 'the continued fractions found exactly x_final/(2^(2n)).',\n", | |
" '11000000': (5, 3),\n", | |
" '01000000': (5, 3)}}" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"%%time\n", | |
"backend = Aer.get_backend(\"qasm_simulator\")\n", | |
"factorize.run(backend)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"f = Shor(N=33)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Wall time: 3h 5min 12s\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"{'factors': [],\n", | |
" 'results': {'111001101001': 'denominator of continued fraction is too big.',\n", | |
" '110011001100': 'unable to find factors after too many attempts.',\n", | |
" '100110011001': 'unable to find factors after too many attempts.',\n", | |
" '100110011111': 'denominator of continued fraction is too big.',\n", | |
" '100000000000': 'the continued fractions found exactly x_final/(2^(2n)).',\n", | |
" '000000000000': 'x_value is <= 0, there are no continued fractions.',\n", | |
" '110011001101': 'unable to find factors after too many attempts.',\n", | |
" '001100111001': 'unable to find factors after too many attempts.',\n", | |
" '100110010110': 'unable to find factors after too many attempts.',\n", | |
" '101100110010': 'unable to find factors after too many attempts.',\n", | |
" '011001100110': 'unable to find factors after too many attempts.',\n", | |
" '100110001101': 'denominator of continued fraction is too big.',\n", | |
" '010011001100': 'unable to find factors after too many attempts.',\n", | |
" '111001100100': 'unable to find factors after too many attempts.',\n", | |
" '101100110101': 'unable to find factors after too many attempts.',\n", | |
" '110011001110': 'unable to find factors after too many attempts.',\n", | |
" '111001100101': 'denominator of continued fraction is too big.',\n", | |
" '010011001101': 'unable to find factors after too many attempts.',\n", | |
" '010011010000': 'denominator of continued fraction is too big.',\n", | |
" '011001100101': 'unable to find factors after too many attempts.',\n", | |
" '011001011110': 'denominator of continued fraction is too big.',\n", | |
" '111001100000': 'denominator of continued fraction is too big.',\n", | |
" '110111000000': 'denominator of continued fraction is too big.',\n", | |
" '011001100010': 'denominator of continued fraction is too big.',\n", | |
" '001100110010': 'unable to find factors after too many attempts.',\n", | |
" '001100110011': 'unable to find factors after too many attempts.',\n", | |
" '011001101001': 'denominator of continued fraction is too big.',\n", | |
" '110011010000': 'denominator of continued fraction is too big.',\n", | |
" '100110011011': 'unable to find factors after too many attempts.',\n", | |
" '101100110100': 'unable to find factors after too many attempts.',\n", | |
" '000110011010': 'unable to find factors after too many attempts.',\n", | |
" '010011001000': 'denominator of continued fraction is too big.',\n", | |
" '111001101011': 'unable to find factors after too many attempts.',\n", | |
" '111001101000': 'denominator of continued fraction is too big.',\n", | |
" '011001101000': 'denominator of continued fraction is too big.',\n", | |
" '011001100100': 'denominator of continued fraction is too big.',\n", | |
" '011001110101': 'denominator of continued fraction is too big.',\n", | |
" '101100110001': 'unable to find factors after too many attempts.',\n", | |
" '100101000110': 'denominator of continued fraction is too big.',\n", | |
" '111001101010': 'denominator of continued fraction is too big.',\n", | |
" '010011010001': 'denominator of continued fraction is too big.',\n", | |
" '001100110100': 'unable to find factors after too many attempts.',\n", | |
" '000110010111': 'denominator of continued fraction is too big.',\n", | |
" '010011001010': 'unable to find factors after too many attempts.',\n", | |
" '011001101010': 'unable to find factors after too many attempts.',\n", | |
" '000110011011': 'denominator of continued fraction is too big.',\n", | |
" '110011001011': 'denominator of continued fraction is too big.',\n", | |
" '000110010110': 'denominator of continued fraction is too big.',\n", | |
" '000110010101': 'unable to find factors after too many attempts.',\n", | |
" '100110011101': 'denominator of continued fraction is too big.',\n", | |
" '000110011100': 'unable to find factors after too many attempts.',\n", | |
" '011001100111': 'unable to find factors after too many attempts.',\n", | |
" '110011001010': 'denominator of continued fraction is too big.',\n", | |
" '101100110110': 'unable to find factors after too many attempts.',\n", | |
" '001100101100': 'denominator of continued fraction is too big.',\n", | |
" '110001101100': 'denominator of continued fraction is too big.',\n", | |
" '010011001110': 'unable to find factors after too many attempts.',\n", | |
" '010011001011': 'unable to find factors after too many attempts.',\n", | |
" '101100110011': 'unable to find factors after too many attempts.',\n", | |
" '000110011001': 'unable to find factors after too many attempts.',\n", | |
" '100110010101': 'denominator of continued fraction is too big.',\n", | |
" '100110011100': 'denominator of continued fraction is too big.',\n", | |
" '010011100111': 'denominator of continued fraction is too big.',\n", | |
" '000110011000': 'denominator of continued fraction is too big.',\n", | |
" '100110100011': 'denominator of continued fraction is too big.',\n", | |
" '100110011010': 'unable to find factors after too many attempts.',\n", | |
" '111001100110': 'unable to find factors after too many attempts.',\n", | |
" '011001100011': 'denominator of continued fraction is too big.',\n", | |
" '111001101100': 'denominator of continued fraction is too big.',\n", | |
" '111001100010': 'denominator of continued fraction is too big.',\n", | |
" '111001100111': 'unable to find factors after too many attempts.',\n", | |
" '010011010100': 'denominator of continued fraction is too big.',\n", | |
" '101100101111': 'denominator of continued fraction is too big.',\n", | |
" '100110010111': 'denominator of continued fraction is too big.',\n", | |
" '101100101110': 'denominator of continued fraction is too big.',\n", | |
" '001100110101': 'denominator of continued fraction is too big.'}}" | |
] | |
}, | |
"execution_count": 6, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"%%time\n", | |
"backend = Aer.get_backend(\"qasm_simulator\")\n", | |
"f.run(backend)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Wall time: 9.56 s\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"{'factors': [],\n", | |
" 'results': {'1000': 'the continued fractions found exactly x_final/(2^(2n)).',\n", | |
" '0000': 'x_value is <= 0, there are no continued fractions.'}}" | |
] | |
}, | |
"execution_count": 7, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"%%time\n", | |
"f = Shor(N=3)\n", | |
"backend = Aer.get_backend(\"qasm_simulator\")\n", | |
"f.run(backend)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Wall time: 10min 35s\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"{'factors': [[3, 7]],\n", | |
" 'results': {'0101010101': 'unable to find factors after too many attempts.',\n", | |
" '0101010110': 'denominator of continued fraction is too big.',\n", | |
" '0101100101': 'unable to find factors after too many attempts.',\n", | |
" '1101010101': (3, 7),\n", | |
" '1101010010': (3, 7),\n", | |
" '1101011000': (3, 7),\n", | |
" '1101011010': (3, 7),\n", | |
" '0000000000': 'x_value is <= 0, there are no continued fractions.',\n", | |
" '0101011000': 'denominator of continued fraction is too big.',\n", | |
" '1101011011': (3, 7),\n", | |
" '1101011111': (3, 7),\n", | |
" '1010101011': 'unable to find factors after too many attempts.',\n", | |
" '1101000100': 'denominator of continued fraction is too big.',\n", | |
" '0010110011': (3, 7),\n", | |
" '0101010111': 'denominator of continued fraction is too big.',\n", | |
" '0010101100': (3, 7),\n", | |
" '1010101000': 'denominator of continued fraction is too big.',\n", | |
" '1101100110': (3, 7),\n", | |
" '0100111011': 'unable to find factors after too many attempts.',\n", | |
" '0010101010': (3, 7),\n", | |
" '1010101111': 'denominator of continued fraction is too big.',\n", | |
" '0010100101': (3, 7),\n", | |
" '0101010100': 'denominator of continued fraction is too big.',\n", | |
" '0010101000': (3, 7),\n", | |
" '1010100110': 'denominator of continued fraction is too big.',\n", | |
" '1010101101': 'unable to find factors after too many attempts.',\n", | |
" '0010100100': (3, 7),\n", | |
" '1101010000': (3, 7),\n", | |
" '1010101001': 'denominator of continued fraction is too big.',\n", | |
" '1101010001': (3, 7),\n", | |
" '0101100110': 'denominator of continued fraction is too big.',\n", | |
" '1000000000': 'the continued fractions found exactly x_final/(2^(2n)).',\n", | |
" '1010101010': 'denominator of continued fraction is too big.',\n", | |
" '0010101110': (3, 7),\n", | |
" '0010101011': (3, 7),\n", | |
" '1010100111': 'denominator of continued fraction is too big.',\n", | |
" '0010101001': (3, 7),\n", | |
" '0010110110': (3, 7),\n", | |
" '1101010111': (3, 7),\n", | |
" '0101001010': 'denominator of continued fraction is too big.',\n", | |
" '1101010110': (3, 7),\n", | |
" '1010100101': 'unable to find factors after too many attempts.',\n", | |
" '0101010010': 'denominator of continued fraction is too big.',\n", | |
" '0010011111': (3, 7),\n", | |
" '1010101110': 'denominator of continued fraction is too big.',\n", | |
" '0101010011': 'unable to find factors after too many attempts.',\n", | |
" '0101110000': 'denominator of continued fraction is too big.',\n", | |
" '1101010011': (3, 7),\n", | |
" '0101100000': 'unable to find factors after too many attempts.',\n", | |
" '1101001110': (3, 7),\n", | |
" '1101010100': (3, 7),\n", | |
" '0101010001': 'denominator of continued fraction is too big.',\n", | |
" '0010101101': (3, 7),\n", | |
" '0010100111': (3, 7),\n", | |
" '0101001001': 'unable to find factors after too many attempts.',\n", | |
" '1010101100': 'denominator of continued fraction is too big.'}}" | |
] | |
}, | |
"execution_count": 8, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"%%time\n", | |
"f = Shor(N=21)\n", | |
"backend = Aer.get_backend(\"qasm_simulator\")\n", | |
"f.run(backend)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 25, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Wall time: 2.02 ms\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"{'factors': [5]}" | |
] | |
}, | |
"execution_count": 25, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"%%time\n", | |
"f = Shor(25)\n", | |
"backend = Aer.get_backend(\"qasm_simulator\")\n", | |
"f.run(backend)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 26, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Wall time: 2 ms\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"{'factors': [3]}" | |
] | |
}, | |
"execution_count": 26, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"%%time\n", | |
"f = Shor(27)\n", | |
"backend = Aer.get_backend(\"qasm_simulator\")\n", | |
"f.run(backend)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 27, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Wall time: 9min 38s\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"{'factors': [],\n", | |
" 'results': {'0000100110': 'denominator of continued fraction is too big.',\n", | |
" '1111011001': 'unable to find factors after too many attempts.',\n", | |
" '0110010011': 'denominator of continued fraction is too big.',\n", | |
" '1010011001': 'denominator of continued fraction is too big.',\n", | |
" '0110110111': 'unable to find factors after too many attempts.',\n", | |
" '1101101101': 'denominator of continued fraction is too big.',\n", | |
" '1000011001': 'denominator of continued fraction is too big.',\n", | |
" '0000000000': 'x_value is <= 0, there are no continued fractions.',\n", | |
" '0111011001': 'denominator of continued fraction is too big.',\n", | |
" '1000100001': 'denominator of continued fraction is too big.',\n", | |
" '1010110111': 'unable to find factors after too many attempts.',\n", | |
" '1110010011': 'denominator of continued fraction is too big.',\n", | |
" '0010010001': 'unable to find factors after too many attempts.',\n", | |
" '1010101000': 'denominator of continued fraction is too big.',\n", | |
" '0010010100': 'denominator of continued fraction is too big.',\n", | |
" '1110001100': 'denominator of continued fraction is too big.',\n", | |
" '1010111000': 'denominator of continued fraction is too big.',\n", | |
" '1001101110': 'denominator of continued fraction is too big.',\n", | |
" '1111011011': 'unable to find factors after too many attempts.',\n", | |
" '0100100100': 'denominator of continued fraction is too big.',\n", | |
" '0011011101': 'unable to find factors after too many attempts.',\n", | |
" '0000111001': 'unable to find factors after too many attempts.',\n", | |
" '1111011101': 'denominator of continued fraction is too big.',\n", | |
" '0101101100': 'denominator of continued fraction is too big.',\n", | |
" '1011100000': 'unable to find factors after too many attempts.',\n", | |
" '0101111100': 'denominator of continued fraction is too big.',\n", | |
" '0001111011': 'unable to find factors after too many attempts.',\n", | |
" '0110010010': 'denominator of continued fraction is too big.',\n", | |
" '1111011111': 'unable to find factors after too many attempts.',\n", | |
" '0111011100': 'denominator of continued fraction is too big.',\n", | |
" '0000100101': 'unable to find factors after too many attempts.',\n", | |
" '1110010010': 'denominator of continued fraction is too big.',\n", | |
" '0011011100': 'denominator of continued fraction is too big.',\n", | |
" '0001101101': 'denominator of continued fraction is too big.',\n", | |
" '1000100101': 'denominator of continued fraction is too big.',\n", | |
" '1100010111': 'unable to find factors after too many attempts.',\n", | |
" '1010011000': 'denominator of continued fraction is too big.',\n", | |
" '0101001000': 'denominator of continued fraction is too big.',\n", | |
" '1000011010': 'denominator of continued fraction is too big.',\n", | |
" '1110001011': 'unable to find factors after too many attempts.',\n", | |
" '1110010100': 'denominator of continued fraction is too big.',\n", | |
" '1000101000': 'denominator of continued fraction is too big.',\n", | |
" '1011011011': 'unable to find factors after too many attempts.',\n", | |
" '0111010110': 'denominator of continued fraction is too big.',\n", | |
" '1100110000': 'denominator of continued fraction is too big.',\n", | |
" '0100101111': 'denominator of continued fraction is too big.',\n", | |
" '0101101110': 'denominator of continued fraction is too big.',\n", | |
" '0110010000': 'denominator of continued fraction is too big.',\n", | |
" '1010010011': 'unable to find factors after too many attempts.',\n", | |
" '1000011000': 'denominator of continued fraction is too big.',\n", | |
" '0010110111': 'unable to find factors after too many attempts.',\n", | |
" '0011011010': 'denominator of continued fraction is too big.',\n", | |
" '0011011111': 'denominator of continued fraction is too big.',\n", | |
" '1101101100': 'denominator of continued fraction is too big.',\n", | |
" '1011011100': 'denominator of continued fraction is too big.',\n", | |
" '1110010101': 'unable to find factors after too many attempts.',\n", | |
" '0001101110': 'denominator of continued fraction is too big.',\n", | |
" '1011010111': 'denominator of continued fraction is too big.',\n", | |
" '1001000111': 'unable to find factors after too many attempts.',\n", | |
" '1101101110': 'denominator of continued fraction is too big.',\n", | |
" '0101101111': 'denominator of continued fraction is too big.',\n", | |
" '1010001110': 'denominator of continued fraction is too big.',\n", | |
" '1110110111': 'unable to find factors after too many attempts.',\n", | |
" '1000100100': 'denominator of continued fraction is too big.',\n", | |
" '0101101101': 'unable to find factors after too many attempts.',\n", | |
" '1000100010': 'denominator of continued fraction is too big.',\n", | |
" '0100111110': 'denominator of continued fraction is too big.',\n", | |
" '1001101111': 'unable to find factors after too many attempts.',\n", | |
" '0010010010': 'denominator of continued fraction is too big.',\n", | |
" '0011010011': 'unable to find factors after too many attempts.',\n", | |
" '1111011010': 'denominator of continued fraction is too big.',\n", | |
" '0001001001': 'unable to find factors after too many attempts.',\n", | |
" '1011011001': 'denominator of continued fraction is too big.',\n", | |
" '0111011010': 'denominator of continued fraction is too big.',\n", | |
" '0110110110': 'denominator of continued fraction is too big.',\n", | |
" '0001001000': 'denominator of continued fraction is too big.',\n", | |
" '0000100100': 'denominator of continued fraction is too big.',\n", | |
" '1010010000': 'denominator of continued fraction is too big.',\n", | |
" '1101101001': 'denominator of continued fraction is too big.',\n", | |
" '1011011101': 'denominator of continued fraction is too big.',\n", | |
" '1101110010': 'denominator of continued fraction is too big.',\n", | |
" '0011011001': 'denominator of continued fraction is too big.',\n", | |
" '0011011011': 'unable to find factors after too many attempts.',\n", | |
" '1001010011': 'denominator of continued fraction is too big.',\n", | |
" '0111011101': 'denominator of continued fraction is too big.',\n", | |
" '1010010001': 'denominator of continued fraction is too big.',\n", | |
" '0110010100': 'denominator of continued fraction is too big.',\n", | |
" '1000000000': 'the continued fractions found exactly x_final/(2^(2n)).',\n", | |
" '1100100110': 'denominator of continued fraction is too big.',\n", | |
" '1010010010': 'denominator of continued fraction is too big.',\n", | |
" '0100100010': 'denominator of continued fraction is too big.',\n", | |
" '1100000001': 'unable to find factors after too many attempts.',\n", | |
" '1101001001': 'unable to find factors after too many attempts.',\n", | |
" '1111011100': 'denominator of continued fraction is too big.',\n", | |
" '1001101000': 'denominator of continued fraction is too big.',\n", | |
" '1100100111': 'denominator of continued fraction is too big.',\n", | |
" '1010011101': 'unable to find factors after too many attempts.',\n", | |
" '1010010100': 'denominator of continued fraction is too big.',\n", | |
" '1000100110': 'denominator of continued fraction is too big.',\n", | |
" '0100100101': 'unable to find factors after too many attempts.',\n", | |
" '1001101101': 'denominator of continued fraction is too big.',\n", | |
" '1110001010': 'denominator of continued fraction is too big.',\n", | |
" '1000100111': 'denominator of continued fraction is too big.',\n", | |
" '1001001010': 'denominator of continued fraction is too big.',\n", | |
" '1101101111': 'unable to find factors after too many attempts.',\n", | |
" '0101001010': 'denominator of continued fraction is too big.',\n", | |
" '0111011011': 'denominator of continued fraction is too big.',\n", | |
" '1100100101': 'unable to find factors after too many attempts.',\n", | |
" '0110010001': 'unable to find factors after too many attempts.',\n", | |
" '1100100001': 'denominator of continued fraction is too big.',\n", | |
" '1100000000': 'the continued fractions found exactly x_final/(2^(2n)).',\n", | |
" '0100000000': 'the continued fractions found exactly x_final/(2^(2n)).',\n", | |
" '1101001010': 'denominator of continued fraction is too big.',\n", | |
" '0111010000': 'denominator of continued fraction is too big.',\n", | |
" '0101001001': 'unable to find factors after too many attempts.',\n", | |
" '1001001001': 'unable to find factors after too many attempts.',\n", | |
" '1100100100': 'denominator of continued fraction is too big.',\n", | |
" '0000001111': 'denominator of continued fraction is too big.',\n", | |
" '1100110101': 'denominator of continued fraction is too big.'}}" | |
] | |
}, | |
"execution_count": 27, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"%%time\n", | |
"f = Shor(29)\n", | |
"backend = Aer.get_backend(\"qasm_simulator\")\n", | |
"f.run(backend)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 28, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Wall time: 8min 56s\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"{'factors': [],\n", | |
" 'results': {'0011010000': 'denominator of continued fraction is too big.',\n", | |
" '0110011011': 'denominator of continued fraction is too big.',\n", | |
" '1100101111': 'unable to find factors after too many attempts.',\n", | |
" '1101101110': 'denominator of continued fraction is too big.',\n", | |
" '1001100110': 'denominator of continued fraction is too big.',\n", | |
" '1001011111': 'denominator of continued fraction is too big.',\n", | |
" '0000000000': 'x_value is <= 0, there are no continued fractions.',\n", | |
" '0110010110': 'denominator of continued fraction is too big.',\n", | |
" '0110010101': 'denominator of continued fraction is too big.',\n", | |
" '0110011100': 'denominator of continued fraction is too big.',\n", | |
" '1001110001': 'denominator of continued fraction is too big.',\n", | |
" '0011010111': 'denominator of continued fraction is too big.',\n", | |
" '0011001011': 'denominator of continued fraction is too big.',\n", | |
" '1001101110': 'denominator of continued fraction is too big.',\n", | |
" '1001100101': 'denominator of continued fraction is too big.',\n", | |
" '1100110110': 'denominator of continued fraction is too big.',\n", | |
" '1001100111': 'denominator of continued fraction is too big.',\n", | |
" '0011001100': 'denominator of continued fraction is too big.',\n", | |
" '0101111011': 'denominator of continued fraction is too big.',\n", | |
" '0011001010': 'denominator of continued fraction is too big.',\n", | |
" '0110011001': 'denominator of continued fraction is too big.',\n", | |
" '0110011101': 'denominator of continued fraction is too big.',\n", | |
" '1001100100': 'denominator of continued fraction is too big.',\n", | |
" '1001101000': 'denominator of continued fraction is too big.',\n", | |
" '1100111100': 'denominator of continued fraction is too big.',\n", | |
" '1100110010': 'denominator of continued fraction is too big.',\n", | |
" '1100110011': 'unable to find factors after too many attempts.',\n", | |
" '0110011000': 'denominator of continued fraction is too big.',\n", | |
" '1001011001': 'unable to find factors after too many attempts.',\n", | |
" '0011001110': 'denominator of continued fraction is too big.',\n", | |
" '1100010111': 'unable to find factors after too many attempts.',\n", | |
" '0110100011': 'unable to find factors after too many attempts.',\n", | |
" '0110011010': 'denominator of continued fraction is too big.',\n", | |
" '1010011110': 'denominator of continued fraction is too big.',\n", | |
" '0110011110': 'denominator of continued fraction is too big.',\n", | |
" '0110101001': 'denominator of continued fraction is too big.',\n", | |
" '0011000001': 'unable to find factors after too many attempts.',\n", | |
" '1001101001': 'denominator of continued fraction is too big.',\n", | |
" '1001110000': 'denominator of continued fraction is too big.',\n", | |
" '0011001001': 'denominator of continued fraction is too big.',\n", | |
" '0011001111': 'denominator of continued fraction is too big.',\n", | |
" '0011001101': 'unable to find factors after too many attempts.',\n", | |
" '1100110100': 'denominator of continued fraction is too big.',\n", | |
" '0110010111': 'denominator of continued fraction is too big.',\n", | |
" '1100110101': 'denominator of continued fraction is too big.'}}" | |
] | |
}, | |
"execution_count": 28, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"%%time\n", | |
"f = Shor(31)\n", | |
"qasm = Aer.get_backend(\"qasm_simulator\")\n", | |
"f.run(qasm)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 29, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Wall time: 3h 16min 53s\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"{'factors': [],\n", | |
" 'results': {'111001101001': 'denominator of continued fraction is too big.',\n", | |
" '110011001100': 'unable to find factors after too many attempts.',\n", | |
" '100110011001': 'unable to find factors after too many attempts.',\n", | |
" '000110010011': 'unable to find factors after too many attempts.',\n", | |
" '001100111101': 'denominator of continued fraction is too big.',\n", | |
" '100000000000': 'the continued fractions found exactly x_final/(2^(2n)).',\n", | |
" '000000000000': 'x_value is <= 0, there are no continued fractions.',\n", | |
" '110011001101': 'unable to find factors after too many attempts.',\n", | |
" '001100111001': 'unable to find factors after too many attempts.',\n", | |
" '111001101101': 'unable to find factors after too many attempts.',\n", | |
" '101100110010': 'unable to find factors after too many attempts.',\n", | |
" '011001100110': 'unable to find factors after too many attempts.',\n", | |
" '010011010011': 'denominator of continued fraction is too big.',\n", | |
" '010011001100': 'unable to find factors after too many attempts.',\n", | |
" '010000111011': 'unable to find factors after too many attempts.',\n", | |
" '111001100100': 'unable to find factors after too many attempts.',\n", | |
" '110011001110': 'unable to find factors after too many attempts.',\n", | |
" '111001100101': 'denominator of continued fraction is too big.',\n", | |
" '010011001101': 'unable to find factors after too many attempts.',\n", | |
" '010011010110': 'denominator of continued fraction is too big.',\n", | |
" '000110011101': 'denominator of continued fraction is too big.',\n", | |
" '111001100000': 'denominator of continued fraction is too big.',\n", | |
" '011001100010': 'denominator of continued fraction is too big.',\n", | |
" '101100110111': 'unable to find factors after too many attempts.',\n", | |
" '001100110010': 'unable to find factors after too many attempts.',\n", | |
" '001100110011': 'unable to find factors after too many attempts.',\n", | |
" '011001101001': 'denominator of continued fraction is too big.',\n", | |
" '101100111101': 'denominator of continued fraction is too big.',\n", | |
" '100110011011': 'unable to find factors after too many attempts.',\n", | |
" '100110100001': 'denominator of continued fraction is too big.',\n", | |
" '101100110100': 'unable to find factors after too many attempts.',\n", | |
" '000110011010': 'unable to find factors after too many attempts.',\n", | |
" '111001101011': 'unable to find factors after too many attempts.',\n", | |
" '100110101011': 'denominator of continued fraction is too big.',\n", | |
" '111001101000': 'denominator of continued fraction is too big.',\n", | |
" '111010011010': 'denominator of continued fraction is too big.',\n", | |
" '011001101000': 'denominator of continued fraction is too big.',\n", | |
" '011001100100': 'denominator of continued fraction is too big.',\n", | |
" '000110100010': 'unable to find factors after too many attempts.',\n", | |
" '101100110001': 'unable to find factors after too many attempts.',\n", | |
" '100110011000': 'denominator of continued fraction is too big.',\n", | |
" '111001101010': 'denominator of continued fraction is too big.',\n", | |
" '001100110100': 'unable to find factors after too many attempts.',\n", | |
" '000110010111': 'denominator of continued fraction is too big.',\n", | |
" '000110011011': 'denominator of continued fraction is too big.',\n", | |
" '000110010110': 'denominator of continued fraction is too big.',\n", | |
" '100110011101': 'denominator of continued fraction is too big.',\n", | |
" '011001100001': 'denominator of continued fraction is too big.',\n", | |
" '011001100111': 'unable to find factors after too many attempts.',\n", | |
" '001100110001': 'unable to find factors after too many attempts.',\n", | |
" '011010000111': 'denominator of continued fraction is too big.',\n", | |
" '010011001111': 'unable to find factors after too many attempts.',\n", | |
" '000111100010': 'unable to find factors after too many attempts.',\n", | |
" '101100110011': 'unable to find factors after too many attempts.',\n", | |
" '110011010101': 'denominator of continued fraction is too big.',\n", | |
" '110011001111': 'unable to find factors after too many attempts.',\n", | |
" '000110010100': 'denominator of continued fraction is too big.',\n", | |
" '000110011001': 'unable to find factors after too many attempts.',\n", | |
" '100110010101': 'denominator of continued fraction is too big.',\n", | |
" '000110011000': 'denominator of continued fraction is too big.',\n", | |
" '100110011010': 'unable to find factors after too many attempts.',\n", | |
" '111001100110': 'unable to find factors after too many attempts.',\n", | |
" '011001100011': 'denominator of continued fraction is too big.',\n", | |
" '111001100111': 'unable to find factors after too many attempts.',\n", | |
" '101100100110': 'unable to find factors after too many attempts.',\n", | |
" '011001100101': 'unable to find factors after too many attempts.',\n", | |
" '001100110101': 'denominator of continued fraction is too big.'}}" | |
] | |
}, | |
"execution_count": 29, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"%%time\n", | |
"f = Shor(33)\n", | |
"f.run(qasm)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Wall time: 1min 11s\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"{'factors': [[3, 5]],\n", | |
" 'results': {'01000000': (5, 3),\n", | |
" '00000000': 'x_value is <= 0, there are no continued fractions.',\n", | |
" '11000000': (5, 3),\n", | |
" '10000000': 'the continued fractions found exactly x_final/(2^(2n)).'}}" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"%%time\n", | |
"f = Shor(15)\n", | |
"qasm = Aer.get_backend(\"qasm_simulator\")\n", | |
"f.run(qasm)" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.7.4" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment