James L. Weaver

jweaver@pivotal.io
JavaFXpert.com

@JavaFXpert

Dr. Johan Vos
Co-founder & CTO

johan.vos@gluonhq.com
gluonhq.com

# Quantum Computing

### Hacking into Nature's Computer

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"

### About Presenter Dr. Johan Vos

Developer / Physicist / Writer / Speaker -  Gluon

Introduction to quantum computing

Axioms of quantum mechanics (with cats)

• Superposition principle
• Measurement
• Unitary evolution

Abstracting cats with qubits

Quantum computing gates and circuits

Java and quantum computing

## History repeating itself

### massive hardware, limited bits, software infancy

Quantum computers make direct use of quantum-mechanical phenomena, such as superposition and entanglement, to perform operations on data.

## Some QC proofs of concept

University of Sussex

Professor Winfried Hensinger spoke at Devoxx/UK

Don't try this at home, kids!

## Why use a quantum computer?

Feasible on classical computers

Feasible on quantum computers

Solutions to problems

## Breaking RSA crypto

### someday maybe, using Shor's algorithm

“If you start factoring 10-digit numbers then it’s going to start getting scary”

Dr. Peter Shor, 2013

Related paper published 25 Jan 1997 by Dr. Shor:

Note: Shor's algorithm was formulated in 1994

## Quickly searching unsorted data

### using Grover's algorithm

"Programming a quantum computer is particularly interesting since there are multiple things happening in the same hardware simultaneously.  One needs to think like both a theoretical physicist and a computer scientist."

Dr. Lov Grover, 2002

Related paper published 17 Jul 1997 by Dr. Grover:

## Simulating nature

### complex chemical reactions, for example

“Nature isn't classical, dammit, and if you want to make a simulation of nature, you'd better make it quantum mechanical, and by golly it's a wonderful problem, because it doesn't look so easy.”

Dr. Richard Feynman, 1981

## Machine learning

### estimating gradients using quantum computing

Introduction to quantum computing

Axioms of quantum mechanics (with cats)

• Superposition principle
• Measurement
• Unitary evolution

Abstracting cats with qubits

Quantum computing gates and circuits

Java and quantum computing

## Axioms of Quantum Mechanics

\vert\space\space\space\rangle
$\vert\space\space\space\rangle$

## My microscopic cat is often grumpy

\vert\space\space\space\rangle
$\vert\space\space\space\rangle$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$

## Axiom 1: Superposition principle

### my cat can be in any combination of grumpy and happy

\vert\space\space\space\rangle
$\vert\space\space\space\rangle$
= \begin{bmatrix} 1 \\ 0 \end{bmatrix}
$= \begin{bmatrix} 1 \\ 0 \end{bmatrix}$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$
= \begin{bmatrix} 0 \\ 1 \end{bmatrix}
$= \begin{bmatrix} 0 \\ 1 \end{bmatrix}$
= \begin{bmatrix} \sqrt{\frac{1}{3}} \\ \sqrt{\frac{2}{3}} \end{bmatrix}
$= \begin{bmatrix} \sqrt{\frac{1}{3}} \\ \sqrt{\frac{2}{3}} \end{bmatrix}$
\sqrt{\frac{1}{3}}
$\sqrt{\frac{1}{3}}$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$
+
$+$
\sqrt{\frac{2}{3}}
$\sqrt{\frac{2}{3}}$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$

## Representing quantum states

### geometrically, ket notation, and vectors

\vert\space\space\space\space\rangle
$\vert\space\space\space\space\rangle$
\vert\space\space\space\space\rangle
$\vert\space\space\space\space\rangle$
\vert\space\space\space\space\rangle
$\vert\space\space\space\space\rangle$
\vert\space\space\space\space\rangle
$\vert\space\space\space\space\rangle$
\vert\space\space\space\space\rangle
$\vert\space\space\space\space\rangle$
\vert\space\space\space\space\rangle
$\vert\space\space\space\space\rangle$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$

## Axiom 2: Unitary evolution

### gates modeled as matrices

X

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

NOT gate (Pauli/X, bit-flip)

\vert\space\space\space\rangle
$\vert\space\space\space\rangle$

### great for putting cats in equal superpositions

H

\begin{bmatrix} \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}} \end{bmatrix} \cdot \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} \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} \cdot \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{bmatrix}$

