Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

QuantumPlaybook

Guides

  • QuantumPlaybook

Tech Notes

  • Addition of Numbers
  • Baker-Hausdorff Lemma
  • Chiral Fermion Random Circuit
  • Clifford Operators: How to Test
  • Commutation Relations for Qubits
  • Entanglement Distillation
  • Generalized Pauli Operators: Implementation
  • Hatano-Nelson-Kitaev Model: Monte Carlo Simulation
  • Hatano-Nelson Model: Monte Carlo Simulation
  • Kitaev Chain
  • Kitaev Random Circuit
  • Λ-Matter in a Cavity
  • Measurement of Total Pauli Z
  • Non-Unitary Dynamics of Quantum States
  • Partial Trace: Physical Meaning
  • Quantum Dot Systems
  • A Quantum Playbook
  • Magnetic Exchange Coupling
  • Solovay-Kitaev Algorithm
  • Spin Code
  • Symmetry Effects On Quantum Master Equations
  • Transmon: Quantum Phase Model
  • Transposition as a Supermap
  • Variational Quantum Classifier: Iris
  • Variational Quantum Classifier: Parity
  • Variational Quantum Eigensolver: Transverse-Field Ising Model

Symbols

  • BlochEnergy
  • BlochFunction
  • QuantumPlaybookCheckUpdate
  • QuantumPlaybookEdition
  • QuantumPlaybookUpdate
  • TransmonEnergy
  • TransmonExponent
  • TransmonFunction
  • TransmonHamiltonian
Measurement of Total Pauli Z
Here, a quantum circuit implementation is introduced to measure the total Pauli Z, that is,
Z
tot
:=
Z
1
+
Z
2
+…
Z
n
, where
Z
k
is the Pauli Z operator acting on the
th
k
qubit.
Make sure that Q3 is loaded.
In[1]:=
Needs["QuantumMob`Q3`"]
Let us consider a system of n qubits.
In[41]:=
$n=5;​​$l=Ceiling@Log[2,$n+1];
We want to measure
z
S
tot
:=
z
S
1
+
z
S
2
+…+
z
S
n
. The auxiliary register T is used to store the result.
In[43]:=
Let[Qubit,S,T]​​SS=S[Range@$n,None];​​TT=T[Range@$l,None];
This is a short-cut function:
addBitValue[p]
generates the quantum circuit elements to add the bit value of qubit
p
.
In[46]:=
Clear[addBitValue];addBitValue[]:=Sequence@@Table[addBitValue[p],{p,$n}]​​addBitValue[p_]:=Sequence@@With[​​{logp=Ceiling@Log[2,p+1]},​​Table[CNOT[Prepend[T@Range[k-1],S[p]],T[k]],{k,logp,1,-1}]​​]
This copies the value of the first qubit.
In[48]:=
QuantumCircuit[​​Ket[TT],​​addBitValue[1],​​"Visible"SS,​​"Invisible"S[$n+1/2]​​]
Out[48]=
Then, the value of the second qubit is added. Note that the second qubit in the ancillary register plays the role of carrier bit.
In[49]:=
QuantumCircuit[​​Ket[TT],​​addBitValue[1],"Separator",​​addBitValue[2],​​"Visible"SS,​​"Invisible"S[$n+1/2]​​]
Out[49]=
We repeat the same procedure for the third qubit. Note here that the third qubit is not necessary at this stage because the maximum value of the sum of the values of three qubits is 3.
In[50]:=
QuantumCircuit[​​Ket[TT],​​addBitValue[1],"Separator",​​addBitValue[2],"Separator",​​addBitValue[3],​​"Visible"SS,​​"Invisible"S[$n+1/2]​​]
Out[50]=
We repeat the same procedure, but now we need additional carrier bit (the third) in the ancillary register.
In[51]:=
QuantumCircuit[​​Ket[TT],​​addBitValue[1],"Separator",​​addBitValue[2],"Separator",​​addBitValue[3],"Separator",​​addBitValue[4],​​"Visible"SS,​​"Invisible"S[$n+1/2]​​]
Out[51]=
Putting all together, the following quantum circuit can measure the sum of the values of all qubits in the native register.
In[52]:=
qc=QuantumCircuit[Ket[TT],addBitValue[],"Invisible"S[$n+1/2]]
Out[52]=
Let us check that the above quantum circuit indeed generates the correct value in the ancillary register.
Extracts the sum from the output state in the ancillary register. In actual situation, one should perform the measurement on the ancillary register in the computation basis.
Compare the input state and the sum.

© 2025 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com