Exponential growth with a growth rate that varies with time

Say I have a value which is growing at a constant percentage-increase. I can calculate this using the exponential growth function, where $r$ is my growth rate; $y=y_0(1+r)^t$ Now, consider the case where $r$ is not constant, but rather changes with time: $r(t)$. For example, $r(t)$ could be the return on investment for an asset which varies with market conditions. If I know the integral of $r(t)$, can I use this to calculate $y$? How would I go about this?

-

Suppose we have discrete time: Then $y(t) = y_0 \prod_{i=0}^{t-1}(1+r(i)$).

The continuous analogue is, as far as I recall: $y(t) = y_0 \exp(\int_0^t r(x) dx)$.

(Somebody correct me if I'm wrong; at least it makes sense for $r(i) = r$ constant.)

-

If $f(t)$ grows exponentially, that is if the growth (or derivative) of $f$ at some point $t$ is proportional to $f(t)$, $f$ is described by the following linear differential equation with constant coefficients $$f'(t) = \lambda f(t)$$

If you replace the constant $\lambda$ with a function $\lambda(t)$ you again get a linear differential equation, but with time-varying coefficients $$f'(t) = \lambda(t) f(t)$$

Equations of that type can always be solved by separation of variables ( http://en.wikipedia.org/wiki/Separation_of_variables ). If you set $y = f(t)$, you get $$\frac{dy}{dt} = \lambda(t) y$$ Then you throw all caution to the wind, forget that you're not supposed to handle $dx$ and $dy$ as if they were actual quantities, and get $$\begin{eqnarray*} \frac{1}{y} dy &=& \lambda(t) dt &\implies\\ \int \frac{1}{y} dy &=& \int \lambda(t) dt &\implies\\ f(t) &=& e^{\int \lambda(t) dt} \end{eqnarray*}$$

By the chain rule, $f'(t) = \lambda(t) e^{\int_0^t \lambda(t) dt}$, i.e. $f$ is actually a solution of the original differential equation. Since you can pick any antiderivative of $\lambda(t)$, i.e. add an arbitrary constant to $\int \lambda(t) dt$, you might was well pick $\int_0^t \lambda(t) dt$, which yields the general solution $$f(t) = f(0)e^{\int_0^t \lambda(t) dt}$$

-