TITLE: Terminology re: continuity of discrete $a\sin(t)$
QUESTION [5 upvotes]: This question is specifically about the terminology used to explain a particular problem and its solution, not the math itself. I am a programmer, I am not really a math person, but I have at least an intuitive understanding of the concepts I frequently encounter in computer graphics.
Recently a friend was doing some computer animation work that involved a sine wave with an amplitude and period that were functions of time. Let's call value $V$, amplitude $a$, period $p$, time $t$. He ran into a classic problem where he was doing:
$$
V(t)=a(t)\sin\left(\frac{2\pi t}{p(t)}\right)
$$
With $t$ set to the elapsed time since the start of the program, i.e. $t=t_\text{now}-t_\text{start}$. The problem, of course, is that as $p(t)$ changed, all sorts of artifacts were visible and the sine wave did not smoothly transition in apparent speed. He asked how to solve this problem. I explained to him that he instead needed to work with the current phase instead of absolute time, incrementing each frame based on the period, like so (initializing $t$ to 0):
$$
t = t + \frac{\Delta t}{p(t)}
$$
$$
V(t)=a(t)\sin(2\pi t)
$$
Then I awkwardly launched into some explanation (that ultimately required a pen and paper) about how you want to "smoothly move around the circle, incrementing so that changes in speed don't jump to far away positions" rather than "jumping between graphs of sine waves of different frequencies" or something. In the end he got it, and fortunately he intuitively understood what I was trying to say, but I did a really poor job of explaining it.
So my first question is, and apologies if this is asking too much, but how would you explain this to somebody, succinctly, using proper math terms? I realize there are many answers, but currently I know 0 answers. How can I explain to somebody why incrementing the phase based on $\Delta{t}$ and $p(t)$ leads to continuity, while calculating the value based on the total elapsed time doesn't?
My second question is this: My friend then asked me, "do I need to do the same with amplitude?" The answer is no (assume that the "continuity" of $a(t)$ is "good enough"). I couldn't explain why, though. I mean, intuitively, I knew why, and I said, "No. I don't know the math term for it but the $a(t)$ is outside the $\sin()$ so it works out." What are the words I was looking for there? How can I explain to somebody that $a(t)$ doesn't suffer the same problem as the $t/p(t)$ did? I know it has something to do with the way $\sin(x)$ varies with $x$, but I don't know the proper way to describe it.
My third question is that at some point during this process I was explaining why the two equations above were identical for a constant $p(t)$. My explanation involved something like, "Well, I mean, the elapsed time is the same as all of the delta times added together, so you can see if you pull these terms out of the $\sin()$ and increment instead, the value is the same." Even typing that, it makes very little, if any, sense. On paper I wrote:

The original:
$$t=t_\text{now}-t_\text{start}$$ $$\sin\left(\frac{2\pi t}{p(t)}\right)$$
Is the same as:
$$t=t+\Delta t$$ $$\sin\left(\frac{2\pi t}{p(t)}\right)$$
Is the same as:
$$t=t+\frac{\Delta t}{p(t)}$$ $$\sin\left(2\pi t\right)$$
When $p(t)$ is a constant function.

... but I couldn't explain why. How can I explain to somebody that incrementing by deltas every frame is the same as the difference between the current frame and the first frame? Is there some terminology that fully encapsulates this so that an example is not necessary?
Heck, I don't even know what the fundamental problem is called, I always just refer to it as an "artifact" in a generic sense.
How would you explain this problem and its solution to somebody?
Note: I realize I am liberally interchanging "time" (i.e. seconds) and "phase" above -- this is really just another symptom of my inability to express these thoughts clearly.
Update:
I have created two JavaScript demos that try and illustrate the problem:

Example 1: Period is linear function of x (i.e. time)
Example 2: Period is step function of x (i.e. time)
Sorry, the examples are no longer online (11/11/15).

The first example is a more typical case in my experience. The second example shows the problem very sharply and may be more illustrative. 
Basically, my question is: How could I explain why the incorrect approach is incorrect, and why the correct approach is correct, without using pictures or animated examples, but instead with proper and clear mathematical language?

REPLY [4 votes]: Example Results
To make this more self-contained, I'll paraphrase the two pairs of example results linked in the OP.
"The goal is a sine wave where period is a function of x. Example uses period=80 at x=0, decreasing linearly to period=20 at x=600, then holding at 20 (x range is 0 to 800)."
Good: 
Bad: 
"The goal is a sine wave where period is a function of x. Example uses a step function where period=80 for x<390, and period=120 for x>=390."
Good: 
Bad: 

