homepage.univie.ac.at/~prevedr4/swapping-pra.pdf
entanglement swapping
http://en.wikipedia.org/wiki/Quantum_teleportation
"Although Alice and Carol never interacted with each other, their particles are now entangled."
/*
0.500000 0.499596
0.484923 0.484231
0.441511 0.441873
0.375000 0.375881
0.293412 0.292801
0.206588 0.206399
0.125000 0.125874
0.058489 0.058706
0.015077 0.015104
0.000000 0.000116
0.015077 0.015596
0.058489 0.058666
0.125000 0.125018
0.206588 0.207258
0.293412 0.293752
0.375000 0.375797
0.441511 0.441711
0.484923 0.485913
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double frandom() {return (double )(rand()%10000)/10000.0;}
double sqr(double n) {return n*n;}
int main()
{
int i,j,n=500000;
double amp1,amp2,counter=0,amp3,amp4,e,a1,a2,f1,f2,radian=M_PI/180;
for(j=0;j<180;j+=10)
{
a1=35*radian;
a2=a1+j*radian;
for(i=0;i<n;i++)
{
int o=(int)(frandom()*4);
if(o==0) f1=a1;
if(o==1) f1=a2;
if(o==2) f1=a1+M_PI/2;
if(o==3) f1=a2+M_PI/2;
amp1=sqr(cos(a1-f1));
amp2=sqr(cos(a2-f1));
if(amp1>frandom())
if(amp2>frandom())
counter++;
}
counter/=n;
printf("%f %f \n",0.5*sqr(cos(a1-a2)),counter);
}
}
/*
0: coscos: 1.764341 rndcos: 2.000000 time: 1.999680 qm: 1.999792
2: coscos: 1.774606 rndcos: 2.003830 time: 2.013945 qm: 2.013852
4: coscos: 1.808995 rndcos: 2.043348 time: 2.053251 qm: 2.058670
6: coscos: 1.860177 rndcos: 2.194100 time: 2.124515 qm: 2.121954
8: coscos: 1.934398 rndcos: 2.343363 time: 2.217131 qm: 2.211656
10: coscos: 2.026840 rndcos: 2.483678 time: 2.318277 qm: 2.324558
12: coscos: 2.154286 rndcos: 2.596969 time: 2.426289 qm: 2.433258
14: coscos: 2.298731 rndcos: 2.651904 time: 2.540324 qm: 2.541841
16: coscos: 2.439928 rndcos: 2.646289 time: 2.647895 qm: 2.657488
18: coscos: 2.568770 rndcos: 2.637119 time: 2.729894 qm: 2.736943
20: coscos: 2.651101 rndcos: 2.642091 time: 2.794881 qm: 2.803168
22: coscos: 2.674454 rndcos: 2.648914 time: 2.822810 qm: 2.824158
24: coscos: 2.675089 rndcos: 2.638483 time: 2.821858 qm: 2.810100
26: coscos: 2.603293 rndcos: 2.632903 time: 2.752856 qm: 2.762008
28: coscos: 2.502867 rndcos: 2.481346 time: 2.657021 qm: 2.660109
30: coscos: 2.352291 rndcos: 2.319259 time: 2.502547 qm: 2.497054
32: coscos: 2.168887 rndcos: 2.149921 time: 2.291414 qm: 2.294501
34: coscos: 1.945423 rndcos: 1.928039 time: 2.028045 qm: 2.033644
36: coscos: 1.686752 rndcos: 1.594489 time: 1.733787 qm: 1.740050
38: coscos: 1.371546 rndcos: 1.243032 time: 1.391123 qm: 1.393814
*/
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
//reference : google:alain aspect theorem pdf
double radian=M_PI/180.0;
int counter[16];
int qm=0;
double sqr(double n) {return n*n;}
inline double frandom() {return (double)(rand()%10000)/10000.0;}
double Ef(int s1,int s2,int s3,int s4)
{
double counter_base2=(counter[s1]+counter[s2]+counter[s3]+counter[s4]);
if(counter_base2==0) return 0;
return (double)(counter[s1]+counter[s2]-counter[s3]-counter[s4])/counter_base2;
}
int channel_a=0;
int channel_a_=0;
int channel_a2=0;
int channel_a2_=0;
int channel_b=0;
int channel_b_=0;
int channel_b2=0;
int channel_b2_=0;
void check_counters()
{
if(channel_a)
if(channel_b) counter[0]++; //++
if(channel_a_)
if(channel_b_) counter[1]++; //--
if(channel_a)
if(channel_b_) counter[2]++; //+-
if(channel_a_)
if(channel_b) counter[3]++; //-+
if(channel_a)
if(channel_b2) counter[4]++; //++
if(channel_a_)
if(channel_b2_) counter[5]++; //--
if(channel_a)
if(channel_b2_) counter[6]++; //+-
if(channel_a_)
if(channel_b2) counter[7]++; //-+
if(channel_a2)
if(channel_b) counter[8]++; //++
if(channel_a2_)
if(channel_b_) counter[9]++; //--
if(channel_a2)
if(channel_b_) counter[10]++; //+-
if(channel_a2_)
if(channel_b) counter[11]++; //-+
if(channel_a2)
if(channel_b2) counter[12]++; //++
if(channel_a2_)
if(channel_b2_) counter[13]++; //--
if(channel_a2)
if(channel_b2_) counter[14]++; //+-
if(channel_a2_)
if(channel_b2) counter[15]++; //-+
}
double S2coscos(double a,double b,double a2,double b2,int op)
{
int k;
for(k=0;k<16;k++) counter[k]=0;
for(k=0;k<500000;k++)//meres
{
double photon_polarization=frandom()*M_PI*2;
double photon_polarization2=photon_polarization;//frandom()*M_PI*2;
double probability, probability2,m1,m2;
channel_a=0;
channel_a_=0;
channel_a2=0;
channel_a2_=0;
channel_b=0;
channel_b_=0;
channel_b2=0;
channel_b2_=0;
int o1=0,o2=0;
m1=a;if(frandom()<0.5) {m1=a2;o1=1;}
m2=b;if(frandom()<0.5) {m2=b2;o2=1;}
//cos*cos
probability=sqr(cos(m1-photon_polarization)*cos(m1-photon_polarization2));
if(probability>frandom())
{
if(o1==0) channel_a=1;
else channel_a2=1;
}
else
{
m1+=M_PI/2;//ez a 3 sor csalas!
probability=sqr(cos(m1-photon_polarization)*cos(m1-photon_polarization2));
if(probability>frandom())
{
if(o1==0) channel_a_=1;
else channel_a2_=1;
}
}
probability=sqr(cos(m2-photon_polarization)*cos(m2-photon_polarization2));
if(probability>frandom())
{
if(o2==0) channel_b=1;
else channel_b2=1;
}
else
{
m2+=M_PI/2;//ez a 3 sor csalas!
probability=sqr(cos(m2-photon_polarization)*cos(m2-photon_polarization2));
if(probability>frandom())
{
if(o2==0) channel_b_=1;
else channel_b2_=1;
}
}
check_counters();
}
//ab -ab2 a2b a2b2
double N=0.0;
N=Ef(0,1,2,3);
N-=Ef(4,5,6,7);
N+=Ef(8,9,10,11);
N+=Ef(12,13,14,15);
return N;
}
double S2rndcos(double a,double b,double a2,double b2,int op)
{
int k;
for(k=0;k<16;k++) counter[k]=0;
for(k=0;k<500000;k++)//meres
{
double photon_polarization=frandom()*M_PI*2;
double photon_polarization2=frandom()*M_PI*2;
double probability, probability2,m1,m2;
channel_a=0;
channel_a_=0;
channel_a2=0;
channel_a2_=0;
channel_b=0;
channel_b_=0;
channel_b2=0;
channel_b2_=0;
int o1=0,o2=0;
m1=a;if(frandom()<0.5) {m1=a2;o1=1;}
m2=b;if(frandom()<0.5) {m2=b2;o2=1;}
//rnd = cos()
probability=sqr(cos(m1-photon_polarization));
probability2=fabs(cos(m1-photon_polarization2));
if(probability>probability2)
{
if(o1==0) channel_a=1;
else channel_a2=1;
}
else
{
m1+=M_PI/2;//ez a negy sor csalas!
probability=sqr(cos(m1-photon_polarization));
probability2=fabs(cos(m1-photon_polarization2));
if(probability>probability2)
{
if(o1==0) channel_a_=1;
else channel_a2_=1;
}
}
probability=sqr(cos(m2-photon_polarization));
probability2=fabs(cos(m2-photon_polarization2));
if(probability>probability2)
{
if(o2==0) channel_b=1;
else channel_b2=1;
}
else
{
m2+=M_PI/2;//ez a negy sor csalas!
probability=sqr(cos(m2-photon_polarization));
probability2=fabs(cos(m2-photon_polarization2));
if(probability>probability2)
{
if(o2==0) channel_b_=1;
else channel_b2_=1;
}
}
check_counters();
}
//ab -ab2 a2b a2b2
double N=0.0;
N=Ef(0,1,2,3);
N-=Ef(4,5,6,7);
N+=Ef(8,9,10,11);
N+=Ef(12,13,14,15);
return N;
}
double S2time(double a,double b,double a2,double b2,int op)
{
int k;
for(k=0;k<16;k++) counter[k]=0;
for(k=0;k<500000;k++)//meres
{
double photon_polarization=frandom()*M_PI*2;
double probability, m1,m2;
channel_a=0;
channel_a_=0;
channel_a2=0;
channel_a2_=0;
channel_b=0;
channel_b_=0;
channel_b2=0;
channel_b2_=0;
int o1=0,o2=0,o=(int)(frandom()*4);
m1=a;if(frandom()<0.5) {m1=a2;o1=1;}
m2=b;if(frandom()<0.5) {m2=b2;o2=1;}
if(o==0) photon_polarization=m1;
if(o==1) photon_polarization=m2;
if(o==2) photon_polarization=m1+M_PI/2;
if(o==3) photon_polarization=m2+M_PI/2;
probability=sqr(cos(m1-photon_polarization));
if(probability>frandom() )
{
if(o1==0) channel_a=1;
else channel_a2=1;
}
else
{
//m1+=M_PI/2;//igy tul sok, S(22)=3.22
//probability=sqr(cos(m1-photon_polarization));
//if(probability>frandom() )
{
if(o1==0) channel_a_=1;
else channel_a2_=1;
}
}
probability=sqr(cos(m2-photon_polarization));
if(probability>frandom() )
{
if(o2==0) channel_b=1;
else channel_b2=1;
}
else
{
//m2+=M_PI/2;
//probability=sqr(cos(m2-photon_polarization));
//if(probability>frandom() )
{
if(o2==0) channel_b_=1;
else channel_b2_=1;
}
}
check_counters();
}
//ab -ab2 a2b a2b2
double N=0.0;
N=Ef(0,1,2,3);
N-=Ef(4,5,6,7);
N+=Ef(8,9,10,11);
N+=Ef(12,13,14,15);
return N;
}
double S2qm(double a,double b,double a2,double b2,int op)
{
int k;
for(k=0;k<16;k++) counter[k]=0;
for(k=0;k<500000;k++)//meres
{
double photon_polarization=frandom()*M_PI*2;
double photon_polarization2=photon_polarization;
double probability, m1,m2;
channel_a=0;
channel_a_=0;
channel_a2=0;
channel_a2_=0;
channel_b=0;
channel_b_=0;
channel_b2=0;
channel_b2_=0;
int o1=0,o2=0;
m1=a;if(frandom()<0.5) {m1=a2;o1=1;}
m2=b;if(frandom()<0.5) {m2=b2;o2=1;}
//pol1-2 50% -> foton
// if(frandom()<0.5) photon_polarization=m2;
// else photon_polarization2=m1;
probability=sqr(cos(m1-photon_polarization));
if(probability>frandom() )
{
if(o1==0) channel_a=1;
else channel_a2=1;
photon_polarization2=m1;
}
else
{
m1+=M_PI/2;//!!!
//probability=sqr(cos(m1-photon_polarization));
//if(probability>frandom() )
{
if(o1==0) channel_a_=1;
else channel_a2_=1;
photon_polarization2=m1;
}
}
probability=sqr(cos(m2-photon_polarization2));
if(probability>frandom() )
{
if(o2==0) channel_b=1;
else channel_b2=1;
}
else
{
//m2+=M_PI/2;
// probability=sqr(cos(m2-photon_polarization2));
//if(probability>frandom() )
{
if(o2==0) channel_b_=1;
else channel_b2_=1;
}
}
check_counters();
}
//ab -ab2 a2b a2b2
double N=0.0;
N=Ef(0,1,2,3);
N-=Ef(4,5,6,7);
N+=Ef(8,9,10,11);
N+=Ef(12,13,14,15);
return N;
}
int main()
{
int j,k,i;
for(i=0;i<40;i+=2)
{
double S=0.0,angle=i,a,a2,b,b2;
a=0.0;
b=angle;
a2=angle*2.0;
b2=angle*3.0;
a*=radian;
b*=radian;
a2*=radian;
b2*=radian;
qm=0;
printf("%d: ",i);
S=S2coscos(a,b,a2,b2 ,0);
printf("coscos: %f ",S);
S=S2rndcos(a,b,a2,b2 ,0);
printf("rndcos: %f ",S);
S=S2time(a,b,a2,b2 ,0);
printf("time: %f ",S);
S=S2qm(a,b,a2,b2 ,0);
printf("qm: %f \n",S);
}
}