Solving Lagrangian Dynamics of Coupled Oscillators Using Python
DOI:
https://doi.org/10.58526/jsret.v5i3.1225Keywords:
Computational Physics, Coupled Oscillators, Lagrangian Formalism, PythonAbstract
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.
Downloads
References
Bao, L., & Redish, E. F. (2001). Concentration analysis: A quantitative assessment of student states. American Journal of Physics, 69(S1), S45–S53. https://doi.org/10.1119/1.1371253
Chabay, R., & Sherwood, B. (2008). Computational physics in the introductory calculus-based course. American Journal of Physics, 76(4), 307–313. https://doi.org/10.1119/1.2835054
Goldstein, H., Poole, C., & Safko, J. (2014). Classical Mechanics 3rd ed. Pearson Education Limited.
Guttag, J. V. (2016). Introduction to computation and programming using Python: With application to understanding data. MIT press.
Harris, C. R., Millman, K. J., van der Walt, S. J., Gommers, R., Virtanen, P., Cournapeau, D., Wieser, E., Taylor, J., Berg, S., Smith, N. J., Kern, R., Picus, M., Hoyer, S., van Kerkwijk, M. H., Brett, M., Haldane, A., del Río, J. F., Wiebe, M., Peterson, P., … Oliphant, T. E. (2020). Array programming with NumPy. Nature, 585(7825), 357–362. https://doi.org/10.1038/s41586-020-2649-2
Hunter, J. D. (2007). Matplotlib: A 2D Graphics Environment. Computing in Science & Engineering, 9(3), 90–95. https://doi.org/10.1109/MCSE.2007.55
Johansson, J. R., Nation, P. D., & Nori, F. (2012). QuTiP: An open-source Python framework for the dynamics of open quantum systems. Computer Physics Communications, 183(8), 1760–1772. https://doi.org/10.1016/j.cpc.2012.02.021
Kibble, T. W. B., & Berkshire, F. H. (2004). Classical Mechanics. IMPERIAL COLLEGE PRESS. https://doi.org/10.1142/p310
Landau Rubin, H. (2015). Computational Physics. Problem Solving with Python./Rubin H. Landau, Manuel J. Páez, Cristian C. Bordeianu. Singapore: WILEY-VCH.
Linge, S., & Langtangen, H. P. (2016). Programming for Computations - Python (Vol. 15). Springer International Publishing. https://doi.org/10.1007/978-3-319-32428-9
McKinney, W. (2010). Data Structures for Statistical Computing in Python. 56–61. https://doi.org/10.25080/Majora-92bf1922-00a
Perez, F., & Granger, B. E. (2007). IPython: A System for Interactive Scientific Computing. Computing in Science & Engineering, 9(3), 21–29. https://doi.org/10.1109/MCSE.2007.53
R Taylor, J. (2005). Classical mechanics. University science books.
Susskind, L., & Hrabovsky, G. (2014). The theoretical minimum: what you need to know to start doing physics. Basic Books.
Virtanen, P., Gommers, R., Oliphant, T. E., Haberland, M., Reddy, T., Cournapeau, D., Burovski, E., Peterson, P., Weckesser, W., Bright, J., van der Walt, S. J., Brett, M., Wilson, J., Millman, K. J., Mayorov, N., Nelson, A. R. J., Jones, E., Kern, R., Larson, E., … Vázquez-Baeza, Y. (2020). SciPy 1.0: fundamental algorithms for scientific computing in Python. Nature Methods, 17(3), 261–272. https://doi.org/10.1038/s41592-019-0686-2
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2026 Munzir Absa

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Copyright @2022. This is an open-access article distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License (https://creativecommons.org/licenses/by-sa/4.0/) which permits unrestricted commercial used, distribution and reproduction in any medium
JRSET is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.


