iconEuler Examples

The Riemann Sphere

The Riemann Sphere is a representation of the compactified (with infinity) complex plane on the sphere with center (0,0,1/2) and radius 1/2.

It uses the so-called stereographic projection from the north pole (0,0,1) through the sphere to the x-y-plane of points (x,y,0). A little geometry reveals the following equation

Riemann Sphere

>function px(x,y,z) &= x/(1-z)
                                1 - z

>function py(x,y,z) &= y/(1-z)
                                1 - z

To compute the inverse function, we use the "solve" function of Maxima. Thus we solve

Riemann Sphere

under condition that (x,y,z) is on the sphere. There are two solutions. One of them is the north pole (0,0,1) and discard this solution.

>xyz &= solve([x^2+y^2+(z-1/2)^2=1/4,tx=px(x,y,z),ty=py(x,y,z)],[x,y,z])[2]
                                                      2     2
                 tx                 ty              ty  + tx
       [x = -------------, y = -------------, z = -------------]
              2     2            2     2            2     2
            ty  + tx  + 1      ty  + tx  + 1      ty  + tx  + 1

Now we define the components of the inverse function.

>function qx(tx,ty) &= x with xyz
                              2     2
                            ty  + tx  + 1

>function qy(tx,ty) &= y with xyz
                              2     2
                            ty  + tx  + 1

>function qz(tx,ty) &= z with xyz
                                2     2
                              ty  + tx
                              2     2
                            ty  + tx  + 1

We now want to draw a grid on the sphere with the usual longitudinal and equilateral circles. We use a very dense grid to get a smooth representation.

If the grid is projected to the plane the result will be a grid with radials and circles. The radii of the circles are computed using the projection "px" from above.

>s=(1:119)*pi/120; r=px(sin(s),0,cos(s));

Riemann Sphere

This is the projection of the grid on the ball to the plane. Note "cgrid" which is a way to reduce the grid lines that are actually drawn for a complex grid matrix.

To draw the grid on the ball, we use the inverse projection.

>tx=re(w); ty=im(w);
>x=qx(tx,ty); y=qy(tx,ty); z=qz(tx,ty);

Riemann Sphere

Note that the surface has a very fine resolution, but we draw only 20 and 10 grid lines in each direction.

Let us now distort the grid with a Möbius transformation. We plot the distorted grid back on the sphere.

>tx=re(wm); ty=im(wm);
>x=qx(tx,ty); y=qy(tx,ty); z=qz(tx,ty);

Riemann Sphere

The Möbius transformation maps infinity to 1 and 0 to 1/2. Projecting back we get the two points on the sphere in the image above.

The Stereographic Projection and Povray

We can use Povray to visualize the stereographic projection. For this, Povray must be installed completely, and the path to "pvengine.exe" must be in the system path, or the variable "defaultpovray" must be set in EMT.

>load povray
Functions to generate Povray files for the open Raytracer. 

We start the Povray scene and set the zoom and the center point.


The first element is a red, half transparent sphere.


The next element is a transparent, gray plane which represents the x-y-plane. It is bounded by cylinder with radius 2.4.


The next elements are three blue points.

>x=0.7; y=0.6; 
>r=x^2+y^2+1; xp=x/r; yp=y/r; zp=(x^2+y^2)/r;

Then there is a segment in gray, connecting the North pole to the point in the x-y-plane.


Then we want the coordinate axes.


THe following ends the scene and generates an image with a high resolution.


Riemann Sphere