Leanpub Header

Skip to main content

Quantum Python. From Complex Amplitudes to a Priced, Replayable Pipeline.

Quantum Python. From Complex Amplitudes to a Priced, Replayable Pipeline.
This book is 100% completeLast updated on 2026-11-19

Minimum price

$29.00

$29.00

You pay

Author earns

$

Also available for 2 book credits with a Reader Membership

EPUB
About

About

About the Book

A quantum computer is a machine that computes with amplitudes: complex numbers whose squared magnitudes are probabilities. Everything else in this book follows from that sentence. A qubit is a vector, a gate is a matrix, a measurement is a projection, and a program is a sequence of matrices applied to a vector you never see. The book teaches those four ideas in Python, on a laptop, and then takes them to real hardware.

It is written for a senior software engineer who has never opened a physics textbook and does not intend to. There is no calculus prerequisite beyond a derivative, no Hilbert-space formalism beyond “a vector of complex numbers”, and no result that is asserted without a program that reproduces it. When the book needs a matrix, it prints the matrix. When it needs a number, it records the run that produced it.

The arc is deliberate. The first five chapters build the rules: the state vector, the tensor product and its endianness, compilation and depth, entanglement measured through CHSH, and the statistics that turn a histogram into a claim. The next four are the canonical algorithms — Deutsch-Jozsa and Bernstein-Vazirani, Grover, the quantum Fourier transform, and order finding up to Shor-lite. The middle six apply them: VQE for hydrogen, one interface over seven providers, noise and mitigation, QAOA, annealing without a D-Wave machine, and quantum kernels. The last five are the engineering the field usually skips — error correction, dynamic circuits, a benchmark with a shot-noise floor, a pipeline with four gates — and a closing experiment that puts all of it to work: teleporting a state on a real device and proving it arrived.

The method is the book’s real subject. Every chapter ships a harness that asserts on numbers, five exercises with their own checks, and a recorded run that a reader can replay without an account. Across the twenty chapters that is 2,629 assertions. The bill for all of it was 0.00 USD, and the one quote the book refused — 984.84 USD for six circuits at 2,048 shots — is a chapter of its own.

What You Will Learn in This Volume

By the end of this book, you will be able to:

  • Represent a quantum state and evolve it. Build state vectors and unitaries in NumPy, apply gates in the right order, and read a measurement as a projection rather than a peek.
  • Compile a circuit for a device. Count depth and two-qubit gates, transpile against a real coupling map, and say what the hardware actually executes.
  • Measure entanglement. Run CHSH on a simulator and on a QPU, computeS, and compare it with the classical bound of 2.
  • Turn shots into a claim. Compute error bars, separate shot noise from gate error, and refuse a difference that the sample cannot support.
  • Implement the canonical algorithms. Deutsch-Jozsa, Bernstein-Vazirani, Grover with the right iteration count, the QFT, phase estimation, and order finding up to the resource count for a real factorisation.
  • Use a variational loop. Build an ansatz, evaluate an energy, take a gradient with the parameter-shift rule, and run VQE for hydrogen to chemical accuracy.
  • Talk to providers through one interface. Submit, poll, retrieve and price a job on IBM, IonQ, Quantum Inspire and qBraid, with a replay that runs offline.
  • Model and mitigate noise. Fit a depolarising rate, apply readout correction and zero-noise extrapolation, and say where extrapolation stops being honest.
  • Run QAOA, annealing and kernels. Build a phase separator and a mixer, write a QUBO and a chain, and compute a quantum kernel with itsn2bill.
  • Correct errors and measure mid-circuit. Encode a repetition code, decode a syndrome, feed a measurement forward, and measure what the dynamic circuit buys.
  • Benchmark and pipeline. Compare sources against an ideal with the shot-noise floor as the control, then run a task through validation, estimation, execution, correction and a record a stranger can replay.
  • Decide what to run. Take a problem in six fields, ask four questions in order, and produce one of five decisions with the question that forced it.

Who This Book Is For

This book is designed for:

  • Software engineers who want to understand what a quantum program is made of, without a physics degree and without a vendor’s marketing.
  • Data and machine-learning engineers who have heard that kernels and optimisation are where quantum computing might land first, and want the arithmetic rather than the promise.
  • Technical leads and architects evaluating whether a quantum component belongs in a system in 2026, and what it would cost to find out.
  • Instructors and students who need a course where every claim is a program and every number has a recorded run behind it.

Prerequisites

To get the most out of this volume, readers should possess:

  • Working Python. Functions, classes, dataclasses, virtual environments, and enough NumPy to be comfortable with arrays and matrix multiplication.
  • Linear algebra at the level of a NumPy user. Complex numbers as pairs of floats, vectors as arrays, matrices and matrix multiplication, and the idea of an eigenvector and an eigenvalue. A reader who has written A @ B and called an inverse has enough.
  • Basic probability. Expectation, variance, and the idea of a standard error. Chapter 5 derives the binomial error bar the rest of the book uses.
  • No physics, and no prior quantum computing. Every physical fact the book needs — a qubit’s coherence, a gate’s error rate, a device’s connectivity — arrives as a number measured on a machine, not as a law to memorise.

The book does not assume the quantum vocabulary, and it introduces the mathematics in the order the chapters need it: amplitudes and normalization in chapter 1, the tensor product and bit order in chapter 2, unitaries and depth in chapter 3, expectation and correlation in chapter 4, the standard error in chapter 5, roots of unity in chapter 8, eigenvalues and order in chapter 9, the Hamiltonian in chapter 10, the density matrix and channels in chapter 12, the Ising and QUBO formulation in chapter 14, kernels in chapter 15, parity checks and syndromes in chapter 16, distances in chapter 18, and the Bloch vector and the Pauli frame in chapter 20.

What it does not teach is arithmetic with complex numbers or matrix multiplication. Those are the two things to be comfortable with before chapter 1; everything above them arrives with the task that needs it.

Chapters

  1. The Qubit Is a Vector
  2. Two Qubits, and the Order That Bites
  3. Circuits, Unitaries, Compilation
  4. Entanglement and the CHSH Inequality
  5. Shots, Statistics, Error Bars
  6. Oracles: Deutsch-Jozsa and Bernstein-Vazirani
  7. Grover and Amplitude Amplification
  8. The Quantum Fourier Transform and Phase Estimation
  9. Order Finding and Shor-lite
  10. VQE for the Hydrogen Molecule
  11. One Interface, Seven Providers
  12. Noise and Error Mitigation
  13. QAOA and Combinatorial Optimization
  14. Annealing and the D-Wave Problem
  15. Quantum Machine Learning
  16. Error Correction
  17. Dynamic Circuits
  18. The Benchmark
  19. The Pipeline
  20. The Last Experiment

If printed, this ebook would span over 500 pages. Each chapter is structured into theoretical foundations, an annotated basic example, an annotated advanced example, and five coding exercises with complete solutions.

Share this book

Author

About the Author

Edgar Milvus

A veteran software engineer with 20 years of experience, I have dedicated my career to the art of automation. My philosophy is simple: programming should eliminate repetitive chores to unlock human creativity. This journey began early on with the development of custom code-generation tools and has evolved into a deep mastery of LLMs and their APIs. Today, I specialize in architecting AI-driven solutions that handle everything from complex coding and security tasks to advanced knowledge retrieval, transforming the way we interact with technology

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub