# Changes of variables

I have a confession to make: I am confused about changes of variables.

Now, don’t get me wrong. I know how to change variables in a given problem. But (as is often the trigger for me realising I don’t have as good a grasp on something as I’d like) I’m trying to write up teaching notes on changes of variables, in a precise and principled way, and keep finding myself bogged down. So this post will be an effort to, as it were, think aloud through the issues that come up.

Let’s start with a nice easy example. Suppose that we’re thinking about the equation of the unit circle, in $x$-, $y$-coordinates:

$x^2 + y^2 = 1$

And now suppose that we want to convert to two-dimensional polar coordinates $(r, \theta)$:

$r = \sqrt{x^2 + y^2}$

$\theta = \tan^{-1}(\frac{y}{x})$

Now, if we want to know the equation of the unit circle in these new coordinates, we substitute $r$ and $\theta$ into the above equation, using the inverse expressions to those above:

$x = r \cos \theta$

$y = r \sin \theta$

Which gets us the expected result, $r = 1$. In this case, the use of the inverse expressions maybe doesn’t seem totally necessary since the original expression already only depended on $x$ and $y$ via $x^2 + y^2$; but it should hopefully be clear that that’s a peculiarity of this simple example.

Now, I want to claim that even this relatively simple case picks up on a few potentially confusing things. For starters, we might be a little perturbed by the fact that the thing we actually use to convert our first equation (in terms of x and y) into our second (in terms of r and $\theta$) isn’t the definition of the new coordinates in terms of the old, but the inverse expressions that define the old coordinates in terms of the new. More than that, what – when you get down to it – is an expression like $x = r \cos \theta$ suppose to mean? In particular, is this the defining equation for a real-valued function of $r$ and $\theta$, or a recipe licencing the replacement of the simple expression “$x$” by the complex expression “$r \cos \theta$“? Or, if it’s both at once, then how do these two functions intertwine?

Let’s take a bit of a step back, then. We started with an equation, formulated in a particular mathematical language (namely, one employing the variables $x$ and $y$). This equation may be regarded as a certain kind of syntactic object, formulated in a particular mathematical language: one featuring, in particular, the variables $x$ and $y$, in addition to the usual algebraic symbols (+, etc.). We’ll think of this as analogous to a formula formed in a first-order or propositional language.

On the semantic side, this equation is to be interpreted over $\mathbb{R}^2$. We’re helping ourselves to the idea that this structure has been parameterised by $x$ and $y$; that is to say, an element of $\mathbb{R}^2$ is really a map $p$ from $\{\ulcorner x \urcorner, \ulcorner y \urcorner\}$ to $\mathbb{R}$; I’m using corner-quotes here to stress that it’s the symbols that are being mapped to points of $\mathbb{R}$. (This is supposed to resemble the manner in which an interpretation of a logical formula is a map from the set of propositional or predicate symbols to truth-values or sets of tuples.) Such a point satisfies the equation if $p(\ulcorner x \urcorner)^2 + p(\ulcorner y \urcorner)^2 = 1$. A solution to this equation is a set of points in $\mathbb{R}^2$, such that each point in the set satisfies this equation.

All this might seem like a massive palaver to go through, just in order to state the elementary fact that a solution to the equation $x^2 + y^2 = 1$ is a set of points $(x, y)$ for which the equation is true. And of course, that’s certainly true; but the hope is that by being as careful as possible, and in particular by distinguishing starkly between syntactic and semantic considerations, we can figure out what’s going on when we start working with new variables.

(Incidentally, as a side-note to the above: if we do want to think of the equation as analogous to a first-order formula like $\forall x Px$, there’s an interesting question about what the proper analogue of a first-order model of that formula ought to be. Is it an individual point in $\mathbb{R}^2$ satisfying the equation, or a solution to the equation?)

