The formula for the magnetic field generated by a current-carrying wire at a distance r is given by B (mu naught I) / (2 pi r), where B is the magnetic field strength, I is the current in the wire, r is the distance from the wire, and mu naught is the permeability of free space.