Notation: we use an added array of amplitude and its value to capture quantum states.
Quantum state: a list of amplitude such that the squares of the amplitudes add up to one.
The above is only a subset of 2^5 possible states. Assuming other states are non-zero.
Minus sign is only meaningful when combined with plus sign in the amplitude. This is because constant factor will get normalized in amplitude. Making minus sign is equivalent to
Make M on A
: get some negative sign for variable A
@require |A> = 1|0>
def Make_M(A):
Add 1 to A // 90 degree
H on A // 22.5-(90-22.5) = -45 degree
Resulting joint state is:
We define join-state's amplitude |-\rangle or \vec{m} as:
@require |A> = 1|0>
def Make_-M(A):
Make M on A
Add 1 to A
Resulting joint state is:
Notice logical negation turned into amplitude exchanged in "Minus World".
The resulting join-state's amplitude is the following:
Note that we will see later for any quantum join state, -|v\rangle = |v\rangle
We want something beautiful like -1 instead of -\sqrt{1/2}
@require |A> = 1|0>
def Make_-1(A):
Make M on A
Add 1 to A
(Make M on A)^{-1}
@require |A> = 1|0>
def Make_-1(A):
// Make M
NOT A
H A
// Add 1
NOT A
// Unmake M
H A
NOT A
Notice the operation will be an identity if we don't do
Add 1 to A
The resulting join-state's amplitude is the following:
Or equivalently:
Note that \begin{bmatrix}-1\\0\end{bmatrix} is equivalent to \begin{bmatrix}1\\0\end{bmatrix} since we have no way to tell the difference
Ancilla: temporary variable
@require |A> = 1|0>
def Hide_f()_on_Amplitude_of(A): (If f() then Minus)
Make M on A
Add f() to A
(Make M on A)^{-1}
If we expand the function out, we get
@require |A> = 1|0>
def If f() then Minus(A):
Add 1 to A // 90 degree
H on A // -45 degree (now is parallel to NOT gate, if apply NOT now, we can't tell whether we have applied NOT)
Add f() to A // -45 degree or 90+45 degree
H on A // 90 degree or -90 degree
Add 1 to A // 0 degree or 180 degree
Result:
if f() = 1
, then we have state -1|0\rangle
if f() = 0
, then we have state +1|0\rangle
Observe no bits value printed out is changed, but only the amplitude changed.
We need to make sure f() is garbage-free, and only compute boolean function (only 1 output bit)
Some reasons sign compute:
save one more variable
negative amplitude for cancelation
cryptography
We can also build
@require |A> = 1|0>
def If_f()_then_Minus_and_Flip(A):
H on A
Add f() to A
H on A
Also even simpler
def If_(A)_then_Minus(A):
H on A
Add 1 to A
H on A
The result is: \begin{cases} 1|1\rangle \to -1|1\rangle\\ 1|0\rangle \to 1|0\rangle\\ \end{cases}
if A = 0
: then nothing happen
if A = 1
: then the amplitude is negated
Average and Displacement: an operation on two natural number
Input: (a, b)
Return: (\frac{a + b}{2}, \max(a, b) - \frac{a + b}{2})
Matrix: \begin{bmatrix} 1 & 1\\ 1 & -1\\ \end{bmatrix}
Add and Difference: an operation on two natural number
Input: (a, b)
Return: (a + b, |a - b|)
Matrix: \begin{bmatrix} \frac{1}{2} & \frac{1}{2}\\ \frac{1}{2} & -\frac{1}{2}\\ \end{bmatrix}
Observe the inverse of "Average and Displacement" is "Add and Difference".
Observe Hadamard matrix is just a scale of \sqrt{\frac{1}{2}} on 1 or scale of 2\sqrt{\frac{1}{2}} on \frac{1}{2}. In some way, the scaling merges the difference between 1 and \frac{1}{2} and making the inverse of the operation the operation itself.
By observation, since the difference is only a constant scale, we can use any "AD" operation to mimic Hadamard matrix. The result will only differ by a constant value.
Also, when we use the same number of "Add and Difference" and "Average and Displacement", then the behavior is the same if we use Hadamard matrix.
When you use this trick, you called the resulting amplitude "un-normalized quantum state"
This greatly simplifies the handling of square roots in computer programs that tries to simulate quantum behavior.
Firstly, write out the state a|xxx\rangle + b|xxx\rangle + ..., then apply the instruction on each of the amplitudes. If it has some amplitude to go to the original amplitude, multiply the amplitude in front. If it has some amplitude to go to other existing states, add a multiplied copy to that amplitude. If it has some amplitude to go to other non-existing states, add a state with multiplied copy.
When you do deterministic computation, just change what is in | \cdot \rangle
When you try to do Hadamard that only diff by one bit a|000\rangle + b|100\rangle, then the result is:
The average & displacement
and add & difference
gives us methods for fast calculation
average & displacement
, we get \frac{a+b}{2}|0\rangle + \frac{a-b}{2}|1\rangleadd & difference
, we get a+b|0\rangle + a-b|1\rangledef swap(A, B)
CNOT A B // B = A + B
CNOT B A // A = 2A + B = B
CNOT A B // B = 3A + 2B = A
Table of Content