This project is an educational tool that explores the dynamics of a relativistic particle using the Lagrangian and Hamiltonian formulations of classical mechanics. The goal is to derive the relativistic energy and analyze the equations of motion for a particle in special relativity, incorporating concepts like velocity, acceleration, momentum.
The project is implemented in Python using the SymPy library for symbolic mathematics, making it easy to derive and manipulate complex equations.
-
Lagrangian Formulation: Derives the relativistic Lagrangian for a particle and computes the equations of motion using the Euler-Lagrange equations.
-
Hamiltonian Formulation: Converts the Lagrangian into the Hamiltonian framework, providing insights into the energy and momentum of the system.
-
Symbolic Computation: Uses SymPy to perform symbolic differentiation, substitution, and simplification of equations.
-
Velocity and Acceleration Analysis: Computes the velocity and acceleration components in 3D space.
-
Momentum and Force Calculations: Derives the momentum and force components from the Hamiltonian.
To run this project, you need the following:
Python 3.x: The code is written in Python.
SymPy: A Python library for symbolic mathematics. Install it using pip:
pip install sympy
Running the Code
-
Clone the repository:
git clone https://github.com/your-username/special-relativity-hamiltonian.git cd special-relativity-hamiltonian -
Open the Jupyter Notebook:
jupyter notebook Special_Relativity_w_Hamiltonian.ipynb -
Run the cells in the notebook to see the derivations and results.
The Lagrangian
Where:
$ ds = (cdt)^2 - dx^2 - dy^2 - dz^2$ -
$m$ is the mass of the particle, and -
$c$ is the speed of light.
The Euler-Lagrange equations are used to derive the equations of motion:
where
The Hamiltonian H is derived from the Lagrangian using the Legendre transformation:
where
The Hamiltonian represents the total energy of the system and is used to analyze the dynamics in phase space.
The velocity
The generalized momenta
The force components are derived from the Hamiltonian:
This project is licensed under the MIT License. See the LICENSE file for details.
SymPy: For providing a powerful symbolic mathematics library.
If you have any questions or feedback, feel free to reach out:
Email: miguel.a.estrada26@gmail.com
GitHub: github.com/Fisissist