Optimal control and reinforcement learning in simple physical systems