On the other side of the divide, we have an equation in a different language – namely, one having the same algebraic and operation symbols, etc., but having instead the variables $r$ and $\theta$. This equation just reads $r = 1$. (Let’s forget, for the moment, that we obtained this equation from the previous one through some substitution work.) On the semantic side, this language is also interpreted over points of $\mathbb{R}^2$, as parameterised by $r$ and $\theta$: that is, it is interpreted by maps from $\{\ulcorner r \urcorner, \ulcorner \theta \urcorner\}$ to $\mathbb{R}$. We also include the specifications (i) that we’ll only consider maps $p$ such that $p(\ulcorner r \urcorner) \geq 0$, and (ii) that $\theta$ is periodic, so that if $p(\ulcorner r \urcorner) = q (\ulcorner r \urcorner)$ and $p(\ulcorner \theta \urcorner) = q (\ulcorner \theta \urcorner) + 2\pi$, then $p = q$. (Which means that we’re not really interpreting it over $\mathbb{R}^2$ after all, but rather over the half-cylinder obtained by gluing $\{(r, \theta) : r \geq 0, 0 \leq \theta < 2\pi\} \subset \mathbb{R}^2$ to itself.) So analogously to what we had before, a point $p$ satisfies the equation if $p(\ulcorner r \urcorner) = 1$.

Now, there is meant to be some sense in which these two equations “have the same content”. What sense is that? Well, here are two relevant observations. First, at the syntactic level: uniformly substituting $\ulcorner r \cos \theta \urcorner$ for $\ulcorner x \urcorner$ and $\ulcorner r \sin \theta \urcorner$ for $\ulcorner y \urcorner$ in the former equation yields the latter, and uniformly substituting $\ulcorner x^2 + y^2 \urcorner$ for $\ulcorner r \urcorner$ (and $\ulcorner\tan^{-1}(y/x)\urcorner$ for $\ulcorner \theta \urcorner$) in the latter equation yields the former. Moreover, applying these two substitutions to $\ulcorner x \urcorner$ in turn yields an expression (namely, $\ulcorner \sqrt{x^2 + y^2} \cos(\tan^{-1}(y/x)) \urcorner$) that is provably equivalent to $\ulcorner x \urcorner$; the same goes for all the other variables. In other words, we’ve got a pair of mutually inverse “translations” between the two equations.

At the semantic level, suppose I fix the following map $F$ from $\mathbb{R}^2$, parameterised by x and y, to the half-cylinder constructed from $\mathbb{R}^2$ and parameterised by $r$ and $\theta$: given any $p: \{\ulcorner x \urcorner, \ulcorner y \urcorner\} \to \mathbb{R}$, $F(p) : \{\ulcorner r \urcorner, \ulcorner \theta \urcorner\} \to \mathbb{R}$ according to

$F(p) : \ulcorner r \urcorner \mapsto \sqrt{ p(\ulcorner x \urcorner)^2 + p(\ulcorner y \urcorner)^2}$

$F(p) : \ulcorner \theta \urcorner \mapsto \tan^{-1}(p(\ulcorner y \urcorner)/ p(\ulcorner x \urcorner))$

This map then has the following feature: given any point $p \in \mathbb{R}^2$, if $p$ satisfies the first equation then $F(p)$ satisfies the second equation. Similarly, we can construct a map $G$ from the half-cylinder to $\mathbb{R}^2$, which will have the feature that for any point q of the former, if q satisfies the second equation then $G(q)$ satisfies the first equation. And moreover, a little work will show that F and G are inverse to one another (well, other than places like $r = 0$).

The reason this is interesting is that it mirrors what happens with translations in formal languages: there too, one has both syntactic translations between expressions and semantic maps between interpretational structures. Moreover, it draws out one of the things that makes changes of variables so confusing (at least to me!): I started out by saying that an expression like $x = r \cos \theta$ seems to be both a specification of a function, and a substitution manual. We’ve now got a more precise grip on what is meant by this – these two identities correspond to the semantic and syntactic maps just described. But note that (as, again, happens with formal languages) the two maps associated to an expression like $x = r \cos \theta$ “go in opposite directions”, i.e. are dual concepts. The syntactic side of the coin is a map from expressions in the (x, y)-language to expressions in the $(r, \theta)$-language; the semantic side of the coin, however, is a map from points of the $(r, \theta)$-structure (the half-cylinder) to points of the (x, y)-structure. (That is, the semantic map is half of the instructions needed to construct G above; if I’d thought this through more carefully I’d have explicitly constructed G rather than F, but the point stands – in the construction of F we used the expressions $r = \sqrt{x^2 + y^2}$ and $\theta = \tan^{-1}(y/x)$.)

In any event, all of this was supposed to just be a warmup to the really tricky case – doing all this for differential equations, not just algebraic equations. Still, writing this has helped me unpick some of the tangle (admittedly, which might well be a tangle I have entirely created for myself); extending this to differential equations will have to wait for another day.