Example Problem
We will solve an example of both elastic and inelastic collisions in one dimension.
The simulation will calculate the velocities after the collision for two masses and illustrate their behavior.
Problem Description
Elastic Collision:
- Two objects, $(m_1)$ and $(m_2)$, collide with initial velocities $(v_{1i})$ and $(v_{2i})$.
- Conservation of momentum and kinetic energy holds:
$$
m_1 v_{1i} + m_2 v_{2i} = m_1 v_{1f} + m_2 v_{2f}
$$
$$
\frac{1}{2} m_1 v_{1i}^2 + \frac{1}{2} m_2 v_{2i}^2 = \frac{1}{2} m_1 v_{1f}^2 + \frac{1}{2} m_2 v_{2f}^2
$$
Inelastic Collision:
- Two objects stick together after the collision.
- Only momentum is conserved:
$$
m_1 v_{1i} + m_2 v_{2i} = (m_1 + m_2) v_f
$$
Python Code Implementation
Here’s the code to calculate and visualize the results:
1 | import numpy as np |
Code Explanation
Elastic Collision:
- The final velocities $(v_{1f})$ and $(v_{2f})$ are derived using the conservation equations.
- These velocities are used to calculate the positions over time for visualization.
Inelastic Collision:
- A single final velocity $(v_f)$ is computed since the objects stick together.
- This velocity is used to show the combined motion.
Visualization:
- Two subplots illustrate the motion before and after both types of collisions.
Results Visualization

Elastic Collision:
- The two objects bounce off each other, maintaining kinetic energy.
- Their positions diverge after the collision.
Inelastic Collision:
- The two objects stick together and move with the same final velocity.
- Their positions are represented by a single line post-collision.
This simulation provides a clear comparison of elastic and inelastic collisions.










