Analogy between mechanics and electricity