Calculus and Category theory

Quick question:

Is it possible to differentiate a function with respect to another function, or is it limited to a particular variable?

I tried thinking around how to make this question make sense, but I can't figure it out!

I mean, $\frac{\mathrm{d}}{\mathrm{d}x}$ is a function which accepts a function, and returns a function (the derivative of the original function). However, $\frac{\mathrm{d}}{\mathrm{d}x}$ is not equal to $\frac{\mathrm{d}}{\mathrm{d}y}$, and not equal to $\frac{\mathrm{d}}{\mathrm{d}z}$, so it appears that the function for differentiation would be:

derivative :: (real -> real) -> variable with respect to which you are differentiating -> (real -> real)

so, why can't I do: $$ \begin{align} \text{let }f(x) &= \sin(x)\\ \text{let }g(x) &= \cos(x)\\ \frac{\mathrm{d}}{\mathrm{d}g} f(x) &=\ ??? \end{align} $$ and if I can, what is this called and where can I read more about this?

Sorry for badly formulating the question, but I am really curious on how to understand this idea, as I feel like I huge gap in understanding...

I would formulate this better, but the books on Calculus are so focused on applications and proofs, rather than explaining what it is, and when they try to explain what it is, they still do not explain it in terms that are useful to me. I am trying to understand how Calculus can be visualized under Category Theory, so that I can model it better in Haskell other programming languages.

Thanks! ~Dmitry


To answer the part of your question about a categorical point of view of calculus, Bill Lawvere developed an axiomatization of differential geometry in a smooth topos, which unifies many operations in both differential geometry (hence classical calculus) and algebraic geometry. This beautiful theory is called synthetic differential geometry, and is in many ways much simpler than the usual approach to calculus via limits.

In synthetic differential geometry the total derivative is the internal hom functor $(-)^D$, where $D := \{ d \in R : d^2 = 0\}$ is the "walking tangent vector". Here, $R$ is the line object in the smooth topos, which is like the classical real line but augmented with nilpotent elements.

To be more precise the above definition is an axiomatization of the tangent functor from classical differential geometry, so unlike the single-variable classical calculus derivative (which is a special case of the exterior derivative or Darboux derivative) it keeps track of the base points in the space. The classical derivative of a map between vector spaces can be obtained from the tangent map by projecting to the typical fibre of the tangent bundle, which is trivial in this case.

I apologize if this is a bit over your head, but check out John Bell's A Primer of Infinitesimal Analysis for an undergrad-level introduction, or Anders Kock's freely available text for a slightly more advanced but more comprehensive introduction.


Your question for the derivative of a function $f$ with respect to a function $g$ is answered in the comments: $\frac{df}{dg}=f'(g(x))\cdot g'(x)$.

As for the categorical approach, I'll try to indicate some inherent problems with categorifying the notions of limits and derivatives from analysis.

When you define something in a category, you are defining a concept that is sensitive to all of the morphisms in the category. The more category theoretic way of phrasing this is of course the notion of universality, which is everywhere in category theory.

However, a limit of a function at a point, or the derivative of a function at a point is a notion that is very local. You can change the function's values everywhere out of a tiny little neighborhood of the point, and the local behaviour of the function at that point does not change.

Thus, there is some tension here between the categorical philosophy where everything is global and highly sensitive to the other morphisms in the category, and the analytical notions of locality.

Having said that, there are some things that can (sort of) be categorified. There is Lawvere's work on generalized metric spaces which shows that quite a lot of metric space theory can be seen as enriched category theory. In particular, the notion of weighted (co)limits does related to an analytical notion of limit but not quite the ordinary one. Completion of metric spaces has been categorified, but here too the categorified notion is not quite the same as the analytic metric one.