Giter Club home page Giter Club logo

quantumparenthesis's Introduction

QuantumParenthesis

A lispy quantum language experiment

Dependencies:

  • Python 3
  • Numpy

How to use:

Running qsch2.py launches a repl (read-eval-print loop) for the language that will interpret any expression given to it

qsch> (+ 2 2)
4

Vectors are represented by lists and operators/matrices by lists of lists.

For example, let's create a state of two qubits |01>, apply flip to the second one and measure them:

qsch> (define state (tensor (list 1 0) (list 0 1)))  ;our state is the tensor product of |0> and |1>

qsch> (define id (list     			     ;define identity and flip matrices
		  (list 1 0)
		  (list 0 1)))

qsch> (define flip (list
		    (list 0 1)
		    (list 1 0)))

qsch> (measure (apply (tensor id flip) state))       ;apply the tensor product ID (x) FLIP to our state (essentialy flipping the second bit) and measure
Probability of state 0 is 1.0
Probability of state 1 is 0.0
Probability of state 2 is 0.0
Probability of state 3 is 0.0
System collapsed to state: 0
0

As we can see, after our measurment we will always observe the state |00>.

Definitions can also be written on a seperate file which can be then loaded at repl

For example let's load deutsch.qsch (.qsch files are just plaintext files with a .qsch extension! You can edit them in any text editor)

qsch> (load "deutsch.qsch") 			     ;general syntax : (load "filename")

qsch> hadamard 					     ;invoking an operator defined in deutsch.qsch works as expected
(((0.7071067811865475+0i) (0.7071067811865475+0i)) 
((0.7071067811865475+0i) (-0.7071067811865475+0i)))

quantumparenthesis's People

Contributors

wintershammer avatar

Watchers

 avatar  avatar  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.