# Visualising Special Relativity

Mathematica newbie learning by doing (or not so far, in this case).

Problem: Special Relativity - consider two inertial frames $A$ & $A'$ in relative motion. At a time $t0$ as measured in $S$, draw a sphere $S'$ of radius $b$ in the hyperplane of simultaneity of $A'$ (i.e. orthogonal to $t'$), i.e. a surface that is spherical seen in $A'$ and exists only for the "moment" $t'0$. $t'0$ is simultanous with $t0$ as seen from $A$. (I have the Lorentz transformation matrix ready; use c=1 for simplicity)

Objectives:

a) visualise $S$, the image of $S'$ as seen from $A$ as a function of time in $A$, ideally with some surface patterning (e.g. lat/long grid, colour gradients, etc.) on $S'$ that will be transformed along with $S'$ so that the appearance of the surface seen from $A$ is also meaningful (shows orientation, distortion, etc.)

b) determine analytically $tmin$ and $tmax$, the times at which the $S$ appears and disappears according to $A$ (see Expectatons below)

Expectation: I think $S$ becomes an ellipsoid that grows and shrinks betweem $tmin$ and $tmax$: since simultaneous events in $A'$ are not simultaneous in $A$ they must be at different times and continuity of the sphere implies a continuous temporal interval. I am not sure which is harder: doing 4D geometry in one's head or trying to do it by programming [Mathematica]

Polite request for explicit code, if possible: at this stage I don't think I can be relied on to read between the lines - and if you wouldn't mind explaining how it works then I would also learn two things at once.

PS: It is not difficult to plot a sphere (thanks to Kuba for an nice way of doing that), the problem is producing a description (functions?) that can be both plotted and transformed so as to preserve surface features and to get the analytical answer b) above. I have looked at many Mathematic demonstrations and code, and tried too many graphics functions to list here and explain why they didn't seem to work for me - it's a completely open question: how would you do it?

Code for generating the Lorentz matrix.

NB you may notice special case handling for v = 0 because Mma objected to 0/0 (and for v>=c returning a 0 matrix because I don't know how to throw an error)

LorentzF[v_] := Module[{l, i, j, dim, γ},
dim = Length[v] + 1;
If[NumericQ[Norm[v]] == True  && (Norm[v] == 0  || Norm[v] >= 1),
If[Norm[v] == 0,
l = Table[KroneckerDelta[i, j], {i, 1, dim}, {j, 1, dim}],
l = Table[0, {i, 1, dim}, {j, 1, dim}]],
If[dim < 2, l = {},
l = Table[0, {i, 1, dim}, {j, 1, dim}];
l[[1, 1]] = γ;
For[i = 2, i <= dim, i++,
l[[1, i]] = l[[i, 1]] = -γ v[[i - 1]]
];
For[i = 2, i <= dim, i++,
For[j = 2, j <= dim, j++,
l[[i, j]] =
l[[j, i]] = (γ - 1) v[[i - 1]] v[[j - 1]]/ v.v +
KroneckerDelta[i, j]
]
];
]
];
γ = 1/Sqrt[1 - v.v];
l
];


Bona fides

Check that -v is the inverse

Simplify[LorentzF[{bx, by, bz}].LorentzF[-{bx, by, bz}]]  // MatrixForm


Pick out the spatial part [NB, this is physically wrong, but I'm showing willing] creating something that can be used by GeometricTransformation

LorentzFSpace[{vx_, vy_, vz_}] :=  LorentzF[{vx, vy, vz}][[2 ;; 4]][[All, 2 ;; 4]]


Plot a sphere using RegionPLot

RegionPlot3D[x^2 + y^2 + z^2 < 1, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}]


Another attempt

Graphics3D[
GeometricTransformation[Sphere[], LorentzFSpace[{0.56, 0.56, 0.56}]], Axes -> True,
AxesLabel -> {x, y, z}, FaceGrids -> {{-1, 0, 0}, {0, 1, 0}, {0, 0, -1}} ]


But I can't "markup" Sphere[] or do a proper hyperplane intersection because only the presentation is being changed (and it's still the wrong transform)

