Polychorons are the 4D version of polyhedrons. One way to visualize a polychoron is to apply a 4D to 3D stereographic projection to it. A dodecaplex is a uniform 4D polychoron composed 120 dodecahedral cells. These cells can be divided into 12 rings (Hopf fibrations) of 10 cells each. This picture shows a stereographic projection of 6 rings of the dodecaplex. Each ring is shown in a different color, but only 5 rings are open to direct view because they are wrapped around the 6th ring. I first saw this concept on Matthias Weber'sbook page. Click here to download some POV-Ray code.
The Hopf map is a special transformation invented by Heinz Hopf that maps to each point on the ordinary 3D sphere from a unique circle of points on the 4D sphere. Taken together, these circles form a fiber bundle called a Hopf Fibration. If you apply a 4D to 3D stereographic projection to the Hopf Fibration, you get a beautiful 3D torus called a Clifford Torus composed of interlinked Villarceau circles. By applying 4D rotations to the Hopf Fibration, you can transform the Clifford Torus into a Dupin cyclide or you can turn it inside-out. Click here to download some POV-Ray code. The right picture shows a complex cubic polynomial. Here is some Mathematica code:
(* runtime: 7 seconds *)
HopfInverse[theta_, phi_, psi_] := {Cos[phi/2] Cos[psi], Cos[phi/2]Sin[psi], Cos[theta + psi]Sin[phi/2], Sin[theta + psi]Sin[phi/2]};
Ryw[theta_] := {{1, 0, 0, 0}, {0, Cos[theta], 0, Sin[theta]}, {0, 0, 1, 0}, {0, -Sin[theta], 0, Cos[theta]}};
StereographicProjection[{x_, y_, z_, w_}] := {x, y, z}/(1 - w);
Table[Show[Graphics3D[Table[{Hue[(4 phi/Pi - 1)/3],Table[Line[Table[StereographicProjection[Ryw[alpha].HopfInverse[theta, phi, psi]], {psi, 0.0, 2Pi, Pi/18}]], {theta, 0.0, 2 Pi,Pi/9}]}, {phi, Pi/4, 3Pi/4, Pi/4}], PlotRange -> 3{{-1, 1}, {-1, 1}, {-1, 1}}]], {alpha, 0, Pi, Pi/18}];
One way to create a double spiral is by applying a light projection from the top of a Riemann sphere (loxodrome) onto a plane. This type of projection is called a stereographic projection. Click here to download a Mathematica notebook. Here is some Mathematica code:
(* runtime: 3 seconds *)
<< Graphics`Shapes`; a = 0.25; Rx[phi_] := {{1, 0, 0}, {0, Cos[phi], -Sin[phi]}, {0, Sin[phi], Cos[phi]}};
Do[loxodrome = Table[Rx[phi].{Sin[t], -a t, -Cos[t]}/Sqrt[1 + (a t)^2], {t, -100, 100, 0.1}]; projection = Map[Module[{r = 2/(1 - #[[3]])}, {r #[[1]],r #[[2]], -1}] &, loxodrome]; Show[Graphics3D[{EdgeForm[], Sphere[0.99, 37, 19], Polygon[{{4, 4, -1}, {-4, 4, -1}, {-4, -4, -1}, {4, -4, -1}}],Line[loxodrome], Line[projection]},PlotRange -> {{-4, 4}, {-4, 4}, {-1, 1}}]], {phi, 0, Pi -Pi/12, Pi/12}]
Another kind of double spiral can be made by applying a special homography to a single logarithmic spiral:
(* runtime: 0.05 second *)
Show[Graphics[Table[Line[Table[z = Exp[r + (2 r + theta)I]; z = (1 + z)/(1 - z); {Re[z], Im[z]}, {r, -10, 10, 0.1}]], {theta, -Pi, Pi, Pi/3}], PlotRange -> {{-2, 2}, {-2, 2}}, AspectRatio -> Automatic]]
Here is some Mathematica code that uses the inverse method:
(* runtime: 17 seconds *)
Show[Graphics[RasterArray[Table[r1 = (x - 1)^2 + y^2; r2 = (x + 1)^2 + y^2; Hue[(Sign[y]ArcCos[(x^2 + y^2 - 1)/Sqrt[r1 r2]] -Log[r1/r2])/(2Pi)], {x, -2, 2, 4/274}, {y, -2, 2, 4/274}]], AspectRatio -> 1]] and here is some POV-Ray code:
// runtime: 2 seconds
camera{orthographic location <0,0,-2> look_at 0 angle 90}
#declare r1=function(x,y) {(x-1)*(x-1)+y*y}; #declare r2=function(x,y) {(x+1)*(x+1)+y*y};
#declare f=function{(y/abs(y)*acos((x*x+y*y-1)/sqrt(r1(x,y)*r2(x,y)))-ln(r1(x,y)/r2(x,y)))/(2*pi)};
plane{z,0 pigment{function{f(x,y,0)}} finish{ambient 1}}
This one-sided surface was first parametrized correctly by Bernard Morin. The animation looks like it’s turning inside-out, although technically that’s impossible because it only has one side! Robert Bryant told me that the parameters (p,q) = (0,1) give this Willmore immersion of RP2 a trilateral symmetry. The parameters (p,q) = (1,0) should give bilateral symmetry. Click here to download some POV-Ray code for this image. Here is some Mathematica code:
(* runtime: 1 second *)
ParametricPlot3D[Module[{z = r E^(I theta), a, m}, a = z^6 + Sqrt[5]z^3 - 1; m = {Im[z(z^4 - 1)/a], Re[z(z^4 + 1)/a], Im[(2/3) (z^6 + 1)/a] + 0.5}; Append[m/(m.m), SurfaceColor[Hue[r]]]], {r, 0, 1}, {theta, -Pi, Pi}, PlotPoints -> {20, 72}, ViewPoint -> {0, 0, 1}]
POV-Ray also has an internal function for a different parametrization:
// runtime: 50 seconds
camera{location -1.5*z look_at 0} light_source{-z,1}
#declare f=function{internal(8)} isosurface{function{-f(x,y,z,1e-4,1)} pigment{rgb 1}}
A sphere is an elliptic surface with constant positive curvature. A pseudosphere is a hyperbolic surface with constant negative curvature. This pseudosphere is called a Breather. Click here to download some POV-Ray code for this image. You can also see this image described as an "Imploding Flower" on Chewxy's Math Art website. Here is some Mathematica code:
(* runtime: 6 seconds *)
a = 0.498888; vmax = 47.1232; w = Sqrt[1 - a^2];
Breather[u_, v_] := Module[{d = a((w Cosh[a u])^2 + (a Sin[w v])^2)}, x = -u + 2w^2 Cosh[a u]Sinh[a u]/d; y = 2w Cosh[a u](-w Cos[v]Cos[w v] - Sin[v]Sin[w v])/d; z = 2w Cosh[a u](-w Sin[v]Cos[w v] +Cos[v]Sin[w v])/d; {x, y, z, {EdgeForm[], SurfaceColor[Hue[v/vmax]]}}];
ParametricPlot3D[Breather[u, v], {u, -10, 10}, {v, 0, vmax}, PlotPoints -> {49, 79}, Compiled -> False]
Here is my attempt to recreate a similar-looking structure to Bathsheba Grossman’s beautiful Quin Pendant Lamp. The topology is equivilent to a sphere with 30 holes. The boundary of each hole loops over itself twice with two Reidemeister-I twists and links with 6 others. I’m still not sure what the linking number of this 30-component knot is (let me know if you find out). In terms of symmetry, it can by described as:
a rhombic triacontahedron with a hole over each face (the arms trace a graph isomorphic to the edge graph)
Special thanks to Jonathan Schneider for pointing out these interesting observations to me.
The animation shows a homotopy that continuously maps the structure to a sphere with 30 holes. Here is some Mathematica code:
A dodecahedron is a polyhedron with 12 pentagonal faces. This dodecahedron uses spheres for each face. Here is some POV-Ray code for the hyperbolic dodecahedron. See also my expanding dodecahedron.
<< Graphics`Polyhedra`; Show[Graphics3D[Polyhedron[Dodecahedron][[1]]]]
This is what the dodecahedron would look like viewed from the inside with spherical mirrored walls. At certain dihedral angles, this resembles a Poincaré projection of 3D hyperbolic space tiled with ideal dodecahedrons. Notice that when the space becomes elliptic, a black “hole” opens up in the center. This is because the space loops around on itself causing objects beyond the “maximum distance” to appear larger because they are actually closer. Weird huh?
The area inside this circle represents a hyperbolic plane filled with “ideal triangles”. Notice that all the angles inside these triangles go to zero at the edge of the circle. This image was generated using a series of reflections called anti-homographies. I learned about homographies while participating at the Experimental Geometry Lab at the University of Maryland. The right animation shows how a single homography can transform the upper half plane into the Poincaré disk. See also my POV-Ray code, Mathematica code, homography test, and circle inversion.
This “hyperbolic beach ball” and hyperboloid were ray traced and textured using inverse transformations (the “pull back” method). Click here to download the complete Mathematica notebook for this image. Also, here is a C++ version for this image.
This rose is actually a plot of a single continuous math equation. Click here to see a larger animation. Click here to see a rotatable 3D version. Click here to download some POV-Ray code for this image. You can also see this on Abdessemed Ali’s web site. See also my Passion Flower. Here is some Mathematica code:
(* runtime: 16 seconds *)
Rose[x_, theta_] := Module[{phi = (Pi/2)Exp[-theta/(8 Pi)], X = 1 - (1/2)((5/4)(1 - Mod[3.6 theta, 2 Pi]/Pi)^2 - 1/4)^2}, y = 1.95653 x^2 (1.27689 x - 1)^2 Sin[phi]; r = X(x Sin[phi] + y Cos[phi]); {r Sin[theta], r Cos[theta], X(x Cos[phi] - y Sin[phi]), EdgeForm[]}];
ParametricPlot3D[Rose[x, theta], {x, 0, 1}, {theta, -2 Pi, 15 Pi}, PlotPoints -> {25, 576}, LightSources -> {{{0, 0, 1}, RGBColor[1, 0, 0]}}, Compiled -> False]
This surface can be formed by twisting Scherk’s Minimal Surface. This one came out a little lumpy. Brent Collins has some nicer-looking surfaces. Click here to download some POV-Ray code for this image. Here is some Mathematica code:
(* runtime: 0.7 second *)
n = 7; r = Pi; R = 2Pi;
Twist[{x_, y_}, theta_] := {x Cos[theta] - y Sin[theta], x Sin[theta] + y Cos[theta]};
Warp[{x_, y_}, theta_] := {(x + R) Cos[theta], y, (x + R) Sin[theta]};
f[z_, i_] := Module[{x = Max[-r, Min[r, Re[2(Log[1 + z] - Log[1 - z])]]], y = Max[-r, Min[r, Re[4I ArcTan[z]]]],z1 = Re[2Pi i + (1 - 2Mod[i, 2]) 2I (Log[1 + z^2] - Log[1 - z^2])]}, Warp[Twist[{x, y}, z1/(n + 1)], z1/(n + 1)]];
Show[Table[ParametricPlot3D[f[r1 E^(I theta), i], {theta, 0, 2Pi}, {r1, 0, 1}, PlotPoints -> {25, 7}, Compiled -> False], {i, 0, n}]]
A tessellation is a regular tiling of figures without any gaps or overlapping. If you have access to AutoCAD, you can use this AutoLisp routine to help you design your own tessellations.
I modelled this tessellation after “Spirit” from Disney’s “Spirit - Stallion of Cimarron” movie. I had to overlap the horse’s hind legs because there was not enough room. Still, I think the rest of it fits together remarkably well.
This 3D vortex image is hidden in the above picture. To see it, relax your eyes and focus behind the screen. This autostereogram was generated with William Steer’s free autostereogram generating program SISgen. Click here to see an animated version of this picture. I also have a Mathematica-only version of this picture, but it is not as accurate. See also Pascal Massimino’s“Maelstrom” autostereogram.
The left image shows 12,629 pictures from my computer's hard drive. The right image shows what you get when you average them all together and increase the contrast (the result looks uniformly gray if you don't increase the contrast).
A Moiré pattern is the interference of two similar overlapping patterns. Here is the Moiré pattern on a twisted IKEA wastepaper basket. The mesh on the wastepaper basket was ray-traced from 100,000 tiny cylinders. Here is some Mathematica code to plot Moiré contours around radiating lines:
(* runtime: 1.7 seconds *)
f[dx_] := Sin[200ArcTan[x - dx, y]];
DensityPlot[f[0.1] - f[-0.1], {x, -1, 1}, {y, -1, 1}, PlotRange -> {0, 1}, PlotPoints -> 275, Mesh -> False, Frame -> False]
Here is some Mathematica code to plot a Moiré pattern from rapidly varying contours of a function:
(* runtime: 0.8 second *)
f[z_] := z^3; DensityPlot[Sin[20Pi Abs[f[x + I y]]], {x, -2.5, 2.5}, {y, -2.5, 2.5}, PlotPoints -> 275, Mesh -> False, Frame -> False]
This is an example of a minimal surface. If you dipped this wire in a soap solution, the resulting soap film would be shaped like this (ideally). Click here to download some POV-Ray code for this image. Here is some Mathematica code for the Second Enneper surface:
(* runtime: 0.5 second *)
ParametricPlot3D[{r Cos[phi] - r^5Cos[5phi]/5, r Sin[phi] + r^5Sin[5phi]/5, 2r^3Cos[3phi]/3, EdgeForm[]}, {phi, 0, 2Pi}, {r, 0, 1.3}, PlotPoints -> {181, 20}, ViewPoint -> {0, 0, 1}, PlotRange -> All]
Click here to download some POV-Ray code for this image. You can also make hyperboloids quickly in POV-Ray using the quadric command:
camera{location <0,10,0> look_at <0,0,0>}
light_source{<0,10,0>,1}
quadric{<1,1,-1>,<0,0,0>,<0,0,0>,1 pigment{rgb 1}}
Here is an amazing technique for focusing a blurry image. In order for this technique to work, the exact blurring function must be known. This technique can also be used for generating beautiful periodic textures. Here is some Mathematica code:
(* runtime: 50 seconds *)
image = Import["C:/GrayPicture.jpg"][[1, 1]]; n = Length[image];
dx = 2.0/n; blurfunction = Fourier[Table[Exp[-(x^2 + y^2)/0.01^2], {y, -1, 1 - dx, dx}, {x, -1, 1 - dx, dx}]]^2;
blurryimage = Re[InverseFourier[Fourier[image]blurfunction]];
ListDensityPlot[blurryimage, Mesh -> False, Frame -> False];
restoredimage = Re[InverseFourier[Fourier[blurryimage]/blurfunction]];
ListDensityPlot[restoredimage, Mesh -> False, Frame -> False]
Here is a beautiful technique for finding edges. I learned this technique from Mariusz Jankowski’s Mathematica code, which uses Mathematica’s ListConvolve function.
(* runtime: 0.2 second *)
image = Import["C:/GrayPicture.jpg"][[1, 1]];
A = Table[j Exp[-(j^2 + i^2)], {j, -1.0, 1.0}, {i, -1.0, 1.0}];
ListDensityPlot[Sqrt[ListConvolve[A, image]^2 + ListConvolve[Transpose[A],image]^2], Mesh -> False, Frame -> False]
Here is another variation to make the image appear embossed:
(* runtime: 0.1 second *)
image = Import["C:/GrayPicture.jpg"][[1, 1]];
A = Table[1.0j E^-(j^2+i^2), {j, -1, 1}, {i, -1, 1}];
ListDensityPlot[ListConvolve[A, image] + ListConvolve[Transpose[A], image], Mesh -> False, Frame -> False]
Spherical Canvas versus Reflective Sphere - POV-Ray 3.6.1, 10/17/07
This image was inspired by Dick Termes' paintings of 3D worlds on a spherical “canvas” called Termespheres. These images have 6 vanishing points as opposed to linear perspective drawings which only have 3 vanishing points. The left picture shows my version of a spherical canvas for my factory scene. This was accomplished by rendering a spherical panorama of the scene in POV-Ray, and then mapping it to a sphere. Click here to download some sample POV-Ray code. The right picture shows a reflective sphere when viewed from the exact same position. As you can see, it looks quite different.
Complex Map Polar Transformation: f(z) = e2 p z - Mathematica 4.2, 6/14/04
These images were generated by mapping a tessellation to the complex plane, similar to M. C. Esher’s Development II. Here is some Mathematica code:
(* runtime: 80 seconds *)
image = Import["Picture.jpg"][[1, 1]];
n = Length[image]; m = Length[image[[1]]];
Show[Graphics[RasterArray[Table[RGBColor @@ Module[{z = Log[2j/275 - 1 + I (2i/275 - 1)]/(2Pi) + 1.0}, image[[Floor[n Mod[6 m Re[z]/n, 1]] + 1, Floor[m Mod[6 Im[z], 1]] + 1]]/255.0], {i, 1, 275}, {j, 1, 275}]], ImageSize -> 275, PlotRange -> {{0, 275}, {1, 275}}, AspectRatio -> 1]]
Here is some Mathematica code to encrypt messages using prime numbers. Anyone with the public key (and n) can encode messages, but only the person with the secret key can decode them:
(* runtime: 0.05 second *)
message = "This is a secret message containing 112 characters. This message will be divided into 4 blocks of 28 characters.";
<< NumberTheory`NumberTheoryFunctions`; SeedRandom[0];
PublicKey = NextPrime[Random[]256^28]; p = NextPrime[Random[]256^14]; q = NextPrime[256.0^28/p]; n = p q; SecretKey = PowerMod[PublicKey, -1, (p - 1)(q - 1)];
ToNumbers[str_] := Map[FromDigits[#, 256] &, Partition[ToCharacterCode[str], 28]];
ToText[nlist_] := StringJoin @@ Map[StringJoin @@ Map[FromCharacterCode, IntegerDigits[#, 256, 28]] &, nlist];
encryption = ToText[Map[PowerMod[#, PublicKey, n] &, ToNumbers[message]]]
ToText[Map[PowerMod[#, SecretKey, n] &, ToNumbers[encryption]]]
If you do not know p and q, you can try to break the code using this method (but it is very slow):
(* runtime: 40 minutes *)
SecretKey = PowerMod[PublicKey, -1, EulerPhi[n]];
I made these a very long time ago on my old Macintosh. I don’t remember how to make them anymore.
Mathematica Typesetting Shortcuts Here is a Mathematica notebook that summarizes some convenient Mathematica typesetting shortcuts. You can type equations quite quickly in Mathematica once you know these shortcuts. I use these shortcuts to type my class notes in Mathematica.
Other Math Links Mathematica - excellent technical computing software, easy to make beautiful plots and play equations as sounds MathWorld - mathematics dictionary MathGL3d - free Mathematica package for rendering with OpenGL and writing POV-Ray scripts LiveGraphics3D - software for displaying rotatable 3D Mathematica graphics on the internet JavaView - another program similar to LiveGraphics3D Mathematica Information Center - many sample notebooks & packages Mathematica Art - I especially like the animated GIFs Sphere Eversion - beautiful animation turning a sphere inside-out by Bill Thurston Hyperspheres - If a 2-sphere is a circle, and a 3-sphere is a regular sphere, then what is a 4-sphere? How about a 4.5-sphere? Did you know there is a formula to find the “volume” for any n-sphere? Amazing! Who thinks of this stuff? Penrose Tiling - amazing aperiodic tilings discovered by Roger Penrose, here is a Mathematica notebook by E. Arthur Robinson Sphere Packing - by Jos Leys Chatin’s Constant - the infamous “incalculable” constant, the probability that a random algorithm halts Who can name the Biggest Number? - Chained Arrow Notation, Busy Beavers Large Numbers Srinivasa Ramanujan - amazing mathematician Andrew Wiles - solver of Fermat’s Last Theorem John Nash - A Beautiful Mind, see also autobiography Fractional Calculus - fractional derivatives Discrete Cosine Transform - how JPEGs are made Hyperspheres - surface areas & volumes of n-dimensional spheres Strang’s Strange Figures - unexpected patterns in trig functions Wikipedia article on p Gödel's Incompleteness Theorem - famous proof that there are true statements which are unprovable. I can’t say I understand it, but it’s interesting Chinese Rings - a simple puzzle that can be solved in no less than 18446744073709551616 moves Number Spiral - interesting pattern of prime numbers echochrome - M.C. Escher video game