How does one derive the elasticity of substitution? For two goods $x$ and $y$, the elasticity of substitution is defined as $$\sigma \equiv \frac{d\log\left(\frac{y}{x}\right)}{ d\log\left(\frac{U_x}{U_y}\right) }= \frac{\frac{d\left(\frac{y}{x}\right)}{\frac{y}{x}}}{ \frac{d\left(\frac{U_x}{U_y}\right)}{\frac{U_x}{U_y}}} $$

I am confused by two things: 


Why do we just write $d\log\left(\frac{y}{x}\right)$? What are we differentiating with respect to? 
How do I use that that to show the above relation? 


Can someone explain?
How to derive elasticity of substitution
The first step is to recall the definition of a differential. If you have a function $f: \Bbb R^n \to \Bbb R$, say, $f(x_1,\cdots,x_n)$, then: $${\rm d}f = \frac{\partial f}{\partial x_1}{\rm d}x_1 + \cdots + \frac{\partial f}{\partial x_n}\,{\rm d}x_n. $$
For example,  $$d\log v = \frac{1}{v}dv$$
Now suppose $v = \tfrac{y}{x}$, then we have $$ d\log(y/x)=\frac{d(y/x)}{(y/x)}$$
and for $v = \tfrac{U_x}{U_y}$
$$ d\log(U_x/U_y)=\frac{d(U_x/U_y)}{(U_x/U_y)}$$
In other words, if you reduce the problem to (1) understanding the definition of a differential and (2) use a simple change of variable, the problem becomes very straightforward.
You then get
$$\sigma \equiv \frac{d\log\left(\frac{y}{x}\right)}{ d\log\left(\frac{U_x}{U_y}\right) }= \frac{ \frac{d(y/x)}{(y/x)} }{ \frac{d(U_x/U_y)}{(U_x/U_y)} } $$
ASIDE:
Note, it is important to recognize that $ d(y/x)$ is a meaningful concept. You simply apply quotient rule and you find
$$ d(y/x)= \frac{xdy-ydx}{x^2}$$
This makes sense because
$$ d\log(y/x) = d\log(y) - d\log(x) = \frac{dy}{y}-\frac{dx}{x}$$
And if you compute
$$ d\log(y/x)=\frac{d(y/x)}{(y/x)}=\frac{ \frac{xdy-ydx}{x^2}}{y/x} =  \frac{xdy-ydx}{xy} = \frac{dy}{y}-\frac{dx}{x}$$
Same logic applies to $d(U_x/U_y)$.
Thus, all of $\sigma$ is well-defined in the sense we are using the calculus tools correctly / legally.

What is elasticity of substitution?
Elasticity is by how much % one thing changes relative to a % change in another. Therefore, in this case, it is % change in ratio of two goods  relative to a single % change in the $MRS$ for those two goods.