Again, I start with a two-qubit register psi, initialized to zero. I perform the Hadamard on it to create an equal superposition of states. Then I measure it, getting a different result each time I try it.
Note the two different quantum state notations used. Vector notation is used be default in QCF as it makes computation simpler. But as a human, I prefer binary ket notation, so I go from binary ket to vector notation using bin2vec(), and vector to binary ket notation using pretty().
Also measurement in QCF does not collapse the wavefunction explicitly (although you could do psi=measure(psi) to be more realistic about the measurement process collapsing the waveform).
octave-3.2.3:132> addpath("/pathtoqcf/qcf")octave-3.4.0:133> psi=bin2vec("00")psi =1000octave-3.4.0:134> pretty(psi)ans = 1|00>octave-3.4.0:135> psi=hadamard(2)*psipsi =0.500000.500000.500000.50000octave-3.4.0:136> pretty(psi)ans = 0.5|00> + 0.5|01> + 0.5|10> + 0.5|11>octave-3.4.0:137> pretty(measure(psi))ans = 1|10>octave-3.4.0:138> pretty(measure(psi))ans = 1|01>octave-3.4.0:139> pretty(measure(psi))ans = 1|11>octave-3.4.0:140> pretty(measure(psi))ans = 1|01>
No comments:
Post a Comment