I'm trying to solve an economics problem but I cannot figure out how to build the equation system, or how to find the maximum in a piecewise function.
A simplified version of the function would be like this:
From 0 to $t_1$:
$X=X(t)$
Then:
$f = X_{t_1} * e^{-r * t_1}$
I want to find the $t_1$ that maximizes $f$. The maximum will depend on the function $X(t)$ directly (which in practice will be similar to $ln(x)$), but will be inverse to the $e^{-r * t_1}$ part.
Any help appreciated. Thanks!
As you said, it will depend on what $X(t)$ is, but keeping it general, the maximum can be found by finding the critical points. This will include the two endpoints $t=0$ and $t=t_1$. To find the ones in between, take the derivative and find where it equals 0:
$$f'(t)=-r*X(t)e^{-rt}+X'(t)e^{-rt}$$ $$f'(t)=e^{-rt}(X'(t)-rX(t))$$
Now find where the derivative is equal to zero: $$X'(t) = rX(t)$$
Then just compare the function value at all the critical points. Whichever one is the greatest, is the maximum.