\sqrt{\frac{1}{2}}
$\sqrt{\frac{1}{2}}$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$
+
$+$
\sqrt{\frac{1}{2}}
$\sqrt{\frac{1}{2}}$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$
\sqrt{\frac{1}{3}}
$\sqrt{\frac{1}{3}}$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$
+
$+$
\sqrt{\frac{2}{3}}
$\sqrt{\frac{2}{3}}$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$

## Axiom 3: Measurement

### probability is amplitude squared

When observed there is a:

\frac{1}{3}
$\frac{1}{3}$
\frac{2}{3}
$\frac{2}{3}$

probability of being grumpy

probability of being happy

## Multiple cats

\vert\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$
=
$=$
\vert\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\rangle$
= \begin{bmatrix} 1 \\ 0 \end{bmatrix}
$= \begin{bmatrix} 1 \\ 0 \end{bmatrix}$
\otimes \begin{bmatrix} 1 \\ 0 \end{bmatrix}
$\otimes \begin{bmatrix} 1 \\ 0 \end{bmatrix}$

### Composite quantum states

= \begin{bmatrix} 1 \\ \\ \\ \end{bmatrix}
$= \begin{bmatrix} 1 \\ \\ \\ \end{bmatrix}$
= \begin{bmatrix} 1 \\ 0 \\ \\ \end{bmatrix}
$= \begin{bmatrix} 1 \\ 0 \\ \\ \end{bmatrix}$
= \begin{bmatrix} 1 \\ 0 \\ 0 \\ \end{bmatrix}
$= \begin{bmatrix} 1 \\ 0 \\ 0 \\ \end{bmatrix}$
= \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix}
$= \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix}$

## Multiple cats

\vert\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$
=
$=$
= \begin{bmatrix} 0 \\ 1 \\ 0 \\ 0 \end{bmatrix}
$= \begin{bmatrix} 0 \\ 1 \\ 0 \\ 0 \end{bmatrix}$
= \begin{bmatrix} 1 \\ 0 \end{bmatrix}
$= \begin{bmatrix} 1 \\ 0 \end{bmatrix}$
\otimes \begin{bmatrix} 0 \\ 1 \end{bmatrix}
$\otimes \begin{bmatrix} 0 \\ 1 \end{bmatrix}$

### Composite quantum states

\vert\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\rangle$

## Multiple cats

\vert\space\space\space\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$
=
$=$
= \begin{bmatrix} 0 \\ 0 \\ 0 \\ 1 \\ 0 \\ 0 \\ 0 \\ 0 \end{bmatrix}
$= \begin{bmatrix} 0 \\ 0 \\ 0 \\ 1 \\ 0 \\ 0 \\ 0 \\ 0 \end{bmatrix}$
= \begin{bmatrix} 1 \\ 0 \end{bmatrix}
$= \begin{bmatrix} 1 \\ 0 \end{bmatrix}$
\otimes \begin{bmatrix} 0 \\ 1 \end{bmatrix}
$\otimes \begin{bmatrix} 0 \\ 1 \end{bmatrix}$

### Composite quantum states

\vert\space\space\space\rangle
$\vert\space\space\space\rangle$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$
\otimes \begin{bmatrix} 0 \\ 1 \end{bmatrix}
$\otimes \begin{bmatrix} 0 \\ 1 \end{bmatrix}$
\vert\space\space\space\space\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\space\space\space\space\rangle$
\sqrt{\frac{1}{2}}
$\sqrt{\frac{1}{2}}$
+
$+$

## Superpositions, evolution & measurement

### putting the three axioms together

\vert\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\rangle$
\sqrt{\frac{1}{2}}
$\sqrt{\frac{1}{2}}$
\sqrt{\frac{1}{2}}
$\sqrt{\frac{1}{2}}$
+
$+$
\vert\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\rangle$
\sqrt{\frac{1}{6}}
$\sqrt{\frac{1}{6}}$
+
$+$
\vert\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\rangle$
\sqrt{\frac{1}{3}}
$\sqrt{\frac{1}{3}}$
\vert\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\rangle$

quantum gates

quantum gates

measure

\downarrow
$\downarrow$
\downarrow
$\downarrow$
\downarrow
$\downarrow$
\vert\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\rangle$

with 1/2 probability

with 1/6 probability

with 1/3 probability

\vert\space\space\space\rangle
$\vert\space\space\space\rangle$

## Quantum entanglement

### spooky actions at a distance

H

\vert\space\space\space\rangle
$\vert\space\space\space\rangle$

