Magnet
Rare earth (lanthanoid) elements have a partially occupied "f" electron shell (which can accommodate up to 14 electrons). The spin of these electrons can be aligned, resulting in very strong magnetic fields, and therefore, these elements are used in compact high-strength magnets where their higher price is not a concern. The most common types of rare-earth magnets are samarium-cobalt and neodymium-iron-boron (NIB) magnets.
Rare-earth magnet
The greater strength of rare-earth magnets is mostly due to two factors. First, their crystalline structures have very high magnetic anisotropy. This means that a crystal of the material preferentially magnetizes along a specific crystal axis but is very difficult to magnetize in other directions. Like other magnets, rare-earth magnets are composed of microcrystalline grains, which are aligned in a powerful magnetic field during manufacture, so their magnetic axes all point in the same direction. The resistance of the crystal lattice to turning its direction of magnetization gives these compounds a very high magnetic coercivity (resistance to being demagnetized).