liveBook · Manning

Binary decomposition

As explained in Building Quantum Software with Python

Binary decomposition expresses an integer as the sum of powers of two selected by the positions of its one-valued binary digits.

Binary decomposition rewrites an integer as the sum of powers of two at the positions of its one-valued binary digits. In quantum function encoding, this turns a key k into the angle multiple kθ needed to construct a geometric sequence state. section 10.1.1

Decomposing k = 4

With n = 3, 4 is written as 100 in binary. The one-valued digit is at position 2, so 4 = 2². For θ = π/4, the same decomposition gives 4θ = 2²θ.

How Building Quantum Software with Python covers it

How deep it goes
Defines the representation, implements bit scanning, verifies weighted sums, and applies them through controlled phase rotations.
Examples
Uses k = 4 with three binary digits and θ = π/4 to demonstrate integer and angle decompositions.
What it assumes
Assumes binary notation, powers of two, integer ranges below 2ⁿ, and basic Python bitwise operations.
What you can do after
Build quantum function encodings by converting one-valued key bits into weighted phase rotations.
How it connects
Connects binary representation with geometric sequence states, quantum state encoding, and controlled phase rotations.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Quantum Software with Python. The section links point to the parts of the book it draws on.