Present value of all future costs associated with a policy of equipment replacement after time $T$. It is required to  find the optimal replacement time  of a certain type of equipment. The initial cost of equipment is $C$. Salvage value and repair cost are given by $S(t)$ and $R(t)$ respectively. The cost of capital is $r \%$ and $T$ is the time period of the replacement cycle.

*

*Show that the present value of all future costs associated with a policy of equipment replacement after time $T$ is $$\Big(\frac{1}{1- e^{-rt}}\Big)\Big[C-s(t)e^{-rt} + \int_0 ^T R(t)e^{-rt} dt\Big].$$


*The optimal value of $T$ is given by $$R(t) - S^\prime (t) +S(t)r = \frac{r^k}{1-e^{-rt}}$$ where $k$ is the present value of the cycle.


I have no idea. Please help me.
 A: During the life of the equipment, you pay $R(t)$ repeatedly. Also, you pay $C$ at the beginning of the cycle, and receive $s(t)$ when you sell the equipment. For ease of exposition, consider first the problem in discrete time.
$$
    \quad \quad \quad     \quad \quad \quad                 +S\\
..\longleftarrow\downarrow-\downarrow-\downarrow-\downarrow-\uparrow \longrightarrow...\\
-C -R-R-R  \quad \quad \quad \\ 
$$
The present value (at $t=0$) of your discrete expenses from $t=1$ to $t=T$ is $X_0=-C-\sum_{t=0}^{T}\frac{R_t}{(1+r)^ t}$, and the present value of your income is $N_0=\dfrac{s_t}{(1+r)^t}$. In total $-C+s_t(1+r)^{-t}-\sum_{t=0}^{T}R_t(1+r)^{-t}$.
The above expresion, for a continuous (logarithmic) rate $r$, is
$$V=-C+s(t)e^{-rt}-\int_{t=0}^{T}R(t)e^{-rt}dt$$
As the equipment replacement takes place in cycles, my guess is that $V$ is a perpetuity. Also, recall that a discrete (geometric) rate $i$ for the whole period of each cycle equals $e^{rt}-1$, or $-i=1-e^{rt}$. Thus, the value of the perpetuity is
$$-\frac{V}{1-e^{rt}}=\left[\dfrac{1}{1-e^{rt}}\right]\left[C-s(t)e^{-rt}+\int_{t=0}^{T}R(t)e^{-rt}dt\right]$$
