Solution to geometric Brownian motion with time dependent volatility and drift?

I am able to compute the general solution of a standard geometric Brownian motion, but I'm struggling to find the general solution for a GBM where volatility and mean depend on time, $$\text{d}S_t = \mu(t) S_t\text{d}t+\sigma(t) S_t\text{d}W_t.$$

The general solution for a standard geometric Brownian, $$\text{d}S_t = \mu S_t\text{d}t+\sigma S_t\text{d}W_t$$ can be computed by firstly separating the variables $$\frac{\text{d}S_t}{S_t} = \mu \text{d}t+\sigma \text{d}W_t$$, then taking integration on both sides $$\int\frac{\text{d}S_t}{S_t} = \int \mu dt+\sigma dW_t$$. Since $$\frac{\text dS_t}{S_t}$$ links to the derivative of $$\ln(S_t)$$, the proceeding step constitutes the Itô calculus and results in $$\ln(S_t) = (\mu - \frac{1}{2} \sigma^2)t + \sigma W_t$$. Then taking exponential on both sides and plugging in the initial condition $$S(0)$$ we obtain the analytical solution $$S(t) = S(0) e^{(\mu - \frac{1}{2} \sigma^2)t+ \sigma W_t}$$

However, when $$\mu$$ and $$\sigma$$ are time dependent $$\text{d}S_t = \mu(t) S_t\text{d}t+\sigma(t) S_t\text{d}W_t$$, the solution is totally different and I tried applying the same methods I used in a standard geometric Brownian motion but the solution is not correct. I have found some material online but it doesn't seem to make sense to me ... I am able to continue up until integrating on both sides, then after that I don't know what to do.

Consider the generalised geometric Brownian motion $$\text{d}S_t = \mu(t)S_t \text{d}t+\sigma(t)S_t \text{d}W_t.$$
Using Itô's Lemma, you get $$\text{d}\ln(S_t) = \left(\mu(t)-\frac{1}{2}\sigma^2(t)\right)\text{d}t+\sigma(t) \text{d}W_t.$$ Thus, by definition of an SDE, $$\ln(S_t) =\ln(S_0)+\int_0^t \left(\mu(s)-\frac{1}{2}\sigma^2(s)\right)\text{d}s+\int_0^t\sigma(s) \text{d}W_s.$$ Thus, $$S_t =S_0\exp\left(\int_0^t \left(\mu(s)-\frac{1}{2}\sigma^2(s)\right)\text{d}s+\int_0^t\sigma(s) \text{d}W_s\right).$$ You cannot simplify these integrals without assuming what your drift and variance are. You can however compute moments of the stock price, etc. The process is still log-normally distributed.
• Thanks @Kevin, that is actually what I want to do, I am doing this for project in mathematical modelling module I study at my final year bachelor's studies. I notice that $\mu(t)$ changes to $\mu(s)$, could you clarify what does 's' represent? Is it same as t (time) but different notation? – PlatinumMaths Mar 23 at 19:15
• @PlatinumMaths I hope you enjoy your modelling module :) The $s$ is just an integral dummy variable. You can use $u$ or $\tau$ instead (or whatever really). The point is that $S_t$ contains integrals that go from $0$ to $t$ (depend on the entire history of the path up to time $t$). Thus, the integrals of the drift and volatility need to have another variable, other than $t$. By default, I picked $s$. It's like writing $t^2 = 2\int_0^t s\text{d}s$. Makes sense? – Kevin Mar 23 at 19:20