Just work backwards to set up a "glide path" are the closest points/maximum speeds you can get without overshooting:
If you arrive to the destination at max 2f/s velocity and then change it to 0,
0.5 seconds earlier you are 1 ft away changing from 4f/s to 2f/s,
1 second earlier you are 3 ft away changing from 5f/s (the max) to 4f/s,
More than 3 ft away you are at 5f/s.
So the glide path is:
Distance |
Max speed arrival |
Max speed departure |
3 |
5 |
4 |
1 |
4 |
2 |
0 |
2 |
0 |
The idea is that when you get to a particular distance on a tick, you are are travelling at no more than the arrival speed, and at that distance you switch to the departure speed.
Taking your 5.4f example, if you were to travel at maximum speed if 5 f/second then you will be 5.4-2.5=2.9f away moving at 5, which is no good (faster and closer than specified by the glide path), so instead immediately reduce the speed to 4.8f/s, then after one tick you are 3f away and can reduce to 4f/s and stay on the glide path, so:
time |
distance |
speed |
0.0 |
5.4 |
4.8 |
0.5 |
3.0 |
4.0 |
1.0 |
1.0 |
2.0 |
1.5 |
0.0 |
0.0 |
So it takes 3x0.5=1.5s to get to the stopping point (your solution in comments takes 2s by travelling slower).