The magnetic properties of ferromagnetic thin films with three spin layers were investigated for the first time using fourth-order perturbed Heisenberg Hamiltonian. Total magnetic energy was determined for ferromagnetic materials with simple cubic lattice. The simulation was carried out for Heisenberg Hamiltonian with different second-order magnetic anisotropy constants in different spin layers. The total magnetic energy periodically varies with spin-exchange interaction, azimuthal angle of spin, and the second-order magnetic anisotropy constant in each spin layer. The peaks along the axis of the angle are closely packed except in the 3-D plot of energy versus angle and second-order magnetic anisotropy constant of the middle spin layer. 2-D plots were perceived by rotating 3-D plots in MATLAB. According to the 3-D plot, the angle between magnetic easy and hard directions is 90 degrees. The minimum energy range was found in the 3-D plot of energy versus angle and the second-order anisotropy constant of the middle spin layer. The samples with the minimum magnetic anisotropy energies have potential application in transformer cores, magnetic switching, and magnetic amplifiers.