My Topological Trip To Baguio

Last weekend, we went up to Baguio, the summer capital of the Philippines, to escape the summer heat. As we were going up the long and winding road to Baguio, I find myself frequently looking at my watch, impatient to get over the long trip. As I looked at the time, I also took note of the place where we were during that time. Suddenly, a question popped in my head: “Will it be possible that we’d be in this same place at this time when we return to Manila?”. We can visualize this problem using the diagram below:


In the figure above, the blue dot is the location along the way from Manila to Baguio which we occupied where the clock time was the same when going up as when going down. It turns out that such a place exists. However, where it is located is arbitrary. To see this, suppose that we leave Manila at 6 am and arrive in Baguio at 6 pm. (On the average, it takes about 5-6 hours to reach Baguio from Manila. In this case, we will be taking our time enjoying the scenery). On the day that we go back, we will leave Baguio at 6 am and arrive in Manila at 6 pm. To find the place and time in question, use 2 cars, one starting in Manila going to Baguio and the other car starting from Baguio and going to Manila. When they meet each other along the way, that’s precisely the place and time we are looking!.

Topology

The problem above is an illustration of the power of Topology, a branch of mathematics that studies the properties of mathematical objects that are invariant under stretching without tearing or gluing. For a topologist, there is no difference between a doughnut and a cup because we can always deform the doughnut to look like a cup.


The most obvious topological property of the doughnut is the single hole it has. Any transformation that stretches or deforms it will always retain that hole. Which means it is always possible to find a transformation that will transform your doughnut to a cup. Of course, don’t eat the cup!

Topology is sometimes called “Rubber Sheet Geometry” because it studies objects and its properties that are invariant under stretching. In the diagram below, we start with a flat sheet of rubber with a straight line in it. Stretch this rubber in any which way. You will notice that the line, even though it will not look straight anymore, will still be one piece of line and not two. In other words, the line retains its property of connectedness. It will still be in one piece and not suddenly become two pieces.


Brouwer’s Fixed Point Theorem

The Baguio trip example I gave is an instance of what is known as the Brouwer’s Fixed Point Theorem. In its simplest form, it states that any continuous function f from a closed interval to itself has a fixed point. Let [a,b] be the closed interval in 1 dimension. This means that f(a) and f(b) lie also in [a,b]. Furthermore, whatever number f(a) is mapped to, it is always greater than or equal to a. Also, whatever number f(b) is mapped to, it is always less than or equal to b.


Define the function g(x) = f(x) - x. We can easily see that g(a) \ge 0 and g(b) \le 0. Since g is a continuous function, then there is a point \xi such that g(\xi) = 0 (by the Intermediate Value Theorem), that is, f(\xi) = \xi. The number \xi is called a fixed point of f.


For example, consider the cosine function defined in [-1,1],

\displaystyle f(x) = \cos(x), -1 \le x \le 1

then by Brouwer’s Fixed Point Theorem, there is a point x_0 \in [-1,1] such that

\displaystyle \cos(x_0) = x_0


As can be seen from the diagram above, this point is the intersection of the graph of the cosine function and the line f(x) = x and is equal to 0.73909.

The Baguio trip has filled me with fond memories of my university days especially on Topology. I’ll be sharing them in my subsequent posts.

Mathematically Romancing Mt Mayon

The name Mayon is short for Daragang Magayon, or “Beautiful Lady”, which is the legend associated with Mt Mayon. No wonder, I still find myself captivated by its charms after visiting it three weeks ago.

While playing with google maps this sunday, I decided to take a look at Mt Mayon and I was hoping I could get a three dimensional view of the beauty. I was disappointed. Although there is a 3D view, but it was not beautiful at all. Luckily, google map provides a topographical information of Mt Mayon. Suddenly, I was inspired to recreate the view of Mt Mayon using that information and using the tool called R.

First thing I did was to capture the image from the google maps and saved it as JPEG. Using the ReadImages library of R, I loaded the image and plotted it.

# load the library
library("ReadImages")

# read the file and plot
x=read.jpeg("mount_mayon_topography2.jpg")
plot(x)

# add grid lines
grid(nx=20,ny=20,col="red")

The result of the code above is a plot of the image with red grid lines, as shown below.


