I have a slight confusion on how to integrate functions of the form: $$\int\frac{a}{x}dx$$
Suppose we have the following function: $$\int\frac{-2}{x}dx$$ There are two ways we can proceed to integrate this function. One is to treat the $-2$ sign as a constant and take it out of the integration function: $$-2\int\frac{1}{x} = -2\ln{x} = \ln{\frac{1}{x^2}}$$ Another way to do this is to treat the $-2$ as part of the integration variable: $$\int\frac{1}{-0.5x}dx = -2\ln{(-0.5x)}$$
This seems to obtain two different answers. Which method is correct? Or is there something that I'm missing?
To be proper, you should use that
$$\int \frac{1}{x} dx = \ln |x| + C$$
not just $\ln x$ (as defining the logarithm for negative numbers requires some care). Given this, you found two antiderivatives:
$$\ln \frac{1}{x^2} \quad \text{ and } -2 \ln (.5 |x|)$$
The second one can be written as
$$-2 \ln (.5) - 2 \ln |x| = -2 \ln (.5) + \ln \frac{1}{x^2}$$
These differ by a constant, which is not a problem.