An electromagnet produces a magnetic field using an electric current. Winding an electrical conductor into a coil combines the fields from its turns; a long solenoid is an idealized example. Far from its ends, an air-core solenoid has approximately
where turns carry electric current over length . Reversing reverses the axial magnetic field. [ref]
A core with ferromagnetism can concentrate the magnetic flux, but its response depends on magnetic saturation and magnetic hysteresis. The constant-permeability air-core formula cannot simply be extrapolated to arbitrarily large core fields. A magnetic compass near a powered coil provides a qualitative test: switching or reversing the electric current changes the compass orientation.

Articles by others on the same topic (1)

Electromagnet by Ciro Santilli 40 Created 2024-06-26 Updated 2025-07-16
Electromagnets allow us to create controllable magnetic fields, i.e.: they act as magnets that we can turn on and off as we please but controlling an input voltage.
Compare them to permanent magnet: on a magnet, you always have a fixed generated magnetic field. But with an electromagnet you can control the field, and even turn it off entirely.
This type of "useful looking thing that can be controlled by a voltage" tends to be of huge importance in electrical engineering, the transistor being another example.