If you need to wake up, caffeine can help. But for the optimal jolt, how much and when?

The U.S. Army and the Department of Defense have developed an algorithm to answer that question. It’s of critical interest because soldiers may go for days without getting enough sleep or, in some cases, any sleep at all.

A perfectly timed and ideal portion...