How do magnetic fields work?

A bar magnet attracts iron objects to its ends, called poles. One end is the north pole, and the other is the south pole. If the bar is suspended so that it is free to move, the magnet will align itself so that its north pole points to the geographic north of the earth. The suspended bar magnet acts like a compass in the earth's magnetic field. If two bar magnets are brought close together, the like poles will repel each other, and the unlike poles attract each other. (Note: By this definition, the magnetic pole under the earth's north geographical pole is the south pole of the earth's magnetic field.)

This magnetic attraction or repulsion can be explained as the effect of one magnet on the other, or it can be said that one magnet sets up a magnetic field in the region around it that affects the other magnet. The magnetic field at any point is a vector. The direction of the magnetic field (B) at a specified point is the direction that the north end of a compass needle points at that position. Magnetic field lines, analogous to electric field lines, describe the force on magnetic particles placed within the field. Iron filings will align to indicate the patterns of magnetic field lines.