Think about doing it by points and lines based upon a lat/long grid (which won't work for reasons given above) latdivs = # divisions of latitude to use, etc. NB, when I first entered the function below I used "=" instead of ":=" by mistake, which lead to a "Iterator does not have appropriate bounds" error on the inner iterator. I don't understand why that mistake had that effect.

sphereGrid4D[latdivs_, longdivs_, originpt_, radius_]  :=  Table[{originpt[[1]], originpt[[2]] + radius*sin[i 2 Pi/longdivs], originpt[[3]] + radius*cos[i 2 Pi/ longdivs], originpt[[4]] - radius*sin[j Pi /latdivs]}, {j, 0, longdivs}, {i, 0, latdivs}]


Kuba's contribution (on the question they suggested I delete, which I did)

frame = Chop@First@ParametricPlot3D[{Sin[u] Sin[v], Cos[u] Sin[v], Cos[v]}, {u, 0, 2 Pi}, {v, -Pi, Pi}, Axes -> None, PlotStyle -> None, PlotPoints -> 10];

Graphics3D[{frame, GeometricTransformation[frame, {{{2, 0, 0}, {0, 2, 0}, {0, 0, 2}}, {5, 5, 0}}]}]


(and I still don't understand the Chop@First@ part)

Last comment for tonight (Spanish time)

Actually, I may have solved the $tmin$, $tmax$ problem, but I'd like to see the pictures to confirm!

Idea: consider the sphere as define by the dot product of the vector p (I think I swapped my frames around, but it doesn't really matter) transform the vector back to the other frame and solve (my copy/paste may be screwed up and it's late, but I hope you get the idea)

v = {vx, vy, vz}; (* assign velocity components *)
sphere[p_] := Sum[p[[i]]^2, {i, 1, Length[p]}]; (* define a sphere by magnitude of p*)
p0 = {t0, 0, 0, 0};
s = Simplify[sphere[LorentzF[-v].p0]];
solns = Solve[s == b, t0]; Simplify[solns]


Getting: (sorry, don't know how to do this nicely)

{{t0 -> -(Sqrt[b]/Sqrt[-((1 + vx^2 + vy^2 + vz^2)/(-1 + vx^2 + vy^2 + vz^2))])}, {t0 -> Sqrt[b]/Sqrt[-((1 + vx^2 + vy^2 + vz^2)/(-1 + vx^2 + vy^2 + vz^2))]}}


which seemed OK (too) late last night, but now doesn't. Hence my confusions

It would have been nice if I could have found a way to create a substitution V^2=vx^2+vy^2+vz^2 but V^2 can't be a symbol (?)

-
You're going to need to post code showing some minimal attempt(s) at this, in general this is not a internet-based code-for-free sweatshop... –  rasher Mar 9 at 22:57
I've spent two full days at this so far; I will gladly share the failure in further detail tomorrow. I thought I was being considerate by omitting my garbage! –  Julian Moore Mar 9 at 23:10
You might want to ask on physics.SE how to represent this, since you seem to be unsure whether you want an ellipsoid or how the sphere is deformed. If I knew what you wanted Mma to draw, I'm pretty sure someone here could help you do that. –  Michael E2 Mar 9 at 23:25
@Michael, I may try that too, but it's not a question of whether I "want" an ellipsoid, I'd like to confirm (or refute) my intuition; this is just one part of a much bigger question and I'm happy with the SR theory it's how to handle the equations effectively in Mma I'm really struggling with. To be brief, of course in A the sphere is going to appear contracted along the direction of motion (and not perpendicular to it), it's the temporal aspect that is of greater interest at the moment - and I would lik to produce some robust figures for an outline of a paper. –  Julian Moore Mar 9 at 23:36
@JulianMoore take a look at structure of graphics to see why there is First. Chop is not necessary, it only makes 10^-17 be 0 etc. –  Kuba Mar 10 at 8:36