GithubHelp home page GithubHelp logo

deutsch-josza's Introduction

Deutsch-Josza Quantum Algorithm Simulation

dj is a Matlab function that simulates the Deutsch-Josza quantum algorithm. quarter_dj can simulate the algorithm for 3/4-balanced functions.

Usage

These functions have the following syntax:

dj(n, f)
quarter_dj(n, f)

To use these functions in the Matlab prompt, simply run Matlab in the same directory, and then call these functions.

>> dj(5, @(x) 1)

ans =

CONST

In this example, we applied the constant function to the algorithm. We put n=5 so the function must return 0 or 1 for any input in 0,...,2^5 - 1. For this function that always return 1, the algorithm detected that f was constant. Here is another example that f is balanced.

>> dj(8, @(x) rem(x, 2))

ans =

BALANCED

The function

@(x) rem(x, 2)

is balanced because it returns 1 if x is odd, and it return 0 if x is even.

for 3/4-balanced functions

quarter_dj can be used exactly the same as dj.

>> quarter_dj(5, @(x) 0)

ans =

CONST

We prepared quarter_balanced function that simulates a 3/4-balanced function.

>> quarter_dj(5, @quarter_balanced)

ans =

BALANCED

Since it has error rate 1/4, it sometimes output CONST for 3/4-balanced functions.

>> quarter_dj(5, @quarter_balanced)

ans =

CONST

deutsch-josza's People

Contributors

usami avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.