# Randomized values for FindInstance

momentumfind[m1_, m2_, v1x_, v1y_, v1z_, v2x_, v2y_, v2z_] :=
FindInstance[
{m1*v1x, m1*v1y, m1*v1z} + {m2*v2x, m2*v2y, m2*v2z} == {m3*v3x,
m3*v3y, m3*v3z} + {m4*v4x, m4*v4y, m4*v4z} + {m5*v5x, m5*v5y,
m5*v5z} + {m6*v6x, m6*v6y, m6*v6z} && m3 == (m1 + m2)/4 &&
m4 == (m1 + m2)/4 && m5 == (m1 + m2)/4 && m3 > 0 && m4 > 0 &&
m5 > 0 && m6 > 0, {m3, v3x, v3y, v3z, m4, v4x, v4y, v4z, m5, v5x,
v5y, v5z, m6, v6x, v6y, v6z}, Reals, 2]

momentumfindrand[m1_, m2_, v1x_, v1y_, v1z_, v2x_, v2y_, v2z_] :=
momentumfind[m1, m2, v1x, v1y, v1z, v2x, v2y, v2z][[1]]

momentumfindrand[1, 1, 0, 14, -1, 0, -15, 1] // N

I am trying to implement a conservation of momentum function in which 2 objects are inputed with their mass and an {x,y,z} velocity. It outputs 4 objects with equal mass and different velocities. However whenever I run this function I always get velocities that are extremely unevenly distributed. For example with the parameters below I get a few velocities being above 5 and others being .0031. When I scale this up and use larger parameters I get 2 velocities being like 10,000 and the rest being like 3-5. I am using the 2 outputs from FindInstance and momentumfindrand for a more random output. How do I distribute this more evenly?

momentumfind[m1_, m2_, v1x_, v1y_, v1z_, v2x_, v2y_, v2z_] :=
Module[{p1 = m1 {v1x, v1y, v1z}, p2 = m2 {v2x, v2y, v2z},
p3 = (m1 + m2)/4 {v3x, v3y, v3z}, p4 = (m1 + m2)/4 {v4x, v4y, v4z},
p5 = (m1 + m2)/4 {v5x, v5y, v5z},
p6 = (m1 + m2)/4 {v6x, v6y, v6z}},
FindInstance[
p1 + p2 == p3 + p4 + p5 + p6, {v3x, v3y, v3z, v4x, v4y, v4z, v5x,
v5y, v5z, v6x, v6y, v6z}, Reals, 2]
]

momentumfindrand[m1_, m2_, v1x_, v1y_, v1z_, v2x_, v2y_, v2z_] :=
momentumfind[m1, m2, v1x, v1y, v1z, v2x, v2y, v2z][[1]]

momentumfindrand[1, 1, 0, 14, -1, 0, -15, 1] // N

{m3 -> 1., v3x -> -2.4, v3y -> 0.6, v3z -> 2.2, m4 -> 1., v4x -> -0.5,
v4y -> -4.8, v4z -> -0.6, m5 -> 1., v5x -> -1.8, v5y -> -4.2,
v5z -> -1.2, m6 -> 1., v6x -> 4.7, v6y -> 6.4, v6z -> -0.4}
• Can you explain what changes you've made to the OP's code, and how they address the question in the OP? Jul 12 at 12:41
• I simply cleaned up the code. Jul 12 at 14:51