liveBook · Manning

Cosine-sine factor

As explained in Quantum Programming in Depth

A cosine-sine matrix, or CS matrix, is the structured matrix in a cosine-sine decomposition whose blocks contain cosine and sine values.

A cosine-sine factor, or CS matrix, is the middle matrix in a cosine-sine decomposition. For an n-qubit operation, it has the form CS = [[C, -S], [S, C]], where C and S are diagonal 2^(n−1) × 2^(n−1) matrices satisfying C² + S² = I. Each matching pair obeys cₖ² + sₖ² = 1, so the CS matrix describes a unitary transformation even though C and S individually need not be unitary. section 3.4 section 3.9 section 3.6.1

Implement a two-qubit CS unitary by converting its coefficient pairs into controlled rotations:

  • Form M₀ = [[c₀, −s₀], [s₀, c₀]] and M₁ = [[c₁, −s₁], [s₁, c₁]]. section 3.6.1
  • Apply controlled M₁ with the least significant qubit as control. section 3.6.1 section 3.6.2
  • Apply controlled-on-zero M₀ using the same control; the two gates act independently, so their order does not matter. section 3.6.1

Two-qubit implementation

Qiskit accepts only the nonzero coefficients, constructs M₀ and M₁, and appends their controlled forms. Q# performs the same decomposition with Controlled and ApplyControlledOnInt; its least significant control is the register’s last qubit. Tests reconstruct the implemented matrix and are expected to pass. section 3.6.2 section 3.6.3

Figure 3.3 Cosine-sine decomposition for an example \(4 \times 4\) matrix. This matrix is represented as a product of three matrices: a block-diagonal matrix defined by \(2 \times 2\) matrices \(A_l\) and \(B_l\), a block matrix of special shape called CS matrix defined by \(2 \times 2\) diagonal matrices \(C\) and \(S\), and another block-diagonal matrix defined by \(2 \times 2\) matrices \(A_r\) and \(B_r\).
figure

Inspect the factor’s position between block-diagonal matrices in a 4 × 4 cosine-sine decomposition. section 3.4

For arbitrary size, pair each diagonal entry cₖ, sₖ with a controlled single-qubit gate Mₖ. The n−1 control bits encode k in little-endian form, allowing the CS unitary to be assembled from multi-controlled gates and used as a building block for arbitrary real unitaries. section 3.9.1 section 3.10.2

How Quantum Programming in Depth covers it

How deep it goes
Derives two-qubit controlled-gate constructions and generalizes them to n qubits, but defers deriving the classical decomposition algorithm.
Examples
Uses a 4 × 4 decomposition, two-qubit coefficient pairs, Qiskit and Q# implementations, and matrix-reconstruction tests.
What it assumes
Assumes matrix decomposition, block structure, qubit ordering, and controlled operations, while refreshing the coefficient constraints needed for implementation.
What you can do after
Build it from scratch in Qiskit or Q#, then verify the resulting operation through reconstructed matrix tests.
How it connects
Connects cosine-sine decomposition with block-diagonal matrices, controlled single-qubit gates, and arbitrary unitary implementation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quantum Programming in Depth. The section links point to the parts of the book it draws on.