Modern cars with fuel injection change the rules a bit. Ideally, you want to keep the engine running at it's peak power band in regards to economy and efficiency as well. Gas engines are not volumetrically efficient at low speeds nor at high speeds....the optimum economy is achieved by accelerating briskly to about 45 mph and staying there. In a general way, anything lower is not efficient and anything higher puts exponentially more drag on the car to overcome. It's also based on how the engine and other components were engineered to stay in a certain range of driving parameters for the optimal economy. We could start discussing volumetric efficiency and coefficient of drag and get into all sorts of mathematical equations based on air density, wind, C.D., friction losses and such but it all boils down to general rules and real world driving and testing for individual cars and engines.
Hybrids are somewhat different in that they run off electric power and gas under different loads and conditions so maximizing economy for them will differ with driving methods than on gas alone.
5th gear is not always best if it strains the engine or keeps it out of it's optimum power band for best efficiency.