I'm trying to understand how to integrate stochastic differential equations using Ito's lemma. In my textbooks, I've noticed that different SDEs seem to be integrated in different ways and I cannot seem to understand the concept behind that. I would really appreciate any help.
Take for example, two equations:
$$ dX_t = -aXdt + \sigma dW_t $$
and
$$ dX_t = \mu Xdt + \sigma X dW_t $$
To solve the first equation, the method shows to let $$ f(t,x) = e^{at}x $$ such that $$ \begin{align*} d(e^{at}X_t) = df(t,X_t) &= \partial_t f(t,X_t)dt + \partial_x f(t,X_t)dX_t + \frac 12 \partial_{xx}f(t,X_t)dt \\ &= ae^{at}X_tdt + e^{at}(-aX_tdt + \sigma dW_t) \\ &= \sigma e^{at}dW_t. \end{align*} $$ which gives $$ X_t = X_0+\sigma \int_0^t e^{-a(t-u)} dW_u $$
Whereas, for the second SDE, the method is: let $$ f=log X $$ such that $$\begin{align*} df &= \partial_x fdX_t + \frac 12 \sigma^2 x^2 \partial_{xx}f dt \\ &= (\mu-\frac12 \sigma^2) dt \ +\sigma dW_t \\ \end{align*} $$ which gives $$\begin{align*} f_t = f_0 + (\mu-\frac12 \sigma^2) t \ +\sigma (W_t-W_0) \\ or, X_t = X_0 exp^ {(\mu-\frac12 \sigma^2) t \ +\sigma (W_t-W_0)} \end{align*} $$
The two SDE seems almost similar, yet the function $f$ for each differs. Which brings me to my question : How do I choose which function $f$ would be appropriate for my SDE?