A random thought came into my head today when I was in the subway:
Suppose we have a train in a subway where the stations are evenly spaced in a straight line. The train accelerates for some amount of time, moves with a constant speed for some amount of time, and starts decelerating until it reaches the next station such that the same amount of time spent accelerating and decelerating are the same, and the magnitudes of both are the same. Create a possible function that illustrates this scenario.
I decided that I would try to use some combination of a sinusoidal function and a linear function, since the train would try to do the same thing during certain periods of time, and the train is moving only in one direction. I hopped onto Desmos and played around a little bit, and I was able to create a function that gets me somewhat close to what I want. $$d_1(t)=t-\frac1{2\pi}\sin 2\pi t$$

I chose the constant multiple $\frac1{2\pi}$ to simplify the distance between each station to $1$, and the multiplier $2\pi$ for $t$ to suggest that it takes $1$ unit of time to get from one station to the next. Choosing the sinusoidal function means that there will be no length of time where the train is moving at a constant speed, and the acceleration and deceleration will be exactly opposite, separated by the point of inflection halfway between the stations.
The problem: trains usually stop at every station. I want to, arbitrarily at first, modify the function so that the train waits for the same amount of time as it takes to travel from one station to another. Eventually, I want to be able to construct a function that can describe the waiting time in some proportion to the traveling time. I came up with the function
$$d_2(t)=\begin{cases}t-\frac{\lfloor t\rfloor}2-\frac1{2\pi}\sin 2\pi t,& \lfloor t\rfloor \textrm{ is even}\\ \frac{\lceil t\rceil}2,& \lfloor t\rfloor \textrm{ is odd}
\end{cases}$$

This gets me something closer to what I want.
My questions:
- What alternative ways of representing the scenario are there? For example, would it be possible to construct a piecewise function based only on polynomials that meets the criteria above?
- Is there a way to represent this particular scenario without use of a piecewise function?
- Suppose there must be a stretch of time where the train is moving at a constant speed between stations. How can I factor that in to the equation for the function?
- Suppose the train makes the return trip in a similar manner, and it makes some number of return trips daily. Does this suggest that it can be written as a periodic function? If so, what would be the equation for that function?