Explanations
0. Explaining the goal
The examples in the OP made it clear what we're looking for on an intuitive level, but what does "a sine wave where period is a function of x" really mean? For it to be called a wave at all, it better be continuous. But to have a "period" at a particular time, we need to figure out a way to detect the period of a sine wave based on local information, and we can use that as our definition. I claim that if $|f'(t)|$ at the point is the same as the derivative of the sine wave of appropriate period $p$ when that sine wave is at height $f(t)$, then we should say "the period of $f$ at $t$ is $p$" (note that when $f(t)=\pm1$ then $|f'(t)|=0$ and "the period at $t$ is $p$" is true for all $p$).
Justification for claim (you can skip this if it's geometrically intuitive):
If we have a sine wave of constant period $p>0$ (and amplitude $1$), then we may as well pick $s(t)=\sin(2\pi t/p+\phi)$, and I claim we can detect the period via the use of the derivative: $s'(t)=(2\pi/p)\cos(2\pi t/p+\phi)$. Note that $$|s'(t)|=\frac{2\pi}p\sqrt{\cos^2(2\pi t/p+\phi)}=\frac{2\pi}p\sqrt{1-\sin^2(2\pi t/p+\phi)}=\frac{2\pi}p\sqrt{1-\left(f(t)\right)^2}\text{,}$$ so that $p=2\pi\sqrt{1-\left(s(t)\right)^2}/|s'(t)|$. If you have two sine waves with the same height and derivative-magnitude somewhere, then they have the same period. Conversely, since you can solve that last equation for $|s'(t)|$, if they have the same height and the same period, then they have the same derivative-magnitude (this makes sense because one could be going up and the other could be going down).
1a. Why does the good method work?
The OP said "Essentially the correct approach is something like computing a discrete integral, maybe." Indeed, the result of adding $(\Delta t)/p\left(t\right)$ to $t$ at each stage (for small $\Delta t$) is an approximation to $\int_{0}^{t}1/p\left(\tau\right)\,\mathrm{d}\tau$. The good method is approximating a function like $$f(t)=\sin\left(2\pi\int_{0}^{t}\frac{1}{p\left(\tau\right)}\mathrm{d}\tau\right)\text{.}$$ For the period to be correct, we expect that to have derivative (at least up to a sign change) $$\frac{2\pi}{p(t)}\cos\left(2\pi\int_{0}^{t}\frac{1}{p\left(\tau\right)}\mathrm{d}\tau\right)$$ at every point of continuity of $p$, and by the chain rule and the fundamental theorem of calculus, we can see that it does. Furthermore, the sign of $f'$ doesn't suddenly flip because even though $p(t)$ suddenly changes at points of discontinuity, it's still positive everywhere, and the cosine part is of the derivative is continuous because integrals like this of reasonable functions are always continuous (see Lemma 6.1 in these lecture notes).
1b. Why does the bad method fail? and 3. But why not if $p$ is constant?
In part 0, we said that having the right period at a given height means having the right $|f'(t)|$. We just have to show that in general, the bad method doesn't give us that. If we use $f(t)=\sin(2\pi t/p(t))$, then we expect a derivative of $(2\pi/p(t))\cos(2\pi t/p(t))$ but (assuming $p$ is differentiable) we get a derivative of $$2\pi\left(\frac{\mathrm{d}}{\mathrm{d}t}\frac{t}{p(t)}\right)\cos\left(2\pi\frac{t}{p(t)}\right)=2\pi\left(\frac{1}{p(t)}-t\frac{p'\left(t\right)}{\left(p\left(t\right)\right)^{2}}\right)\cos\left(2\pi\frac{t}{p(t)}\right)\text{.}$$ The error in this method is caused by the term with $-tp'(t)/\left(p(t)\right)^2$, which is zero when $t=0$ (the starting point), $\cos=0$ (the function is $\pm1$ so the derivative is just $0$), or $p'(t)=0$ ($p$ is constant near $t$).
But what about if $p$ is constant on two sides of a jump discontinuity? Then $sin(2πt/p(t))$ will likely be discontinuous there. That's a different problem with the bad method compared to what I explained above, which covers the first example but didn't really explain the step function example.
2. What about $a(t)$?
First note that if $a(t)$ is constant and positive, you can just stick $a$ in front of all the formulas above and nothing really changes. Now, the OP's examples both had $a=1$, but I'm going to assume the goal is things that still look like sine waves. The solutions discussed above are sine waves with minimum $-1$ and maximum $1$, so if we want to stretch/squish things vertically at the input $t$ by a factor of $a(t)$, we replace $y$ by $y/(a(t))$ (just like horizontal stretch by a constant factor is replacing $t$ with $t/p$). But $y/(a(t))=\sin(\text{whatever})$ is equivalent to $y=a(t)*\sin(\text{whatever})$. It's not like horizontally stretching which could mess up nearby points; we do this at every $t$ independently, so there's nothing else to worry about.

Bonus: How could we find all good methods?
Let's forget about this discrete situation for a second, and ask ourselves the following: Suppose that $p(t)$ is some piecewise continuous, strictly positive, function. Which continuous function(s) $f(t)$ with $|f(t)|\le1$ have period $p(t)$ at every point of continuity of $p$ and signs of the left and right derivative match up wherever $p(t)$ is discontinuous? We can break this up into two parts: solving the problem for continuous $p$, and stitching the solutions together for other $p$.
Continuous period functions
Our earlier work tells us that the having period $p(t)$ means $|f'(t)|=2\pi\sqrt{1-\left(f(t)\right)^2}/p(t)$, where this makes perfect sense since $|f(t)|\le1$ and $p(t)>0$. This may look a little scary, but it's essentially a separable differential equation:
$$\left|y'\right|=2\pi\sqrt{1-y^{2}}/p\left(t\right)\Rightarrow\frac{\mathrm{d}y}{\mathrm{d}t}=\pm2\pi\sqrt{1-y^{2}}/p\left(t\right)$$ If $\left|y\right|=1$, then $\mathrm{d}y/\mathrm{d}t=0$. Otherwise, we can divide to get:
$$\frac{1}{\sqrt{1-y^{2}}}\mathrm{d}y=\pm\frac{2\pi}{p\left(t\right)}\mathrm{d}t\Rightarrow\arcsin y=\pm2\pi\int_{t_{0}}^{t}\frac{1}{p\left(\tau\right)}\mathrm{d}\tau+C$$$$\Rightarrow y=\sin\left(\pm2\pi\int_{t_{0}}^{t}\frac{1}{p\left(\tau\right)}\mathrm{d}\tau+C\right)$$
(Note that for these $y$, $\mathrm{d}y/\mathrm{d}t=0$ whenever $\left|y\right|=1$, so we didn't really lose that special case.)
To generate the pictures like in the examples, we should force $f(0)=0$ and $f'(0)>0$. The first condition makes $C=2\pi k$ or $C=\pi+2\pi k$, but $\sin(x+\pi+2\pi k)=-\sin x=\sin(-x)$, so the $\pm$ sign allows us to safely take $C=0$. Since $f'(0)=\pm(2\pi/p(0))\cos(0)$, we should pick the $+$ sign, and for continuous $p$ we have the solution $$f(t)=\sin\left(2\pi\int_{0}^{t}\frac{1}{p\left(\tau\right)}\mathrm{d}\tau\right)\text{.}$$
Arbitrary period functions
Now, if $p$ is discontinuous, we might have to break this into separate cases. Suppose $p$ is first discontinuous at $t_1>0$, with left limit $p_\ell(t_1)$ and right limit $p_r(t_1)$. Then the solution to the left of $t_1$ is given by the formula above, and has (left) derivative at $t_1$ given by $$\frac{2\pi}{p_\ell(t_1)}\cos\left(2\pi\int_{0}^{t_1}\frac{1}{p\left(\tau\right)}\mathrm{d}\tau\right)\text{.}$$ Since $f$ is supposed to be continuous at $t_1$, the solution to the right of $t_1$ is given by $$\sin\left(\pm2\pi\int_{t_{1}}^{t}\frac{1}{p\left(\tau\right)}\mathrm{d}\tau+2\pi\int_{0}^{t_1}\frac{1}{p\left(\tau\right)}\mathrm{d}\tau\right)$$ for a certain choice of sign for $\pm$. The (right) derivative at $t_1$ is then given by $$\pm\frac{2\pi}{p_r(t_1)}\cos\left(\pm2\pi\int_{t_{1}}^{t_1}\frac{1}{p\left(\tau\right)}\mathrm{d}\tau+2\pi\int_{0}^{t_1}\frac{1}{p\left(\tau\right)}\mathrm{d}\tau\right)=\pm\frac{2\pi}{p_r(t_1)}\cos\left(2\pi\int_{0}^{t_1}\frac{1}{p\left(\tau\right)}\mathrm{d}\tau\right)\text{.}$$ Since $p_\ell(t_1),p_r(t_1)>0$, the sign matches up correctly when the $+$ sign is chosen. We can repeat this argument at each discontinuity, so that the original formula $f(t)=\sin\left(2\pi\int_{0}^{t}(1/p\left(\tau\right))\,\mathrm{d}\tau\right)$ still works as written even for discontinuous $p$!
Discretization
A standard way to discretize the above exact solution is by replacing the integral in the above along the lines of $$\int_{0}^{t}\frac{1}{p\left(\tau\right)}\mathrm{d}\tau\rightsquigarrow\sum_{k=1}^{t/\Delta t}\frac{\Delta t}{p\left(k\Delta t\right)}\text{.}$$
But that's just the "right-hand sum". You could use the left-hand sum or a trapezoidal rule or Simpson's rule, etc. Now that we know that the exact solution involves an integral, we can use any simple or advanced method for approximating that integral.