{"id":42504,"date":"2025-11-08T10:41:41","date_gmt":"2025-11-08T05:11:41","guid":{"rendered":"https:\/\/tocxten.com\/?page_id=42504"},"modified":"2025-11-08T13:07:38","modified_gmt":"2025-11-08T07:37:38","slug":"superposition-of-qubits-the-foundation-of-quantum-computing","status":"publish","type":"page","link":"https:\/\/tocxten.com\/index.php\/superposition-of-qubits-the-foundation-of-quantum-computing\/","title":{"rendered":"Superposition of Qubits: The Foundation of Quantum Computing"},"content":{"rendered":"\n<h2 class=\"wp-block-heading has-background\" style=\"background-color:#d3c0c0\"><strong>1. Introduction<\/strong><\/h2>\n\n\n\n<p>At the heart of quantum computing lies a fundamental concept that defies classical logic \u2014 <strong>superposition<\/strong>. Unlike a classical bit that can be in only one of two definite states, <strong>0 or 1<\/strong>, a <strong>quantum bit (qubit)<\/strong> can exist in a combination, or <strong>superposition<\/strong>, of both states simultaneously. This principle enables quantum computers to process a vast number of possibilities at once, leading to unprecedented computational power.<\/p>\n\n\n\n<p>Mathematically, a qubit in superposition is represented as:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"221\" height=\"37\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-29.png\" alt=\"\" class=\"wp-image-42505\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"963\" height=\"221\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-30.png\" alt=\"\" class=\"wp-image-42506\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-30.png 963w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-30-300x69.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-30-768x176.png 768w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-30-760x174.png 760w\" sizes=\"auto, (max-width: 963px) 100vw, 963px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading has-background\" style=\"background-color:#e5dddd\"><strong>2. Representation of Quantum States<\/strong><\/h2>\n\n\n\n<p>Quantum states are expressed using <strong>Dirac notation<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"676\" height=\"198\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-31.png\" alt=\"\" class=\"wp-image-42509\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-31.png 676w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-31-300x88.png 300w\" sizes=\"auto, (max-width: 676px) 100vw, 676px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Inner Product<\/strong><\/h3>\n\n\n\n<p>The <strong>inner product<\/strong> \u27e8\u03d5|\u03c8\u27e9 gives a scalar indicating the <strong>overlap<\/strong> between two quantum states.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Outer Product<\/strong><\/h3>\n\n\n\n<p>The <strong>outer product<\/strong> |\u03c8\u27e9\u27e8\u03d5| yields a <strong>matrix<\/strong>, which is used to construct <strong>quantum operators<\/strong> such as projectors and density matrices.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-background\" style=\"background-color:#e1d7d7\"><strong>3. Types of Superposition States<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\"><strong>a) Equal Superposition<\/strong><\/h3>\n\n\n\n<p>A qubit has <strong>equal probability<\/strong> of being measured as 0 or 1.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"227\" height=\"71\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-32.png\" alt=\"\" class=\"wp-image-42511\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"859\" height=\"182\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-33.png\" alt=\"\" class=\"wp-image-42513\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-33.png 859w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-33-300x64.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-33-768x163.png 768w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-33-760x161.png 760w\" sizes=\"auto, (max-width: 859px) 100vw, 859px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\"><strong>b) Biased Towards |0\u27e9<\/strong><\/p>\n\n\n\n<p>A state with a <strong>higher probability<\/strong> of collapsing to |0\u27e9: <\/p>\n\n\n\n<p>Example : \u2223\u03c8\u27e9=0.9\u22230\u27e9+0.435\u22231\u27e9 <\/p>\n\n\n\n<p>Here, \u2223\u03b1\u2223^2  =  0.81,                 \u2223\u03b2^\u22232 =  0.19 <\/p>\n\n\n\n<p>The qubit is more likely to yield <strong>0<\/strong> upon measurement.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>c) Biased Towards |1\u27e9<\/strong><\/h3>\n\n\n\n<p>A state with a <strong>higher probability<\/strong> of collapsing to |1\u27e9: <\/p>\n\n\n\n<p>Example : \u2223\u03c8\u27e9=0.435\u22230\u27e9+0.9\u22231\u27e9 <\/p>\n\n\n\n<p>Here, \u2223\u03b1\u2223^2 = 0.19,  \u2223\u03b2\u2223^ 2=0.81 <\/p>\n\n\n\n<p>This bias can be generated using a <strong>rotation gate<\/strong>, such as <strong>Ry(\u03b8)<\/strong>, that tilts the qubit closer to |1\u27e9 on the Bloch sphere.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>d) Closer to |0\u27e9<\/strong><\/h3>\n\n\n\n<p>Intermediate state leaning toward |0\u27e9, e.g., \u2223\u03c8\u27e9=0.95\u22230\u27e9+0.312\u22231\u27e9 <\/p>\n\n\n\n<p>Measurement is <strong>very likely<\/strong> to result in 0.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>e) Very Close to |1\u27e9<\/strong><\/h3>\n\n\n\n<p>\u2223\u03c8\u27e9=0.1\u22230\u27e9+0.995\u22231\u27e9         <\/p>\n\n\n\n<p>Measurement is <strong>almost certain<\/strong> to give 1.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-background\" style=\"background-color:#ebe9e9\"><strong>4. Visualization on the Bloch Sphere<\/strong><\/h2>\n\n\n\n<p>The <strong>Bloch Sphere<\/strong> is a 3D geometrical representation of a single qubit\u2019s state.<br>Each point on the sphere corresponds to a possible qubit state, described as:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"311\" height=\"62\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-34.png\" alt=\"\" class=\"wp-image-42518\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-34.png 311w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-34-300x60.png 300w\" sizes=\"auto, (max-width: 311px) 100vw, 311px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u03b8 (theta):<\/strong> Polar angle representing the probability distribution.<\/li>\n\n\n\n<li><strong>\u03c6 (phi):<\/strong> Phase angle responsible for interference effects.<\/li>\n\n\n\n<li><strong>|0\u27e9<\/strong> \u2192 North Pole (\u03b8 = 0)<\/li>\n\n\n\n<li><strong>|1\u27e9<\/strong> \u2192 South Pole (\u03b8 = \u03c0)<\/li>\n\n\n\n<li><strong>Superpositions<\/strong> lie on the surface between the poles.<\/li>\n<\/ul>\n\n\n\n<p>The <strong>Hadamard gate<\/strong> rotates |0\u27e9 to the <strong>equatorial plane<\/strong>, creating equal superposition \u2014 a crucial step for quantum parallelism.<\/p>\n\n\n\n<p class=\"has-background\" style=\"background-color:#a0b79d;font-size:24px\"><strong>Qiskit Program: Bloch Sphere Visualization of \u03b8 and \u03c6<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Visualizing Qubit States on the Bloch Sphere (\u03b8 &amp; \u03c6)\nThis notebook demonstrates:\n- The Bloch-sphere representation of a single qubit.\n- How \u03b8 (polar) and \u03c6 (azimuthal\/phase) determine the qubit state.\n- |0\u27e9 at the North pole (\u03b8=0) and |1\u27e9 at the South pole (\u03b8=\u03c0).\n- Superpositions on the equator and the effect of \u03c6 (phase).\n- How the Hadamard gate moves |0\u27e9 to the equator (equal superposition).\n- A measurement histogram for H|0\u27e9 using AerSimulator.\n\n**Instructions:** Run cells in order in a Jupyter Notebook. Requires `qiskit` and `qiskit-aer`.\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code><strong># Cell 2: Imports and notebook plotting setup<\/strong>\n\n%matplotlib inline\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom IPython.display import display, HTML\n\nfrom qiskit import QuantumCircuit\nfrom qiskit.quantum_info import Statevector\nfrom qiskit.visualization import plot_bloch_vector, plot_histogram\nfrom qiskit_aer import AerSimulator\n\n# Clear existing matplotlib figures (avoid leftover empty plots)\nplt.close('all')\n<\/code><\/pre>\n\n\n\n<p><strong>Explanation:<br>Load required libraries, configure inline plotting for Jupyter, and close stray figures to avoid empty boxes.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code><strong># Cell 3: Helper functions to compute and plot Bloch vectors<\/strong>\n\ndef bloch_coords_from_statevector(state: Statevector):\n    \"\"\"\n    Convert a single-qubit Statevector to Bloch coordinates &#91;x, y, z].\n    state.data is a length-2 complex array: &#91;a, b] representing a|0> + b|1>.\n    \"\"\"\n    a = state.data&#91;0]\n    b = state.data&#91;1]\n    x = 2 * np.real(a * np.conj(b))\n    y = 2 * np.imag(a * np.conj(b))\n    z = np.abs(a)**2 - np.abs(b)**2\n    return &#91;x, y, z]\n\ndef plot_state_on_bloch(qc: QuantumCircuit, title: str = None):\n    \"\"\"\n    Given a single-qubit circuit (no measurements), compute its Statevector,\n    convert to Bloch coordinates, and plot using plot_bloch_vector.\n    Returns (fig, state).\n    \"\"\"\n    state = Statevector.from_instruction(qc)\n    vec = bloch_coords_from_statevector(state)\n    fig = plot_bloch_vector(vec)   # returns a matplotlib.figure.Figure\n    if title:\n        fig.suptitle(title, fontsize=12)\n    display(fig)\n    return fig, state\n\ndef show_circuit(qc: QuantumCircuit, title: str = None):\n    \"\"\"Display the circuit diagram (matplotlib) with an optional title.\"\"\"\n    if title:\n        display(HTML(f\"&lt;b>{title}&lt;\/b>\"))\n    display(qc.draw('mpl'))\n<\/code><\/pre>\n\n\n\n<p><strong>Explanation:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>bloch_coords_from_statevector<\/code>: converts state amplitudes to Bloch (x,y,z).<\/li>\n\n\n\n<li><code>plot_state_on_bloch<\/code>: uses the above and <code>plot_bloch_vector<\/code> to produce a robust figure.<\/li>\n\n\n\n<li><code>show_circuit<\/code>: displays the circuit diagram for clarity.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-background\" style=\"background-color:#bda8a8\">Case A \u2014 The ground state |0\u27e9 (North Pole, \u03b8 = 0)<\/h2>\n\n\n\n<p>No gates applied; the qubit is in |0\u27e9, which corresponds to the North Pole on the Bloch sphere.<\/p>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>\n\n<strong># Cell 4: |0> state<\/strong>\n\nqc_0 = QuantumCircuit(1)   # no gates -> |0>\nfig0, state0 = plot_state_on_bloch(qc_0, title=\"|0\u27e9 \u2192 North Pole (\u03b8 = 0)\")\nshow_circuit(qc_0, title=\"Circuit for |0\u27e9 (no gates)\")\ndisplay(state0.draw('latex'))   # show the ket in LaTeX form\n\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"519\" height=\"519\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-37.png\" alt=\"\" class=\"wp-image-42523\" style=\"width:403px;height:auto\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-37.png 519w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-37-300x300.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-37-150x150.png 150w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-37-100x100.png 100w\" sizes=\"auto, (max-width: 519px) 100vw, 519px\" \/><\/figure>\n\n\n\n<p><strong>Explanation:<\/strong><br>This shows the Bloch vector pointing up; the statevector should be <code>[1, 0]<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-background\" style=\"background-color:#c0b0b0\">Case B \u2014 The excited state |1\u27e9 (South Pole, \u03b8 = \u03c0)<\/h2>\n\n\n\n<p>Apply an X gate to flip |0\u27e9 \u2192 |1\u27e9. This state maps to the South Pole on the Bloch sphere.<\/p>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code><strong># Cell 5: |1> state<\/strong>\n\nqc_1 = QuantumCircuit(1)\nqc_1.x(0)   # X gate flips to |1>\nfig1, state1 = plot_state_on_bloch(qc_1, title=\"|1\u27e9 \u2192 South Pole (\u03b8 = \u03c0)\")\nshow_circuit(qc_1, title=\"Circuit for |1\u27e9 (X gate)\")\ndisplay(state1.draw('latex'))<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"519\" height=\"519\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-38.png\" alt=\"\" class=\"wp-image-42524\" style=\"width:308px;height:auto\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-38.png 519w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-38-300x300.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-38-150x150.png 150w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-38-100x100.png 100w\" sizes=\"auto, (max-width: 519px) 100vw, 519px\" \/><\/figure>\n\n\n\n<p><strong>Explanation:<\/strong><br>X rotates the state from north to south; statevector should be <code>[0,1]<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-background\" style=\"background-color:#ddd7d7\">Case C \u2014 Equal superposition along the X-axis (\u03b8 = \u03c0\/2, \u03c6 = 0)<\/h2>\n\n\n\n<p>Prepare the state with <code>Ry(\u03c0\/2)<\/code> or directly using the Hadamard gate. This puts the Bloch vector on the equator pointing along +X.<\/p>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code><strong># Cell 6: Superposition on X-axis using Ry(\u03c0\/2)<\/strong>\n\nqc_sup_x = QuantumCircuit(1)\nqc_sup_x.ry(np.pi\/2, 0)   # rotate from |0> down to equator (theta=pi\/2)\nfig_sup_x, state_sup_x = plot_state_on_bloch(qc_sup_x, title=\"Superposition (\u03b8 = \u03c0\/2, \u03c6 = 0) \u2192 X-axis\")\nshow_circuit(qc_sup_x, title=\"Circuit: Ry(\u03c0\/2) (equator, \u03c6=0)\")\ndisplay(state_sup_x.draw('latex'))\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"472\" height=\"448\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-39.png\" alt=\"\" class=\"wp-image-42527\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-39.png 472w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-39-300x285.png 300w\" sizes=\"auto, (max-width: 472px) 100vw, 472px\" \/><\/figure>\n\n\n\n<p><strong>Explanation:<\/strong><br><code>Ry(\u03c0\/2)<\/code> moves the vector from the North Pole to the equator; probabilities for |0\u27e9 and |1\u27e9 are both 0.5.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-background\" style=\"background-color:#b8aeae\">Case D \u2014 Superposition on the equator with phase (\u03b8 = \u03c0\/2, \u03c6 = \u03c0\/2)<\/h2>\n\n\n\n<p>Apply <code>Ry(\u03c0\/2)<\/code> then <code>Rz(\u03c0\/2)<\/code>. The Rz adds relative phase <code>\u03c6<\/code>, rotating the equatorial point around the Z axis (e.g., moves from X-axis towards Y-axis).<\/p>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code><strong># Cell 7: Superposition with phase<\/strong>\n\nqc_sup_y = QuantumCircuit(1)\nqc_sup_y.ry(np.pi\/2, 0)\nqc_sup_y.rz(np.pi\/2, 0)    # adds phase \u03c6 = \u03c0\/2\nfig_sup_y, state_sup_y = plot_state_on_bloch(qc_sup_y, title=\"Superposition (\u03b8 = \u03c0\/2, \u03c6 = \u03c0\/2) \u2192 Y-axis\")\nshow_circuit(qc_sup_y, title=\"Circuit: Ry(\u03c0\/2) then Rz(\u03c0\/2)\")\ndisplay(state_sup_y.draw('latex'))<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"412\" height=\"441\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-40.png\" alt=\"\" class=\"wp-image-42528\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-40.png 412w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-40-280x300.png 280w\" sizes=\"auto, (max-width: 412px) 100vw, 412px\" \/><\/figure>\n\n\n\n<p><strong>Explanation:<\/strong><br>This demonstrates that \u03c6 changes the azimuthal angle \u2014 interference behavior depends on phase, even though probabilities remain 50\/50.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-background\" style=\"background-color:#cab7b7\">Case E \u2014 Hadamard on |0\u27e9 \u2192 equal superposition<\/h2>\n\n\n\n<p>Apply H to |0\u27e9. H maps |0\u27e9 to (|0\u27e9 + |1\u27e9)\/\u221a2 which is on the equator (\u03b8 = \u03c0\/2) along the X-axis.<\/p>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code><strong># Cell 8: Hadamard effect<\/strong>\n\nqc_h = QuantumCircuit(1)\nqc_h.h(0)\nfig_h, state_h = plot_state_on_bloch(qc_h, title=\"Hadamard on |0\u27e9 \u2192 Equal superposition on equator\")\nshow_circuit(qc_h, title=\"Circuit: H on |0\u27e9\")\ndisplay(state_h.draw('latex'))<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"400\" height=\"451\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-41.png\" alt=\"\" class=\"wp-image-42531\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-41.png 400w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-41-266x300.png 266w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/figure>\n\n\n\n<p><strong>Explanation:<\/strong><br>Hadamard is commonly used to create quantum parallelism by placing qubits in equal superposition.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-background\" style=\"background-color:#cfbdbd\">Measurement demonstration (histogram)<\/h2>\n\n\n\n<p>Create the same H|0\u27e9 state but in a circuit with a classical bit and measure it many times using AerSimulator.<br>This shows the probabilistic collapse: counts should be \u2248 50% |0\u27e9 and 50% |1\u27e9.<\/p>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code><strong># Cell 9: Measurement histogram using a separate circuit with a classical bit<\/strong>\n\nqc_measure = QuantumCircuit(1, 1)\nqc_measure.h(0)\nqc_measure.measure(0, 0)\n\nshow_circuit(qc_measure, title=\"Measurement circuit (H then measure)\")\n\n# Run simulation\nsim = AerSimulator()\njob = sim.run(qc_measure, shots=2000)\nresult = job.result()\ncounts = result.get_counts()\n\nfig_hist = plot_histogram(counts)\nfig_hist.suptitle(\"Measurement outcomes (shots=2000) for H|0\u27e9\", fontsize=12)\ndisplay(fig_hist)\n\nprint(\"Counts:\", counts)\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"398\" height=\"440\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-42.png\" alt=\"\" class=\"wp-image-42532\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-42.png 398w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-42-271x300.png 271w\" sizes=\"auto, (max-width: 398px) 100vw, 398px\" \/><\/figure>\n\n\n\n<p><strong>Explanation:<\/strong><br><code>Statevector<\/code> can&#8217;t be used on circuits with measurements. We use a <strong>separate<\/strong> circuit with classical bits for the measurement step and AerSimulator to collect frequencies.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-background\" style=\"background-color:#cdbbbb\">Parameterized state builder<\/h2>\n\n\n\n<p>Helper to construct a state for arbitrary \u03b8 and \u03c6:<br>|\u03c8\u27e9 = cos(\u03b8\/2)|0\u27e9 + e^{i\u03c6} sin(\u03b8\/2)|1\u27e9<br>We implement this by <code>Ry(\u03b8)<\/code> followed by <code>Rz(\u03c6)<\/code>.<br>Try different \u03b8 and \u03c6 values interactively.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Cell 10: Parameterized circuit from theta and phi\ndef circuit_from_theta_phi(theta, phi):\n    qc = QuantumCircuit(1)\n    qc.ry(theta, 0)\n    qc.rz(phi, 0)\n    return qc\n\n# Example: custom \u03b8 and \u03c6\ntheta_example = np.pi\/3   # 60 degrees\nphi_example = np.pi\/4     # 45 degrees\nqc_custom = circuit_from_theta_phi(theta_example, phi_example)\nfig_custom, state_custom = plot_state_on_bloch(qc_custom, title=f\"Custom: \u03b8={theta_example:.2f}, \u03c6={phi_example:.2f}\")\nshow_circuit(qc_custom, title=\"Circuit: Ry(theta) then Rz(phi)\")\ndisplay(state_custom.draw('latex'))\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"363\" height=\"429\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-43.png\" alt=\"\" class=\"wp-image-42537\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-43.png 363w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-43-254x300.png 254w\" sizes=\"auto, (max-width: 363px) 100vw, 363px\" \/><\/figure>\n\n\n\n<p><strong>Explanation:<\/strong><br>Use this to explore arbitrary positions on the Bloch sphere. You can vary \u03b8 in [0, \u03c0] and \u03c6 in [0, 2\u03c0].<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading has-background\" style=\"background-color:#d5c1c1\"><strong>5. Real-Time Example Using Qiskit<\/strong><\/h2>\n\n\n\n<p>Here\u2019s how to create and visualize superposition in <strong>Qiskit<\/strong> (Jupyter Notebook ready):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>%matplotlib inline\nfrom qiskit import QuantumCircuit\nfrom qiskit.quantum_info import Statevector\nfrom qiskit_aer import AerSimulator\nfrom qiskit.visualization import plot_bloch_multivector, plot_histogram\nimport matplotlib.pyplot as plt\nfrom IPython.display import HTML\nimport io\nfrom base64 import b64encode\n\n# --- prepare state (no measurements) and get Bloch fig ---\nqc_state = QuantumCircuit(1)\nqc_state.h(0)\nstate = Statevector.from_instruction(qc_state)\nfig1 = plot_bloch_multivector(state)   # returns a matplotlib.figure.Figure\n\nbuf1 = io.BytesIO()\nfig1.savefig(buf1, format='png', bbox_inches='tight')\nbuf1.seek(0)\nimg1_b64 = b64encode(buf1.read()).decode('ascii')\nplt.close(fig1)\n\n# --- prepare measured circuit and histogram fig ---\nqc_measure = QuantumCircuit(1, 1)\nqc_measure.h(0)\nqc_measure.measure(0, 0)\n\nsim = AerSimulator()\nresult = sim.run(qc_measure, shots=2000).result()\ncounts = result.get_counts()\n\nfig2 = plot_histogram(counts)  # this also returns a Figure\nbuf2 = io.BytesIO()\nfig2.savefig(buf2, format='png', bbox_inches='tight')\nbuf2.seek(0)\nimg2_b64 = b64encode(buf2.read()).decode('ascii')\nplt.close(fig2)\n\n# --- render both images side-by-side in notebook output ---\nhtml = f\"\"\"\n&lt;div style=\"display:flex; align-items:flex-start; gap:20px;\">\n  &lt;div>&lt;img src=\"data:image\/png;base64,{img1_b64}\" \/>&lt;\/div>\n  &lt;div>&lt;img src=\"data:image\/png;base64,{img2_b64}\" \/>&lt;\/div>\n&lt;\/div>\n\"\"\"\ndisplay(HTML(html))\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"419\" src=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-36-1024x419.png\" alt=\"\" class=\"wp-image-42522\" srcset=\"https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-36-1024x419.png 1024w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-36-300x123.png 300w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-36-768x315.png 768w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-36-760x311.png 760w, https:\/\/tocxten.com\/wp-content\/uploads\/2025\/11\/image-36.png 1089w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading has-background\" style=\"background-color:#e3dada\"><strong>6. Applications of Superposition<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>a) Quantum Parallelism<\/strong><\/h3>\n\n\n\n<p>Superposition enables a quantum computer to evaluate <strong>multiple inputs simultaneously<\/strong> \u2014 a core principle behind algorithms like:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Shor\u2019s algorithm<\/strong> for factorization,<\/li>\n\n\n\n<li><strong>Grover\u2019s search algorithm<\/strong> for database searching.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>b) Quantum Communication<\/strong><\/h3>\n\n\n\n<p>In <strong>Quantum Key Distribution (QKD)<\/strong> (e.g., <strong>BB84 protocol<\/strong>), superposed states are used to encode cryptographic keys that are impossible to intercept without detection.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>c) Quantum Sensors<\/strong><\/h3>\n\n\n\n<p>Superposition-based sensors can detect minuscule changes in physical quantities such as magnetic fields, gravity, or time with <strong>ultra-high sensitivity<\/strong> (used in atomic clocks and MRI).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>d) Quantum Neural Networks<\/strong><\/h3>\n\n\n\n<p>Superposition allows <strong>quantum neurons<\/strong> to represent multiple states at once, enhancing pattern recognition and decision-making capabilities.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>e) Real-Time Control Systems<\/strong><\/h3>\n\n\n\n<p>In emerging <strong>Quantum AI systems<\/strong>, superposition is exploited to model uncertainty and probabilistic reasoning in <strong>smart traffic lights<\/strong>, <strong>autonomous vehicles<\/strong>, and <strong>financial modeling<\/strong>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading has-background\" style=\"background-color:#e3dcdc\"><strong>7. Conclusion<\/strong><\/h2>\n\n\n\n<p>The <strong>superposition of qubits<\/strong> forms the foundation of all quantum computation. It transforms binary thinking into a <strong>continuous spectrum of probabilities<\/strong>, enabling algorithms to explore multiple outcomes simultaneously. From secure communication to intelligent control systems and advanced computation, superposition is not merely a quantum concept \u2014 it is the bridge between classical limits and quantum possibilities.<\/p>\n\n\n\n<p class=\"has-background\" style=\"background-color:#ded0d0\"><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction At the heart of quantum computing lies a fundamental concept that defies classical logic \u2014 superposition. Unlike a classical bit that can be in only one of two&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":"","_links_to":"","_links_to_target":""},"class_list":["post-42504","page","type-page","status-publish","hentry"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/pages\/42504","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/comments?post=42504"}],"version-history":[{"count":17,"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/pages\/42504\/revisions"}],"predecessor-version":[{"id":42549,"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/pages\/42504\/revisions\/42549"}],"wp:attachment":[{"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/media?parent=42504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}