Extending Mechanics to Minds: The Mechanical Foundations of Psychology and Economics