# perpectly elastic collision pi model

Can you make a model like the video ? It's so amazing that I want to check it out.

• Do you mean elastic collisions of two blocks? Commented Sep 15, 2020 at 22:56
• Yes. As in the video, one side is the wall, and there is a full elastic collision between the two connections and the wall.
– Milk
Commented Sep 15, 2020 at 23:04
• I am happy that you got the answer, it is indeed a beautiful model. But please update the question to make it self-contained. External links may disappear, they should only play a supporting role. Also, it is in the rules of this forum to show some preliminary work. The absence of it explains so many downvotes (not me). Commented Sep 16, 2020 at 19:03

## 1 Answer

It is really amazing that Pi pops up. Here is a simulation, using constant energy and elastic collision with momentum conservation. Note that by a collision with the wall, energy stays constant, but momentum changes.

m1 = 1; m2 = 10;(*masses*)
x10 = 1; x20 = 2; (*initial locations*)
v10 = 0; v20 = -1;(*inital velocities*)
etot = m1 v10^2 + m2 v20^2;(*const energy*)
tmax =10; (*max. time for solution*)
newvelocity[vv1_,
vv2_] := (tsol =
Quiet[Solve[{m1 vn1 + m2 vn2 == m1 vv1 + m2  vv2,
m1 vn1^2 + m2 vn2^2 == etot}, {vn1, vn2}]]; {vn1, vn2} /.
If[Sign[tsol[[1, 1, 2]]] != Sign[vv1], tsol[[1]], tsol[[2]]]);

sol = NDSolve[{x1'[t] == v1[t], x2'[t] == v2[t], x1[0] == x10,
x2[0] == x20, v1[0] == v10, v2[0] == v20,
WhenEvent[
x1[t] == x2[t], {tsol = newvelocity[v1[t], v2[t]],
v1[t] -> tsol[[1]], v2[t] -> tsol[[2]] }],
WhenEvent[x1[t] == 0, v1[t] -> -v1[t]]}, {x1, x2, v1, v2}, {t, 0,
tmax}, DiscreteVariables -> {v1, v2}];
Plot[{ x1[t], x2[t]} /. sol // Evaluate, {t, 0, tmax},
PlotLegends -> {"m1", "m2"}, AxesLabel -> {"time", "space"}, PlotLabel ->
"Expected # of collisions:"<>ToString[Floor[Pi/ArcTan[Sqrt[m1/m2]]]]]


• It helps a lot. Thank you.
– Milk
Commented Sep 17, 2020 at 4:32