Mathematical Principles of Mechanics and Electromagnetism