r/QuantumComputing • • Jan 22 '21

My first article on Quantum Computing! The Deutsch-Jozsa Algorithm can be difficult to understand, so here's an intuitive guide!

https://medium.com/quantum-untangled/quantum-untangled-quantum-computing-deutsch-jozsa-algorithm-guide-untangled-27adf4205913
52 Upvotes

13 comments sorted by

11

u/LegendStreak Jan 22 '21 edited Jan 23 '21

I spent quite a few days trying to understand why Deutsch-Jozsa worked - surprisingly few resources described the reasons for parts of the Algorithm. So, I made my own! Hopefully I can shed some new light on the 'why?' of Quantum Computing, instead of just 'how?'.

If this does help, please do let me know - I'd really love seeing that my work's been useful! If it doesn't help, I'd appreciate some feedback so I can try and improve. I plan to go into Grover's, Shor's, and many more popular Algorithms - explaining Quantum Computing simply and intuitively!

Also, I'd like to give a simply massive thanks to Quantum Untangled for letting me publish the article with them! Part two of Deutsch-Jozsa, along with all those other Algorithms from before will be posted at https://medium.com/quantum-untangled. You can also see some other great articles, like one about Quantum Teleportation!

3

u/BestN00b Jan 22 '21

You forgot to write about the constant 1 oracle, where every state got phase kickback

Edit: also, you wrote “if the query measures 0” for both balanced and constant

1

u/LegendStreak Jan 22 '21

The Constant 1 Oracle also has no Phase Kickback - the Query would be unaffected throughout.

Instead, the Oracle would just always change the Auxiliary bit to an Output of 1. With no effect from the Query, there's no opportunity for Phase Kickback to occur at all.

In Part 2, the Maths & Code section, we'll see that the Auxiliary always enters the Oracle in the |-> state, as it has an X Gate then Hadamard applied. A Constant One Oracle does absolutely nothing to the Query or Auxiliary, and just Outputs the exact input it got - so, when the Auxiliary bit goes through a Hadamard before measurement, it becomes the |1> state.

This would change slightly if we used, say, the |+> state, or a Qubit with just a Hadamard. But, all that happens is an X Gate within the Oracle, so that the Output gets measured as |1>. We'll generally use |-> since it's easier to implement with Phase Kickback, though - the example's just to show that Constant One Oracles never affect the Query, only the Auxiliary.

So the Query will always measure 0, and the Auxiliary will always measure 1!

1

u/BestN00b Jan 23 '21

I thought the real answer to constant 1 oracle is that everything gets phase kickback, which means the query states all got the same phase change, AKA a global phase change. And global phase changes do nothing to qubits; only relative phase changes matter. Therefore, we can pretend that nothing happens.

Your explanation seems to just skip all that.

Is my long explanation wrong?

1

u/LegendStreak Jan 23 '21 edited Jan 24 '21

There's no effect on the global phase. A Constant Oracle doesn't even operate on the Query - it might as well not even be there!

Incidentally, even for the Balanced Oracle where the Qubits have some changes in phase:

Global Phase affects the entire statevector of a qubit, by multiplying it by a scalar *in a way that the magnitude of the vector is still 1*. Like, if you have a state |1>, a change in global phase could simply be to -|1>. Multiplying by '-1' doesn't affect the magnitude in any way, so the Global Phase is the same. You can look at the Qiskit Textbook to get an idea of it, and I'll see if Quantum Untangled can put out a post to explain this. Crucially though, Global Phase has to apply to the entire Quantum State - a Qubit in superposition |0> + |1> has a different Global Phase for something like -(|0> +|1>). If it only applies to one side, that's a different Relative Phase, like |0> - |1>.

Let's look at our example of Phase Kickback on a single-qubit Query (I'll go deeper into this in Part 2 - you're right, it's quite confusing). When the phase gets 'kicked back', it has the effect of 'kicking back' the effect of the CX Gate. However, only the |1> component of the Query receives the kickback, since the |0> component would tell the CX Gate to do nothing. Let's say the effect of the CX Gate was to apply a negative scalar to the Target - specifically, transforming |-> into -|1>. The negative gets 'kicked back' onto the |1>, but not the |0>, preventing this from affecting Global Phase.

So, our new state would be some form of |0> - |1>, instead of |0> + |1>. Looking back at our explanation of Global and Relative Phase above, you can verify that it's actually a change in Relative Phase and not Global Phase.

That's how the Balanced Oracle works. Global Phase doesn't come into play at all during the Deutsch-Jozsa Algorithm; we only exploit Relative Phase here.

I'll try to release Part 2 on Thursday and share it on Reddit as well - hopefully the mathematics, and actually seeing the implementation in Circuit form can help.

1

u/LegendStreak Jan 22 '21

You're right! I've corrected that typo about the Query, thanks so much for catching it and letting me know!

2

u/lizaanna Jan 22 '21

Just opened it and will read it in the morning, great job tho

1

u/LegendStreak Jan 22 '21

Thanks! I hope it can help :)

2

u/WhyDoISuckAtW2 Jan 23 '21

"We just need to split We’ll go over it more in the follow-up to this post"

I think you have some typo or something missing here?

1

u/LegendStreak Jan 23 '21

Ah, thanks so much for catching that and letting me know! I've taken out the 'split' part so it reads properly now - thanks again!

2

u/MaoGo Jan 23 '21

Very pedagogical, keep it on!

1

u/LegendStreak Jan 23 '21

Thanks, I'll do my best!

1

u/theshadows96 Oct 09 '23

This was a great write-up, thank you! :D