Nonlinear Analysis and Planet Wars
This post won't make sense if you don't know about Planet Wars.
The number of ships at a planet is given by the following equation where $$s$$ is the number of ships $$t$$ is which turn and $$r$$ is the rate of growth for the planet.
$$s(t) = r+s(t-1)$$
This can be re-written in an explicitly linear form.
$$s(t) = r*t+s(0)$$
Using this equation, it is simple to solve for how many ships are required to take a planet if the fleet arrives in say 10 turns (assuming there are no other fleets). The solution is $$ r*10+s(0)+1$$. The equation is simple to solve because it is linear. But what happens if there are several fleets coming at a planet- some reinforcements and some enemies. What is the equation for the number of ships on the planet? We can let enemy ships be represented as negative values.
$$ s(t) = \begin{cases} s(t-1) \geq 0, r+s(t-1)\\ s(t-1) < 0, -(r+s(t-1)) \end{cases}$$
This equation says that if a planet is taken it will generate enemy troops instead of friendly troops. Unfortunately it is not so easy to answer how many ships are required to take/keep this planet when there are several incoming fleets with competing interests. Imagine a planet with 1 ship and a growth rate of 1 and also imagine that -10 ships arrive in 5 turns, 20 arrive in 10 turns, and -30 arrive in 15 turns. I can send reinforcements in 3 turns. How big of a fleet to I need to send to keep the planet? Well what happens if I don't send any?
$$ s(0) = 1 \\ s(5) = 1+5*1 - 10 = -4 \\ s(10) = -4-(5*1)+20=11\\ s(15)= 11+5*1-30=-14$$
So does that mean I send 14?
$$ s(0) = 1 \\ s(3)= 1+3*1 + 14 = 19\\ s(5) = 19+2*1 - 10 = 11 \\ s(10) = 11+(5*1)+20=36\\ s(15)= 36+5*1-30=11$$
But what if I don't have 14 or if I only want to send the minimum number of ships to keep the planet how do I find that out? The only method I can think of at the moment is guess and check.