Parameters & Coordinates

So far we've talked about representing data using (nn-tuples of) numbers. In this post I want to take a closer look at how we do this, and distinguish between two different ways of describing spaces.

Example: the unit circle

Let's start with the example of the unit circle (which we are calling S1).S^1). This is defined to be the set of points in the plane which are at distance 1 from the origin (0,0).(0, 0). Using the Pythagorean theorem (to be discussed in the next chapter), this translates to

{(x,y)R2x2+y2=1}.\{(x, y)\In\R^2 \mid \red{x^2 + y^2 = 1}\}.

For example, (1,0),(0,1),(1,0),\,(0, -1), and (22,22)\left(\frac{\sqrt2}2,\frac{\sqrt2}2\right) are in the unit circle since

12+02=102+(1)2=1(22)2+(22)2=12+12=1\begin{align*} 1^2 + 0^2 &= 1\\ 0^2 + (-1)^2 &= 1\\ \left(\tfrac{\sqrt2}2\right)^2 + \left(\tfrac{\sqrt2}2\right)^2 &= \tfrac12 + \tfrac12\\ &= 1 \end{align*}

and (0.3,0.7)(0.3, 0.7) is not since

0.32+0.72=0.09+0.49=0.581.\begin{align*} 0.3^2 + 0.7^2 &= 0.09 + 0.49\\ &= 0.58\\ &\ne 1. \end{align*}

So this description of the unit circle makes it easy to check whether a given point (x,y)(x, y) is in S1S^1 or not. But it's not easy to come up with examples of points on the circle. Let's start by picking a value for x,x, e.g. x=0.3.x=0.3. We can rearrange the equation for the circle as follows:

x2+y2=1y2=1x2y=±1x2\begin{align*} x^2 + y^2 &= 1\\ y^2 &= 1 - x^2\\ y &= \pm\sqrt{1 - x^2} \end{align*}

In our case x=0.3,x=0.3, the possibilities for yy are ±0.7.\pm0.7. In general, once we fix a value of x,x, we get either one or two options for yy (one option if 1x2=0,1-x^2=0, i.e. when x=±1.x=\pm1.

However, not every value of xx is possible, since we can't take the square root of a negative number. Let's solve for the constraint on x:x:

1x201x21x\begin{align*} 1 - x^2 &\ge 0\\ 1 &\ge x^2\\ 1 &\ge |x| \end{align*}

which is equivalent to

1x1.-1 \le x \le 1 .

In other words, x[1,1].x\In[-1, 1].

We now have two maps

f+,f ⁣:[1,1]S1R2\fplus ,\, \fminus \colon [-1, 1] \to S^1 \subset \R^2

given by

f+(x)=(x,1x2)f(x)=(x,1x2)\begin{align*} \fplus(x) &\blue{{}= \left(x, \phantom-\sqrt{1 - x^2}\right)}\\ \fminus(x) &\purple{{}= \left(x, -\sqrt{1 - x^2}\right)} \end{align*}

With this description, it's easy to produce examples of points on the unit circle: we just plug in any value of xx between 1-1 and 1.1. On the other hand, it's difficult to check whether a given point, say (0.71,0.73),(0.71, 0.73), is on the unit circle: we'd need to reverse the above derivation.

Implicit, parametric, and explicit descriptions

Let's generalize what we saw in the above example.

Being able to find an explicit description of a space is rare, since it implies that if you fix all but one coordinate, there is at most one possibility for the last coordinate. This is not true for the circle, since e.g. there are two possibilities for (0,?),(0, \mathord ?), namely (0,1)(0,1) and (0,1).(0,-1). However, it's always possible to find explicit descriptions locally:

y=1x2y = \sqrt{1-x^2}

is an explicit description of the top half of the circle, even though an explicit description can't exist for the entire circle.

We can think about "solving equations" very generally as trying to convert between implicit and parametric descriptions of a space.

Check membershipProduce examples
Parametric
Implicit
Explicit

Coordinates

Let me give a slightly different perspective on implicit descriptions which is more symmetric with parametric descriptions.

Let's think an object in motion, e.g. a cow hurtling through the air, and freeze at a particular moment in time. Let SS be the space of all possible situations like this. Given such a situation sS,s\In S, there are various quantities we can measure:

  • the kinetic energy E(s)E(s) of the object;
  • the mass m(s)m(s) of the object;
  • the speed v(s)v(s) of the object.

If we pick units of measurement, (say joules for energy, kilograms for mass, and meters per second for speed), then we can view these as three maps

E,m,v ⁣:SR.E,m,v\colon S \to \R.

Recall that three maps SRS\to\R can equivalently be viewed as a single map

(E,m,v) ⁣:SR3.(E,m,v)\colon S\to\R^3.

Not every point (x,y,z)R3(x,y,z)\In\R^3 can be hit by this map: physics tells us that these quantities must satisfy the constraint

E=12mv2E = \frac12 mv^2

so we will only hit points in

{(x,y,z)R3x=12yz2}.\{ (x,y,z) \In \R^3 \mid x = \tfrac12 yz^2 \}.

In many cases, it is difficult to find a "global" coordinate system, but we may be able to find a local coordinate system

(x1,,xn) ⁣:URn(x_1, \dotsc, x_n) \colon U \to \R^n

where USU\subset S is a subset of SS (similar to local parametrizations, above).

The upshot of this discussion is that we can view parametrizations of XX as maps RnX,\R^n\to X, and coordinate systems on XX as maps XRn.X\to\R^n. This also applies to local parametrizations/coordinate systems if we allow a subspace UXU\subset X in place of the entire X.X.

Marching squares / cubes

We won't be able to solve every system of equations algebraically---in fact, it's extremely rare that we can. So how can we visualize spaces that are given to us implicitly?

We take advantage of the fact that it's easy to test whether a given point belongs to an implicitly defined subspace. Let's take the example

2y(y23x2)(1z2)+(x2+y2)2(9z21)(1z2)=02y(y^{2}-3x^{2})(1-z^{2})+(x^{2}+y^{2})^{2}-(9z^{2}-1)(1-z^{2})=0

(I just took this example from Wikipedia). If we plug in the point (0.5,0.9,0.9),(0.5,0.9,0.9), the left-hand side works out to 0.051.\approx-0.051. That means this point is not in S.S. But 0.051-0.051 is close to 0,0, so there's probably a point near (0.5,0.9,0.9)(0.5,0.9,0.9) which is in S.S.

Therefore, we can try to graph an implicit equation as follows. We'll restrict our attention to some box, like the cube [1,1]3;[-1,1]^3; maybe we know ahead of time that our space is contained in this box, or maybe it's not and we'll only be graphing part of it. We can subdivide this box, take a bunch of sample points from it, and plug them into our equation. Our sample points will almost certainly not satisfy the equation, but we can use how close/far they are from satisfying the equation to get a good idea of what our shape must look like.

The marching squares / marching cubes algorithms are sophisticated implementations of this basic idea. They let us graph implicitly defined shapes without finding a parametrization, and are used internally by tools like Desmos and Grapher. We need to cover a bit more math in order to fully understand how these algorithms work, but I can give you source code right now:

Access source on GitHubSource