Library Cookbook
A hands-on guide that teaches FockMap from the ground up.
Each chapter introduces a concept through worked examples, building toward a complete molecular Hamiltonian by the end.
Prerequisites: .NET 10 installed (setup guide), basic comfort with F#. Prior quantum computing knowledge is helpful but not required — we explain the physics as we go.
Chapters
| # | Chapter | What you’ll learn |
|---|---|---|
| 1 | Hello, Qubit | Pauli operators and exact symbolic phases |
| 2 | Building Expressions | The C / P / S type hierarchy |
| 3 | Operators on Specific Qubits | IxOp and string parsing |
| 4 | Creation and Annihilation | Ladder operators and product terms |
| 5 | Normal Ordering | CAR / CCR rewriting and pluggable algebras |
| 6 | Your First Encoding | Jordan–Wigner step by step |
| 7 | Six Encodings, One Interface | Drop-in encoder comparison |
| 8 | Encoding Internals | Majorana decomposition and EncodingScheme |
| 9 | Trees and Fenwick Trees | Tree-shaped parity structures |
| 10 | Building a Real Hamiltonian | End-to-end Hâ‚‚ pipeline |
| 11 | Mixed Bosonic–Fermionic Systems | Sector tags, mixed normal ordering, and hybrid workflows |
| 12 | The Utility Belt | Complex extensions, map helpers, currying |
| 13 | Grand Finale | Three encodings, one molecule — a capstone script |
| 14 | Bosonic-to-Qubit Encodings | Unary, Binary, and Gray code truncation encodings |
| 15 | Qubit Tapering | Diagonal Zâ‚‚ and Clifford tapering for qubit reduction |
| 16 | Trotterization | Trotter decomposition, gate sequences, CNOT cost analysis |
| 17 | Circuit Output | Export to OpenQASM 3.0, Q#, and JSON |
| 18 | Measurement & Resources | Measurement grouping, shot estimates, QPE resources, skeleton API |
Quick Reference
Encoding functions
| Function | Scaling | Best for |
|---|---|---|
jordanWignerTerms |
$O(n)$ | Small systems, simplicity |
bravyiKitaevTerms |
$O(\log_2 n)$ | General-purpose logarithmic |
parityTerms |
$O(n)$ | When parity is the natural basis |
balancedBinaryTreeTerms |
$O(\log_2 n)$ | Logarithmic via binary tree |
ternaryTreeTerms |
$O(\log_3 n)$ | Best asymptotic scaling |
vlasovTreeTerms |
$O(\log_3 n)$ | Complete ternary tree (Vlasov) |
encodeOperator scheme |
Varies | Your custom scheme |
encodeWithTernaryTree tree |
Varies | Your custom tree shape |
unaryBosonTerms |
$d$ qubits | Bosonic, weight ≤ 2 |
binaryBosonTerms |
$\lceil\log_2 d\rceil$ qubits | Bosonic, standard binary basis |
grayCodeBosonTerms |
$\lceil\log_2 d\rceil$ qubits | Bosonic, reduced avg weight |
Type cheat sheet
| Type | What it represents |
|---|---|
Pauli |
Single-qubit operator: I, X, Y, Z |
Phase |
Exact phase: P1 (+1), M1 (−1), Pi (+i), Mi (−i) |
C<'T> |
Coefficient × single operator |
P<'T> |
Ordered product of operators |
S<'T> |
Sum of products (the Hamiltonian shape) |
IxOp<'idx,'op> |
Operator tagged with a mode index |
LadderOperatorUnit |
Raise ($a^\dagger$) / Lower ($a$) / Identity |
PauliRegister |
Fixed-width Pauli string with coefficient |
PauliRegisterSequence |
Sum of Pauli strings (encoding output) |
EncodingScheme |
Three index-set functions → custom encoding |
EncodingTree |
Tree shape for tree-based encodings |
FenwickTree<'a> |
Immutable binary indexed tree |
SectorLadderOperatorUnit |
Sector-tagged ladder operator (mixed systems) |
BosonicEncoderFn |
LadderOperatorUnit → uint32 → uint32 → uint32 → PauliRegisterSequence |
TrotterStep |
Ordered list of Pauli rotations with time step |
Gate |
H \| S \| Sdg \| Rz \| CNOT — elementary quantum gates |
CircuitStats |
Rotation count, CNOT count, total gates, weight stats |
OpenQasmOptions |
QASM export configuration (version, precision, qubit name) |
QSharpOptions |
Q# export configuration (namespace, operation name) |
MeasurementProgram |
Grouped commuting Pauli terms for VQE measurement |
QPEResourceEstimate |
System/ancilla qubits, CNOT count, circuit depth |
HamiltonianSkeleton |
Precomputed Pauli structure for PES scans |
Where to Go Next
- Architecture Guide — the two-framework design in depth
- The Book — 22-chapter narrative with labs and computed results
- API Reference — generated from source XML docs
PDF Version
A TeX-typeset version of this cookbook is available as a companion preprint (PDF) suitable for printing and citation.