# Is it allowed to take the total derivative of an infinitesimal, and is it equal to zero?

$$s^2=x^2+y^2$$

Taking the total derivative on each side, I get:

$$2sds=2xdx+2ydy$$

Can I take the total derivative a second like this:

$$d[sds]=d[xdx]+d[ydy]\\ dsds+sd[ds]=dxdx+xd[dx]+dydy+yd[dy]\\ (ds)^2=(dx)^2+(dy)^2$$

where $$d[d[s]]=0$$.

If you are treating differentials as algebraic units, the second differential is not equal to zero. You can think of it as a second-order infinitesimal, but it is not zero. It can be represented as you did $$\text{d}(\text{d}x)$$, but it is more often represented as $$d^2(x)$$.
$$(\text{d}s)^2 + s\,\text{d}^2s = (\text{d}x)^2 + x\,\text{d}^2x + (\text{d}y)^2 + y\,\text{d}^2y$$