I am making a game, and controlling a character's velocity.
The game works by updating the character's velocity 60 times per second.
At each frame, I do this:
"set new velocity to current velocity + accelerationRate * (maxVelocity – currentVelocity)"
I wrote this out as this series equation (I think that's what this is called, if not please let me know). To simplify I'm using my accelerationRate as .2 and the maxVelocity as 800.
$$a_n = a_{n-1} + .2 * (800 – a_{n-1})$$
So as a series that starts at 0, I'd have:
0, 160, 288, 390.4, 472.32
for my first 5 values.
So I have a few questions:
- What is my $a_n$ equation called? Is that a "series equation"?
- How do I solve for the nth term?
- How do I rewrite this as a sum and/or as an exponential function?
Thanks.. I am really rusty on this.. Sorry for abusing terminology here
Best Answer
Take $a_0=0,a_n = \frac45a_{n-1} + 160$. Now notice that by repeated substitution, $$\begin{align} a_n&=\frac45a_{n-1} + 160 \\&=\left(\frac45\right)^2a_{n-2} + 160+\frac45\cdot160 \\&=\left(\frac45\right)^3a_{n-3}+160+\frac45\cdot160+\left(\frac45\right)^2\cdot160 \\&=\left(\frac45\right)^na_0+160\sum_{k=0}^{n-1}\left(\frac45\right)^k \\&=800\left(1-\left(\frac45\right)^n\right) \end{align}$$