CNOT gate

\sqrt{\frac{1}{2}}
$\sqrt{\frac{1}{2}}$
+
$+$
\vert\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\rangle$
\sqrt{\frac{1}{2}}
$\sqrt{\frac{1}{2}}$
\sqrt{\frac{1}{2}}
$\sqrt{\frac{1}{2}}$
+
$+$
\vert\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\rangle$
\sqrt{\frac{1}{2}}
$\sqrt{\frac{1}{2}}$

Mars - ESA

Alice Cat

Bob Cat

Venus - NASA

\vert\space\space\rangle
$\vert\space\space\rangle$
=
$=$

Introduction to quantum computing

Axioms of quantum mechanics (with cats)

• Superposition principle
• Measurement
• Unitary evolution

Abstracting cats with qubits

Quantum computing gates and circuits

Java and quantum computing

## Hardware representation of qubits

Physical support Type
Microscopic cats Mood Grumpy Happy
Photon Polarization Horizontal Vertical
Electrons Spin Up Down
Superconductor Energy levels Ground Excited
\vert0\rangle
$\vert0\rangle$
\vert1\rangle
$\vert1\rangle$

## Superconducting qubits on a chip

Introduction to quantum computing

Axioms of quantum mechanics (with cats)

• Superposition principle
• Measurement
• Unitary evolution

Abstracting cats with qubits

Quantum computing gates and circuits

Java and quantum computing

## Quantum software development

• Classic computing -> classic algorithms (classic gates)
• Quantum computing -> quantum algorithms (quantum gates)
• Operations on a single qubit may affect other qubits
• Qubits can in different states at the same moment

## Quantum software development

• In many cases, the best approach to a problem is a combination of classic algorithms and quantum algorithms
• Quantum algorithms leverage quantum gates, taking into account entanglement

## Shor’s algorithm

• “IT WILL BREAK ALL ENCRYPTION”
• It allows faster integer factorization (52 = 2 * 2 * 13)
• quantum: polynomial time
• classic: sub-exponential time
• The problem is decomposed in a number of steps, including finding the periodicity of a function f(x) = f(x + r)
• This problem can relatively fast be solved using a quantum algorithm

## Multiple cats

\vert\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$
\vert\space\space\space\rangle
$\vert\space\space\space\rangle$
=
$=$
\vert\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\rangle$
\vert\space\space\space\space\space\space\space\space\rangle
$\vert\space\space\space\space\space\space\space\space\rangle$
= \begin{bmatrix} 1 \\ 0 \end{bmatrix}
$= \begin{bmatrix} 1 \\ 0 \end{bmatrix}$
\otimes \begin{bmatrix} 1 \\ 0 \end{bmatrix}
$\otimes \begin{bmatrix} 1 \\ 0 \end{bmatrix}$

### Composite quantum states

= \begin{bmatrix} 1 \\ \\ \\ \end{bmatrix}
$= \begin{bmatrix} 1 \\ \\ \\ \end{bmatrix}$
= \begin{bmatrix} 1 \\ 0 \\ \\ \end{bmatrix}
$= \begin{bmatrix} 1 \\ 0 \\ \\ \end{bmatrix}$
= \begin{bmatrix} 1 \\ 0 \\ 0 \\ \end{bmatrix}
$= \begin{bmatrix} 1 \\ 0 \\ 0 \\ \end{bmatrix}$
= \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix}
$= \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix}$

## Measuring quantum state

### a Java analogy

Introduction to quantum computing

Axioms of quantum mechanics (with cats)

• Superposition principle
• Measurement
• Unitary evolution

Abstracting cats with qubits

Quantum computing gates and circuits

Java and quantum computing

## Quantum Computer simulators

• With some matrix algebra, a quantum computer can be simulated by a classic computer
• This requires heaps of memory, increasing with increasing number of qubits
• Cloud-based quantum simulators can deal with more qubits
• Different languages:

## StrangeFX

### Java-based quantum simulator by Gluon / Johan Vos

James L. Weaver

jweaver@pivotal.io
JavaFXpert.com

@JavaFXpert

Dr. Johan Vos
Co-founder & CTO

johan.vos@gluonhq.com
gluonhq.com

# Quantum Computing

By javafxpert

### Quantum Computing Exposed: Hacking Nature's Computer

Gentle introduction to quantum computing by James Weaver and Dr. Johan Vos

• 516