I am having trouble knowing what to do here. Can you give me a hint about what to solve this? It's a recurrence relation. Anything is helpful at this point.
"You take a loan of S dollars that is to be paid back in T periods of time. If r is the interest rate per period of the loan, what constant payment P do you have to make at the end of each period? This is a boundary value problem. What are the boundary values? Solve it on the computer. Say r = 0:05 and S = 10000. Try different P and see for which T you have paid back. Plot with command Plot the values of your debt after period n, an, where a0 = S."
The plotting is referred to Mathematica by the way. I know that, with interest at 5%, we have A0 = 10000, A1 = 10.500, A2 = 11.025 and so on. So a recurrence relation (in my head) would be An = An-1 + 0.05*An-1. But I don't know how that helps me solve the problem. How can I define P if T is also not defined?
$a_n = a_{n-1} \cdot (1+r) - P$ where $a_0 = S$.
Plot out some values to get a sense for how things change:
$a_0 = S$
$a_1 = S \cdot (1+r) - P$
$a_2 = S \cdot (1+r)^2 - P - P \cdot (1+r)$
$a_3 = S \cdot (1+r)^3 - P - P \cdot (1+r) - P \cdot (1+r)^2$
And so on. This means:
$$a_T = S \cdot (1+r)^T - P \cdot \sum_{k=0}^{T-1} (1+r)^k$$
or
$$a_T = \dfrac{(1 + r)^T (S \cdot r - P) + P}{r}$$
We want $a_T = 0$, which means if we know $T$ and want to solve for $P$:
$$P = \dfrac{r \cdot S \cdot (1 + r)^T}{(1 + r)^T - 1}$$
Or if we know $P$ but want to solve for $T$:
$$ T = \dfrac{\log\left(\dfrac{P}{P - r \cdot S}\right)}{\log(1 + r)} $$