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
Second, atoms of rare-earth elements can have high magnetic moments because their orbital electron structure contains many unpaired electrons, in contrast to other elements, in which almost all of the electrons exist in pairs with opposite spins, so their magnetic fields cancel out. This is a consequence of incomplete filling of the f-shell, which can contain up to 7 unpaired electrons. In a magnet it is the unpaired electrons, aligned so they spin in the same direction, which generate the magnetic field. This gives the materials high remanence (saturation magnetization "J"). The maximal energy density "BH" is proportional to "J", so these materials have the potential for storing large amounts of magnetic energy. The magnetic energy product "BH" of neodymium magnets is about 18 times greater than "ordinary" magnets by volume. This allows rare-earth magnets to be smaller than other magnets with the same field strength.