FA-91086 / Quantum circuit simulation / Open access
Bloch vector normalizes by the norm instead of the squared norm · case 01
The unnormalized input 3|0> + 4|1> yields a vector of length 5 instead of 1.
ROOT CAUSE
nrm is computed as the Euclidean norm of the amplitudes rather than its square.
VERIFIED REPAIR
Use |a|^2 + |b|^2 as the normalizer.
Unsuccessful approach: The attempted repair squares the sum of magnitudes, (|a| + |b|)^2, which over-normalizes mixed superpositions.
Case contract
Input [[ar, ai], [br, bi]] for a|0> + b|1> (possibly unnormalized). Return the Bloch vector [2Re(conj(a) b), 2Im(conj(a) b), |a|^2 - |b|^2] divided by |a|^2 + |b|^2, rounded to 6 decimals, or "zero-state" when the squared norm is below 1e-12.
Why this case matters
Bloch coordinates feed visualizers and single-qubit tomography checks; sign or scale slips put states on the wrong axis.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
(ar, ai), (br, bi) = x
a, b = complex(ar, ai), complex(br, bi)
nrm = math.hypot(abs(a), abs(b))
if nrm < 1e-12:
return 'zero-state'
cross = a.conjugate() * b
bx = 2 * cross.real / nrm
by = 2 * cross.imag / nrm
bz = (abs(a) ** 2 - abs(b) ** 2) / nrm
return [round(v, 6) + 0.0 for v in (bx, by, bz)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: unnormalized', [[3, 0], [0, 4]], [0.0, 0.96, -0.28]], ['regression: random qubit 0', [[-1.176, -0.41], [1.26, -1.053]], [-0.494424, 0.826337, -0.26965]], ['repair check: plus', [[0.707107, 0], [0.707107, 0]], [1.0, 0.0, 0.0]], ['control: ket zero', [[1, 0], [0, 0]], [0.0, 0.0, 1.0]], ['control: ket one', [[0, 0], [1, 0]], [0.0, 0.0, -1.0]], ['control: zero vector', [[0, 0], [0, 0]], 'zero-state'], ['control: global phase i', [[0, 1], [0, 0]], [0.0, 0.0, 1.0]]], [['regression: random qubit 2', [[0.057, -1.052], [0.48, 1.205]], [-0.888347, 0.410865, -0.205012]], ['regression: random qubit 3', [[1.769, -1.743], [0.441, -0.443]], [0.47339, -0.004576, 0.880841]], ['repair check: minus i', [[0.707107, 0], [0, -0.707107]], [0.0, -1.0, 0.0]], ['control: ket zero', [[1, 0], [0, 0]], [0.0, 0.0, 1.0]], ['control: ket one', [[0, 0], [1, 0]], [0.0, 0.0, -1.0]], ['control: zero vector', [[0, 0], [0, 0]], 'zero-state'], ['control: global phase i', [[0, 1], [0, 0]], [0.0, 0.0, 1.0]]], [['regression: random qubit 5', [[1.781, 0.313], [-0.534, -1.473]], [-0.493327, -0.858114, 0.142371]], ['regression: random qubit 6', [[1.624, -0.932], [-1.233, 0.708]], [-0.963265, 0.00023, 0.268554]], ['regression: random qubit 0', [[-1.176, -0.41], [1.26, -1.053]], [-0.494424, 0.826337, -0.26965]], ['control: ket zero', [[1, 0], [0, 0]], [0.0, 0.0, 1.0]], ['control: ket one', [[0, 0], [1, 0]], [0.0, 0.0, -1.0]], ['control: zero vector', [[0, 0], [0, 0]], 'zero-state'], ['control: global phase i', [[0, 1], [0, 0]], [0.0, 0.0, 1.0]]], [['regression: random qubit 8', [[-1.932, 0.067], [0.651, -1.416]], [-0.438732, 0.873211, 0.212174]], ['regression: random qubit 9', [[0.467, -1.484], [-1.959, -0.631]], [0.006475, -0.962062, -0.272753]], ['regression: random qubit 2', [[0.057, -1.052], [0.48, 1.205]], [-0.888347, 0.410865, -0.205012]], ['control: ket zero', [[1, 0], [0, 0]], [0.0, 0.0, 1.0]], ['control: ket one', [[0, 0], [1, 0]], [0.0, 0.0, -1.0]], ['control: zero vector', [[0, 0], [0, 0]], 'zero-state'], ['control: global phase i', [[0, 1], [0, 0]], [0.0, 0.0, 1.0]]], [['regression: random qubit 11', [[0.295, -0.421], [-0.884, -0.915]], [0.13217, -0.682004, -0.719306]], ['regression: random qubit 12', [[0.596, 0.022], [-1.906, -0.045]], [-0.569828, 0.007574, -0.821729]], ['regression: random qubit 4', [[-1.063, 1.137], [0.11, -1.819]], [-0.760893, 0.629754, -0.156369]], ['control: ket zero', [[1, 0], [0, 0]], [0.0, 0.0, 1.0]], ['control: ket one', [[0, 0], [1, 0]], [0.0, 0.0, -1.0]], ['control: zero vector', [[0, 0], [0, 0]], 'zero-state'], ['control: global phase i', [[0, 1], [0, 0]], [0.0, 0.0, 1.0]]]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: unnormalized | [0.0, 4.8, -1.4] | [0.0, 0.96, -0.28] | Failed |
| regression: random qubit 0 | [-1.01898, 1.703034, -0.555733] | [-0.494424, 0.826337, -0.26965] | Failed |
| repair check: plus | [1.0, 0.0, 0.0] | [1.0, 0.0, 0.0] | Passed |
| control: ket zero | [0.0, 0.0, 1.0] | [0.0, 0.0, 1.0] | Passed |
| control: ket one | [0.0, 0.0, -1.0] | [0.0, 0.0, -1.0] | Passed |
| control: zero vector | zero-state | zero-state | Passed |
| control: global phase i | [0.0, 0.0, 1.0] | [0.0, 0.0, 1.0] | Passed |
SHA-256 / abe55b69b451cc560528cae7ae3139d6f8d5a277cf5c3b44411f60e092dca8bf
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
(ar, ai), (br, bi) = x
a, b = complex(ar, ai), complex(br, bi)
nrm = (abs(a) + abs(b)) ** 2
if nrm < 1e-12:
return 'zero-state'
cross = a.conjugate() * b
bx = 2 * cross.real / nrm
by = 2 * cross.imag / nrm
bz = (abs(a) ** 2 - abs(b) ** 2) / nrm
return [round(v, 6) + 0.0 for v in (bx, by, bz)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: unnormalized', [[3, 0], [0, 4]], [0.0, 0.96, -0.28]], ['regression: random qubit 0', [[-1.176, -0.41], [1.26, -1.053]], [-0.494424, 0.826337, -0.26965]], ['repair check: plus', [[0.707107, 0], [0.707107, 0]], [1.0, 0.0, 0.0]], ['control: ket zero', [[1, 0], [0, 0]], [0.0, 0.0, 1.0]], ['control: ket one', [[0, 0], [1, 0]], [0.0, 0.0, -1.0]], ['control: zero vector', [[0, 0], [0, 0]], 'zero-state'], ['control: global phase i', [[0, 1], [0, 0]], [0.0, 0.0, 1.0]]], [['regression: random qubit 2', [[0.057, -1.052], [0.48, 1.205]], [-0.888347, 0.410865, -0.205012]], ['regression: random qubit 3', [[1.769, -1.743], [0.441, -0.443]], [0.47339, -0.004576, 0.880841]], ['repair check: minus i', [[0.707107, 0], [0, -0.707107]], [0.0, -1.0, 0.0]], ['control: ket zero', [[1, 0], [0, 0]], [0.0, 0.0, 1.0]], ['control: ket one', [[0, 0], [1, 0]], [0.0, 0.0, -1.0]], ['control: zero vector', [[0, 0], [0, 0]], 'zero-state'], ['control: global phase i', [[0, 1], [0, 0]], [0.0, 0.0, 1.0]]], [['regression: random qubit 5', [[1.781, 0.313], [-0.534, -1.473]], [-0.493327, -0.858114, 0.142371]], ['regression: random qubit 6', [[1.624, -0.932], [-1.233, 0.708]], [-0.963265, 0.00023, 0.268554]], ['regression: random qubit 0', [[-1.176, -0.41], [1.26, -1.053]], [-0.494424, 0.826337, -0.26965]], ['control: ket zero', [[1, 0], [0, 0]], [0.0, 0.0, 1.0]], ['control: ket one', [[0, 0], [1, 0]], [0.0, 0.0, -1.0]], ['control: zero vector', [[0, 0], [0, 0]], 'zero-state'], ['control: global phase i', [[0, 1], [0, 0]], [0.0, 0.0, 1.0]]], [['regression: random qubit 8', [[-1.932, 0.067], [0.651, -1.416]], [-0.438732, 0.873211, 0.212174]], ['regression: random qubit 9', [[0.467, -1.484], [-1.959, -0.631]], [0.006475, -0.962062, -0.272753]], ['regression: random qubit 2', [[0.057, -1.052], [0.48, 1.205]], [-0.888347, 0.410865, -0.205012]], ['control: ket zero', [[1, 0], [0, 0]], [0.0, 0.0, 1.0]], ['control: ket one', [[0, 0], [1, 0]], [0.0, 0.0, -1.0]], ['control: zero vector', [[0, 0], [0, 0]], 'zero-state'], ['control: global phase i', [[0, 1], [0, 0]], [0.0, 0.0, 1.0]]], [['regression: random qubit 11', [[0.295, -0.421], [-0.884, -0.915]], [0.13217, -0.682004, -0.719306]], ['regression: random qubit 12', [[0.596, 0.022], [-1.906, -0.045]], [-0.569828, 0.007574, -0.821729]], ['regression: random qubit 4', [[-1.063, 1.137], [0.11, -1.819]], [-0.760893, 0.629754, -0.156369]], ['control: ket zero', [[1, 0], [0, 0]], [0.0, 0.0, 1.0]], ['control: ket one', [[0, 0], [1, 0]], [0.0, 0.0, -1.0]], ['control: zero vector', [[0, 0], [0, 0]], 'zero-state'], ['control: global phase i', [[0, 1], [0, 0]], [0.0, 0.0, 1.0]]]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: unnormalized | [0.0, 0.489796, -0.142857] | [0.0, 0.96, -0.28] | Failed |
| regression: random qubit 0 | [-0.251877, 0.420965, -0.137369] | [-0.494424, 0.826337, -0.26965] | Failed |
| repair check: plus | [0.5, 0.0, 0.0] | [1.0, 0.0, 0.0] | Failed |
| control: ket zero | [0.0, 0.0, 1.0] | [0.0, 0.0, 1.0] | Passed |
| control: ket one | [0.0, 0.0, -1.0] | [0.0, 0.0, -1.0] | Passed |
| control: zero vector | zero-state | zero-state | Passed |
| control: global phase i | [0.0, 0.0, 1.0] | [0.0, 0.0, 1.0] | Passed |
SHA-256 / 30142ba4c3c76dda9936b591c2a50f36f9e2b69bdec3c237503bb8cf98dcb89f
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
(ar, ai), (br, bi) = x
a, b = complex(ar, ai), complex(br, bi)
nrm = abs(a) ** 2 + abs(b) ** 2
if nrm < 1e-12:
return 'zero-state'
cross = a.conjugate() * b
bx = 2 * cross.real / nrm
by = 2 * cross.imag / nrm
bz = (abs(a) ** 2 - abs(b) ** 2) / nrm
return [round(v, 6) + 0.0 for v in (bx, by, bz)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: unnormalized', [[3, 0], [0, 4]], [0.0, 0.96, -0.28]], ['regression: random qubit 0', [[-1.176, -0.41], [1.26, -1.053]], [-0.494424, 0.826337, -0.26965]], ['repair check: plus', [[0.707107, 0], [0.707107, 0]], [1.0, 0.0, 0.0]], ['control: ket zero', [[1, 0], [0, 0]], [0.0, 0.0, 1.0]], ['control: ket one', [[0, 0], [1, 0]], [0.0, 0.0, -1.0]], ['control: zero vector', [[0, 0], [0, 0]], 'zero-state'], ['control: global phase i', [[0, 1], [0, 0]], [0.0, 0.0, 1.0]]], [['regression: random qubit 2', [[0.057, -1.052], [0.48, 1.205]], [-0.888347, 0.410865, -0.205012]], ['regression: random qubit 3', [[1.769, -1.743], [0.441, -0.443]], [0.47339, -0.004576, 0.880841]], ['repair check: minus i', [[0.707107, 0], [0, -0.707107]], [0.0, -1.0, 0.0]], ['control: ket zero', [[1, 0], [0, 0]], [0.0, 0.0, 1.0]], ['control: ket one', [[0, 0], [1, 0]], [0.0, 0.0, -1.0]], ['control: zero vector', [[0, 0], [0, 0]], 'zero-state'], ['control: global phase i', [[0, 1], [0, 0]], [0.0, 0.0, 1.0]]], [['regression: random qubit 5', [[1.781, 0.313], [-0.534, -1.473]], [-0.493327, -0.858114, 0.142371]], ['regression: random qubit 6', [[1.624, -0.932], [-1.233, 0.708]], [-0.963265, 0.00023, 0.268554]], ['regression: random qubit 0', [[-1.176, -0.41], [1.26, -1.053]], [-0.494424, 0.826337, -0.26965]], ['control: ket zero', [[1, 0], [0, 0]], [0.0, 0.0, 1.0]], ['control: ket one', [[0, 0], [1, 0]], [0.0, 0.0, -1.0]], ['control: zero vector', [[0, 0], [0, 0]], 'zero-state'], ['control: global phase i', [[0, 1], [0, 0]], [0.0, 0.0, 1.0]]], [['regression: random qubit 8', [[-1.932, 0.067], [0.651, -1.416]], [-0.438732, 0.873211, 0.212174]], ['regression: random qubit 9', [[0.467, -1.484], [-1.959, -0.631]], [0.006475, -0.962062, -0.272753]], ['regression: random qubit 2', [[0.057, -1.052], [0.48, 1.205]], [-0.888347, 0.410865, -0.205012]], ['control: ket zero', [[1, 0], [0, 0]], [0.0, 0.0, 1.0]], ['control: ket one', [[0, 0], [1, 0]], [0.0, 0.0, -1.0]], ['control: zero vector', [[0, 0], [0, 0]], 'zero-state'], ['control: global phase i', [[0, 1], [0, 0]], [0.0, 0.0, 1.0]]], [['regression: random qubit 11', [[0.295, -0.421], [-0.884, -0.915]], [0.13217, -0.682004, -0.719306]], ['regression: random qubit 12', [[0.596, 0.022], [-1.906, -0.045]], [-0.569828, 0.007574, -0.821729]], ['regression: random qubit 4', [[-1.063, 1.137], [0.11, -1.819]], [-0.760893, 0.629754, -0.156369]], ['control: ket zero', [[1, 0], [0, 0]], [0.0, 0.0, 1.0]], ['control: ket one', [[0, 0], [1, 0]], [0.0, 0.0, -1.0]], ['control: zero vector', [[0, 0], [0, 0]], 'zero-state'], ['control: global phase i', [[0, 1], [0, 0]], [0.0, 0.0, 1.0]]]]
for label, args, expected in fixtures[N-1]:
check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: unnormalized | [0.0, 0.96, -0.28] | [0.0, 0.96, -0.28] | Passed |
| regression: random qubit 0 | [-0.494424, 0.826337, -0.26965] | [-0.494424, 0.826337, -0.26965] | Passed |
| repair check: plus | [1.0, 0.0, 0.0] | [1.0, 0.0, 0.0] | Passed |
| control: ket zero | [0.0, 0.0, 1.0] | [0.0, 0.0, 1.0] | Passed |
| control: ket one | [0.0, 0.0, -1.0] | [0.0, 0.0, -1.0] | Passed |
| control: zero vector | zero-state | zero-state | Passed |
| control: global phase i | [0.0, 0.0, 1.0] | [0.0, 0.0, 1.0] | Passed |
SHA-256 / 131ea3198da6dcfac69cb68f068651834de7488a026d4cb9882a944f0b0ae9fa
Verification & scope
A deterministic bounded teaching model with a stipulated toy contract; amplitudes are rounded to fixed decimals for strict JSON output. It is not a production quantum SDK and claims no standards conformance. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:51:32.804456+00:00.
Case digest / 7e550efc49c5df8f12295fdd950a5c36f7b5df6d677c8c311906b5d1272a2b87