Archive

Archive for June, 2011

Where are the powers of two?

June 29, 2011 2 comments

The following construction gives an interesting pairing map between the positive integers and the lattice of integer-valued points in the plane:

  • Place \boldsymbol{z}=1 at the origin.
  • For each level n \in \mathbb{N}, populate the 4n points of the plane on the square with vertices \big\{ (\pm n, 0), (0, \pm n) \big\}, starting from z=2(n^2-n+1) at the position (n,0), and going counter-clockwise.

    mypfschema

After pairing enough positive integers on the lattice, pay attention to the powers of two: they all seem to be located on the same two horizontal lines: y=0 and y=2.

mypfproofofconcept

Is this statement true?

Read more…

Geolocation

June 15, 2011 Leave a comment

Recall the First Spherical Law of Cosines:

Given a unit sphere, a spherical triangle on the surface of the sphere is defined by the great circles connecting three points u, v, and w on the sphere. If the lengths of these three sides are a (from u to v), b (from u to w), and c (from v to w), and the angle of the corner opposite c is C, then

\cos c = \cos a \cos b + \sin a \sin b \cos C

In any decent device and for most computer languages, this formula should give well-conditioned results down to distances as small as around three feet, and thus can be used to compute an accurate geodetic distance between two given points in the surface of the Earth (well, ok, assuming the Earth is a perfect sphere). The geodetic form of the law of cosines is rearranged from the canonical one so that the latitude can be used directly, rather than the colatitude, and reads as follows: Given points p_1 and p_2 with positions (lat_1, long_1) and (lat_2, long_2) respectively, the distance d between the two points is given by the following formula.

\cos\displaystyle{\frac{d}{R_\oplus}}=\sin(lat_1)\sin(lat_2) + \cos(lat_1)\cos(lat_2)\cos(long_2-long_1),

where R_\oplus=3,959 is the radius of the Earth in miles (well, ok, the average radius of the Earth…)

A nice application of this formula can be used for geolocation purposes, and I recently had the pleasure to assist a software company (thumb-mobile.com) to write such functionality for one of their clients.

Go to www.lizardsthicket.com in your mobile device, and click on “Find a Location.” This fires up the location services of your browser. When you accept, your latitude and longitude are tracked. After a fast, reliable and resource-efficient algorithm, the page offers the location of the restaurant from the Lizard’s chain that is closest to you. Simple, right?