Skip to content

cirq.Simulator final_state_vector is not normalized #6402

Closed
@NoureldinYosri

Description

Description of the issue
The final state vector of cirq.Simulator.simulate may acccumulate enough numerical error that it may not have unit norm. similar to #5916

How to reproduce the issue

q0 = cirq.LineQubit(0)
circuit = cirq.Circuit(
    cirq.S(q0),
    cirq.H(q0),
    cirq.S(q0),
    cirq.Y(q0),
    cirq.S(q0),
    cirq.H(q0),
    cirq.S(q0),
    cirq.measure(q0),
)

state_vector_simulator = cirq.Simulator()
state_vector_simulator.simulate(circuit).final_state_vector
array([0.+0.j        , 0.+0.99999994j], dtype=complex64)

Cirq version
1.2.0

Metadata

Assignees

Labels

good first issueThis issue can be resolved by someone who is not familiar with the codebase. A good starting issue.good for learningFor beginners in QC, this will help picking up some knowledge. Bit harder than "good first issues"kind/bug-reportSomething doesn't seem to work.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions