jreed wrote:
I just finished a Mathematica simulation of the two particle experiment. I used quaternions (a built in Mathematica package), which is closer to the description given by Joy in his paper. The results are equal to those of GAViewer. The code using quaternions seems to be easier to read and understand.
Joy Christian wrote:jreed wrote:
I just finished a Mathematica simulation of the two particle experiment. I used quaternions (a built in Mathematica package), which is closer to the description given by Joy in his paper. The results are equal to those of GAViewer. The code using quaternions seems to be easier to read and understand.
Thanks for doing the simulation in Mathematica. Can you post the code here? That will be useful. Also, can you please tell us which of my papers you referred to for the simulation?
***
a = Normalize@RandomVariate[NormalDistribution[], 3]
(1 0).(PauliMatrix[1]*Part[a,1]+PauliMatrix[2]*Part[a,2]+PauliMatrix[3]*Part[a,3]).(1 0)^T.
(1 0).(PauliMatrix[1]*Part[a,1]+PauliMatrix[2]*Part[a,2]+PauliMatrix[3]*Part[a,3]).(1 0)^T
(* Quaternion simulation of two level entangled state from "Quantum Correlations are Weaved by the Spinors of the Euclidean Primitives"
III B 1 *)
<<Quaternions`;
β0=Quaternion[1,0,0,0];
β1=Quaternion[0,1,0,0];
β2=Quaternion[0,0,1,0];
β3=Quaternion[0,0,0,1];
Qcoordinates={β1,β2,β3};
(* randomVector generates a random normed 3D vector in the X-Y plane *)
randomVector:=Module[{x,y,z},
x=RandomVariate[UniformDistribution[{-1,1}]];
y=RandomVariate[UniformDistribution[{-1,1}]];
z=0;
{x,y,z}={x,y,z}/Sqrt[(x^2+y^2+z^2)];
{x,y,z}]
s=0; t=0; u=0;
m=10000;
plotArray=Table[{0,0},m];
For[nn=1,nn<=m,nn+=1,
{
vectorA=randomVector;
vectorB=randomVector;
Da=vectorA.Qcoordinates;
Db=vectorB.Qcoordinates; (* Convert to quaternion coordinates *)
λ=RandomChoice[{-1,1}];
=Re[FromQuaternion[-λ Da**Da]]; (* detector *)ℬ=Re[FromQuaternion[λ Db**Db]]; (* ℬ detector *)
NA=/(-Da);
NB=ℬ/(Db);
q=0;
If[λ==1,q=NA**NB,q=NB**NA];
s=s+q;
t=t+;
u=u+ℬ;
ϕA=ArcTan[vectorA[[2]],vectorA[[1]]];
ϕB=ArcTan[vectorB[[2]],vectorB[[1]]];
angle=Abs[ϕB-ϕA]/Degree;
plotArray[[nn]]={angle,Re[q]};
};]
mean=FromQuaternion[s/m ] (*shows vanishing of the non-real part K *)
(0.00493082 +0. I)-0.00439433 K
av=t/m;
avℬ=u/m;
Print[" <> = ",av," <ℬ> = ",avℬ]
<> = -0.0036 <ℬ> = 0.0036
ListPlot[plotArray]
FrediFizzx wrote:
Here is a PDF copy of John's code showing the output at the end.
download/john_reed_prod_calc.pdf
.
Joy Christian wrote:FrediFizzx wrote:
Here is a PDF copy of John's code showing the output at the end.
download/john_reed_prod_calc.pdf
.
Beautiful!
***
FrediFizzx wrote:It is kind of hard to post Mathematica code. Yeah, using the Pauli Matrices is pretty gnarly. Here is just a very small part of what would be required.
- Code: Select all
a = Normalize@RandomVariate[NormalDistribution[], 3]
(1 0).(PauliMatrix[1]*Part[a,1]+PauliMatrix[2]*Part[a,2]+PauliMatrix[3]*Part[a,3]).(1 0)^T.
(1 0).(PauliMatrix[1]*Part[a,1]+PauliMatrix[2]*Part[a,2]+PauliMatrix[3]*Part[a,3]).(1 0)^T
a is a random uniform unit 3D vector and you have to extract its 3 parts separately. However, something is not working right because that should output a 1 and it is not.
.
ajw wrote:I don't think the function for the random vectors is quite correct (The angle should be uniformly distributed instead of the coordinates). Maybe better to take one random value between 0 and 1, multiply it by 2pi, and take sin and cos.
Of course this is a minor issue and doesn't effect the final results much.
function getRandomUnitVector() //uniform random unit vector:
//http://mathworld.wolfram.com/SpherePointPicking.html
{
v=randGaussStd()*e1+randGaussStd()*e2+ randGaussStd()*e3; //3D Vectors
return normalize(v);
ajw wrote:I don't think the function for the random vectors is quite correct (The angle should be uniformly distributed instead of the coordinates). Maybe better to take one random value between 0 and 1, multiply it by 2pi, and take sin and cos.
Of course, this is a minor issue and doesn't affect the final results much.
## Uniform random points on sphere generated using "trig method"
## (method 3) of Dave Seaman:
## http://mathforum.org/kb/message.jspa?messageID=393612
## (a) Choose z uniformly distributed in [-1,1].
## (b) Choose t uniformly distributed on [0, 2*pi).
## (c) Let r = sqrt(1-z^2).
## (d) Let x = r * cos(t).
## (e) Let y = r * sin(t).
N <- 1000
z <- runif(N, -1, 1)
t <- runif(N, 0, 2*pi)
r <- sqrt(1 - z^2)
x <- r * cos(t)
y <- r * sin(t)
library(lattice)
cloud(z ~ x+y)
gill1109 wrote:ajw wrote:I don't think the function for the random vectors is quite correct (The angle should be uniformly distributed instead of the coordinates). Maybe better to take one random value between 0 and 1, multiply it by 2pi, and take sin and cos.
Of course, this is a minor issue and doesn't affect the final results much.
Here is the smart way to pick a uniform random point on S^2. It relies on the surprising fact that the z-coordinate of such a point is uniformly distributed between -1 and +1. I showed this to Fred, Joy and others 5 years ago. See https://rpubs.com/gill1109/S2uniform. Here's the code in R:
- Code: Select all
## Uniform random points on sphere generated using "trig method"
## (method 3) of Dave Seaman:
## http://mathforum.org/kb/message.jspa?messageID=393612
## (a) Choose z uniformly distributed in [-1,1].
## (b) Choose t uniformly distributed on [0, 2*pi).
## (c) Let r = sqrt(1-z^2).
## (d) Let x = r * cos(t).
## (e) Let y = r * sin(t).
N <- 1000
z <- runif(N, -1, 1)
t <- runif(N, 0, 2*pi)
r <- sqrt(1 - z^2)
x <- r * cos(t)
y <- r * sin(t)
library(lattice)
cloud(z ~ x+y)
The Rpubs page also has a beautiful picture. I still haven't figured out how to efficiently add images to posts here.
FrediFizzx wrote:Mathematica does all that work for you in one line,
a = Normalize@RandomVariate[NormalDistribution[], 3]
Uniform random points on unit S^2 with x, y and z coordinates. Very cool. NormalDistribution is the same as a Gaussian Distribution.
You need to just put your pictures on a web server so that they have an URL then just use the Img button. Or for existing images on a web server, use View Source to find out what the URL is if you don't have Copy Link. For some reason, Copy Link doesn't show up on those R pictures.
.
FrediFizzx wrote:That is Jay's eq. (1.11) BTW with two a vectors instead of a and b.
.
Heinera wrote:FrediFizzx wrote:That is Jay's eq. (1.11) BTW with two a vectors instead of a and b.
.
Since you have the Pauli matrices there, it would be wonderful if you could also do the eqns (8) and (9) in http://www.sciphysicsforums.com/spfbb1/download/QM_with_HV_is_Local_draftv2.pdf, and then post it here.
gill1109 wrote: ...
Sage can do everything you can do in Mathematica, and more. But I haven't used it recently and don't fancy re-learning it all again, just now.
…
gill1109 wrote:I just moved the image back to where I originally wanted it.
Sage can do everything you can do in Mathematica, and more. But I haven't used it recently and don't fancy re-learning it all again, just now.
And R can do this all too, easily, there is a package for doing the quaternions
https://www.rdocumentation.org/packages/orientlib/versions/0.10.3/topics/quaternion
Sure Wolfram makes sure that lots of people stay addicted to using Mathematica
Return to Sci.Physics.Foundations
Users browsing this forum: No registered users and 72 guests