This lecture discusses the production of cosmic magnetic fields during the preheating phase after inflation. The instructor outlines the theoretical framework, referencing significant works from the 1990s that introduced the concept of preheating, where the inflaton field decays into particles in a non-perturbative manner. The dynamics of tachyonic preheating are explained, highlighting how instabilities can lead to the generation of long-wave configurations of fields, including magnetic fields. The lecture also covers the role of quantum initial conditions and the transition from quantum to classical fields, emphasizing the importance of high occupation numbers in this process. The instructor presents simulations that demonstrate the growth of magnetic fields and their correlation with the Higgs field, as well as the implications for baryogenesis and gravitational wave production. The discussion concludes with insights into the significance of these findings for understanding the early universe and the formation of large-scale structures in the cosmos.