Home > Python > Ordinary Differential Equation-1

Ch. 6.2 Motion of a Harmonic Oscillator

Chapters Index
Program 1

Motion of a Harmonic Oscillator

Python 3.11 Ready

                                
Click "Run Code" to execute script and render figures.

Mathematical Problem Formulation

This Python program simulates the motion of a one-dimensional harmonic oscillator using numerical integration (Euler's method). The harmonic oscillator follows Hooke's Law, where the force acting on the object is proportional to its displacement and is given by:

\[ F = -kx \]

Where:

  • \( F \) is the force acting on the object
  • \( k \) is the spring constant
  • \( x \) is the displacement of the object from the equilibrium position