You can flip the coin $100$ times, but instead of having a fixed stake, you can freely choose the stake for each flip, just before the flip. You start out with $\$$$100$. After each flip, if it comes up heads you win twice your stake (and your stake is returned), and if it comes up tails you lose your stake (if you start with $x$ and select a stake of $s$, then after the flip you will either have $x−s$ or $x+2s$. You can never make your stake larger than your current balance.
My goal is to find an optimal strategy $(s_1, s_2, s_3, ..., s_{100})$ to maximize an expected profit. It turns out that the optimal strategy is $S=x$.
I understand that the expected balance after a single coin flip is:
$$\frac{x-s}{2} + \frac{x+2s}{2} = \frac{2x+s}{2}$$
which is maximized when $s = x$. To me, this makes me think that $S = x$ is a locally optimal choice, but is this sufficient to conclude that I should always take $S = x$ for every flip or was it just coincidence (that locally optimal choice leads to globally optimal solution)? I think the good analogy is a greedy algorithm (e.g the greedy algorithm makes a locally optimal choice to find a global optimum - this doesn't work most of the time).