TITLE: Help with solving speed/time/distance traversal problem
QUESTION [6 upvotes]: I'm not any sort of math wiz, and I've run up against a problem that is fairly complex for me to solve. A friend suggested this site might be able to provide some help. So let me try to describe the issue as best I can. Let me start out by saying that I had prepared a couple of images to help explain all this, but I'm not allowed to use them in this post as I'm a new user. Hence, some references to graphs are less meaningful. I have tried to describe what the graphs depicted.
I have a path of a known distance, that must be traversed in a fixed amount of time. However, I must start the traversal of the path and end the traversal at a specific speed. So, for example, if I need to traverse 1200 feet in 10 seconds, and my entry & exit speeds must both be 120 ft./sec, then I can simply stay at the constant speed of 120 ft./second to accomplish my goal. If I graph speed against time, the area under the graph represents distance traveled as so:

(Figure 1 shows speed in the vertical axis, time in the horizontal axis, with points marked for 120 ft./sec. on the vertical and 10 seconds on the horizontal. It shows a rectangular area under the horizontal line at Speed 120 ft/sec. starting a 0 seconds and going until 10 seconds. The area shown represents the 1200 feet that would be traversed).
However, if I have to travel only 700 feet in that same 10 second interval, things get ugly. I thought about decelerating at a constant rate until I could then accelerate at a constant rate to end up with my speed curve carving a triangle out of the graph in Figure 1 above, whose area above the curve would be 500 ft. However that would yield a discontinuity in the acceleration/deceleration that is unacceptable.
I then figured I could use a segment of a circle to do the same thing as shown below:

(Cool image shows a similar graph to the one above, but with a segment of a circle cutting into the shaded area from the image above, such that the segment intersects horizontal line at time = 0 and speed = 120 ft/sec on one side and 120 ft./sec and 10 seconds on the other side, with the segment dipping down to carve out 500 "feet" from the area under the horizontal line representing a constant speed of 120 ft/sec)
Here the orange area would represent the 500 ft less than the distance traveled by a constant speed. Following the speed curve indicated by the circle segment should be pretty trivial. And so it would seem that I have solved my problem. However, when I try to actually implement this into an algorithm, I run into the problem that the area calculations for the segment of a circle doesn't seem to yield units that make any sense. Perhaps it would be better to say that I don't know how to set up the problem so that the units make sense. Sure I can calculate the area of the segment, but what does 10 seconds mean when used as the chord of the circle, and what should the units of the radius be. I guess the value of theta is still easy at least. ;) Unfortunately I'm sort of stumped on the rest. I'm not even sure that this approach is viable.
I'd be just as interested in a numerical approach to the solution as a mathematical approach.
Any help you can offer to help me get my head around this would be greatly appreciated.
= Ed =

REPLY [3 votes]: The "circle" idea is a good one. We'll convert it into more algebraic language to get a decent (general) answer.
Assume that time goes from $0$ to $T$ and the total distance travelled is $D$. Let $f$ be the velocity function, with $f(0)=v_0$ and $f(T)=v_1$. Then 
$$\int_0^T f(t)\; dt=D$$
Such an $f$ is definitely not unique, but we can find a simple $f$ by assuming it is a quadratic polynomial
$$f(t)=a+b\cdot t+c\cdot t^2$$
The boundary value conditions imply that $a=v_0$ and $b=(v_1-v_0-c\cdot T^2)/T$. Plug this in, integrate, set equal to $D$, and solve for $c$ to find that $c=(3T\cdot(v_0+v_1)-6D)/T^3$ (I used WolframAlpha to speed things up). Thus
$$f(t)=v_0+{6D-2T(v_1+2v_0)\over T^2}\cdot t+{3T(v_0+v_1)-6D\over T^3}\cdot t^2$$
satisfies our constraints.

Let's do an example. Take $D=1230$, $v_0=v_1=120$, $T=10$. Then
$$f(t)=120+{9\over 5}t-{9\over 50}t^2$$
WolframAlpha calculates the integral and draws us a picture.
Another one. Take $D=700$, $v_0=v_1=120$, $T=10$. Then
$$f(t)=120-30\cdot t+3\cdot t^2$$
WolframAlpha again for the picture.

Finally, I want to show how we can "normalize" the problem so that we can assume $D$ and $T$ both equal $1$.
We have a simple solution to the problem 
$$f(0)=w_0,\ f(1)=w_1,\ {\rm and}\ \int_0^1 f(t)\; dt=1$$
given by
$$f(t)=w_0+(6-2w_1-4w_0)\cdot t+3(w_0+w_1-2)\cdot t^2$$
We can transform this into a solution of the problem
$$F(0)=v_0,\ F(T)=v_1,\ {\rm and}\ \int_0^T F(t)\; dt=D$$
by setting $w_0=T\cdot v_0/D$, $w_1=T\cdot v_1/D$ in the above formula for $f$ and using
$$F(t)={D\over T}\cdot f\big(t/T\big)$$
Then $F(0)={D\over T}\cdot f(0)={D\over T}\cdot w_0=v_0$, $F(T)={D\over T}\cdot f(1)=v_1$, and
$$\int_0^T F(t)\; dt={D\over T}\int_0^T f\big(t/T\big)\; dt=D\int_0^1 f(t)\; dt=D$$
where the second equality uses the change of variables $t\rightarrow T\cdot t$.
For example, using $v_0=v_1=3$, $T=2$, and $D=4$, we have $w_0=w_1=6/4$ and 
$$f(t)={6\over 4}-3\cdot t+3\cdot t^2$$
Then
$$F(t)=2\cdot f(t/2)=3-3\cdot t+{3\over 2}\cdot t^2$$