# When can you divide out $dx$ in an integral as if it is a fraction?

A recent question on Math SE included finding the antiderivative of

$$\int y'y''\,dx,$$

where $$y'=\frac{dy(x)}{dx},y''=\frac{d^2y(x)}{dx^2}$$ as $$y=y(x)$$. One approach to solve this problem is by direct substitution. Let

$$u=\frac{dy}{dx}=y' \implies du=y''\,dx,$$

then the left hand side becomes

$$\int y'y''\,dx=\int u\,du=\frac{1}{2}u^2+C=\frac{1}{2}\left(y'\right)^2+C.$$

A second approach involves writing out the integral completely and then canceling the $$dx$$

$$\int \frac{dy}{dx} \frac{d^2y}{dx^2}\,dx=\int \frac{d^2y}{dx^2}\,dy=\int y''\,dy=\int\frac{dy'}{dx}\,dy=\int\frac{dy'}{dx}y'\,dx=\int y'\,dy'=\frac{1}{2}\left(y'\right)^2+C.$$

In this approach, it is crucial to make the following observation:

$$dy=\frac{dy}{\require{cancel} \cancel{dx}}\,\require{cancel} \cancel{dx}=y'\,dx \implies \frac{dy'}{dx}\,dy=\frac{dy'}{\require{cancel} \cancel{dx}}y'\,\require{cancel} \cancel{dx}=y'\,dy'.$$

Through reviewing other questions on Math SE and Math Overflow, it appears that you are always able to "divide out" the $$dx/dx$$. This is because $$dx$$ is an infinitesimally small positive change in $$x$$. Therefore, as $$dx\neq 0$$ you can divide out $$dx$$ with itself to conclude

$$\frac{dx}{dx}=1$$

at any point in integration (assuming that what you are integrating is well-defined). This is further represented by the fact that the Riemann integral can be expressed as the limit of Riemann sums

$$\int_a^b f(x)\,dx=\lim_{n\to\infty}\sum_{i=1}^nf(x_i)\Delta x,$$

where $$\Delta x$$ means an infinitesimally small step on the x-axis to correspond with the infinitesimally small change in $$x$$ associated with the Riemann integral.

One can justify canceling the $$dx$$ terms by the answer shown inside this Math Overflow question. However, they would need to know differential forms which is a topic that I am unfamiliar with. A different answer on Math SE provides a more familiar explanation in which one can write the first fundamental theorem of calculus in Leibnitz notation as:

$$\int _a^b \frac{df}{dx}\,dx = f(b) - f(a).$$

Inside this answer, it is shown that you can "cancel" the two $$dx$$ terms even though you are not literally cancelling $$dx/dx$$. The fact that these two terms cancel is directly due to notational convenience. I'm curious if this sort of notational convenience will fail. I think that one could write

$$\int \frac{dy}{dx}\,dx=\int \frac{dy}{\require{cancel} \cancel{dx}}\,\require{cancel} \cancel{dx}=\int dy,$$ $$\int \frac{dy}{dx}\frac{dy}{dx}\,dx=\int \frac{dy}{\require{cancel} \cancel{dx}}\frac{dy}{dx}\,\require{cancel} \cancel{dx}=\int \frac{dy}{dx}\,dy,$$ $$\int \frac{dy^n}{dx^n}\frac{dy}{dx}\,dx=\int \frac{dy^n}{dx^n}\frac{dy}{\require{cancel} \cancel{dx}}\,\require{cancel} \cancel{dx}=\int \frac{dy^n}{dx^n} \,dy,$$ $$\int \frac{dy}{dx}dy\,dx=\int \frac{dy}{\require{cancel} \cancel{dx}}dy\,\require{cancel} \cancel{dx}=\int (dy)^2.$$

Is there a scenario in which you cannot cancel $$\frac{dx}{dx}$$ inside an integral as if it were a fraction equal to $$1$$? Can you also cancel these two terms through a substitution made inside the integral?

It is a common misconception that $$dx$$ is an "infinitesimal". $$dx$$ is a differential, i.e. an arbitrary, nonzero quantity representing a variation.

When there is a dependent variable, say $$y=f(x)$$, the differential of $$y$$ is related to that of $$x$$ by

$$dy=f'(x)\,dx.$$

By this definition, $$dy$$ is "the linear part of the variation of $$y$$ for a given variation of $$x$$", as explained by Taylors' development.

This is to be contrasted with

$$\Delta y=f(x+\Delta x)-f(x)=f'(x)\Delta x+R(x,\Delta x)$$ (where $$R$$ is a remainder term) which is the ordinary variation.

Hence, $$dx,dy$$ can really be handled like numbers, and

$$\frac{dy}{dx}=f'(x)=\lim_{\Delta x\to 0}\frac{\Delta y}{\Delta x}.$$

Example:

For the function $$y=x^2$$,

$$\Delta y=(x+\Delta x)^2-x^2=2x\Delta x+\Delta^2 x$$ while the linear part is

$$dy=2x\,dx.$$

Note that $$dx$$ and $$\Delta x$$ both represent arbitrary variations, but I kept both for the symmetry of the formulas.

The short answer is that you can always cancel the denominator of $$\frac{dy}{dx}$$ with $$dx$$ because, even though the quotient $$\frac{dy}{dx}$$ is not a literal division, when it is exists, it is a function such that $$\frac{dy}{dx}\cdot dx = dy$$ - which is precisely the property you need.

It's somewhat unavoidable, though, that you have to talk about differential forms to justify this, but we don't really have to formally define them to describe what's going on. Basically, to get from the calculus that's usually taught (with magic terms like $$dx$$ floating around without definition) to something a bit more justifiable, you just stop putting $$d$$'s in denominators.

For instance, equations such as $$y=x^2$$ have consequences such as $$dy=2x\,dx$$ which states, essentially, that if you move a point around the curve $$y=x^2$$, the instantaneous rate of change of its $$y$$ component is $$2x$$ times the rate of change of the $$x$$ component - where you might think of these rates of change as velocities. Similarly, $$x^2+y^2=1$$ has a consequence $$x\,dx + y\,dy = 0$$ which gives an equation involving the position and velocity of a point constrained to a circle - and which, wherever $$x$$ is not zero, can be rearranged to $$dy = \frac{-x}y\,dy$$ which has an interpretation like the previous one. Note that the terms traditionally called $$\frac{dy}{dx}$$ are literally just "the thing you need to multiply by $$dx$$ to get $$dy$$". Sometimes this doesn't exist (for instance if you lived on the sphere $$x^2+y^2+z^2=1$$, you could fairly say $$x\,dx+y\,dy+z\,dz=0$$ to relate position and velocity, but your $$y$$ velocity and $$x$$ velocity can still vary independently - so $$dx$$ is not a multiple of $$dy$$), but it generally does when we're talking about one dimensional things and any time we talk about such quotients, we really do mean "the thing that turns 'velocity in one coordinate' to 'velocity in another coordinate'" - which, is expressed precisely as $$dy=dx\cdot \frac{dy}{dx}$$ which is the equation of interest.

That said, the "quotients of differentials" notation is just a fancy way to refer to $$a(x)$$ when you know there's a unique such function such that $$dy=a(x)\,dx$$ and "cancellations" are really just substitutions in disguise where $$a(x)=\frac{dy}{dx}$$. For instance, you might consider the chain rule $$\frac{dx}{dy}\frac{dy}{dz}=\frac{dx}{dz}$$ Which really says that if you know $$dy=a(x)\,dx$$ $$dz=b(x)\,dy$$ then, by substituting $$dz=a(x)b(x)\,dx$$ and this way via substitution is somewhat less prone to error (since ideas like the quotients are supposing some sort of existence and uniqueness, whereas substitutions are absolutely clear in their interpretation).

By this view, the two methods you give are actually similar (although the second one is inefficient - you may as well start at the fifth equation by not expanding $$y''$$ to a second derivative) - either way you end up passing through the equation $$dy'=y''\,dx$$ either by cancelling $$\frac{dy'}{dx}dx$$ to get $$dy'$$ (which uses exactly this equation) or by substituting it directly.

