All problems
Qubit Amplitude Norm Check
Problem
Return True when the real amplitudes (a, b) of a qubit state satisfy the normalization condition a^2 + b^2 = 1 within a tolerance of 1e-9. Physical qubit states must have unit norm.
Hint
The squared amplitudes are probabilities and must sum to one.
Test cases
case 1
in: [1,0]
expected: true
case 2
in: [0.7071067811865476,0.7071067811865476]
expected: true
case 3
in: [0.6,0.8]
expected: true
case 4
in: [0.5,0.5]
expected: false
case 5
in: [0,0]
expected: false
Starter codePython
import math
def qubit_norm_valid(a, b):
# Your code here
pass5 test cases · run your code against them in the editor