This calculator helps you understand the energy transfer involved in a perfectly inelastic collision, often referred to as an "AP Hug" in physics contexts. When two objects collide and stick together, their combined momentum is conserved. The energy lost in such a collision is converted into other forms, like heat and sound.
function calculateAPHug() {
var mass1 = parseFloat(document.getElementById("mass1").value);
var velocity1 = parseFloat(document.getElementById("velocity1").value);
var mass2 = parseFloat(document.getElementById("mass2").value);
var velocity2 = parseFloat(document.getElementById("velocity2").value);
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // Clear previous results
if (isNaN(mass1) || isNaN(velocity1) || isNaN(mass2) || isNaN(velocity2) ||
mass1 <= 0 || mass2 <= 0) {
resultDiv.innerHTML = "Please enter valid positive numbers for all inputs.";
return;
}
// Calculate initial momentum
var initialMomentum = (mass1 * velocity1) + (mass2 * velocity2);
// Calculate final velocity of the combined mass (since they stick together)
var totalMass = mass1 + mass2;
var finalVelocity = initialMomentum / totalMass;
// Calculate initial kinetic energy
var initialKineticEnergy = 0.5 * mass1 * velocity1 * velocity1 + 0.5 * mass2 * velocity2 * velocity2;
// Calculate final kinetic energy of the combined mass
var finalKineticEnergy = 0.5 * totalMass * finalVelocity * finalVelocity;
// Calculate the energy lost (difference between initial and final kinetic energy)
var energyLost = initialKineticEnergy – finalKineticEnergy;
resultDiv.innerHTML = "
Results:
";
resultDiv.innerHTML += "Total Initial Momentum: " + initialMomentum.toFixed(2) + " kg*m/s";
resultDiv.innerHTML += "Final Velocity of Combined Mass: " + finalVelocity.toFixed(2) + " m/s";
resultDiv.innerHTML += "Initial Kinetic Energy: " + initialKineticEnergy.toFixed(2) + " Joules";
resultDiv.innerHTML += "Final Kinetic Energy: " + finalKineticEnergy.toFixed(2) + " Joules";
resultDiv.innerHTML += "Energy Lost in Collision: " + energyLost.toFixed(2) + " Joules";
if (energyLost < 0) {
resultDiv.innerHTML += "Note: A negative energy loss indicates that kinetic energy was gained, which is not possible in a real perfectly inelastic collision. This might indicate an error in input or an unrealistic scenario.";
} else if (energyLost === 0) {
resultDiv.innerHTML += "Note: No kinetic energy was lost. This is a perfectly elastic collision, not a perfectly inelastic (AP Hug) collision.";
}
}