Skip to content
This repository has been archived by the owner on Sep 13, 2019. It is now read-only.

add deutsch-oracle example #85

Merged
merged 1 commit into from
Aug 26, 2019

Conversation

danbev
Copy link
Contributor

@danbev danbev commented Aug 24, 2019

Summary

This commit adds an example of the Deutsch-Oracle algorithm to qiskit-sim.

Details and comments

This is an initial version of adding an example of the Deutsch-Oracle algoritm. I'm looking for feedback on the format and the algorithm (to verify that I've not misunderstood anything).

The goal for this is to help people like me that are learning about quantum algorithms to have a JavaScript example to run/step through/look at. I'm also interested in hearing if this is understandable without a companion doc or more code comments.

Example output:

$ node
Welcome to Node.js v12.4.0.
Type ".help" for more information.
> const d = require('./packages/qiskit-sim/example/deutsch-oracle.js');
undefined
> d.balanced0()
        Balanced function   f(0) = 1, f(1) = 0

          column 0      column 1      column 2      column 3
wire 0 -----------------[h]-----------[uf]----------[h]-----------
                                       |
wire 1 ---[x]-----------[h]-----------[*]-------------------------

Oracle matrix (uf):
[ 0, 1, 0, 0 ]
[ 1, 0, 0, 0 ]
[ 0, 0, 1, 0 ]
[ 0, 0, 0, 1 ]

Final state:
0+0i|00>0%
0+0i|01>0%
-0.70710678+0i|10>50%
0.70710678+0i|11>50%

Show tensor state:
0  ⌈-0.7071067811865474⌉
   ⌊0.7071067811865474 ⌋
1  ⌈-0.7071067811865474⌉
   ⌊0.7071067811865474 ⌋

Measure qubit 0:
qubit[0]: |1>, Function is balanced!

This commit adds an example of the Deutsch-Oracle algorithm to
qiskit-sim.
@danbev danbev requested a review from jesusprubio August 24, 2019 05:09
@jesusprubio jesusprubio merged commit 5f1a824 into qiskit-community:master Aug 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants