From a7a69370278733343d25a3d07927ebb36805bc75 Mon Sep 17 00:00:00 2001 From: Yazan Date: Mon, 20 Jul 2026 18:02:48 +1000 Subject: [PATCH] Initial Deutsch Algorithm Implementation - wrote algorithm description with math basis - modified circuit diagram to conform with standards - created new gate pages to move documentation about oracles out of algorithm page --- .../data/circuits/deutsch.json | 17 +-- .../data/gates/phase-oracle.json | 8 ++ .../data/page-information/deutsch.mdx | 115 ++++++++++++++++++ .../data/page-information/phase-oracle.mdx | 0 4 files changed, 124 insertions(+), 16 deletions(-) create mode 100644 quantum-computing-edu-next/data/gates/phase-oracle.json create mode 100644 quantum-computing-edu-next/data/page-information/phase-oracle.mdx diff --git a/quantum-computing-edu-next/data/circuits/deutsch.json b/quantum-computing-edu-next/data/circuits/deutsch.json index cc14a95..20573aa 100644 --- a/quantum-computing-edu-next/data/circuits/deutsch.json +++ b/quantum-computing-edu-next/data/circuits/deutsch.json @@ -16,11 +16,6 @@ } ], "operations": [ - { - "gate_id": "x", - "qubits": [1] - }, - { "gate_id": "h", "qubits": [0] @@ -31,20 +26,10 @@ }, { - "custom_gate": { - "gate_id": "Uf", - "full_name": "Deutsch Oracle", - "display_name": "Uf", - "color": "green", - "arity": 2 - }, + "gate_id": "phase-oracle", "qubits": [0,1] }, - { - "gate_id": "barrier", - "qubits": [0,1] - }, { "gate_id": "h", "qubits": [0] diff --git a/quantum-computing-edu-next/data/gates/phase-oracle.json b/quantum-computing-edu-next/data/gates/phase-oracle.json new file mode 100644 index 0000000..47d0558 --- /dev/null +++ b/quantum-computing-edu-next/data/gates/phase-oracle.json @@ -0,0 +1,8 @@ +{ + "gate_id": "phase-oracle", + "full_name": "Phase Oracle", + "display_name": "Uf", + "color": "green", + "arity": 2, + "documentation_file": "phase-oracle.mdx" +} \ No newline at end of file diff --git a/quantum-computing-edu-next/data/page-information/deutsch.mdx b/quantum-computing-edu-next/data/page-information/deutsch.mdx index 1de7345..cdd51a3 100644 --- a/quantum-computing-edu-next/data/page-information/deutsch.mdx +++ b/quantum-computing-edu-next/data/page-information/deutsch.mdx @@ -5,3 +5,118 @@ import LoadCircuit from "@/components/circuit-with-loader"; ## Algorithm Overview + +The Deutsch Algorithm offers arguably the simplest example of how quantum computers can utilise superposition to solve problems more efficiently than standard computers.
+ +### The problem: + +Given an arbitrary function, $f(x)$, that accepts a single bit as input and returns a single bit, determine whether the function is balanced or constant. +That is, whether both outputs are the same, or differ. +
+ +$$ +\text{Constant: }f(0)=f(1),\qquad\text{Balanced: } f(0) \neq f(1) +$$ + +
+With traditional computation, two queries would be required to solve this problem, simply evaluating $f(0)$ and $f(1)$ and confirming whether or not they are equal. + +For simple functions, this is trivial, however consider an arbitrary function that offers some challenge in its computation, solving this problem with a single query would certainly be beneficial. +
+ +### The solution: + +Begin with the initial state, +$$ +\ket{\pi_0}=\ket{0}\ket{1} +$$ + +After the passing through the first set of Hadamard gates, the initial state is transformed into $\ket{-}\ket{+}$ + +$$ +\ket{\pi_1}=\ket{-}\ket{+} +$$ + +Recall that +$$ +\ket{-}=\frac{1}{\sqrt{2}}(\ket{0}-\ket{1}),\qquad\ket{+}=\frac{1}{\sqrt{2}}(\ket{0}+\ket{1}). +$$ + +$$ +\therefore\ket{\pi_1}=\frac{1}{2}(\ket{0}-\ket{1})\ket{0}+\frac{1}{2}(\ket{0}-\ket{1})\ket{1}. +$$ + +Next the phase oracle is applied, since the input is in a superposition, the matrix is distributed into each of the superposition states, leaving us with a state of + +$$ +\ket{\pi_2}=\frac{1}{\sqrt{2}}(U_f\ket{0}\ket{-}+U_f\ket{1}\ket{-}) +$$ + +$$ +=\frac{1}{2}(\ket{0\oplus f(0)}-\ket{1\oplus f(0)})\ket{0}+\frac{1}{2}(\ket{0\oplus f(1)}-\ket{1\oplus f(1)})\ket{1}. +$$ + +However, recalling that +$$ +\ket{0\oplus b}-\ket{1\oplus b} += +(-1)^b(\ket{0}-\ket{1}), +$$ + +The state can be further simplified to +$$ +\ket{\pi_2}=\frac{1}{2}(\ket{0}-\ket{1})((-1)^{f(0)}\ket{0}+(-1)^{f(1)}\ket{1}) +$$ + +Before applying the final Hadamard gate to the first qubit, consider each case individually, firstly that $f$ is constant + +$$ +\implies f(0) = f(1) +$$ +$$ +\therefore (-1)^{f(0)}\ket{0}+(-1)^{f(1)}\ket{1}=\pm(\ket{0}+\ket{1})=\pm\sqrt{2}\ket{+} +$$ +Applying the final gate gives a final state of +$$ +\ket{\pi_3}=\pm\ket{0}\ket{-} +$$ +The first qubit will always be measures as a 0. + +In the other case, where $f$ is balanced +$$ +\implies f(0) = f(1) +$$ +$$ +\therefore (-1)^{f(0)}\ket{0}+(-1)^{f(1)}\ket{1}=\pm(\ket{0}-\ket{1})=\pm\sqrt{2}\ket{-} +$$ +Applying the final gate gives a final state of +$$ +\ket{\pi_3}=\pm\ket{1}\ket{-} +$$ +The first qubit will always be measures as a 1. + + +Hence, if $f$ is constant, then a 0 will be measured in the first qubit and conversely if $f$ is balanced a 1 will be measured. + +$$ +f \text{ constant} \implies \text{ first qubit is 0} +$$ +$$ +f \text{ balanced} \implies \text{ first qubit is 1} +$$ +### Solution explanation: + + +## Literature + +## Use Cases + +## Extra Information +https://www.youtube.com/watch?v=7MdEHsRZxvo + +https://www.youtube.com/watch?v=QcK0GK7DUh8 + +https://quantum.cloud.ibm.com/learning/en/courses/fundamentals-of-quantum-algorithms/quantum-query-algorithms/deutsch-algorithm +### Theoretical problems + +### Implementation problems \ No newline at end of file diff --git a/quantum-computing-edu-next/data/page-information/phase-oracle.mdx b/quantum-computing-edu-next/data/page-information/phase-oracle.mdx new file mode 100644 index 0000000..e69de29