The reason why so many people get the wrong idea about differentials is that they aren't really taught what the notation means. They are merely taught "this is what the notation is, and please don't ask any deep questions." This is a recipe for misusing the notation. Additionally, some of the standard notations (like for the second derivative) are flat-out wrong, but we will get to that later.
To start out with, you should think of $d()$ as a function. Therefore, $dy$ is actually shorthand for $d(y)$. The differential function can be applied multiple times, such as $d(d(y))$, which is normally written as $d^2y$.
So, when you see a notation that says $d^2(y)$ you should think $d(d(y))$ and when you see a notation that says $dx^2$ you should think $(dx)^2$.
This alone clears up a LOT of confusions that people have in dealing with the notation.
With this explanation in hand, it becomes obvious and clear why $d^2y$ and $dy$ don't cancel. It's the same reason why you can't cancel with $\sin(\sin(y))$ and $\sin(y)$. In fact, for this reason, when I'm doing technical writing, I usually write the "d" with non-italic text, like $\mathrm{d}y$, so that it is typographically evident that "d" and "y" are playing different roles (I don't do that here, because I have a bunch of LaTeX macros that help me out that I don't have here).
Now, I'm going to go against mainstream wisdom and say that $\frac{dy}{dx}$ absolutely should be treated as a fraction. Doing so simplifies Calculus in a number of ways, which I will show:
- It is more clear to the student what is going on
- It removes the distinction between explicit and implicit differentiation
- It removes the distinction between single-variable and multivariable differentiation
In other words, you get a single, unified, standardized process for all of these types of differentiation.
The way that I teach it is to NEVER take derivatives initially. ONLY take differentials. Then, you can SOLVE for whatever derivative you want. But first, you have to convert your derivative rules into differential rules. So, for a few rules (hopefully you can figure out the rest):
- $d(C) = 0$
- $d(u) = du$
- $d(nu) = n\,du$
- $d(u^n) = n\,u^{n-1}\,du$
- $d(uv) = u\,dv + v\,du$
Now, let's take the equation $z = xy - g$, where all of these letters are actual variables. Let's say we want to find $\frac{dg}{dy}$. Well, the first step NO MATTER WHAT derivative you want to find, is to take the differential of both sides:
$$
d(z) = d(xy - g) \\
d(z) = d(xy) - d(g) \\
dz = x\,dy + y\,dx - dg
$$
Now, to find the derivative $\frac{dg}{dy}$ we just algebraically manipulate the equation:
$$
dz = x\,dy + y\,dx - dg \\
dg = dz - x\,dy - y\,dx \\
\frac{dg}{dy} = \frac{dz}{dy} - x\frac{dy}{dy} - y\frac{dx}{dy} \\
\frac{dg}{dy} = \frac{dz}{dy} - x - y\frac{dx}{dy}
$$
Now, the real problem comes with the second derivative. You can't treat that as a fraction. However, this is not because it doesn't work, but because the notation that has been handed down is simply wrong (or, technically, it is only right within a particular context). The second derivative is usually given as:
$$\frac{d^2y}{dx^2}$$
This is only true when x is the independent variable. If you later say that $x$ depends on some other variable, such as $t$, the notation will break down. The full notation for the second derivative (which does allow for treating it as fractions) is:
$$\frac{d^2y}{dx^2} - \frac{dy}{dx}\frac{d^2x}{dx^2}$$
This can be easily shown by just applying the quotient rule to the first derivative and simplifying:
$$
d\left(\frac{dy}{dx}\right) = \frac{dx\,d(dy) - dy\,d(dx)}{dx^2} \\
= \frac{dx\,d^2y - dy\,d^2x}{dx^2} \\
= \frac{dx\,d^2y}{dx^2} - \frac{dy\,d^2x}{dx^2} \\
= \frac{d^2y}{dx} - \frac{dy}{dx}\frac{d^2x}{dx} \\
$$
That was just the differential--to get the second derivative you also have to divide by $dx$, yielding:
$$ = \frac{d^2y}{dx^2} - \frac{dy}{dx}\frac{d^2x}{dx^2} $$
So, as you can see, using basic differential rules, most (all?) of the "problems" with treating the derivative as a fraction go away, and, in its place, you have students who not only know what the notation means, they can use it effectively.
For more information on this notation for the second derivative, see
Disclaimer: I am currently working on a book on Calculus, the reason which I wrote it is largely to answer questions like these - most (all?) Calculus books have very awful discussions of differentials and what they mean.