ID photo of Ciro Santilli taken in 2013 right eyeCiro Santilli OurBigBook logoOurBigBook.com  Sponsor 中国独裁统治 China Dictatorship 新疆改造中心、六四事件、法轮功、郝海东、709大抓捕、2015巴拿马文件 邓家贵、低端人口、西藏骚乱
In this example we will initialize a quantum circuit with a single CNOT gate and see the output values.
By default, Qiskit initializes every qubit to 0 as shown in the qiskit/hello.py. But we can also initialize to arbitrary values as would be done when computing the output for various different inputs.
Output:
     ┌──────────────────────┐
q_0: ┤0                     ├──■──
     │  Initialize(1,0,0,0) │┌─┴─┐
q_1: ┤1                     ├┤ X ├
     └──────────────────────┘└───┘
c: 2/═════════════════════════════

init: [1, 0, 0, 0]
probs: [1. 0. 0. 0.]

init: [0, 1, 0, 0]
probs: [0. 0. 0. 1.]

init: [0, 0, 1, 0]
probs: [0. 0. 1. 0.]

init: [0, 0, 0, 1]
probs: [0. 1. 0. 0.]

     ┌──────────────────────────────────┐
q_0: ┤0                                 ├──■──
     │  Initialize(0.70711,0,0,0.70711) │┌─┴─┐
q_1: ┤1                                 ├┤ X ├
     └──────────────────────────────────┘└───┘
c: 2/═════════════════════════════════════════

init: [0.7071067811865475, 0, 0, 0.7071067811865475]
probs: [0.5 0.5 0.  0. ]
which we should all be able to understand intuitively given our understanding of the CNOT gate and quantum state vectors.
quantumcomputing.stackexchange.com/questions/13202/qiskit-initializing-n-qubits-with-binary-values-0s-and-1s describes how to initialize circuits qubits only with binary 0 or 1 to avoid dealing with the exponential number of elements of the quantum state vector.

Ancestors (11)

  1. Qiskit example
  2. Qiskit
  3. Quantum programming framework
  4. Quantum software
  5. Quantum computing
  6. Quantum information
  7. Information
  8. Information technology
  9. Area of technology
  10. Technology
  11. Home