You will notice that the image contains contour lines with a height information associated with it. I used the grid lines to manually interpolate the height of Mt Mayon at each intersection. I started at the bottom line and worked myself upward from left to right. However, I got lazy interpolating from point to point so I just stopped when I reached the middle line. I decided that the upper half of the image is just a mirror image of the bottom so I might as well use the same numbers. Here’s a dump of the interpolated height from the bottom half of the image:

0,        0,    0,     0,     0,    0,400,400,400,450,450,420,400,350,300,280,250,220,200,
0,     100,200,300,400,420,450,500,550,570,550,500,480,420,400,380,350,250,200,
200,300,350,400,420,500,550,580,600,650,600,600,580,550,500,400,350,300,320,
280,350,380,400,500,580,610,650,780,800,750,730,650,600,500,450,380,310,300,
300,400,430,500,580,650,780,800,950,990,970,900,800,700,580,500,520,350,300,
310,400,480,580,610,750,840,1000,1100,1200,1150,1100,1000,800,650,550,450,380,350,
320,450,500,600,700,800,1000,1200,1350,1500,1500,1380,1180,900,800,650,510,400,350,
350,450,500,600,750,900,1100,1350,1600,1800,1800,1600,1350,1100,900,700,550,450,350,
370,450,500,600,780,900,1200,1500,1800,2100,2000,1800,1500,1180,900,700,550,500,350,
380,450,500,620,780,970,1200,1500,1900,2250,2200,1800,1400,1150,900,700,550,520,400,

Reflecting this information about the middle line and inputting this to R, we get

z=c(0,        0,    0,     0,     0,    0,400,400,400,450,450,420,400,350,300,280,250,220,200,
0,     100,200,300,400,420,450,500,550,570,550,500,480,420,400,380,350,250,200,
200,300,350,400,420,500,550,580,600,650,600,600,580,550,500,400,350,300,320,
280,350,380,400,500,580,610,650,780,800,750,730,650,600,500,450,380,310,300,
300,400,430,500,580,650,780,800,950,990,970,900,800,700,580,500,520,350,300,
310,400,480,580,610,750,840,1000,1100,1200,1150,1100,1000,800,650,550,450,380,350,
320,450,500,600,700,800,1000,1200,1350,1500,1500,1380,1180,900,800,650,510,400,350,
350,450,500,600,750,900,1100,1350,1600,1800,1800,1600,1350,1100,900,700,550,450,350,
370,450,500,600,780,900,1200,1500,1800,2100,2000,1800,1500,1180,900,700,550,500,350,
380,450,500,620,780,970,1200,1500,1900,2250,2200,1800,1400,1150,900,700,550,520,400,
370,450,500,600,780,900,1200,1500,1800,2100,2000,1800,1500,1180,900,700,550,500,350,
350,450,500,600,750,900,1100,1350,1600,1800,1800,1600,1350,1100,900,700,550,450,350,
320,450,500,600,700,800,1000,1200,1350,1500,1500,1380,1180,900,800,650,510,400,350,
310,400,480,580,610,750,840,1000,1100,1200,1150,1100,1000,800,650,550,450,380,350,
300,400,430,500,580,650,780,800,950,990,970,900,800,700,580,500,520,350,300,
280,350,380,400,500,580,610,650,780,800,750,730,650,600,500,450,380,310,300,
200,300,350,400,420,500,550,580,600,650,600,600,580,550,500,400,350,300,320,
0,     100,200,300,400,420,450,500,550,570,550,500,480,420,400,380,350,250,200,
0,        0,    0,     0,     0,    0,400,400,400,450,450,420,400,350,300,280,250,220,200)

Next, I generated the coordinates of the x and y plane:

myx=seq(-9,9,1)
myy=seq(-9,9,1)

To generate the 3D view, I used the persp3d function of the rgl library and animated the 3D plot so that we can see the plot 360 degrees.

library(rgl)
persp3d(myx,myy,z,col="darkseagreen", aspect=c(4,4,1))
play3d(spin3d(axis=c(0,0,1), rpm=8), duration=20)

The result of the above code is an animated plot of Mt Mayon using partial topographical information. Shown below is the animation:

This is indeed a great waste of time. But I guess, that’s what you do when you fall in love…mathematically!

Mt. Mayon’s Mathematical Beauty and Elegance

