What is the formula to calculate the magnetic field inside and outside of a very long solenoid? The solenoid consists of n turns per unit length on a cylinder with a radius of r and carries a steady current of i.