Solving Lagrangian Dynamics of Coupled Oscillators Using Python
Abstract
The aim of this study is to comprehensively analyze the complex dynamics of coupled oscillator systems utilizing the analytical Lagrangian formalism paired with advanced computational numerical methods in the Python programming environment. To achieve this objective, a quantitative computational research design was rigorously implemented, focusing on the numerical evaluation of theoretical mathematical models. The analytical models were derived using the Euler-Lagrange equations, and the resulting second-order ordinary differential equations were solved numerically utilizing Python's SciPy and NumPy libraries. The simulated physical system consisted of two identical masses connected by a central spring, moving in a one-dimensional frictionless environment. The process of data analysis evaluated the accuracy of the numerical solutions against established theoretical predictions by continuously monitoring total mechanical energy conservation across the temporal domain. As a result, the computational approach demonstrated an exceptionally high degree of precision in predicting the phase space trajectories and the time-evolution of the system, maintaining energy conservation with a numerical error margin of less than 10^-6 Joules over thousands of integration steps. The Python-based simulation effectively visualized the normal modes of the coupled oscillators. This study implies that integrating Python programming with analytical Lagrangian mechanics provides a robust, interactive framework for physics education.