Mayon volcano refused to show its glory last weekend. It was like a beautiful but shy girl that hides her face behind a veil of clouds. You know the beauty that it is hiding but it keeps you in suspense and wants you go to back there and try your luck again to see it in all its splendor.

Fortunately, Mayon is a perfect cone volcano and it does not take a lot of effort to imagine how it looks like. I was inspired by Mayon to generate its shape using some computer algebra tools at my disposal. The first tool I used is the tool I always bring with me, the iPhone. The iPhone has a neat computer algebra system called Spacetime. It can do a lot of things you would expect from a Computer Algebra System among which is plotting surfaces. To plot the surface of Mayon, I used a coordinate system that is suited to its symmetrical shape. This coordinate system is the cylindrical coordinate system.

Cylindrical Coordinate System

Any point in three dimensions can be specified by three numbers. In the rectangular coordinate system, which we are very familiar with, these three numbers correspond to the x, y and z coordinates of the point. Shown below is how we specify a point using the rectangular coordinate system.



The rectangular coordinate system is not always the most convenient system to use. For example, to specify a circle in rectangular coordinates, you need to specify it as

\displaystyle x^2 + y^2 = r^2

where r is the radius of the circle.

In fact, we can specify a circle even simpler by using polar coordinates. We only need to specify the radius and the angle. For a circle of radius 1, the equation is

\displaystyle r=1

How simple can it get?

In generating the cone, we use a coordinate system that naturally fits the geometry of the cone. This coordinate system is called the cylindrical coordinate system. Imagine a point p in space and a cylinder that contains this point. We can specify the position of this point in the cylinder by three numbers. The first number specifies the height of this point from the xy plane. The second number specifies the distance of this point from the z axis. The last number specifies the angle \phi that this point makes from the x axis. Below is a diagram of the cylindrical coordinate system.


Specifying the Cone Using Cylindrical Coordinates

Since the cone has circular symmetry around the z axis, we only need to specify the value of z with respect to r. Any plane that passes along the z axis intersects the cone through a line that lies on the cone. The diagram below shows the line of intersection of a cone of height h and whose base has radius b.


The equation of this line has the form

\displaystyle z=mr + k

where m is the slope and k is the z intercept. When r=0, we have z=k. When z=0 we have m= - h/b. Therefore, we can specify z as:

\displaystyle z = - \frac{h}{b} r + h.

Mayon has a base approximately 4 times its height. Using h=4 and b=8, we can then specify the cone as

\displaystyle z = - 0.5 r + 4.
\displaystyle 0 \le r \le b
\displaystyle 0 \le \phi \le 2\pi

Using the function CylindricalPlot3D of spacetime, we get the plot of the cone as shown below.



Surface Plot Using Rectangular Coordinates

The plot of the cone using cylindrical coordinates is elegant. It used the circular symmetry of the cone around the z axis. We can still plot the cone using rectangular coordinates but it is quite messy. To do this, I used another tool called R. It’s a statistical computing tool but it has a great 3D plotting engine. Here is the R code I used to generate the plot:

# interval is the distance between points in the x or y axis
interval=2

# noisemean is the mean of the gaussian noise we want to introduce into the plot to
# simulate rugged mountain
noisemean=0

# noisedev is the standard deviation
noisedev=1

# addnoise is a boolean. It specifies if we want to add the noise
addnoise=T

# generate the x and y vectors below using the interval between points
x=seq(-10,10,interval)
y=seq(-10,10,interval)

# generate the matrix of squares for the y axis
l=length(x)
yy=y^2 %*% t(rep(1,l))

# generate the matrix of squares for the x axis, which turns out to be just the transpose of yy
xx=t(yy)

# compute the zz coordinate: zz = -0.5* r +4
# but first let's compute r^2, let's call it rr

rr=xx + yy
zz = -0.5 * sqrt(rr) + 4

# plot only values greater than or equal to  0
myfunc=function(n){
        if(n<0){
                0
        } else {
                n
        }
}

mayon= mapply(myfunc,zz)

# add some noise
if(addnoise){
        noise=0.1*matrix(rnorm(l^2,noisemean,noisedev),l,l)
        mayon=mayon+ noise
}

# plot using rgl
library(rgl)
persp3d(x,y,mayon,col="yellowgreen",aspect=c(4,4,1))

Below is the result of running the above code.


This how I see mayon through the lens of mathematics. But I definitely want to go back there and see its imposing grandeur.