On Derivative Notation, Part 1: The Problems
This is Part 1 of a five-part series on derivative notation. Part 2 explains the origin of these problems and why they persist. Parts 3 and 4 examine two approaches mathematicians have taken to resolve them. Part 5 discusses the challenge of notational redesign. The remaining parts will be published over the coming weeks.
In my recent post, I made a footnote that expressed some of my complaints about the current state of our notation for differentiation. I want to make that a little more precise here. See, I’ve always had a bit of trouble working with derivatives symbolically.1 For the longest time, I had trouble understanding what the means in notation like . Is it a variable? An argument name? A warning label? (It might as well be.) I also had trouble keeping track of types, since many of the resources I used seemed to use “the derivative” loosely in a way that was inconsistent with its formal definition. The situation becomes even worse when one tries to write out higher-order derivatives of compositions of matrix- or tensor-valued functions, at which point the notation stops having any illusion of being helpful.
In this post, I want to present a selection of issues I’ve encountered. I will intentionally rely on your pre-existing knowledge to interpret notation like and and so on, since part of the issue is how mechanically and ritualistically we treat these symbols. Depending on your background, some of these issues may seem more or less problematic. The goal here is simply to confront you with all of the confusion at once, since it’s unlikely that you can reconcile all of these problems with your internal model of the derivative unless your notational abuse Elo is above maybe 1600, or you’ve thought carefully about the issue.
The problems#
They come in two flavors: problems of interpretation, where it’s unclear what the notation even refers to (or whether it refers to anything at all), and problems of representation, where we know perfectly well what we mean (ostensibly) but the notation mangles the object’s type or layout.
Problems of interpretation#
Is a fraction? Let’s get this one out of the way, because it is the most elementary of these and, in the end, the least of them; the question that really festers is the one I opened with, what the in even is. Everyone’s heard it, and most of you probably know the origin story for this notation and why it looks like a fraction. The answer is, well, kind of. It’s not really a fraction, but you can get uncomfortably far treating it as such, until you run into a “paradox” like the following.
Suppose we have three variables , , and subject to a constraint, so that only two of them can vary independently. For concreteness, say . If we treat the partial derivatives as fractions, then we might expect to find an identity like
You could also “derive” this via the chain rule. It’s true that . And naively applying the chain rule gives . So, just put these identities together and you arrive at the same identity.
But if you actually compute these partials, you get . From , we have . From , we have . From , we have . The product is . What went wrong?
What is the scope of a partial derivative? Suppose we are given a function , which we annotate as . Now tell me: what is ? I have asked some version of this question in multiple rooms, and it has never produced fewer than three answers.2 Depending on whom you ask, you might hear that it’s the derivative of with respect to its first argument, evaluated at the point . Or you will hear that it’s the gradient of the map , evaluated at the point . Or you will hear that the expression is ambiguous and can’t be definitively answered without context.
Stanford’s CS 229 has some linear algebra review notes34 that point out another issue that can arise from this ambiguity.6 If is given by , and is a fixed matrix, then what is ? Is it , or is it ? Depending on your interpretation, the answer can have not just a different value, but a completely different type!
What does mean in ? Jason Howald posted a MathOverflow question that identifies a related problem. If we think of as the abstract operator that takes a univariate function to its derivative, then and should be the same operator, since the symbol we decide to use to denote the argument of a function ought not matter. If and are the same operator, then we should be able to substitute freely. But if we annotate a function as , then it seems wrong to write . And, of course, is wrong, while is right.
I can hear some of you mumbling something about lambda expressions. You are probably imagining that is simply shorthand for , i.e., the derivative of the map which cubes its argument. So expresses that . This helps, but if all does is turn into after all variable expressions are turned into lambda functions, then surely you could write . Perhaps worse, if you are suggesting that expressions with free variables are shorthand for the function object, then you’d have to accept that , since and are the same function.
What’s that? The symbol binds the variable ? Well, Joel David Hamkins notes that this problem isn’t fully resolved by suggesting binds the name like a quantifier, since in , one would like to interpret as bound by on the left-hand side, but as free on the right-hand side. That creates a bit of a problem. As Michael Bächtold points out, one is then tempted to conclude from , , and that , so that a priori distinct free variables are all actually the same (which would be nice in a way; a whole lot of mathematics would become simpler).7
The answer clearly isn’t to suppose that is free in the entire expression. Try making a substitution, say, in the identity . You get . What the hell does that mean? So we have to go the other way and try to expand the bound scope of beyond just the immediate expression to keep as bound in some consistent way. How far should this go? To both sides of an equation involving the derivative? To all identities in its context? What would be the nature of this binding? The trouble is that if we want to interpret as binding in some way, then the nature of this binding depends on the context in a way that is difficult (or undesirable) to formalize. Sometimes appears on its own and is, indeed, shorthand for the function . Other times it is intended to be a standalone free expression which is the evaluation of at a free variable . In an identity such as , we might mean the sentence , or perhaps we mean simply the expression , or perhaps we have a specific in mind. The notation is systematically ambiguous about whether and how is bound, and no single semantic interpretation captures all actual usages.
Now I’m sympathetic to the viewpoint here that we should just shut up and calculate and treat as purely a rewrite rule for symbolic expressions. After all, that does seem to be the way we most often use and its kin. Alas, I am not too sure that this quite works. On this view, is perfectly coherent as a syntactic derivation. But should we attempt to interpret this identity to extract mathematical meaning, we run into the same issues as just described, so we’ll have to accept that either interpretation is to be done relatively ad hoc, or that we’ll have phantom expressions haunting our whiteboards and worksheets that on their own represent no specific mathematical content. What’s more, any given function still has no inherent variable names, so a purely syntactic operator would still have no way to distinguish and .
What is the difference between and ? This question may seem absurd at first, but consider that for a function annotated as , the partial derivative with respect to at a point is usually defined to be
And what is ? Well, you might have heard this called the total derivative of with respect to , given at by
But what the hell is ? What does it mean to differentiate a variable with respect to another variable? We can’t apply the limit definition to “the second positional argument of ”. Formally, and are just placeholders that define the intension of . There is no object “ as a function of ” anywhere to be found, since there are no objects or at all, so the only sensible reading is , whence and the vaunted distinction between the total and partial derivative quietly collapses. To make anything other than , you would have to erect some external scaffolding, which we’ll discuss in greater detail in Part 4. So , written as though it differed from , helps itself to a dependence structure that the function , on its own terms, simply does not possess.
Implicit differentiation produces different expressions. Start with the relationship between Cartesian coordinates and polar coordinates , namely, and . We want to treat as a function of the other variables, so that we can compute . However, there is some ambiguity, first explicitly stated by Carl Gustav Jacob Jacobi in 1841 (though not with this example). If you “treat as constant”, then you would compute
On the other hand, if you “treat as constant”, then you compute
Obviously, cannot therefore refer to just one thing. This is why one often sees, particularly in physics, notation like and , where the subscript distinguishes which variables are treated as constant. What exactly does this mean? Syntactically it is clear, since we understand how to handle concrete numbers like “2” when differentiating, so we just follow the same rules for the symbols “held constant” instead. But what is the formal meaning of such manipulations?
Problems of representation#
Why is the gradient a (column) vector? The gradient of a function at a point is traditionally defined as the vector
Let’s now take a look at the units involved. Suppose that the input to is a vector whose entries bear units of meters, and the output of has units of degrees Celsius. Then a quantity such as will have units of degrees Celsius per meter, so the vector collects together these temperature gradients. This issue comes in when we next consider doing gradient descent on , which has iterates
for a step size . If is unitless, then this makes no sense. You can’t add a vector with entrywise units of meters to a vector with entrywise units of degrees Celsius per meter. Are we really to interpret then as having units of square meters per degree Celsius? Well, perhaps it is better to think of as a time-varying step size , where now has units of meters and it scales a unitless direction vector . (Still, the iterates as described above are standard.)
That still leaves a more technical issue. (Don’t worry if this is hard to follow right now; I explain in greater detail in Part 3.) More abstractly, take to be a function over a generic Banach space . Then is supposed to be a representative vector in that encodes the total derivative , which is an element of the dual space . (In particular, don’t confuse this with the total derivative from earlier. I’ll explain how these relate in Part 4.) But even in the finite-dimensional case, there is not a canonical such representative unless we impose some additional structure. Yet we can nevertheless make sense of gradient descent in some of these spaces, and indeed we can do so by picking elements of . So what is “the gradient” of a function really? Does it depend on the context?
There is another issue here, which is that we optimization people like to use the notation to denote the Hessian of at . (Physicists would object that is the Laplacian of at .) This should be illegal though, since as defined is a map , so it makes no sense to apply the gradient operator to . And of course is just a vector, so it’s also not a candidate for differentiation in this way. We apparently have to be sloppy and only now treat as a linear functional (in other words, transpose it), and we can then take its gradient. (This is, for example, what the CS 229 review notes suggest to do.) And then what if we want a third-order or even higher-order derivative? Is a thing? How would we make sense of that notation?
Layout conventions. When dealing with a map , or a map , or a map (whose arguments we’ll label , , and , respectively), there are different conventions for what kind of thing , , and are. In the so-called numerator layout or Jacobian formulation, we are told
In the so-called denominator layout or Hessian formulation, all of these are transposed. And holy buckets are there problems here. Let’s just focus on the numerator layout for now. Each of the three partials is a matrix, yes, but they encode their respective total derivatives (see Part 3) in entirely different ways.
- The Jacobian encodes the linear map via the matrix-vector multiplication .
- The matrix encodes the linear map via the scalar multiplication .
- The matrix encodes the linear map via the trace inner product .
This is a problem because the chain rule for the total derivative, , involves composition of linear maps, which corresponds to matrix multiplication only when all the derivatives are encoded consistently (as with ). Consider the composition
The chain rule says . Well, for a perturbation , first produces the scalar , then scales by this scalar. The result is
an outer-product structure that is emphatically not matrix multiplication. If you naively write “” and interpret it as matrix multiplication, then you get nonsense (it’s not even defined unless , and even then it’s wrong).
OK, so let’s now focus on the case of , since that seems to correspond most clearly with the total derivative. It is common in multivariable calculus and analysis to rename in the numerator layout as the Jacobian . It satisfies the familiar chain rule
Unfortunately, this nice structure is butchered when you use the numerator layout and gradients, since you’re implicitly mixing convention. Strictly adhering to the numerator layout would suggest you should take the gradient to be a row vector, not a column vector. To see how quickly things become unwieldy, imagine a toy computation that is a composition of maps, alternating between vector-valued and scalar-valued,
and suppose we want the gradient of with respect to , expecting an -dimensional column vector. In numerator layout, the Jacobians at a point are , , , and . Using column gradients for the scalar-valued maps, we have and . Working out the chain rule while respecting these conventions, we obtain
where the bracketed factor is a scalar. Good luck intuiting that this is the correct order for the objects to appear when applying the chain rule manually. And this is just with functions whose derivatives are readily written as matrices. Only God8 can help if you want to do any higher-order derivatives, or derivatives of maps between spaces of matrices or higher-order tensors.9
These examples are meant to illustrate the sheer variety of ways our derivative notation has to wear away our will to live. In the next post, I’ll explain how we ended up in this mess.