![]() |
| If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|||||||
| Tags: computing, quantum, software |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Can someone recommend software (preferably free) for teaching about
quantum computing? |
| Ads |
|
#2
|
|||
|
|||
|
Adrienne wrote:
Can someone recommend software (preferably free) for teaching about quantum computing? Perl has modules so that you can create variables that display superposition or entangle variables; I believe they're called Quantum::Superposition and Quantum::Entanglement but in any case they're on CPAN. -- Frodo Morris http://users.ox.ac.uk/~wadh1342 All your bast are belong to us AKA Graham Lee, Wadham College SpectrumSofts currently on show at URL/speccy/: Speccy@Home SETI Client Also the home of iloveyou.bas, the first PC virus ported to the ZX82!!! |
|
#3
|
|||
|
|||
|
|
|
#5
|
|||
|
|||
|
|
|
#6
|
|||
|
|||
|
Adrienne wrote: Can someone recommend software (preferably free) for teaching about quantum computing? Below is a C++ program that simulates the Deutsch-Jozsa algorithm and the Quantum Zeno Effect. I've noticed differences using different languages. For instance the same program in Turbo Pascal 5.5: http://users.bestweb.net/~ca314159/zeno.pas seems to produce much better results for some reason. I don't know whether its the floating point libraries or the random number generators,... [Moderator's note: In general, we would prefer that things such as this be referenced though a URL, rather than included inline. -- KS] /* --------------------------------------------------------------------- Program: A Quantum Computer Simulator - ZENO.CPP MSDOS, Turbo C++ 3.0 Author: Notes: This simulator does the following: * Deutsch-Jozsa Problem: Determines whether a function f is balanced |1 or constant |0. Sometimes said to be equivalent to: Determining whether a coin has two different sides or not without looking at both sides. * Quantum Zeno Effect: Sends 1000 photons through a QZE and measures the number of them that were transmitted. References: Paul Kwiat's The Tao of Quantum Interrogation- The Quantum Zeno Effect: http://www.physics.uiuc.edu/People/F...ments.htm#Zeno Stanford Lectures 2003: http://feynman.stanford.edu/class/apee226/2003/ David Mermin: http://www.ccmr.cornell.edu/~mermin/qcomp/CS483.html ---------------------------------------------------------------------- */ #include iostream.h #include stdio.h #include stdlib.h #include conio.h #include math.h #include time.h // #include complex.h const intensity=100; /* the number of photons in the beam */ typedef struct { double a,b, // 2x2 operator c,d; } matrix; class Qubit { // qubit object class protected: // (extremely protected) double x,y; // 2-state (qubit) wavefunction amplitudes // more generally these are complex numbers public: Qubit (void); ~Qubit(void); void prepare(double a, double b); // prepare a qubit in a state void absorb(void); // set qubit to vacuum state | void operate(matrix m); // apply operator to qubit void peek(void); // not allowed to peek at wavefnct. double measure(void); // measure qubit state }; // -------------------------------------------------------- // global variables Qubit beam[intensity]; // beam of qubits for the QZE int i,j,k,horz,vert,stages; double z,rad,theta; matrix h,r,f; // operators Qubit dj; // single qubit for D-J // -------------------------------------------------------- // Qubit class methods Qubit::Qubit(void) { }; // constructor Qubit::~Qubit(void) { }; // destructor void Qubit: repare(double a, double b){ x=a; y=b; }; void Qubit::absorb(void) // a dead wavefunction { x=0; y=0; }; void Qubit: perate(matrix m) // apply an operator to the qubit{ double temp; temp=x*m.a + y*m.b; y=x*m.c + y*m.d; x=temp; }; void Qubit: eek(void) // peek at the wavefunction amplitudes{ cout x " " y '\n'; }; double Qubit::measure(void) { double rnd, magsqr; rnd=rand()/(double) RAND_MAX; // random number from 0..1 magsqr=pow(fabs(x),2); // cout "rnd: " rnd " mag: " magsqr "\n"; if (rnd magsqr) { x=0; y=1; return 1; // collapse the wavefunction into state |1 = |V } else { x=1; y=0; return 0; // collapse the wavefunction into state |0 = |H } }; // -------------------------------------------------------- // misc matrix operations void smult(double d, matrix* m) { m-a=m-a*d; m-b=m-b*d; m-c=m-c*d; m-d=m-d*d; } void dump(matrix m) { cout '\n'; cout m.a '\t' m.b; cout m.c '\t' m.d; cout '\n'; } // -------------------------------------------------------- // prepare the beam void initbeam(double a,double b) { for (int i=0; iintensity; i++) beam[i].prepare(a,b); } // -------------------------------------------------------- // program begins he int main() { time_t t; randomize(); srand((unsigned) time(&t)); // seed the random number generator clrscr(); rad=M_PI/180; initbeam(1,0); // prepare the beam in horizontally polaried |H == |0 stages=6; // the number of stages in the QZE theta=-90*rad/stages;// the angle of the rotators // Walsh-Hadamard h.a=1; h.b=1; h.c=1; h.d=-1; smult(1/sqrt(2), &h); // Rotation r.a=cos(theta); r.b=sin(theta); r.c=-sin(theta); r.d=cos(theta); // Reflection f.a=1; f.b=0; f.c=0; f.d=-1; //--------------------------------------------------------------------- // Deutch-Jozsa // h=rf hfh|0 = rffrf|0 (theta=-45 degrees) dj.prepare(1,0); dj.operate(h); // dj.peek(); dj.operate(f); // dj.peek(); dj.operate(h); // dj.peek(); cout "Deutch-Jozsa measurement: \n\t|" dj.measure() "\n\n"; //--------------------------------------------------------------------- // Quantum Zeno Effect: cout "Quantum Zeno Effect:\n\n"; for (k=0; kstages; k++) for (i=0; iintensity; i++) { beam[i].operate(r); // rotate theta degrees if (beam[i].measure()==1) beam[i].absorb(); // horz polarizer // Note: technically the attenuated beam array should be a linked list // and the absorbed photons should be removed. } // Count the number of horizontally polarized photons measured // by the last polarizer (analyzer). horz=0; for (i=0; iintensity; i++) if (beam[i].measure()==0) horz++; else beam[i].absorb(); cout "\tStages: " stages "\n"; cout "\tRotator Angle: " theta " radians \n"; z=horz * 100 / intensity; cout "\tTransmitted: " z '%' '\n'; z= exp(stages*log(pow(cos(rad*90/stages),2)))*100; cout "\tExpected: " z '%' '\n'; return 1; } |
|
#7
|
|||
|
|||
|
|
| Thread Tools | |
| Display Modes | |
|
|