Why do we invert then multiply when dividing fractions? I have looked up various sites online. They only explain it in a very basic arithmetic way. Would someone explain to me why is $\displaystyle\frac{x}{\frac{1}{2}}$ is $\displaystyle\frac{2x}{1}$?
$\frac{x}{\frac{1}{2}}=\frac{x}{\frac{1}{2}}\cdot1=\frac{x}{\frac{1}{2}}\cdot\frac{2}{2}=\frac{x\cdot 2}{\frac{1}{2}\cdot2}=\frac{2x}{1}$

Generally, 

$\frac{a}{\frac{b}{c}}=\frac{a}{\frac{b}{c}}\cdot\frac{c}{c}=\frac{ac}{b}=a\cdot\frac{c}{b}$
Division can be defined as multiplication by the inverse. Explicitly, for any associative division algebra (including real numbers, rational numbers, complex numbers, quaternions, etc.) we can define division by

$$a \div b = \frac{a}{b} := ab^{-1}$$

for any $b \neq 0$. If the algebra is commutative (that is $ab = ba$ for any $a, b$), which the real numbers, rationals, and complex numbers are, then we must have

$$\frac{a}{b} \div \frac{c}{d}= ab^{-1}\div (cd^{-1})= ab^{-1}(cd^{-1})^{-1}=ab^{-1}(dc^{-1})=adb^{-1}c^{-1}=(ad)(bc)^{-1}= (ad) \div (bc) =\frac{ad}{bc}= \frac{a}{b} \cdot \frac{d}{c}.$$

Thus, when you divide fractions you "flip and multiply".