Just as an aside, since it's implicit in what I've written: integration works on differential forms. The idea is that something like $$\int_{x=0}^1 f(x)\,dx$$ asks "increase $$x$$ from $$0$$ to $$1$$. At all times, the integral increases at a rate of $$f(x)$$ times the rate at which $$x$$ is increasing. What is the final value of the integral?" where for simple cases like $$\int_{x=0}^1 dx$$, the answer is obvious since $$x$$ and the integral increase at the same rate - so must increase the same amount - and where you get more complicated cases where the ratio of the rates varies with $$x$$, or even where you say "move a point along a path in space; at each point, the integral increases as some linear function of the velocity. What is the end result?" which turns up everywhere in physics and uses differential forms quite explicitly (differential forms are really defined as "a linear function of velocity assigned to each point of a domain" with some constraints). Of course, these manipulations are all valid even outside of an integral, though generally the main place you would want to use such equations is inside integrals.

Yes, you can cancel $$\frac{dx}{dx}$$ as long as you follow some rules. $$dx$$ is a differential, which you can think of as an infinitesimal value. It is not zero, so you can indeed divide by it. Regular fraction rules work just fine. $$\frac{dy}{dx}$$ really is a fraction of differentials.

The big "however" is that if you are going to do this with higher-order differentials and derivatives, you have to take special care, because the typical notation won't allow for canceling. This is why many people think that you can't use it as a fraction at all.

To do it with higher-order differentials and derivatives, you have to remember that the first derivative is $$\frac{dy}{dx}$$. If you take this seriously as a fraction, then to find the second derivative you would have to apply the quotient rule. If you do that, then you WILL NOT get the typical notation of $$\frac{d^2y}{dx^2}$$, but rather

$$\frac{d^2y}{dx^2} - \frac{dy}{dx}\frac{d^2x}{dx^2}$$ Or, written more explicitly:
$$\frac{d(d(y))}{(d(x))^2} - \frac{d(y)}{d(x)}\frac{d(d(x))}{(d(x))^2}$$ When written this way, you can continue to cancel differentials like you normally would in fractions.

I wrote a paper titled "Extending the Algebraic Manipulability of Differentials" which explains this in detail.

So, in short, the first differential can be used as a fraction, because it is. Higher order differentials can be used as fractions ONLY IF you use a notation that supports it, and the standard $$\frac{d^2y}{dx^2}$$ does not support this.

$$y'y''dx=\frac{dy}{dx}\frac{d^2y}{dx^2}dx=y''dy$$ Is true but I think it is easier to look at it from the other side: $$\frac d{dx}\left[y'^2\right]=2y'\frac d{dx}\left[y'\right]=2y'y''$$ and in some cases we can get into trouble thinking of these small changes $$dx,dy$$ as "cancelling out"