On this page:
Once manipulation of a register is complete, measurements may be taken. The MEASURE command in Quantum Console performs the measurement operation.
The Quantum Console syntax for this operation is:
MEASURE({Basis}, {N});
Where Basis specifies the type of measurement to perform, and n specifies the number (or index) of the qubit we wish to use to perform the measurement.
Quantum Console offers X and Z basis measurements.
The syntax to measure qubit 0 using the X basis:
MEASURE(X, 0);
The syntax to measure qubit 2 using the Z basis:
MEASURE(Z, 2);
Measurement of a quantum system is currently thought to be random, however as research advances, this may prove to be untrue. It is my opinion that measurement is not random at all, that we simply do not know enough about what is going on under the hood. That aside, random numbers are used here during measurement to simulate what we currently know to be true.
Quantum measurement differs from measurements taken in the classical world, in so much that quantum measurements interact with the system they measure. This interaction changes the state of the system, meaning that the same measurement cannot be repeated. This runs as counter-intuitive to us users of the classical world, as we are all aware that it is possible and indeed neccessary to repeat a measurement on a system. Classical systems generally do not change after measurement, so the opportunity to repeat measurements are availble.
To measure a quantum system, the following steps must be performed:
* Note that if you are performing an X measurement, then you will need to perform an H on the measurement qubit before executing the rest of the steps above.
This seems at first to be a fairly involved process; the next few examples (and the use of the column method) will make this process a little easier to understand.
Consider the following 1 qubit system:
Let A = 0.641 Let B = 0.768 Let Q0 = (A|› + B|1›) Ψ = (A|› + B|1›)
Using the column method, the state vector can be represented as:
M // The operation to be performed 0 // The index of the qubit 0 1
A list of probabilities is generated, one element for each possible outcome (0 or 1). In this crucial step, state vector elements in the measurement qubit index are sorted into a list of probabilities. If the state vector element has a 0 in the qubit index of the binary index value, then it is added into the 0 probability element. If the state vector element has a 1 in the qubit index of the binary index value, then it is added into the 1 probability element.
In the case of this 1 qubit system, the resultant probabilities are:
Let P0 = |A|2 = |0.641|2 = 0.410 Let P1 = |B|2 = |0.768|2 = 0.589
These final values indicate the possibility of measuring that outcome. On the above system, there is a 41% chance of measuring 0, and a 59% chance of measuring 1.
Next, a random number is generated:
Let R = 0.320
Using this random number R, the first probability that is greater than R is chosen:
(P0 > R) = (0.410 > 0.320) // True, so P0 is selected (P1 > R) = (0.589 > 0.320) // Also true, but P0 is already selected, so this value is ignored
The selection of P0 indicates that the outcome of 0 occured.
The next step is to adjust the register to reflect this. The associated qubit (0 in this example) is set to its 'perfect' state. As a result of 0 was obtained, the qubit must be set to a perfect 0 state:
A|0› = 1 B|1› = 0
The state vector is then updated, setting the amplitude of all elements that were not involved in the operation to 0.
If the state vector element has a 0 in the qubit index of the binary index value, and because this matches the outcome measured (0), this element was involved in the operation, so it is ignored. If the state vector element has a 1 in the qubit index of the binary index value, and as this doesn't match the outcome measured (0), then this element was not involved, and has its amplitude set to 0.
|0› = 1 |1› = 0
Finally, the state vector is normalised, and the entire operation is complete.
MEASURE(X, 0);Consider the following 1 qubit system:
Let A = 0.641 Let B = 0.768 Let Q0 = (A|› + B|1›) Ψ = (A|› + B|1›)
Using the column method, the state vector can be represented as:
M // The operation to be performed 0 // The index of the qubit 0 1
An H is then performed on the corresponding qubit:
H(0); A = 0.996A B = -0.090B
A list of probabilities is generated, one element for each possible outcome (0 or 1). In this step, state vector elements in the measurement qubit index are sorted into a list of probabilities. If the state vector element has a 0 in the qubit index of the binary index value, then it is added into the 0 probability element. If the state vector element has a 1 in the qubit index of the binary index value, then it is added into the 1 probability element.
In the case of this 1 qubit system, the probabilities are:
Let P0 = |A|2 = | 0.996|2 = 0.992 Let P1 = |B|2 = |-0.090|2 = 0.008
These final values indicate the possibility of measuring that outcome. On the above system, there is a 99% chance of measuring 0, and almost a 1% chance of measuring 1.
Next, a random number is generated:
Let R = 0.146
Using this random number R, the first probability that is greater than R is chosen:
(P0 > R) = (0.992 > 0.146) // True, so P0 is selected (P1 > R) = (0.008 > 0.146) // Also true, but P0 is already selected, so this value is ignored
The selection of P0 indicates that the outcome of 0 occured.
The next step is to adjust the register to reflect this. The associated qubit (0 in this example) is set to its 'perfect' state. As a result of 0 was obtained, the qubit must be set to a perfect 0 state:
A|0› = 1 B|1› = 0
The state vector is then updated, setting the amplitudes of all elements that were not involved in the operation to 0.
If the state vector element has a 0 in the qubit index of the binary index value, and because this matches the outcome measured (0), this element was involved in the operation, so it is ignored. If the state vector element has a 1 in the qubit index of the binary index value, and as this doesn't match the outcome measured (1), then this element was not involved, and has its amplitude set to 0.
|0› = 1 |1› = 0
Finally, the state vector is normalised, and the entire operation is complete.
Consider the following 2 qubit system:
Let A = 0.520; Let B = 0.854; Let C = 0.641; Let D = 0.768; Let Q0 = (A|› + B|1›) Let Q1 = (C|› + D|1›) Ψ = (A|› + B|1›) (x) (C|› + D|1›)
On which we will perform the following command:
MEASURE(Z, 0);
Using the column method, the state vector can be represented as:
M // The operation to be performed 01 // The index of the qubit 00 // Binary index is 00 01 10 11 // Binary index is 11
A list of probabilities is generated, one element for each possible outcome (0 or 1). In this step, state vector elements in the measurement qubit index are sorted into a list of probabilities. If the state vector element has a 0 in the qubit index of the binary index value, then it is added into the 0 probability element. If the state vector element has a 1 in the qubit index of the binary index value, then it is added into the 1 probability element.
* Note that in the above example, the outcome 0 has matches in the qubit 0 index column at elements AC and AD. The outcome 1 has matches in the qubit 0 index column at elements BC and BD.
In the case of this 2 qubit system, and the probabilities are:
Let P0 = (|AC|2 + |AD|2) = (|0.333|2 + |0.399|2) = 0.270 Let P1 = (|BC|2 + |BD|2) = (|0.547|2 + |0.655|2) = 0.729
These final values indicate the possibility of measuring that outcome. On the above system, there is a 27% chance of measuring 0, and a 72% chance of measuring 1.
Next, a random number is generated:
Let R = 0.765
Using this random number R, the first probability that is greater than R is chosen:
(P0 > R) = (0.270 > 0.765) // False (P1 > R) = (0.729 > 0.765) // Also false, but as this is the last probability in the list, P1 is selected
The selection of P1 indicates that the outcome of 1 occured.
The next step is to adjust the register to reflect this. The associated qubit (0 in this example) is set to its 'perfect' state. As a result of 1 was obtained, the qubit must be set to a perfect 1 state:
A|0› = 1 B|1› = 0
The state vector is then updated, setting the amplitudes of all elements that were not involved in this operation to 0.
If the state vector element has a 0 in the qubit index of the binary index value, and as this doesn't match the outcome measured (1), then this element was not involved, and has its amplitude set to 0. If the state vector element has a 1 in the qubit index of the binary index value, and as this matches the outcome measured (1), this element was involved in the operation, so it is ignored.
|00› = 0 // Binary index is 00, qubit index is 0, value to check is therefore also 0 (1st position of the binary index) |01› = 0 |10› = 0.547 |11› = 0.656 // Binary index is 11, qubit index is 0, value to check is therefore 1 (1st postion of the binary index)
Finally, the state vector is normalised:
|00› = 0 |01› = 0 |10› = 0.641 |11› = 0.768
The operation is complete.
MEASURE(X, 0);Consider the following 2 qubit system:
Let A = 0.520; Let B = 0.854; Let C = 0.641; Let D = 0.768; Let Q0 = (A|› + B|1›) Let Q1 = (C|› + D|1›) Ψ = (A|› + B|1›) (x) (C|› + D|1›)
On which we will perform the following command:
MEASURE(X, 0);
Using the column method, the state vector can be represented as:
M // The operation to be performed 01 // The index of the qubit 00 // Binary index is 00 01 10 11 // Binary index is 11
An H is then performed on the corresponding qubit:
H(0); AC = 0.623 AD = 0.746 BC = -0.151 BC = -0.181
A list of probabilities is generated, one element for each possible outcome (0 or 1). In this step, state vector elements in the measurement qubit index are sorted into a list of probabilities. If the state vector element has a 0 in the qubit index of the binary index value, then it is added into the 0 probability element. If the state vector element has a 1 in the qubit index of the binary index value, then it is added into the 1 probability element.
* Note that in the above example, the outcome 0 has matches in the qubit 0 index column at elements AC and AD. The outcome 1 has matches in the qubit 0 index column at elements BC and BD.
In the case of this 2 qubit system, and the probabilities are:
Let P0 = (|AC|2 + |AD|2) = (| 0.623|2 + | 0.746|2) = 0.944 Let P1 = (|BC|2 + |BD|2) = (|-0.151|2 + |-0.181|2) = 0.055
These final values indicate the possibility of measuring that outcome. On the above system, there is a 94% chance of measuring 0, and a 5% chance of measuring 1.
Next, a random number is generated:
Let R = 0.773
Using this random number R, the first probability that is greater than R is chosen:
(P0 > R) = (0.944 > 0.773) // True (P1 > R) = (0.055 > 0.773) // False, however P0 has already been selected, so this value is ignored
The selection of P0 indicates that the outcome of 0 occured.
The next step is to adjust the register to reflect this. The associated qubit (0 in this example) is set to its 'perfect' state. As a result of 0 was obtained, the qubit must be set to a perfect 0 state:
A|0› = 1 B|1› = 0
The state vector is then updated, setting the amplitudes of all elements that were not involved in this operation to 0.
If the state vector element has a 0 in the qubit index of the binary index value, and as this matches the outcome measured (0), this element was involved in the operation, so it is ignored. If the state vector element has a 1 in the qubit index of the binary index value, and as this doesn't match the outcome measured (0), then this element was not involved, and has its amplitude set to 0.
|00› = 0.623 |01› = 0.746 |10› = 0 |11› = 0
Finally, the state vector is normalised:
|00› = 0.641 |01› = 0.768 |10› = 0; |11› = 0;
The operation is complete.
MEASURE(Z, 1);Consider the following 2 qubit system:
Let A = 0.520; Let B = 0.854; Let C = 0.641; Let D = 0.768; Let Q0 = (A|› + B|1›) Let Q1 = (C|› + D|1›) Ψ = (A|› + B|1›) (x) (C|› + D|1›)
On which we will perform the following command:
MEASURE(Z, 1);
Using the column method, the state vector can be represented as:
M // The operation to be performed 01 // The index of the qubit 00 // Binary index is 00 01 10 11 // Binary index is 11
A list of probabilities is generated, one element for each possible outcome (0 or 1). In this step, state vector elements in the measurement qubit index are sorted into a list of probabilities. If the state vector element has a 0 in the qubit index of the binary index value, then it is added into the 0 probability element. If the state vector element has a 1 in the qubit index of the binary index value, then it is added into the 1 probability element.
* Note that in the above example, the outcome 0 has matches in the qubit 1 index column at elements AC and BC. The outcome 1 has matches in the qubit 1 index column at elements AD and BD.
In the case of this 2 qubit system, and the probabilities are:
Let P0 = (|AC|2 + |BC|2) = (|0.333|2 + |0.547|2) = 0.410 Let P1 = (|AD|2 + |BD|2) = (|0.399|2 + |0.655|2) = 0.589
These final values indicate the possibility of measuring that outcome. On the above system, there is a 41% chance of measuring 0, and a 59% chance of measuring 1.
Next, a random number is generated:
Let R = 0.926964496694023
Using this random number R, the first probability that is greater than R is chosen:
(P0 > R) = (0.410 > 0.926) // False (P1 > R) = (0.589 > 0.926) // Also false, but this is the last probability in the list, so P1 is selected
The selection of P1 indicates that the outcome of 1 occured.
The next step is to adjust the register to reflect this. The associated qubit (0 in this example) is set to its 'perfect' state. As a result of 1 was obtained, the qubit must be set to a perfect 1 state:
C|0› = 1 D|1› = 0
The state vector is then updated, setting the amplitudes of all elements that were not involved in this operation to 0.
If the state vector element has a 0 in the qubit index of the binary index value, and as this doesn't match the outcome measured (1), then this element was not involved, and has its amplitude set to 0. If the state vector element has a 1 in the qubit index of the binary index value, and as this matches the outcome measured (1), this element was involved in the operation, so it is ignored.
|00› = 0 |01› = 0.399 // Binary index is 01, qubit index is 1, value to check is therefore 1 (2nd position of the binary index) |10› = 0 // Binary index is 10, qubit index is 1, value to check is therefore 0 (2nd postion of the binary index) |11› = 0.656
Finally, the state vector is normalised:
|00› = 0 |01› = 0.520 |10› = 0 |11› = 0.854
The operation is complete.
MEASURE(X, 1);Consider the following 2 qubit system:
Let A = 0.520; Let B = 0.854; Let C = 0.641; Let D = 0.768; Let Q0 = (A|› + B|1›) Let Q1 = (C|› + D|1›) Ψ = (A|› + B|1›) (x) (C|› + D|1›)
On which we will perform the following command:
MEASURE(X, 1);
Using the column method, the state vector can be represented as:
M // The operation to be performed 01 // The index of the qubit 00 // Binary index is 00 01 10 11 // Binary index is 11
An H is then performed on the corresponding qubit:
H(0); AC = 0.518 AD = -0.047 BC = 0.851 BD = -0.077
A list of probabilities is generated, one element for each possible outcome (0 or 1). In this step, state vector elements in the measurement qubit index are sorted into a list of probabilities. If the state vector element has a 0 in the qubit index of the binary index value, then it is added into the 0 probability element. If the state vector element has a 1 in the qubit index of the binary index value, then it is added into the 1 probability element.
* Note that in the above example, the outcome 0 has matches in the qubit 1 index column at elements AC and BC. The outcome 1 has matches in the qubit 1 index column at elements AD and BD.
In the case of this 2 qubit system, and the probabilities are:
Let P0 = (|AC|2 + |AD|2) = (|0.518|2 + |-0.047|2) = 0.992 Let P1 = (|BC|2 + |BD|2) = (|0.851|2 + |-0.077|2) = 0.008
These final values indicate the possibility of measuring that outcome. On the above system, there is a 99% chance of measuring 0, and almost a 1% chance of measuring 1.
Next, a random number is generated:
Let R = 0.235
Using this random number R, the first probability that is greater than R is chosen:
(P0 > R) = (0.992 > 0.235) // True (P1 > R) = (0.008 > 0.235) // False, P0 has already been selected anyway, so this value is ignored
The selection of P0 indicates that the outcome of 0 occured.
The next step is to adjust the register to reflect this. The associated qubit (1 in this example) is set to its 'perfect' state. As a result of 0 was obtained, the qubit must be set to a perfect 0 state:
C|0› = 1 D|1› = 0
The state vector is then updated, setting the amplitudes of all elements that were not involved in this operation to 0.
If the state vector element has a 0 in the qubit index of the binary index value, and as this matches the outcome measured (0), this element was involved in the operation, so it is ignored. If the state vector element has a 1 in the qubit index of the binary index value, and as this doesn't match the outcome measured (0), then this element was not involved, and has its amplitude set to 0.
|00› = 0.518 |01› = 0 |10› = 0.851 |11› = 0
Finally, the state vector is normalised:
|00› = 0.520 |01› = 0 |10› = 0.854 |11› = 0
The operation is complete.
Consider the following 3 qubit system:
Let A = 0.713; Let B = 0.700; Let C = 0.870; Let D = 0.491; Let E = 0.627; Let F = 0.778; Let Q0 = (A|› + B|1›) Let Q1 = (C|› + D|1›) Let Q2 = (C|› + D|1›) Ψ = (A|› + B|1›) (x) (C|› + D|1›) (x) (E|› + F|1›)
On which we will perform the following command:
MEASURE(Z, 0);
Using the column method, the state vector can be represented as:
M // The operation to be performed 012 // The index of the qubit 000 001 010 011 100 101 110 111
A list of probabilities is generated, one element for each possible outcome (0 or 1). In this step, state vector elements in the measurement qubit index are sorted into a list of probabilities. If the state vector element has a 0 in the qubit index of the binary index value, then it is added into the 0 probability element. If the state vector element has a 1 in the qubit index of the binary index value, then it is added into the 1 probability element.
* Note that in the above example, the outcome 0 has matches in the qubit 0 index column at elements ACE, ACF, ADE and ADF. The outcome 1 has matches in the qubit 0 index column at elements BCE, BCF, BDE and BDF.
In the case of this 3 qubit system, and the probabilities are:
Let P0 = (|ACE|2 + |ACF|2 + |ADE|2 + |ADF|2) = (|0.389|2 + |0.484|2 + |0.220|2 + |0.273|2) = 0.509 Let P1 = (|BCE|2 + |BCF|2 + |BDE|2 + |BDF|2) = (|0.382|2 + |0.474|2 + |0.216|2 + |0.268|2) = 0.490
These final values indicate the possibility of measuring that outcome. On the above system, there is a 51% chance of measuring 0, and a 49% chance of measuring 1.
Next, a random number is generated:
Let R = 0.034
Using this random number R, the first probability that is greater than R is chosen:
(P0 > R) = (0.509 > 0.034) // True (P1 > R) = (0.490 > 0.034) // Also true, but P0 has already been selected, so this value is ignored
The selection of P1 indicates that the outcome of 1 occured.
The next step is to adjust the register to reflect this. The associated qubit (0 in this example) is set to its 'perfect' state. As a result of 1 was obtained, the qubit must be set to a perfect 1 state:
A|0› = 1 B|1› = 0
The state vector is then updated, setting the amplitudes of all elements that were not involved in this operation to 0.
If the state vector element has a 0 in the qubit index of the binary index value, and as this doesn't match the outcome measured (1), then this element was not involved, and has its amplitude set to 0. If the state vector element has a 1 in the qubit index of the binary index value, and as this matches the outcome measured (1), this element was involved in the operation, so it is ignored.
|000› = 0.390 // Binary index is 000, qubit index is 0, value to check is therefore also 0 (1st position of the binary index) |001› = 0.484 |010› = 0.220 |011› = 0.273 |100› = 0 |101› = 0 // Binary index is 101, qubit index is 0, value to check is therefore 1 (1st postion of the binary index) |110› = 0 |111› = 0
Finally, the state vector is normalised:
|000› = 0.546 |001› = 0.678 |010› = 0.309 |011› = 0.383 |100› = 0 |101› = 0 |110› = 0 |111› = 0
The operation is complete.
MEASURE(X, 0);Consider the following 3 qubit system:
Let A = 0.713; Let B = 0.700; Let C = 0.870; Let D = 0.491; Let E = 0.627; Let F = 0.778; Let Q0 = (A|› + B|1›) Let Q1 = (C|› + D|1›) Let Q2 = (C|› + D|1›) Ψ = (A|› + B|1›) (x) (C|› + D|1›) (x) (E|› + F|1›)
On which we will perform the following command:
MEASURE(X, 0);
Using the column method, the state vector can be represented as:
M // The operation to be performed 012 // The index of the qubit 000 001 010 011 100 101 110 111
An H is then performed on the corresponding qubit:
H(0); ACE = 0.546 ACF = 0.678 ADE = 0.309 ADF = 0.383 BCE = 0.005 BCF = 0.007 BDE = 0.003 BDF = 0.004
A list of probabilities is generated, one element for each possible outcome (0 or 1). In this step, state vector elements in the measurement qubit index are sorted into a list of probabilities. If the state vector element has a 0 in the qubit index of the binary index value, then it is added into the 0 probability element. If the state vector element has a 1 in the qubit index of the binary index value, then it is added into the 1 probability element.
* Note that in the above example, the outcome 0 has matches in the qubit 0 index column at elements ACE, ACF, ADE and ADF. The outcome 1 has matches in the qubit 0 index column at elements BCE, BCF, BDE and BDF.
In the case of this 3 qubit system, and the probabilities are:
Let P0 = (|ACE|2 + |ACF|2 + |ADE|2 + |ADF|2) = (|0.546|2 + |0.678|2 + |0.309|2 + |0.383|2) = 0.999 Let P1 = (|BCE|2 + |BCF|2 + |BDE|2 + |BDF|2) = (|0.005|2 + |0.007|2 + |0.003|2 + |0.004|2) = 0.000
These final values indicate the possibility of measuring that outcome. On the above system, there is a 99% chance of measuring 0, and a less than 1% chance of measuring 1.
Next, a random number is generated:
Let R = 0.058
Using this random number R, the first probability that is greater than R is chosen:
(P0 > R) = (0.999 > 0.0588) // True (P1 > R) = (0.000 > 0.0588) // False, and P0 has already been selected anyway, this value is ignored
The selection of P0 indicates that the outcome of 0 occured.
The next step is to adjust the register to reflect this. The associated qubit (0 in this example) is set to its 'perfect' state. As a result of 0 was obtained, the qubit must be set to a perfect 0 state:
A|0› = 1 B|1› = 0
The state vector is then updated, setting the amplitudes of all elements that were not involved in this operation to 0.
If the state vector element has a 0 in the qubit index of the binary index value, and as this matches the outcome measured (0), this element was involved in the operation, so it is ignored. If the state vector element has a 1 in the qubit index of the binary index value, and as this doesn't match the outcome measured (0), then this element was not involved, and has its amplitude set to 0.
000› = 0.546 001› = 0.678 010› = 0.309 011› = 0.383 100› = 0 101› = 0 110› = 0 111› = 0
Finally, the state vector is normalised:
000› = 0.546 001› = 0.678 010› = 0.309 011› = 0.383 100› = 0 101› = 0 110› = 0 111› = 0
The operation is complete.
Copyright © 2025 carlbelle.com