Can somebody explain what is the difference between
- $\mathrm{d}^2x$
- $(\mathrm{d}x)^2$
- $\mathrm{d}x^2$?
For example, is $\displaystyle \dfrac{\mathrm{d}^2f}{\mathrm{d}x^2}$ the same as $\displaystyle \dfrac{\mathrm{d}^2f}{(\mathrm{d}x)^2}$?
What about integrating with respect to $1$, $2$ or $3$?
The notation $\frac{\text d^2 f}{\text dx^2}$ is just that, a notation. It is meant to be evocative of the decomposition via first-derivative operators
$$ f'' = (f')' =\frac{\text d}{\text dx}\left(\frac{\text d}{\text dx} f\right) = \left(\frac{\text d}{\text dx}\right)^2 f =: \frac{\text d^2 f}{\text dx^2} $$
The concept of a differential can be formalized, leading to a mathematically sensical justification for the notation $\frac{\text df}{\text dx}$, but these frameworks typically don't have an analogue for higher-order notations.
For example, in the realm of differential topology/geometry, the operator $\text d$ satisfies $\text d^2 f = 0$ for all $f$, and $(\text dx)^2 = \text dx \wedge \text dx = 0$ as well, so their fraction is not defined and certainly doesn't represent a second-order variation in $f$. This isn't to say that this framework doesn't have a concept of higher-order derivatives, only that it is not consistent with the Leibniz notation.
There is, however, a way to view the second derivative which does align with that notation. Consider the operator $\Delta_h$ such that
$$ (\Delta_h f)(x) = f(x+h) - f(x) $$
Then, the first derivative can be written as the limit
$$ \lim\limits_{h\to 0} \frac{\Delta_h f}{\Delta_h x} $$
while the second derivative can be wrriten as the limit
$$ \lim\limits_{h\to 0} \frac{\Delta_h^2 f}{(\Delta_h x)^2} $$
and so on for higher derivatives. Importantly, these operators have no meaning as $h\to 0$ on their own, as they all go to zero individually; it is only when combined into the fraction that the limit becomes non-trivial.