# Quantum Computing

### Understanding the Deutsch-Jozsa algorithm

Java Champion, JavaOne Rockstar, plays well with others, etc :-)

Author of several Java/JavaFX/RaspPi books

Developer Advocate & International Speaker for Pivotal

Mission: "Transform how the world builds software"

Mission: "Transform how the world builds software"

## Why use a quantum computer?

Feasible on classical computers

Feasible on quantum computers

Solutions to problems

## Deutsch's algorithm

### Determine if function is constant or balanced

Input  a Constant  f(a) Constant  f(a) Balanced  f(a) Balanced  f(a)
0 0 1 0 1
1 0 1 1 0

## Deutsch's algorithm

### How many queries of the oracle to solve?

Classical:

This oracle requires 2 queries classically

Quantum:

We create a superposition of inputs to the oracle for constructive/destructive interference.

1
$1$
2
$2$

## Querying the oracle classically


\begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \end{bmatrix} \cdot \begin{bmatrix} 0 \\ 1 \\ 0 \\ 0 \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 0 \\ 1 \end{bmatrix}
$\begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \end{bmatrix} \cdot \begin{bmatrix} 0 \\ 1 \\ 0 \\ 0 \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 0 \\ 1 \end{bmatrix}$
\vert01\rangle
$\vert01\rangle$
\vert11\rangle
$\vert11\rangle$

example: f (0) = 0 and f (1) = 1   balanced

Text

Text

## Querying the oracle quantumly


\begin{bmatrix} +\frac{1}{2} & +\frac{1}{2} & +\frac{1}{2} & +\frac{1}{2} \\ +\frac{1}{2} & -\frac{1}{2} & +\frac{1}{2} & -\frac{1}{2} \\ +\frac{1}{2} & +\frac{1}{2} & -\frac{1}{2} & -\frac{1}{2} \\ +\frac{1}{2} & -\frac{1}{2} & -\frac{1}{2} & +\frac{1}{2} \end{bmatrix} \cdot \begin{bmatrix} 0 \\ 0 \\ 1 \\ 0 \end{bmatrix} = \begin{bmatrix} +\frac{1}{2} \\ +\frac{1}{2} \\ -\frac{1}{2} \\ -\frac{1}{2} \end{bmatrix}
$\begin{bmatrix} +\frac{1}{2} & +\frac{1}{2} & +\frac{1}{2} & +\frac{1}{2} \\ +\frac{1}{2} & -\frac{1}{2} & +\frac{1}{2} & -\frac{1}{2} \\ +\frac{1}{2} & +\frac{1}{2} & -\frac{1}{2} & -\frac{1}{2} \\ +\frac{1}{2} & -\frac{1}{2} & -\frac{1}{2} & +\frac{1}{2} \end{bmatrix} \cdot \begin{bmatrix} 0 \\ 0 \\ 1 \\ 0 \end{bmatrix} = \begin{bmatrix} +\frac{1}{2} \\ +\frac{1}{2} \\ -\frac{1}{2} \\ -\frac{1}{2} \end{bmatrix}$

example: f (0) = 0 and f (1) = 1   balanced

\begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \end{bmatrix} \cdot \begin{bmatrix} +\frac{1}{2} \\ +\frac{1}{2} \\ -\frac{1}{2} \\ -\frac{1}{2} \end{bmatrix} = \begin{bmatrix} +\frac{1}{2} \\ -\frac{1}{2} \\ -\frac{1}{2} \\ +\frac{1}{2} \end{bmatrix}
$\begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \end{bmatrix} \cdot \begin{bmatrix} +\frac{1}{2} \\ +\frac{1}{2} \\ -\frac{1}{2} \\ -\frac{1}{2} \end{bmatrix} = \begin{bmatrix} +\frac{1}{2} \\ -\frac{1}{2} \\ -\frac{1}{2} \\ +\frac{1}{2} \end{bmatrix}$
\begin{bmatrix} +\frac{1}{2} & +\frac{1}{2} & +\frac{1}{2} & +\frac{1}{2} \\ +\frac{1}{2} & -\frac{1}{2} & +\frac{1}{2} & -\frac{1}{2} \\ +\frac{1}{2} & +\frac{1}{2} & -\frac{1}{2} & -\frac{1}{2} \\ +\frac{1}{2} & -\frac{1}{2} & -\frac{1}{2} & +\frac{1}{2} \end{bmatrix} \cdot \begin{bmatrix} +\frac{1}{2} \\ -\frac{1}{2} \\ -\frac{1}{2} \\ +\frac{1}{2} \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 0 \\ 1 \end{bmatrix}
$\begin{bmatrix} +\frac{1}{2} & +\frac{1}{2} & +\frac{1}{2} & +\frac{1}{2} \\ +\frac{1}{2} & -\frac{1}{2} & +\frac{1}{2} & -\frac{1}{2} \\ +\frac{1}{2} & +\frac{1}{2} & -\frac{1}{2} & -\frac{1}{2} \\ +\frac{1}{2} & -\frac{1}{2} & -\frac{1}{2} & +\frac{1}{2} \end{bmatrix} \cdot \begin{bmatrix} +\frac{1}{2} \\ -\frac{1}{2} \\ -\frac{1}{2} \\ +\frac{1}{2} \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 0 \\ 1 \end{bmatrix}$
= \begin{bmatrix} \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}} \end{bmatrix}
$= \begin{bmatrix} \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}} \end{bmatrix}$

Inp Con
0 0
1 0
Inp Con
0 1
1 1
Inp Bal
0 0
1 1
Inp Bal
0 1
1 0

## Deutsch's algorithm

### with oracle having constant function

Leverages phase-kickback from the bottom wire to choreograph constructive and destructive interference

Expected result is 100% probability of measuring

\vert0\rangle
$\vert0\rangle$

## Deutsch's algorithm

### with oracle having balanced function

Expected result is 0% probability of measuring

\vert0\rangle
$\vert0\rangle$

Leverages phase-kickback from the bottom wire to choreograph constructive and destructive interference

## Deutsch-Jozsa algorithm, 1992

### Determine if function is constant or balanced

Input Constant Constant Balanced Balanced
000 0 1 0 1
001 0 1 1 0
010 0 1 0 1
011 0 1 1 0
100 0 1 0 1
101 0 1 1 0
110 0 1 0 1
111 0 1 1 0

Results when querying our example oracle

## Deutsch-Jozsa algorithm

### How many invocations of the oracle to solve?

Classical:

Our oracle (black box) requires 5 invocations classically

Quantum:

We create a superposition of inputs to the oracle, and use the phase-kickback trick, for constructive/destructive interference.  See:

Lecture 5: A simple searching algorithm; the Deutsch-Jozsa algorithm by John Watrous, University of Calgary

2^{(n-1)}+1
$2^{(n-1)}+1$
1
$1$

(Exponentially faster!)

## Deutsch-Jozsa in web-based circuit simulator

from quantum computing community member @rasasankar

by Ravisankar from Thrissur, India

Computer Science student

TKM College of Engineering

see relevant blog post

By javafxpert

# Quantum Computing Exposed: Understanding Deutsch-Jozsa

Understanding the quantum computing Deutsch-Jozsa algorithm.

• 2,389