Comments (3)
Your solution doesn't actually prepare the superposition of the two given bit strings, it prepares one of the bit strings at random with 50-50 chance.
Consider the simplest example possible: prepare superposition of |0⟩ and |1⟩ basis states (bits1 = [true], bits2 = [false]). After the two loops, right before Reset, the state of the qubits is |00⟩ + |11⟩ (with appropriate normalization). Reset measures the qubit q and applies X if necessary to convert it to |0⟩ state. If you measure one of the qubits in the superposition |00⟩ + |11⟩, the second one will be left either in |0⟩ state or in |1⟩ state, depending on the measurement result, but not in a superposition.
It is possible to make this approach work, but you'll need to convert the additional qubit to |0⟩ state by uncomputing it, not by measuring it - for example, you can find a position in which the bitstrings differ and do a CNOT with the corresponding qubit the as control and the additional qubit as the target - but then it stops being conceptually simpler :-)
from quantumkatas.
Thanks for the great explanation! So my means of zeroing the additional qubit (i.e. Reset
) simply collapses the superposition I've built and by the time I was measuring my qubits proper, there was no more superposition to collapse, is that right?
I also want to clear one detail about your suggestion of 'uncomputing'. So, the configuration of superpositions between the additional qubit and the one corresponding to the first mismatch in bitstrings can be either 'straight' or 'diagonal' (meaning (q0 = |0⟩+|1⟩, qi = |0⟩+|1⟩) or (q0 = |0⟩+|1⟩, qi = |1⟩+|0⟩), respectively), and so the CNOT results in q0 becoming |0⟩ or |1⟩, respectively, after which measuring it no longer collapses our desired superposition. So the crux here is going with a unitary transformation (CNOT) instead of a measurement. Do I get this right?
from quantumkatas.
I've implemented your suggestion and it worked fine. Perhaps it did in fact lose some conceptual clarity, but somehow it feels more natural to me :). Here's the code:
operation TwoBitstringSuperposition (qs : Qubit[], bits1 : Bool[], bits2 : Bool[]) : Unit {
// Find first index where bit strings differ
mutable mismatch = -1;
for (i in 0..Length(qs)-1) {
if (bits1[i] != bits2[i] && mismatch == -1) {
set mismatch = i;
}
}
// Allocate one additional qubit
using (q = Qubit()) {
H(q); // Produce superposition
// Set one half of the superpositon...
for (i in 0..Length(qs)-1) {
if (bits2[i]) {
CNOT(q, qs[i]);
}
}
// ...then another
X(q);
for (i in 0..Length(qs)-1) {
if (bits1[i]) {
CNOT(q, qs[i]);
}
}
// Uncompute the additional qubit
CNOT(qs[mismatch], q);
// Cleanup
Reset(q);
}
}
Thanks for a very enlightening discussion and keep up the great work :).
from quantumkatas.
Related Issues (20)
- Sample solutions for task 1.14 of the Superposition katas. HOT 2
- Mistake in multi-qubit measurement tutorial exercise 2 calculations. HOT 1
- Enable tests that are currently excluded with multicell solution tag HOT 2
- [MultiQubitSystemMeasurements] Add code to Exercise 2 solution to show state in Pauli X basis HOT 2
- Fix math mode rendering in browser HOT 5
- Task 1.15 in Measurements Kata says two states are orthogonal. HOT 2
- Exercise 5 for RandomNumberGenerationTutorial - slightly cleaner solution HOT 4
- QFT Question HOT 9
- Late introduction of `ControlledOnInt` operation HOT 4
- Disable cell id generation while working on jupyter notebooks locally HOT 2
- Validate only changed katas…
- %kata magic doesn't work with lambda expressions HOT 1
- O(1) time complexity solution to Oracles tutorial, task 4.2 HOT 9
- Add error-free arbitrary state transmission demo to QEC_BitFlipCode kata HOT 7
- docker image creation is stuck HOT 1
- Add Memory Management Tutorials and Concepts HOT 1
- Systems of Equations not properly explained HOT 1
- BasicGates kata task 1.6 PhaseChange fails
- Docker Build Failing HOT 1
- getting issue in exit command HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quantumkatas.